CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

CmsShowCommonPopup Class Reference

#include <CmsShowCommonPopup.h>

Inheritance diagram for CmsShowCommonPopup:
FWParameterSetterEditorBase

List of all members.

Public Member Functions

void changeGeomColor (Color_t)
void changeGeomTransparency2D (int)
void changeGeomTransparency3D (int)
void changeSelectionColorSet (Color_t)
 ClassDef (CmsShowCommonPopup, 0)
virtual void CloseWindow ()
 CmsShowCommonPopup (CmsShowCommon *, const TGWindow *p=0, UInt_t w=1, UInt_t h=1)
void colorSetChanged ()
void switchBackground ()
virtual ~CmsShowCommonPopup ()

Private Member Functions

 CmsShowCommonPopup (const CmsShowCommonPopup &)
void getColorSetColors (int &hci, int &sci)
void makeSetter (TGCompositeFrame *frame, FWParameterBase *param)
const CmsShowCommonPopupoperator= (const CmsShowCommonPopup &)

Private Attributes

TGTextButton * m_backgroundButton
FWColorSelectm_colorRnrCtxHighlightWidget
FWColorSelectm_colorRnrCtxSelectWidget
FWColorSelectm_colorSelectWidget [kFWGeomColorSize]
CmsShowCommonm_common
TGTextButton * m_gammaButton
TGHSlider * m_gammaSlider
std::vector< boost::shared_ptr
< FWParameterSetterBase > > 
m_setters

Detailed Description

Definition at line 24 of file CmsShowCommonPopup.h.


Constructor & Destructor Documentation

CmsShowCommonPopup::CmsShowCommonPopup ( CmsShowCommon model,
const TGWindow *  p = 0,
UInt_t  w = 1,
UInt_t  h = 1 
)

Definition at line 32 of file CmsShowCommonPopup.cc.

References asciidump::attributes, CmsShowCommon::colorManager(), FWColorManager::geomColor(), FWColorManager::geomTransparency(), getColorSetColors(), i, j, gen::k, kFWGeomColorSize, kFWMuonBarrelLineColorIndex, kFWMuonEndcapLineColorIndex, kFWPixelBarrelColorIndex, kFWPixelEndcapColorIndex, kFWTrackerBarrelColorIndex, kFWTrackerEndcapColorIndex, diffTwoXMLs::label, m_backgroundButton, m_colorRnrCtxHighlightWidget, m_colorRnrCtxSelectWidget, m_colorSelectWidget, m_common, CmsShowCommon::m_drawBreakPoints, CmsShowCommon::m_energyScale, CmsShowCommon::m_gamma, CmsShowCommon::m_trackBreak, makeSetter(), h::names, fetchall_from_DQM_v2::pool, and FWColorSelect::SetColorByIndex().

                                                                                                  :
   TGTransientFrame(gClient->GetDefaultRoot(),p,w,h),
   m_common(model),
   m_backgroundButton(0),
   m_gammaSlider(0),
   m_gammaButton(0),
   m_colorRnrCtxHighlightWidget(0),
   m_colorRnrCtxSelectWidget(0)
{
   SetCleanup(kDeepCleanup);

   TGGC *fTextGC;
   const TGFont *font = gClient->GetFont("-adobe-helvetica-bold-r-*-*-14-*-*-*-*-*-iso8859-1");
   if (!font)
      font = gClient->GetResourcePool()->GetDefaultFont();
   GCValues_t   gval;
   gval.fMask = kGCBackground | kGCFont | kGCForeground;
   gval.fFont = font->GetFontHandle();
   fTextGC = gClient->GetGC(&gval, kTRUE);

   
   TGFont* smallFont = 0;
   FontStruct_t defaultFontStruct = m_backgroundButton->GetDefaultFontStruct();
   try
   { 
      TGFontPool *pool = gClient->GetFontPool();
      TGFont* defaultFont = pool->GetFont(defaultFontStruct);
      FontAttributes_t attributes = defaultFont->GetFontAttributes();
      smallFont = pool->GetFont(attributes.fFamily, 8,  attributes.fWeight, attributes.fSlant);                                      
   } 
   catch(...)
   {
      // Ignore exceptions.
   }
   
   TGCompositeFrame* vf2 = new TGVerticalFrame(this);
   AddFrame(vf2, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
   //==============================================================================
   // scales
   //
   {
      TGLabel* xx = new TGLabel(vf2, "GlobalScales     ", fTextGC->GetGC());
      vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft ,2,2,4,4));
   }
   FWViewEnergyScaleEditor* scaleEditor = new FWViewEnergyScaleEditor(m_common->m_energyScale.get(), vf2);
   vf2->AddFrame(scaleEditor);
   //==============================================================================
   // Projections
   //
   vf2->AddFrame(new TGHorizontal3DLine(vf2),  new TGLayoutHints(kLHintsExpandX,4 ,8, 3, 3));
   {
      TGLabel* xx = new TGLabel(vf2, "Projections     ", fTextGC->GetGC());
      vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft ,2,2,4,4));
   }
   vf2->AddFrame(new TGLabel(vf2, "Track behaviour when crossing y=0 in RhoZ-view:"), new TGLayoutHints(kLHintsLeft ,2,2,0,0));
   makeSetter(vf2, &m_common->m_trackBreak);
   makeSetter(vf2, &m_common->m_drawBreakPoints);

   //==============================================================================
   // general colors
   //

   vf2->AddFrame(new TGHorizontal3DLine(vf2),  new TGLayoutHints(kLHintsExpandX ,4 ,8, 8, 2));
   {
      TGLabel* xx = new TGLabel(vf2, "General Colors        ", fTextGC->GetGC());
      vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft,2,2,4,4));
   }
   m_backgroundButton = new TGTextButton(vf2, "Black/White Background");
   vf2->AddFrame(m_backgroundButton);
   makeSetter(vf2, &m_common->m_gamma);

   // rnrCtx colorset
   {
      int hci, sci;
      getColorSetColors(hci, sci); 
      TGHorizontalFrame* top = new TGHorizontalFrame(vf2);
      vf2->AddFrame(top);
      {
         TGHorizontalFrame* hf = new TGHorizontalFrame(top); 
         top->AddFrame(hf);
         
         m_colorRnrCtxHighlightWidget = new FWColorSelect(hf, "highlight", 0, m_common->colorManager(), 3);
         hf->AddFrame(m_colorRnrCtxHighlightWidget); 
         m_colorRnrCtxHighlightWidget->SetColorByIndex(hci , kFALSE);
         m_colorRnrCtxHighlightWidget->Connect("ColorChosen(Color_t)", "CmsShowCommonPopup", this, "changeSelectionColorSet(Color_t)");
         
         TGFrame* lf = new TGHorizontalFrame(hf, 100, 16, kFixedSize);
         TGLabel* label = new TGLabel(lf, "Higlight");
         label->SetTextFont(smallFont);
         hf->AddFrame(lf, new TGLayoutHints(kLHintsLeft |kLHintsCenterY , 0, 0, 0,0)); 
      }
      
      {
         TGHorizontalFrame* hf = new TGHorizontalFrame(top); 
         top->AddFrame(hf);
         
         m_colorRnrCtxSelectWidget = new FWColorSelect(hf, "selectioyn", 0, m_common->colorManager(), 1);
         hf->AddFrame(m_colorRnrCtxSelectWidget); 
         m_colorRnrCtxSelectWidget->SetColorByIndex(sci , kFALSE);
         m_colorRnrCtxSelectWidget->Connect("ColorChosen(Color_t)", "CmsShowCommonPopup", this, "changeSelectionColorSet(Color_t)");
         
         TGFrame* lf = new TGHorizontalFrame(hf, 100, 16, kFixedSize);
         TGLabel* label = new TGLabel(lf, "Selection");
         label->SetTextFont(smallFont);
         hf->AddFrame(lf, new TGLayoutHints(kLHintsLeft |kLHintsCenterY , 0, 0, 0,0)); 
      }
   }
   
   vf2->AddFrame(new TGHorizontal3DLine(vf2),  new TGLayoutHints(kLHintsExpandX ,4 ,8, 8, 2));

   //==============================================================================
   // geom colors
   //

   {
      TGLabel* xx = new TGLabel(vf2, "DetectorColors       ", fTextGC->GetGC());
      vf2->AddFrame(xx, new TGLayoutHints(kLHintsLeft,2,2,8,0));
   }

   TGHSlider* transpWidget2D = 0;
   TGHSlider* transpWidget3D = 0;
   TGCompositeFrame* top  = new TGVerticalFrame(vf2);
   vf2->AddFrame(top, new TGLayoutHints(kLHintsNormal, 2, 2, 2, 0));

   {
      TGHorizontalFrame* hf = new TGHorizontalFrame(top); 
      hf->AddFrame(new TGLabel(hf, "Tansparency 2D:"), new TGLayoutHints(kLHintsBottom, 2,  2, 3, 3));
      transpWidget2D = new TGHSlider(hf, 100, kSlider1);
      hf->AddFrame( transpWidget2D);
      top->AddFrame(hf,new TGLayoutHints( kLHintsNormal, 0, 0, 2, 2));
   }
   {
      TGHorizontalFrame* hf = new TGHorizontalFrame(top); 
      hf->AddFrame(new TGLabel(hf, "Tansparency 3D:") , new TGLayoutHints(kLHintsBottom,2, 2, 2, 2 ));
      transpWidget3D = new TGHSlider(hf, 100, kSlider1);
      hf->AddFrame( transpWidget3D);
      top->AddFrame(hf, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 10));
   }
   std::string names[kFWGeomColorSize];
   names[kFWPixelBarrelColorIndex   ] = "Pixel Barrel";
   names[kFWPixelEndcapColorIndex   ] = "Pixel Endcap" ;
   names[kFWTrackerBarrelColorIndex ] = "Tracker Barrel";
   names[kFWTrackerEndcapColorIndex ] = "Tracker Endcap";
   names[kFWMuonBarrelLineColorIndex] = "Muon Barrel";
   names[kFWMuonEndcapLineColorIndex] = "Muon Endcap";
   int i = 0;
   for (int k = 0; k < 3; ++k)
   {
      TGHorizontalFrame* hf = new TGHorizontalFrame(top); 
      top->AddFrame(hf);

      for (int j = 0 ; j < 2; ++j)
      {
         m_colorSelectWidget[i] = new FWColorSelect(hf, names[i].c_str(), 0, m_common->colorManager(), i);
         hf->AddFrame(m_colorSelectWidget[i]); 
         m_colorSelectWidget[i]->SetColorByIndex(m_common->colorManager()->geomColor(FWGeomColorIndex(i)), kFALSE);
         m_colorSelectWidget[i]->Connect("ColorChosen(Color_t)", "CmsShowCommonPopup", this, "changeGeomColor(Color_t)");

         TGFrame* lf = new TGHorizontalFrame(hf, 100, 16, kFixedSize);
         TGLabel* label = new TGLabel(lf, m_colorSelectWidget[i]->label().c_str());
         label->SetTextFont(smallFont);
         hf->AddFrame(lf, new TGLayoutHints(kLHintsLeft |kLHintsCenterY , 0, 0, 0,0)); 

         ++i;
      }
   }
   //==============================================================================

   m_backgroundButton->Connect("Clicked()", "CmsShowCommonPopup", this, "switchBackground()");

   transpWidget2D->SetRange(0, 100);
   transpWidget2D->SetPosition(m_common->colorManager()->geomTransparency(true));
   transpWidget2D->Connect("PositionChanged(Int_t)", "CmsShowCommonPopup", this, "changeGeomTransparency2D(Int_t)");

   transpWidget3D->SetRange(0, 100);
   transpWidget3D->SetPosition(m_common->colorManager()->geomTransparency(false));
   transpWidget3D->Connect("PositionChanged(Int_t)", "CmsShowCommonPopup", this, "changeGeomTransparency3D(Int_t)");

   SetWindowName("Common Preferences");
   MapSubwindows();
   Resize(GetDefaultSize());
   Layout();
   CenterOnParent(kTRUE, TGTransientFrame::kTopRight);
}
CmsShowCommonPopup::~CmsShowCommonPopup ( ) [virtual]

Definition at line 219 of file CmsShowCommonPopup.cc.

{
}
CmsShowCommonPopup::CmsShowCommonPopup ( const CmsShowCommonPopup ) [private]

Member Function Documentation

void CmsShowCommonPopup::changeGeomColor ( Color_t  iColor)

Definition at line 231 of file CmsShowCommonPopup.cc.

References fwrapper::cs, m_common, and CmsShowCommon::setGeomColor().

{
   TGColorSelect *cs = (TGColorSelect *) gTQSender;
   FWGeomColorIndex cidx = FWGeomColorIndex(cs->WidgetId());
   m_common->setGeomColor(cidx, iColor);
}
void CmsShowCommonPopup::changeGeomTransparency2D ( int  iTransp)

Definition at line 258 of file CmsShowCommonPopup.cc.

References m_common, and CmsShowCommon::setGeomTransparency().

{
   m_common->setGeomTransparency(iTransp, true);
}
void CmsShowCommonPopup::changeGeomTransparency3D ( int  iTransp)

Definition at line 264 of file CmsShowCommonPopup.cc.

References m_common, and CmsShowCommon::setGeomTransparency().

{
   m_common->setGeomTransparency(iTransp, false);
}
void CmsShowCommonPopup::changeSelectionColorSet ( Color_t  idx)

Definition at line 240 of file CmsShowCommonPopup.cc.

References CmsShowCommon::colorManager(), fwrapper::cs, FWColorManager::isColorSetDark(), m_common, and v.

{
   TGColorSelect *cs = (TGColorSelect *) gTQSender;   

   //printf("~~~~~  changeSelectionColorSet sel[%d] idx[%d]\n", cs->WidgetId(), idx);
   for (TEveElement::List_i it = gEve->GetViewers()->BeginChildren(); it != gEve->GetViewers()->EndChildren(); ++it)
   { 
      TGLViewer* v = ((TEveViewer*)(*it))->GetGLViewer();
      
      TGLColorSet& colorset =  m_common->colorManager()->isColorSetDark() ?  v->RefDarkColorSet():v->RefLightColorSet();
      colorset.Selection(cs->WidgetId()).SetColor(idx);
      colorset.Selection(cs->WidgetId()+1).SetColor(idx); // implied selected/higlighted

   }
}
CmsShowCommonPopup::ClassDef ( CmsShowCommonPopup  ,
 
)
virtual void CmsShowCommonPopup::CloseWindow ( ) [inline, virtual]

Definition at line 33 of file CmsShowCommonPopup.h.

{ UnmapWindow(); }
void CmsShowCommonPopup::colorSetChanged ( )

Definition at line 272 of file CmsShowCommonPopup.cc.

References CmsShowCommon::colorManager(), FWColorManager::geomColor(), getColorSetColors(), i, kFWGeomColorSize, m_colorRnrCtxHighlightWidget, m_colorRnrCtxSelectWidget, m_colorSelectWidget, m_common, and FWColorSelect::SetColorByIndex().

Referenced by FWGUIManager::finishUpColorChange().

{
   for (int i = 0 ; i < kFWGeomColorSize; ++i)
      m_colorSelectWidget[i]->SetColorByIndex(m_common->colorManager()->geomColor(FWGeomColorIndex(i)), kFALSE);
   
   int hci, sci;
   getColorSetColors(hci, sci);
   //printf("=============== colorSetChanged() dark ? [%d] %d %d \n",m_common->colorManager()->isColorSetDark(), hci, sci);
   m_colorRnrCtxHighlightWidget->SetColorByIndex(hci , kFALSE);
   m_colorRnrCtxSelectWidget->SetColorByIndex(sci , kFALSE);
}
void CmsShowCommonPopup::getColorSetColors ( int &  hci,
int &  sci 
) [private]

Definition at line 284 of file CmsShowCommonPopup.cc.

References CmsShowCommon::colorManager(), glc, FWColorManager::isColorSetDark(), and m_common.

Referenced by CmsShowCommonPopup(), and colorSetChanged().

{
   TGLColorSet& colorset =  m_common->colorManager()->isColorSetDark() ?  gEve->GetDefaultGLViewer()->RefDarkColorSet():
   gEve->GetDefaultGLViewer()->RefLightColorSet();
   {
      TGLColor& glc = colorset.Selection(3);
      hci = TColor::GetColor(glc.GetRed(), glc.GetGreen(), glc.GetBlue());
     // printf("getSHcolors HIGH %d %d %d , [%d]\n", glc.GetRed(), glc.GetGreen(), glc.GetBlue(), hci);
   }{
      TGLColor& glc = colorset.Selection(1);
      sci = TColor::GetColor(glc.GetRed(), glc.GetGreen(), glc.GetBlue());
     // printf("getSHcolors SEL  %d %d %d , [%d]\n", glc.GetRed(), glc.GetGreen(), glc.GetBlue(), sci);
   }
}
void CmsShowCommonPopup::makeSetter ( TGCompositeFrame *  frame,
FWParameterBase param 
) [private]

Definition at line 300 of file CmsShowCommonPopup.cc.

References m_setters, and FWParameterSetterBase::makeSetterFor().

Referenced by CmsShowCommonPopup().

{
   boost::shared_ptr<FWParameterSetterBase> ptr( FWParameterSetterBase::makeSetterFor(param) );
   ptr->attach(param, this);
 
   TGFrame* pframe = ptr->build(frame);
   frame->AddFrame(pframe, new TGLayoutHints(kLHintsExpandX, 0, 0, 2,2));

   m_setters.push_back(ptr);
}
const CmsShowCommonPopup& CmsShowCommonPopup::operator= ( const CmsShowCommonPopup ) [private]
void CmsShowCommonPopup::switchBackground ( )

Definition at line 224 of file CmsShowCommonPopup.cc.

References m_common, and CmsShowCommon::switchBackground().


Member Data Documentation

TGTextButton* CmsShowCommonPopup::m_backgroundButton [private]

Definition at line 54 of file CmsShowCommonPopup.h.

Referenced by CmsShowCommonPopup().

Definition at line 60 of file CmsShowCommonPopup.h.

Referenced by CmsShowCommonPopup(), and colorSetChanged().

Definition at line 61 of file CmsShowCommonPopup.h.

Referenced by CmsShowCommonPopup(), and colorSetChanged().

Definition at line 59 of file CmsShowCommonPopup.h.

Referenced by CmsShowCommonPopup(), and colorSetChanged().

TGTextButton* CmsShowCommonPopup::m_gammaButton [private]

Definition at line 56 of file CmsShowCommonPopup.h.

TGHSlider* CmsShowCommonPopup::m_gammaSlider [private]

Definition at line 55 of file CmsShowCommonPopup.h.

std::vector<boost::shared_ptr<FWParameterSetterBase> > CmsShowCommonPopup::m_setters [private]

Definition at line 62 of file CmsShowCommonPopup.h.

Referenced by makeSetter().