CMS 3D CMS Logo

Ig3DClipsCategory Class Reference

#include <Iguana/GLBrowsers/interface/Ig3DClipsCategory.h>

Inheritance diagram for Ig3DClipsCategory:

Ig3DObjectCategory< IgSoClipPlane > IgStateElement IgControlCategory IgControlItem

List of all members.

Public Member Functions

virtual void apply (void)
virtual void attach (void)
void browserChanged (Ig3DBaseBrowser *browser)
virtual void detach (void)
 Ig3DClipsCategory (IgState *state, Ig3DBaseBrowser *source)
bool makeOne (Ig3DBaseRep *rep)
void reconstruct (SoSwitch *from)
void reconstruct (void)
virtual void registerBrowser (IgState *state, Ig3DBaseBrowser *browser)
virtual void update (void)

Protected Member Functions

virtual void createNewItem (void)
virtual void deleteItem (void)
virtual void renameItem (const QString &newName)

Private Slots

virtual void deleteOne (void)
virtual bool makeOne (void)

Private Member Functions

void buildDefaults (void)
 Ig3DClipsCategory (const Ig3DClipsCategory &)
 IG_DECLARE_STATE_ELEMENT (Ig3DClipsCategory)
IgSoClipPlanemakeClip (QString name, bool on, SbVec3f center)
Ig3DClipsCategoryoperator= (const Ig3DClipsCategory &)
void reconstruct (SoGroup *from)
SoGroup * repActiveClips (Ig3DBaseRep *rep, bool make)
SoGroup * repAllClips (Ig3DBaseRep *rep, bool make)
SoSwitch * repClips (SoGroup *magic, bool make, SoGroup **objects, SoGroup **active)

Private Attributes

Ig3DBoolControlm_manip
Ig3DBoolControlm_on
Ig3DPlaneControlm_plane
Ig3DBaseBrowserm_source

Static Private Attributes

static const char * s_active = "Active"
static const char * s_all = "All"
static const char * s_group = "Clip Planes"


Detailed Description

Definition at line 29 of file Ig3DClipsCategory.h.


Constructor & Destructor Documentation

Ig3DClipsCategory::Ig3DClipsCategory ( IgState state,
Ig3DBaseBrowser source 
)

Definition at line 39 of file Ig3DClipsCategory.cc.

References reco::fitHelper::add(), Ig3DPlaneControl::axisRotationControl(), IgControlCategory::bottomLayout(), Ig3DRangeControl< C1, C2, C3 >::control(), Ig3DPlaneControl::distanceControl(), m_manip, m_on, m_plane, IgControlCategory::panel(), IgState::put(), IgQtRangeControlCommon::widget(), Ig3DBoolControl::widget(), Ig3DAxisRotationControl::xWidget(), Ig3DAxisRotationControl::yWidget(), and Ig3DAxisRotationControl::zWidget().

00041     : Ig3DObjectCategory<IgSoClipPlane> (state, "Clip Planes"),
00042       m_source (source),
00043       m_plane (new Ig3DPlaneControl (this, "Plane")),
00044       m_on    (new Ig3DBoolControl  (this, "Active")),
00045       m_manip (new Ig3DBoolControl  (this, "Manipulator"))
00046 {
00047     QWhatsThis::add (panel (), "3D Clip-Plane Category");
00048     QWhatsThis::add (m_manip-> widget (), "Trun on/off the 3D Clip Plane's manipulator");
00049     QWhatsThis::add (m_on->widget (), "Activate/deactivate 3D Clip plane");
00050         QWhatsThis::add (m_plane->axisRotationControl ()->xWidget(), 
00051                                         "Rotate 3D clip plane around X-axis.");
00052         QWhatsThis::add (m_plane->axisRotationControl ()->yWidget(), 
00053                                         "Rotate 3D clip plane around Y-axis.");
00054         QWhatsThis::add (m_plane->axisRotationControl ()->zWidget(), 
00055                                         "Rotate 3D clip plane around Z-axis.");
00056     QWhatsThis::add (m_plane->distanceControl ()->control ()->widget (),
00057                    "Distance of 3D Clip plane from origin");
00058 
00059     // Space it up 
00060     bottomLayout ()->addItem (new QSpacerItem (20, 20, 
00061         QSizePolicy::Minimum, QSizePolicy::Expanding));
00062 
00063     state->put (s_key, this);   
00064 }

Ig3DClipsCategory::Ig3DClipsCategory ( const Ig3DClipsCategory  )  [private]


Member Function Documentation

void Ig3DClipsCategory::apply ( void   )  [virtual]

Reimplemented from IgControlCategory.

Definition at line 92 of file Ig3DClipsCategory.cc.

References IgControlBase::apply(), m_manip, m_on, and m_plane.

00093 {
00094     m_plane->apply ();
00095     m_on->apply ();
00096     m_manip->apply ();
00097 }

void Ig3DClipsCategory::attach ( void   )  [virtual]

Reimplemented from IgControlCategory.

Definition at line 67 of file Ig3DClipsCategory.cc.

References IgControlCategory::currentItem(), m_manip, m_on, m_plane, IgSoClipPlane::manip, VarParsing::obj, Ig3DObjectCategory< IgSoClipPlane >::object(), IgSoClipPlane::on, IgSoClipPlane::plane, Ig3DPlaneControl::setField(), and Ig3DBoolControl::setField().

Referenced by reconstruct().

00068 {
00069     IgSoClipPlane *obj = object (currentItem ());
00070     m_plane->setField (&obj->plane);
00071     m_on->setField (&obj->on);
00072     m_manip->setField (&obj->manip);
00073 }

void Ig3DClipsCategory::browserChanged ( Ig3DBaseBrowser browser  ) 

Definition at line 347 of file Ig3DClipsCategory.cc.

References m_source, and reconstruct().

Referenced by registerBrowser().

00348 {
00349     m_source = browser;
00350     reconstruct ();
00351 }

void Ig3DClipsCategory::buildDefaults ( void   )  [private]

Definition at line 183 of file Ig3DClipsCategory.cc.

References Ig3DBaseModel::attachPoint(), m_source, makeClip(), Ig3DBaseBrowser::model(), name, VarParsing::obj, repActiveClips(), repAllClips(), and pydbsAccessor::root.

Referenced by reconstruct().

00184 {
00185     QString     name ("Full Clip Plane");
00186     IgSoClipPlane       *obj  = makeClip (name, false, SbVec3f (0, 0, 0));
00187     Ig3DBaseRep         *root = m_source->model ()->attachPoint ();
00188 
00189     repAllClips (root, true)->addChild (obj);
00190     repActiveClips (root, true)->addChild (obj);
00191     add (obj, true);
00192 }

void Ig3DClipsCategory::createNewItem ( void   )  [protected, virtual]

Reimplemented from IgControlCategory.

Definition at line 230 of file Ig3DClipsCategory.cc.

References IgControlCategory::itemChanged(), IgControlCategory::items(), makeOne(), and IgControlCategory::setCurrentItem().

00231 {
00232         bool isMade = makeOne ();
00233         if (isMade)
00234         {
00235                 setCurrentItem (items ()-1);
00236                 itemChanged (-1);
00237         }
00238 }

void Ig3DClipsCategory::deleteItem ( void   )  [protected, virtual]

Reimplemented from IgControlCategory.

Definition at line 241 of file Ig3DClipsCategory.cc.

References deleteOne().

00242 { deleteOne (); }

void Ig3DClipsCategory::deleteOne ( void   )  [private, virtual, slot]

Definition at line 305 of file Ig3DClipsCategory.cc.

References ASSERT, Ig3DBaseModel::attachPoint(), IgControlCategory::currentItem(), detach(), i, m_source, Ig3DBaseBrowser::model(), VarParsing::obj, Ig3DObjectCategory< IgSoClipPlane >::object(), dbtoconf::parent, pydbsAccessor::root, TRUE, and VERIFY.

Referenced by deleteItem().

00306 {
00307     // Search for the object in all reps below the root and remove it.
00308     int         current  = currentItem ();
00309     Ig3DBaseRep    *root = m_source->model ()->attachPoint ();
00310     IgSoClipPlane  *obj  = object (current);
00311 
00312     SoPath              *location;
00313     SoSearchAction      searcher;
00314 
00315     searcher.setNode (obj);
00316     searcher.setInterest (SoSearchAction::ALL);
00317     searcher.setSearchingAll (TRUE);
00318     searcher.apply (root);
00319 
00320     for (int i = 0; i < searcher.getPaths ().getLength (); ++i)
00321     {
00322         VERIFY (location = searcher.getPaths () [i]);
00323         ASSERT (location->getLength () >= 2);
00324         SoNode *parent = location->getNode (location->getLength () - 2);
00325         ASSERT (parent->isOfType (SoGroup::getClassTypeId ()));
00326         static_cast<SoGroup *> (parent)->removeChild (obj);
00327     }
00328 
00329     detach();
00330     remove (current);
00331 }

void Ig3DClipsCategory::detach ( void   )  [virtual]

Reimplemented from IgControlCategory.

Definition at line 76 of file Ig3DClipsCategory.cc.

References m_manip, m_on, m_plane, Ig3DPlaneControl::setField(), and Ig3DBoolControl::setField().

Referenced by deleteOne(), and reconstruct().

00077 {
00078     m_plane->setField (0);
00079     m_on->setField (0);
00080     m_manip->setField (0);
00081 }

Ig3DClipsCategory::IG_DECLARE_STATE_ELEMENT ( Ig3DClipsCategory   )  [private]

IgSoClipPlane * Ig3DClipsCategory::makeClip ( QString  name,
bool  on,
SbVec3f  center 
) [private]

Definition at line 169 of file Ig3DClipsCategory.cc.

References dot(), Ig3DBaseModel::encode(), IgSoClipPlane::manip, VarParsing::obj, IgSoClipPlane::on, and IgSoClipPlane::plane.

Referenced by buildDefaults(), and makeOne().

00170 {
00171     // Define the clip plane normal as -X axis translated by `center'
00172     // (i.e. distance by dot product of `center' and -X axis).
00173     IgSoClipPlane *obj = new IgSoClipPlane;
00174     obj->setName (Ig3DBaseModel::encode (name.utf8 ().data ()));
00175     obj->plane = SbPlane (SbVec3f(-1,0,0), SbVec3f (-1,0,0).dot (center));
00176     obj->on = on;
00177     obj->manip = false;
00178     return obj;
00179 }

bool Ig3DClipsCategory::makeOne ( void   )  [private, virtual, slot]

Definition at line 258 of file Ig3DClipsCategory.cc.

References Ig3DBaseModel::attachPoint(), m_source, and Ig3DBaseBrowser::model().

Referenced by createNewItem().

00259 { return makeOne (m_source->model ()->attachPoint ());}

bool Ig3DClipsCategory::makeOne ( Ig3DBaseRep rep  ) 

Definition at line 262 of file Ig3DClipsCategory.cc.

References arg, ASSERT, Ig3DBaseModel::attachPoint(), pyDBSguiBaseClass::base, Ig3DBaseModel::decode(), m_source, Ig3DBaseRep::magic(), makeClip(), Ig3DBaseBrowser::model(), name, Ig3DBaseRep::node(), edm::Normal, VarParsing::obj, IgControlCategory::panel(), prof2calltree::prefix, repActiveClips(), repAllClips(), and pydbsAccessor::root.

Referenced by Ig3DWindow::repClip().

00263 {
00264         bool isMade = false;
00265     ASSERT (rep);
00266     ASSERT (rep->node ());
00267     ASSERT (rep->magic ());
00268 
00269     // Build the base name looking at the number of slicers first by
00270     // the node's own name, and failing that, the generic name.  Make
00271     // names unique by counting slicers in that particular rep.
00272     bool        ok = false;
00273     SoGroup     *active = repActiveClips (rep, false);
00274     int         nclips = active ? active->getNumChildren () : 0;
00275     QString     prefix (!! rep->node ()->getName ()
00276                         ? (Ig3DBaseModel::decode (rep->node()->getName()).c_str ())
00277                         : "Clip Plane");
00278     QString     base (nclips ? (prefix + " #%1").arg (nclips+1) : prefix);
00279     QString     name (QInputDialog::getText (tr("Name"), QString::null,
00280                                              QLineEdit::Normal,base,&ok, panel ()));
00281 
00282     if (! ok || name.isEmpty ())
00283         return isMade;
00284 
00285     // OK to construct the clip plane: do so.  Use object's bounding
00286     // box center to place the clip plane.
00287     SoGetBoundingBoxAction      bba (m_source->getViewportRegion ());
00288     SoSearchAction              sa;
00289     Ig3DBaseRep                 *root = m_source->model ()->attachPoint ();
00290 
00291     sa.setNode (rep);
00292     sa.apply (root);
00293     ASSERT (sa.getPath ());
00294     bba.apply (sa.getPath ());
00295 
00296     IgSoClipPlane *obj = makeClip (name, true, bba.getCenter ());
00297     repAllClips (root, true)->addChild (obj);
00298     repActiveClips (rep, true)->addChild (obj);
00299     add (obj, true);
00300         return isMade = true;
00301 }

Ig3DClipsCategory& Ig3DClipsCategory::operator= ( const Ig3DClipsCategory  )  [private]

void Ig3DClipsCategory::reconstruct ( SoGroup *  from  )  [private]

Definition at line 212 of file Ig3DClipsCategory.cc.

References ASSERT, attach(), IgControlCategory::currentItem(), detach(), i, n, prof2calltree::node, and update().

00213 {
00214     for (int i = 0, n = from->getNumChildren (); i < n; ++i)
00215     {
00216       ASSERT (from->getChild(i)->isOfType(IgSoClipPlane::getClassTypeId()));
00217       IgSoClipPlane *node = static_cast<IgSoClipPlane *>(from->getChild(i));
00218       add (node, true);
00219     }
00220     detach ();
00221     if (object (currentItem ()))
00222     {
00223         attach ();
00224         update ();
00225     }
00226 }

void Ig3DClipsCategory::reconstruct ( SoSwitch *  from  ) 

void Ig3DClipsCategory::reconstruct ( void   ) 

Definition at line 195 of file Ig3DClipsCategory.cc.

References ASSERT, Ig3DBaseModel::attachPoint(), buildDefaults(), Ig3DObjectCategory< IgSoClipPlane >::clear(), Ig3DBaseModel::encode(), Ig3DBaseRep::findMagic(), group, m_source, Ig3DBaseBrowser::model(), and s_group.

Referenced by browserChanged().

00196 {
00197     ASSERT (m_source);
00198     SoGroup *group = dynamic_cast<SoGroup *>(
00199         m_source->model ()->attachPoint ()->findMagic (
00200            Ig3DBaseModel::encode (s_group)));
00201     clear ();
00202     if (group)
00203     {
00204       ASSERT (group->getChild (0)->isOfType(SoGroup::getClassTypeId()));
00205       reconstruct (static_cast <SoGroup *>(group->getChild (0)));
00206     }
00207     else
00208       buildDefaults ();
00209 }

void Ig3DClipsCategory::registerBrowser ( IgState state,
Ig3DBaseBrowser browser 
) [virtual]

Reimplemented from Ig3DObjectCategory< IgSoClipPlane >.

Definition at line 335 of file Ig3DClipsCategory.cc.

References IgQtAppContextService::addOnFocusIn(), ASSERT, browserChanged(), lat::CreateCallback(), DBSPlugin::get(), and IgControlCategory::registerMe().

Referenced by Ig3DWindow::initCategories().

00336 {
00337     IgQtAppContextService *cs = IgQtAppContextService::get (state);
00338     ASSERT (cs);    
00339     cs->addOnFocusIn (lat::CreateCallback (this,
00340                                            &Ig3DClipsCategory::browserChanged,
00341                                            browser));    
00342     IgControlCategory::registerMe (state);
00343 }

void Ig3DClipsCategory::renameItem ( const QString &  newName  )  [protected, virtual]

Reimplemented from IgControlCategory.

Definition at line 245 of file Ig3DClipsCategory.cc.

References IgControlCategory::currentItem(), IgControlCategory::currentText(), Ig3DBaseModel::decode(), edm::getName(), Ig3DObjectCategory< IgSoClipPlane >::rename(), and IgControlCategory::renameItem().

00246 {
00247     int current         = currentItem ();
00248     QString oldName (Ig3DBaseModel::decode(object (current)->getName ()).c_str ());
00249     if (!newName.isEmpty() && newName != oldName)
00250     {
00251       IgControlCategory:: renameItem(newName);
00252       rename (current, currentText ());
00253     }
00254 }

SoGroup * Ig3DClipsCategory::repActiveClips ( Ig3DBaseRep rep,
bool  make 
) [private]

Definition at line 151 of file Ig3DClipsCategory.cc.

References Ig3DBaseRep::magic(), and repClips().

Referenced by buildDefaults(), and makeOne().

00152 {
00153     // Find the active slicers group in the slicer switch in rep's `magic()'
00154     SoGroup *active = 0;
00155     repClips (rep->magic (), make, 0, &active);
00156     return active;
00157 }

SoGroup * Ig3DClipsCategory::repAllClips ( Ig3DBaseRep rep,
bool  make 
) [private]

Definition at line 160 of file Ig3DClipsCategory.cc.

References Ig3DBaseRep::magic(), Ig3DObjectCategory< IgSoClipPlane >::objects(), and repClips().

Referenced by buildDefaults(), and makeOne().

00161 {
00162     // Find all slicers group in the slicer switch in rep's `magic()'
00163     SoGroup *objects = 0;
00164     repClips (rep->magic (), make, &objects, 0);
00165     return objects;
00166 }

SoSwitch * Ig3DClipsCategory::repClips ( SoGroup *  magic,
bool  make,
SoGroup **  objects,
SoGroup **  active 
) [private]

Definition at line 101 of file Ig3DClipsCategory.cc.

References ASSERT, Ig3DBaseModel::encode(), edm::getName(), i, s_active, s_all, and s_group.

Referenced by repActiveClips(), and repAllClips().

00104 {
00105    ASSERT (magic);
00106 
00107     // Find the clip planes switch in `magic'
00108     SoSwitch    *clips = 0;
00109     SoNode      *child;
00110     for (int i = 0; i < magic->getNumChildren () && ! clips; ++i)
00111     {
00112         if ((child = magic->getChild (i))->getName ()
00113             == SbName (Ig3DBaseModel::encode (s_group)))
00114         {
00115             ASSERT (child->isOfType (SoSwitch::getClassTypeId ()));
00116             clips = static_cast<SoSwitch *> (child);
00117         }
00118     }
00119     if (! clips && make)
00120     {
00121         SoGroup *objs = new SoGroup;
00122         SoGroup *acts = new SoGroup;
00123         objs->setName (s_all);
00124         acts->setName (s_active);
00125 
00126         clips = new SoSwitch;
00127         clips->setName (Ig3DBaseModel::encode (s_group));
00128         clips->whichChild = 1;
00129         magic->addChild (clips);
00130         clips->addChild (objs);
00131         clips->addChild (acts);
00132     }
00133     
00134     if (clips)
00135     {
00136         ASSERT (clips->whichChild.getValue () == 1);
00137         ASSERT (clips->getChild (0)->isOfType (SoGroup::getClassTypeId ()));
00138         ASSERT (clips->getChild (1)->isOfType (SoGroup::getClassTypeId ()));
00139         // ASSERT (active->getNumChildren () <= objects->getNumChildren ());
00140         if (objects)
00141             *objects = static_cast<SoGroup *> (clips->getChild (0));
00142 
00143         if (active)
00144             *active = static_cast<SoGroup *> (clips->getChild (1));
00145     }
00146 
00147     return clips;
00148 }

void Ig3DClipsCategory::update ( void   )  [virtual]

Reimplemented from IgControlCategory.

Definition at line 84 of file Ig3DClipsCategory.cc.

References m_manip, m_on, m_plane, and IgControlBase::update().

Referenced by reconstruct().

00085 {
00086     m_plane->update ();
00087     m_on->update ();
00088     m_manip->update ();
00089 }


Member Data Documentation

Ig3DBoolControl* Ig3DClipsCategory::m_manip [private]

Definition at line 77 of file Ig3DClipsCategory.h.

Referenced by apply(), attach(), detach(), Ig3DClipsCategory(), and update().

Ig3DBoolControl* Ig3DClipsCategory::m_on [private]

Definition at line 76 of file Ig3DClipsCategory.h.

Referenced by apply(), attach(), detach(), Ig3DClipsCategory(), and update().

Ig3DPlaneControl* Ig3DClipsCategory::m_plane [private]

Definition at line 75 of file Ig3DClipsCategory.h.

Referenced by apply(), attach(), detach(), Ig3DClipsCategory(), and update().

Ig3DBaseBrowser* Ig3DClipsCategory::m_source [private]

Definition at line 73 of file Ig3DClipsCategory.h.

Referenced by browserChanged(), buildDefaults(), deleteOne(), makeOne(), and reconstruct().

const char * Ig3DClipsCategory::s_active = "Active" [static, private]

Definition at line 81 of file Ig3DClipsCategory.h.

Referenced by repClips().

const char * Ig3DClipsCategory::s_all = "All" [static, private]

Definition at line 80 of file Ig3DClipsCategory.h.

Referenced by repClips().

const char * Ig3DClipsCategory::s_group = "Clip Planes" [static, private]

Definition at line 79 of file Ig3DClipsCategory.h.

Referenced by reconstruct(), and repClips().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:24:57 2009 for CMSSW by  doxygen 1.5.4