CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Friends

CmsShowModelPopup Class Reference

#include <Fireworks/Core/interface/CmsShowModelPopup.h>

List of all members.

Public Member Functions

void changeModelColor (Color_t iColor)
void changeModelOpacity (Int_t opacity=100)
 ClassDef (CmsShowModelPopup, 0)
void clicked ()
virtual void CloseWindow ()
 CmsShowModelPopup (FWDetailViewManager *, FWSelectionManager *, const FWColorManager *, const TGWindow *p=0, UInt_t w=1, UInt_t h=1)
void colorSetChanged ()
void disconnectAll ()
void fillModelPopup (const FWSelectionManager &iSelMgr)
void openDetailedView ()
void toggleModelVisible (Bool_t on=kTRUE)
void updateDisplay ()
virtual ~CmsShowModelPopup ()

Private Member Functions

 CmsShowModelPopup (const CmsShowModelPopup &)
const CmsShowModelPopupoperator= (const CmsShowModelPopup &)

Private Attributes

sigc::connection m_changes
const FWColorManagerm_colorManager
FWColorSelectm_colorSelectWidget
sigc::connection m_destroyedConn
FWDetailViewManagerm_detailViewManager
FWDialogBuilderm_dialogBuilder
TGCheckButton * m_isVisibleButton
sigc::connection m_modelChangedConn
TGLabel * m_modelLabel
std::set< FWModelIdm_models
TGHSlider * m_opacitySlider
std::vector< TGTextButton * > m_openDetailedViewButtons

Friends

class CmsShowModelPopupDetailViewButtonAdapter

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 52 of file CmsShowModelPopup.h.


Constructor & Destructor Documentation

CmsShowModelPopup::CmsShowModelPopup ( FWDetailViewManager iManager,
FWSelectionManager iSelMgr,
const FWColorManager iColorMgr,
const TGWindow *  p = 0,
UInt_t  w = 1,
UInt_t  h = 1 
)

Definition at line 54 of file CmsShowModelPopup.cc.

References FWDialogBuilder::addCheckbox(), FWDialogBuilder::addColorPicker(), FWDialogBuilder::addHSeparator(), FWDialogBuilder::addHSlider(), FWDialogBuilder::addLabel(), FWDialogBuilder::expand(), fillModelPopup(), FWDialogBuilder::indent(), m_changes, m_colorSelectWidget, m_dialogBuilder, m_isVisibleButton, m_modelLabel, m_opacitySlider, m_openDetailedViewButtons, and FWSelectionManager::selectionChanged_.

                                                                            :
   TGTransientFrame(gClient->GetDefaultRoot(),p,w,h),
   m_detailViewManager(iManager),
   m_colorManager(iColorMgr),
   m_dialogBuilder(0)
{
   m_changes = iSelMgr->selectionChanged_.connect(boost::bind(&CmsShowModelPopup::fillModelPopup, this, _1));

   SetCleanup(kDeepCleanup);

   TGVerticalFrame* vf = new TGVerticalFrame(this);
   AddFrame(vf, new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 2, 2, 2, 4));
   m_dialogBuilder =  new FWDialogBuilder(vf);
  
   // Do the layouting of the various widgets.
   m_dialogBuilder->indent(4)
      .addLabel(" ", 14, 1, &m_modelLabel)
      .addLabel("Color", 8)
      .addColorPicker(iColorMgr, &m_colorSelectWidget).expand(false)
      .addHSeparator()
      .addLabel("Opacity", 8)
      .addHSlider(150, &m_opacitySlider)
      .addHSeparator(2)
      .addCheckbox("Visible", &m_isVisibleButton)
      .addHSeparator();

   // Dummy button for detail views. Can be overidden.
   TGTextButton *detailedViewButton = new TGTextButton(this, "Open Detailed View", 0); 
   AddFrame(detailedViewButton, new TGLayoutHints(kLHintsExpandX, 4, 4, 4, 4));
   m_openDetailedViewButtons.push_back(detailedViewButton);

   m_colorSelectWidget->Connect("ColorChosen(Color_t)", "CmsShowModelPopup", this, "changeModelColor(Color_t)");
   m_isVisibleButton->Connect("Toggled(Bool_t)", "CmsShowModelPopup", this, "toggleModelVisible(Bool_t)");
   m_opacitySlider->Connect("PositionChanged(Int_t)", "CmsShowModelPopup",
                            this, "changeModelOpacity(Int_t)");

   SetWindowName("Object Controller");
   MapSubwindows();
   Resize(GetDefaultSize());
   Layout();

   fillModelPopup(*iSelMgr);
}
CmsShowModelPopup::~CmsShowModelPopup ( ) [virtual]

Definition at line 106 of file CmsShowModelPopup.cc.

References disconnectAll(), m_changes, m_colorSelectWidget, m_isVisibleButton, and m_opacitySlider.

{
   m_changes.disconnect();
   m_colorSelectWidget->Disconnect("ColorSelected(Pixel_t)", this, "changeModelColor(Pixel_t)");
   m_opacitySlider->Disconnect("PositionChanged(Int_t)", this, "changeModelOpacity(Int_t)");
   m_isVisibleButton->Disconnect("Toggled(Bool_t)", this, "toggleModelVisible(Bool_t)");
   disconnectAll();
}
CmsShowModelPopup::CmsShowModelPopup ( const CmsShowModelPopup ) [private]

Member Function Documentation

void CmsShowModelPopup::changeModelColor ( Color_t  color)

Change the color of the selected objects.

NOTES:

  • Notice that the whole thing works with a "Copy old properties and modify" paradigm.

Definition at line 310 of file CmsShowModelPopup.cc.

References FWEventItem::ModelInfo::displayProperties(), alignCSCRings::e, i, info, m_models, and FWDisplayProperties::setColor().

{
   if (m_models.empty())
      return;
      
   FWChangeSentry sentry(*(m_models.begin()->item()->changeManager()));
   for (std::set<FWModelId>::iterator i = m_models.begin(), e = m_models.end(); i != e; ++i)
   {
      const FWEventItem::ModelInfo &info = i->item()->modelInfo(i->index());
      FWDisplayProperties changeProperties = info.displayProperties();
      changeProperties.setColor(color);
      i->item()->setDisplayProperties(i->index(), changeProperties);
   }
}
void CmsShowModelPopup::changeModelOpacity ( Int_t  opacity = 100)

Change the opacity of the selected objects. See above in changeModelColor for additional notes.

Definition at line 329 of file CmsShowModelPopup.cc.

References FWEventItem::ModelInfo::displayProperties(), alignCSCRings::e, i, info, m_models, and FWDisplayProperties::setTransparency().

{
   if (m_models.empty())
      return;
   
   FWChangeSentry sentry(*(m_models.begin()->item()->changeManager()));
   for (std::set<FWModelId>::iterator i = m_models.begin(), e = m_models.end(); i != e; ++i)
   {
      const FWEventItem::ModelInfo &info = i->item()->modelInfo(i->index());
      FWDisplayProperties changeProperties = info.displayProperties();
      changeProperties.setTransparency(100 - opacity);
      i->item()->setDisplayProperties(i->index(), changeProperties);
   }
}
CmsShowModelPopup::ClassDef ( CmsShowModelPopup  ,
 
)
void CmsShowModelPopup::clicked ( )

Definition at line 371 of file CmsShowModelPopup.cc.

References FWDetailViewManager::detailViewsFor(), m_detailViewManager, m_models, and FWDetailViewManager::openDetailViewFor().

{
   TGTextButton *cs = static_cast<TGTextButton *>(gTQSender);
   int iIndex = cs->WidgetId();
   std::vector<std::string> viewChoices = m_detailViewManager->detailViewsFor(*(m_models.begin()));
   
   m_detailViewManager->openDetailViewFor( *(m_models.begin()), *(viewChoices.begin()+iIndex) );
   
}   
virtual void CmsShowModelPopup::CloseWindow ( ) [inline, virtual]

Definition at line 63 of file CmsShowModelPopup.h.

{ UnmapWindow(); }
void CmsShowModelPopup::colorSetChanged ( )
void CmsShowModelPopup::disconnectAll ( )

This is invoked to when no object is selected and sets the dialog in a disabled look.

Definition at line 279 of file CmsShowModelPopup.cc.

References alignCSCRings::e, i, m_colorSelectWidget, m_destroyedConn, m_isVisibleButton, m_modelChangedConn, m_modelLabel, m_opacitySlider, m_openDetailedViewButtons, and FWColorSelect::SetColorByIndex().

Referenced by fillModelPopup(), and ~CmsShowModelPopup().

                                 {
   m_modelChangedConn.disconnect();
   m_destroyedConn.disconnect();
   //  m_item = 0;
   //  m_model = 0;
   m_modelLabel->SetText("No object selected");
   m_colorSelectWidget->SetColorByIndex(kRed,kFALSE);
   m_isVisibleButton->SetDisabledAndSelected(kTRUE);
   m_colorSelectWidget->SetEnabled(kFALSE);
   m_opacitySlider->SetEnabled(kFALSE);
   m_isVisibleButton->SetEnabled(kFALSE);
   m_openDetailedViewButtons.front()->SetEnabled(kFALSE);
   m_openDetailedViewButtons.front()->SetText("Open Detail View ...");
   assert(!m_openDetailedViewButtons.empty());
   for(size_t i = 1, e = m_openDetailedViewButtons.size(); i != e; ++i)
   {
      TGCompositeFrame* cf = (TGCompositeFrame*)m_openDetailedViewButtons[i]->GetParent();
      cf->HideFrame(m_openDetailedViewButtons[i]);
   }


}
void CmsShowModelPopup::fillModelPopup ( const FWSelectionManager iSelMgr)

this updates the dialog when selection changes. It also handles multiple Selections by updating only the widgets which have non controversial (i.e. different across selected objects) values.

Definition at line 135 of file CmsShowModelPopup.cc.

References FWEventItem::changed_, FWDisplayProperties::color(), FWDetailViewManager::detailViewsFor(), disconnectAll(), FWEventItem::ModelInfo::displayProperties(), alignCSCRings::e, FWEventItem::goingToBeDestroyed_, i, getHLTprescales::index, info, FWDisplayProperties::isVisible(), m_colorSelectWidget, m_destroyedConn, m_detailViewManager, m_isVisibleButton, m_modelChangedConn, m_modelLabel, m_models, m_opacitySlider, m_openDetailedViewButtons, FWEventItem::modelInfo(), FWEventItem::modelName(), FWEventItem::name(), alignCSCRings::s, FWSelectionManager::selected(), FWColorSelect::SetColorByIndex(), FWDisplayProperties::transparency(), and updateDisplay().

Referenced by CmsShowModelPopup().

{
   disconnectAll();
   // Handles the case in which the selection is empty.
   if (iSelMgr.selected().empty())
      return;
   
   // Handle the case in which the selection is not empty.
   bool multipleNames = false, multipleColors = false, multipleVis = false,
      multipleTransparecy = false;

   m_models = iSelMgr.selected();
   std::set<FWModelId>::const_iterator id = m_models.begin();
   const FWEventItem* item = id->item();
   const FWEventItem::ModelInfo info = item->modelInfo(id->index());
   const FWDisplayProperties &props = info.displayProperties();
   
   // The old logic was broken here. It was enought that the last item
   // was the same as the first one, and all of them would have been considered
   // equal. This should fix it. The idea is that if any of the elements in
   // models in [1, N] are different from the first, then we consider the
   // set with multipleXYZ.
   for (std::set<FWModelId>::const_iterator i = ++(m_models.begin()),
           e = m_models.end(); i != e; ++i) 
   {
      const FWEventItem::ModelInfo &nextInfo = i->item()->modelInfo(i->index());
      const FWDisplayProperties &nextProps = nextInfo.displayProperties();
      
      multipleNames = multipleNames || (item->name() != i->item()->name());
      multipleColors = multipleColors || (props.color() != nextProps.color());
      multipleVis = multipleVis || (props.isVisible() != nextProps.isVisible());
      multipleTransparecy = multipleTransparecy 
         || (props.transparency() != nextProps.transparency());
   }
   
   // Handle the name.
   std::ostringstream s;
   if (multipleNames) 
      s << m_models.size() << " objects";
   else
      s << m_models.size() << " " << item->name();
   m_modelLabel->SetText(s.str().c_str());

   if (m_models.size()==1)
   {
      m_modelLabel->SetText(item->modelName(id->index()).c_str());
      std::vector<std::string> viewChoices = m_detailViewManager->detailViewsFor(*id);
      m_openDetailedViewButtons.front()->SetEnabled(viewChoices.size()>0);
      //be sure we show just the right number of buttons
      if(viewChoices.size() > m_openDetailedViewButtons.size()) 
      {
         for(size_t i = 0, e = m_openDetailedViewButtons.size(); i != e; ++i)
         {
            // printf("show existing buttons\n");
            TGCompositeFrame* cf = (TGCompositeFrame*)m_openDetailedViewButtons[i]->GetParent();
            cf->ShowFrame(m_openDetailedViewButtons[i]);
         }

         //now we make additional buttons 
         TGTextButton *button;
         for(size_t index = m_openDetailedViewButtons.size(); index < viewChoices.size(); ++index)
         { 
            // printf("add new button %s \n ",  viewChoices[index].c_str());
            button = new TGTextButton(this, "dummy", index);
            AddFrame(button, new TGLayoutHints(kLHintsExpandX, 4, 4, 4, 4));
            TGCompositeFrame* cf = (TGCompositeFrame*)button->GetParent();
            cf->MapWindow();
            cf->MapSubwindows();
            m_openDetailedViewButtons.push_back(button);

            button->Connect("Clicked()", "CmsShowModelPopup", this, "clicked()");
         }
      }
      else if (!viewChoices.empty())
      {
         //  printf("show button subset %d \n",  viewChoices.size());
         for (size_t i = 0, e = viewChoices.size(); i != e; ++i)
         {
            TGCompositeFrame* cf = (TGCompositeFrame*)m_openDetailedViewButtons[i]->GetParent();
            cf->ShowFrame(m_openDetailedViewButtons[i]);
         }
      }
      
      //set the names
      for (size_t i = 0, e = viewChoices.size(); i != e; ++i)
      {
         m_openDetailedViewButtons[i]->SetText(("Open " + viewChoices[i] + " Detail View ...").c_str());
      }
   }
   
   // Set the various widgets.
   m_colorSelectWidget->SetColorByIndex(props.color(), kFALSE);
   m_opacitySlider->SetPosition(100 - props.transparency());
   m_isVisibleButton->SetDisabledAndSelected(props.isVisible());

   m_opacitySlider->SetEnabled(kTRUE);
   m_colorSelectWidget->SetEnabled(kTRUE);
   m_isVisibleButton->SetEnabled(kTRUE);
   
   m_modelChangedConn = item->changed_.connect(boost::bind(&CmsShowModelPopup::updateDisplay, this));
   m_destroyedConn = item->goingToBeDestroyed_.connect(boost::bind(&CmsShowModelPopup::disconnectAll, this));

   Resize(GetDefaultSize());
   Layout();
}
void CmsShowModelPopup::openDetailedView ( )

Definition at line 363 of file CmsShowModelPopup.cc.

References FWDetailViewManager::detailViewsFor(), m_detailViewManager, m_models, and FWDetailViewManager::openDetailViewFor().

{
   std::vector<std::string> viewChoices = m_detailViewManager->detailViewsFor(*(m_models.begin()));

   m_detailViewManager->openDetailViewFor( *(m_models.begin()), viewChoices.front() );
}
const CmsShowModelPopup& CmsShowModelPopup::operator= ( const CmsShowModelPopup ) [private]
void CmsShowModelPopup::toggleModelVisible ( Bool_t  on = kTRUE)

Change (not toggle actually) the visibility of selected objects. See changeModelColor for additional notes.

Definition at line 348 of file CmsShowModelPopup.cc.

References FWEventItem::ModelInfo::displayProperties(), i, info, m_models, and FWDisplayProperties::setIsVisible().

                                               {
   if(m_models.empty())
      return;
   
   FWChangeSentry sentry(*(m_models.begin()->item()->changeManager()));
   for (std::set<FWModelId>::iterator i = m_models.begin(); i != m_models.end(); ++i) 
   {
      const FWEventItem::ModelInfo &info = i->item()->modelInfo(i->index());
      FWDisplayProperties changeProperties = info.displayProperties();
      changeProperties.setIsVisible(on);
      i->item()->setDisplayProperties(i->index(), changeProperties);
   }
}
void CmsShowModelPopup::updateDisplay ( )

Based on the actual models properties, update the GUI.

Definition at line 244 of file CmsShowModelPopup.cc.

References FWDisplayProperties::color(), FWEventItem::ModelInfo::displayProperties(), alignCSCRings::e, i, info, FWDisplayProperties::isVisible(), m_colorSelectWidget, m_isVisibleButton, m_models, m_opacitySlider, AlCaHLTBitMon_ParallelJobs::p, FWColorSelect::SetColorByIndex(), and FWDisplayProperties::transparency().

Referenced by fillModelPopup().

{
   for (std::set<FWModelId>::iterator i = m_models.begin(), e = m_models.end(); 
        i != e; ++i)
   {
      const FWEventItem::ModelInfo &info = i->item()->modelInfo(i->index());
      const FWDisplayProperties &p = info.displayProperties();
      m_colorSelectWidget->SetColorByIndex(p.color(), kFALSE);
      
      if (p.isVisible())
         m_isVisibleButton->SetState(kButtonDown, kFALSE);
      else
         m_isVisibleButton->SetState(kButtonUp, kFALSE);

      m_opacitySlider->SetPosition(100 - p.transparency());
   }
}

Friends And Related Function Documentation

friend class CmsShowModelPopupDetailViewButtonAdapter [friend]

Definition at line 56 of file CmsShowModelPopup.h.


Member Data Documentation

sigc::connection CmsShowModelPopup::m_changes [private]

Definition at line 98 of file CmsShowModelPopup.h.

Referenced by CmsShowModelPopup(), and ~CmsShowModelPopup().

Definition at line 101 of file CmsShowModelPopup.h.

sigc::connection CmsShowModelPopup::m_destroyedConn [private]

Definition at line 97 of file CmsShowModelPopup.h.

Referenced by disconnectAll(), and fillModelPopup().

Definition at line 100 of file CmsShowModelPopup.h.

Referenced by clicked(), fillModelPopup(), and openDetailedView().

Definition at line 103 of file CmsShowModelPopup.h.

Referenced by CmsShowModelPopup().

TGCheckButton* CmsShowModelPopup::m_isVisibleButton [private]
sigc::connection CmsShowModelPopup::m_modelChangedConn [private]

Definition at line 96 of file CmsShowModelPopup.h.

Referenced by disconnectAll(), and fillModelPopup().

TGLabel* CmsShowModelPopup::m_modelLabel [private]

Definition at line 89 of file CmsShowModelPopup.h.

Referenced by CmsShowModelPopup(), disconnectAll(), and fillModelPopup().

TGHSlider* CmsShowModelPopup::m_opacitySlider [private]
std::vector<TGTextButton*> CmsShowModelPopup::m_openDetailedViewButtons [private]

Definition at line 92 of file CmsShowModelPopup.h.

Referenced by CmsShowModelPopup(), disconnectAll(), and fillModelPopup().