SoFCUnifiedSelection.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2005 Jürgen Riegel <juergen.riegel@web.de>              *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 #include "PreCompiled.h"
00024 
00025 #ifndef _PreComp_
00026 # include <qstatusbar.h>
00027 # include <qstring.h>
00028 # include <Inventor/details/SoFaceDetail.h>
00029 # include <Inventor/details/SoLineDetail.h>
00030 #endif
00031 
00032 #include <Inventor/elements/SoOverrideElement.h>
00033 #include <Inventor/elements/SoLazyElement.h>
00034 #include <Inventor/elements/SoCacheElement.h>
00035 #include <Inventor/elements/SoOverrideElement.h>
00036 #include <Inventor/elements/SoWindowElement.h>
00037 
00038 #include <Inventor/SoFullPath.h>
00039 #include <Inventor/actions/SoGLRenderAction.h>
00040 #include <Inventor/actions/SoHandleEventAction.h>
00041 #include <Inventor/events/SoKeyboardEvent.h>
00042 #include <Inventor/elements/SoComplexityElement.h>
00043 #include <Inventor/elements/SoComplexityTypeElement.h>
00044 #include <Inventor/elements/SoCoordinateElement.h>
00045 #include <Inventor/elements/SoElements.h>
00046 #include <Inventor/elements/SoFontNameElement.h>
00047 #include <Inventor/elements/SoFontSizeElement.h>
00048 #include <Inventor/elements/SoModelMatrixElement.h>
00049 #include <Inventor/elements/SoShapeStyleElement.h>
00050 #include <Inventor/elements/SoProfileCoordinateElement.h>
00051 #include <Inventor/elements/SoProfileElement.h>
00052 #include <Inventor/elements/SoSwitchElement.h>
00053 #include <Inventor/elements/SoUnitsElement.h>
00054 #include <Inventor/elements/SoViewVolumeElement.h>
00055 #include <Inventor/elements/SoViewingMatrixElement.h>
00056 #include <Inventor/elements/SoViewportRegionElement.h>
00057 #include <Inventor/events/SoMouseButtonEvent.h>
00058 #include <Inventor/misc/SoState.h>
00059 #include <Inventor/misc/SoChildList.h>
00060 #include <Inventor/events/SoLocation2Event.h>
00061 #include <Inventor/SoPickedPoint.h>
00062 
00063 #include "View3DInventor.h"
00064 #include "View3DInventorViewer.h"
00065 
00066 #include <Base/Console.h>
00067 #include <App/Application.h>
00068 #include <App/Document.h>
00069 #include <App/DocumentObject.h>
00070 
00071 #include "SoFCUnifiedSelection.h"
00072 #include "Application.h"
00073 #include "MainWindow.h"
00074 #include "Selection.h"
00075 #include "ViewProvider.h"
00076 #include "SoFCInteractiveElement.h"
00077 #include "SoFCSelectionAction.h"
00078 #include "ViewProviderDocumentObject.h"
00079 
00080 using namespace Gui;
00081 
00082 SoFullPath * Gui::SoFCUnifiedSelection::currenthighlight = NULL;
00083 
00084 
00085 // *************************************************************************
00086 
00087 SO_NODE_SOURCE(SoFCUnifiedSelection);
00088 
00092 SoFCUnifiedSelection::SoFCUnifiedSelection() : viewer(0)
00093 {
00094     SO_NODE_CONSTRUCTOR(SoFCUnifiedSelection);
00095 
00096     SO_NODE_ADD_FIELD(colorHighlight, (SbColor(1.0f, 0.6f, 0.0f)));
00097     SO_NODE_ADD_FIELD(colorSelection, (SbColor(0.1f, 0.8f, 0.1f)));
00098     SO_NODE_ADD_FIELD(highlightMode,  (AUTO));
00099     SO_NODE_ADD_FIELD(selectionMode,  (ON));
00100     SO_NODE_ADD_FIELD(selectionRole,  (TRUE));
00101 
00102     SO_NODE_DEFINE_ENUM_VALUE(HighlightModes, AUTO);
00103     SO_NODE_DEFINE_ENUM_VALUE(HighlightModes, ON);
00104     SO_NODE_DEFINE_ENUM_VALUE(HighlightModes, OFF);
00105     SO_NODE_SET_SF_ENUM_TYPE (highlightMode, HighlightModes);
00106 
00107     highlighted = FALSE;
00108     bShift      = FALSE;
00109     bCtrl       = FALSE;
00110 }
00111 
00115 SoFCUnifiedSelection::~SoFCUnifiedSelection()
00116 {
00117     // If we're being deleted and we're the current highlight,
00118     // NULL out that variable
00119     if (currenthighlight != NULL) {
00120         currenthighlight->unref();
00121         currenthighlight = NULL;
00122     }
00123 }
00124 
00125 // doc from parent
00126 void
00127 SoFCUnifiedSelection::initClass(void)
00128 {
00129     SO_NODE_INIT_CLASS(SoFCUnifiedSelection,SoSeparator,"Separator");
00130 }
00131 
00132 void SoFCUnifiedSelection::finish()
00133 {
00134     atexit_cleanup();
00135 }
00136 
00137 void SoFCUnifiedSelection::applySettings()
00138 {
00139     float transparency;
00140     ParameterGrp::handle hGrp = Gui::WindowParameter::getDefaultParameter()->GetGroup("View");
00141     bool enablePre = hGrp->GetBool("EnablePreselection", true);
00142     bool enableSel = hGrp->GetBool("EnableSelection", true);
00143     if (!enablePre) {
00144         this->highlightMode = SoFCUnifiedSelection::OFF;
00145     }
00146     else {
00147         // Search for a user defined value with the current color as default
00148         SbColor highlightColor = this->colorHighlight.getValue();
00149         unsigned long highlight = (unsigned long)(highlightColor.getPackedValue());
00150         highlight = hGrp->GetUnsigned("HighlightColor", highlight);
00151         highlightColor.setPackedValue((uint32_t)highlight, transparency);
00152         this->colorHighlight.setValue(highlightColor);
00153     }
00154     if (!enableSel) {
00155         this->selectionMode = SoFCUnifiedSelection::OFF;
00156     }
00157     else {
00158         // Do the same with the selection color
00159         SbColor selectionColor = this->colorSelection.getValue();
00160         unsigned long selection = (unsigned long)(selectionColor.getPackedValue());
00161         selection = hGrp->GetUnsigned("SelectionColor", selection);
00162         selectionColor.setPackedValue((uint32_t)selection, transparency);
00163         this->colorSelection.setValue(selectionColor);
00164     }
00165 }
00166 
00167 const char* SoFCUnifiedSelection::getFileFormatName(void) const
00168 {
00169     return "Separator";
00170 }
00171 
00172 int SoFCUnifiedSelection::getPriority(const SoPickedPoint* p)
00173 {
00174     const SoDetail* detail = p->getDetail();
00175     if (!detail)                                           return 0;
00176     if (detail->isOfType(SoFaceDetail::getClassTypeId()))  return 1;
00177     if (detail->isOfType(SoLineDetail::getClassTypeId()))  return 2;
00178     if (detail->isOfType(SoPointDetail::getClassTypeId())) return 3;
00179     return 0;
00180 }
00181 
00182 const SoPickedPoint*
00183 SoFCUnifiedSelection::getPickedPoint(SoHandleEventAction* action) const
00184 {
00185     // To identify the picking of lines in a concave area we have to 
00186     // get all intersection points. If we have two or more intersection
00187     // points where the first is of a face and the second of a line with
00188     // almost similar coordinates we use the second point, instead.
00189     const SoPickedPointList & points = action->getPickedPointList();
00190     if (points.getLength() == 0)
00191         return 0;
00192     else if (points.getLength() == 1)
00193         return points[0];
00194     
00195     const SoPickedPoint* picked = points[0];
00196     int picked_prio = getPriority(picked);
00197     const SbVec3f& picked_pt = picked->getPoint();
00198 
00199     for (int i=1; i<points.getLength();i++) {
00200         const SoPickedPoint* cur = points[i];
00201         int cur_prio = getPriority(cur);
00202         const SbVec3f& cur_pt = cur->getPoint();
00203 
00204         if ((cur_prio > picked_prio) && picked_pt.equals(cur_pt, 0.01f)) {
00205             picked = cur;
00206             picked_prio = cur_prio;
00207         }
00208     }
00209     return picked;
00210 }
00211 
00212 void SoFCUnifiedSelection::doAction(SoAction *action)
00213 {
00214     if (action->getTypeId() == SoFCEnableHighlightAction::getClassTypeId()) {
00215         SoFCEnableHighlightAction *preaction = (SoFCEnableHighlightAction*)action;
00216         if (preaction->highlight) {
00217             this->highlightMode = SoFCUnifiedSelection::AUTO;
00218         }
00219         else {
00220             this->highlightMode = SoFCUnifiedSelection::OFF;
00221         }
00222     }
00223 
00224     if (action->getTypeId() == SoFCEnableSelectionAction::getClassTypeId()) {
00225         SoFCEnableSelectionAction *selaction = (SoFCEnableSelectionAction*)action;
00226         if (selaction->selection) {
00227             this->selectionMode = SoFCUnifiedSelection::ON;
00228         }
00229         else {
00230             this->selectionMode = SoFCUnifiedSelection::OFF;
00231         }
00232     }
00233 
00234     if (action->getTypeId() == SoFCSelectionColorAction::getClassTypeId()) {
00235         SoFCSelectionColorAction *colaction = (SoFCSelectionColorAction*)action;
00236         this->colorSelection = colaction->selectionColor;
00237     }
00238 
00239     if (action->getTypeId() == SoFCHighlightColorAction::getClassTypeId()) {
00240         SoFCHighlightColorAction *colaction = (SoFCHighlightColorAction*)action;
00241         this->colorHighlight = colaction->highlightColor;
00242     }
00243 
00244     if (selectionMode.getValue() == ON && action->getTypeId() == SoFCSelectionAction::getClassTypeId()) {
00245         SoFCSelectionAction *selaction = static_cast<SoFCSelectionAction*>(action);
00246         if (selaction->SelChange.Type == SelectionChanges::AddSelection || 
00247             selaction->SelChange.Type == SelectionChanges::RmvSelection) {
00248             // selection changes inside the 3d view are handled in handleEvent()
00249             if (!currenthighlight) {
00250                 App::Document* doc = App::GetApplication().getDocument(selaction->SelChange.pDocName);
00251                 App::DocumentObject* obj = doc->getObject(selaction->SelChange.pObjectName);
00252                 ViewProvider*vp = Application::Instance->getViewProvider(obj);
00253                 if (vp && vp->useNewSelectionModel() && vp->isSelectable()) {
00254                     SoSelectionElementAction::Type type = SoSelectionElementAction::None;
00255                     if (selaction->SelChange.Type == SelectionChanges::AddSelection)
00256                         type = SoSelectionElementAction::All;
00257                     else
00258                         type = SoSelectionElementAction::None;
00259                     SoSelectionElementAction action(type);
00260                     action.setColor(this->colorSelection.getValue());
00261                     action.apply(vp->getRoot());
00262                 }
00263             }
00264         }
00265         else if (selaction->SelChange.Type == SelectionChanges::ClrSelection ||
00266                  selaction->SelChange.Type == SelectionChanges::SetSelection) {
00267             std::vector<ViewProvider*> vps = this->viewer->getViewProvidersOfType
00268                 (ViewProviderDocumentObject::getClassTypeId());
00269             for (std::vector<ViewProvider*>::iterator it = vps.begin(); it != vps.end(); ++it) {
00270                 ViewProviderDocumentObject* vpd = static_cast<ViewProviderDocumentObject*>(*it);
00271                 if (vpd->useNewSelectionModel()) {
00272                     if (Selection().isSelected(vpd->getObject()) && vpd->isSelectable()) {
00273                         SoSelectionElementAction action(SoSelectionElementAction::All);
00274                         action.setColor(this->colorSelection.getValue());
00275                         action.apply(vpd->getRoot());
00276                     }
00277                     else {
00278                         SoSelectionElementAction action(SoSelectionElementAction::None);
00279                         action.setColor(this->colorSelection.getValue());
00280                         action.apply(vpd->getRoot());
00281                     }
00282                 }
00283             }
00284         }
00285     }
00286 
00287     inherited::doAction( action );
00288 }
00289 
00290 // doc from parent
00291 void
00292 SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action)
00293 {
00294     // If off then don't handle this event
00295     if (!selectionRole.getValue()) {
00296         inherited::handleEvent(action);
00297         return;
00298     }
00299 
00300     static char buf[513];
00301     HighlightModes mymode = (HighlightModes) this->highlightMode.getValue();
00302     const SoEvent * event = action->getEvent();
00303 
00304     // If we don't need to pick for locate highlighting,
00305     // then just behave as separator and return.
00306     // NOTE: we still have to pick for ON even though we don't have
00307     // to re-render, because the app needs to be notified as the mouse
00308     // goes over locate highlight nodes.
00309     //if (highlightMode.getValue() == OFF) {
00310     //    inherited::handleEvent( action );
00311     //    return;
00312     //}
00313 
00314     
00315     //
00316     // If this is a mouseMotion event, then check for locate highlighting
00317     //
00318     if (event->isOfType(SoLocation2Event::getClassTypeId())) {
00319         // NOTE: If preselection is off then we do not check for a picked point because otherwise this search may slow
00320         // down extremely the system on really big data sets. In this case we just check for a picked point if the data
00321         // set has been selected.
00322         if (mymode == AUTO || mymode == ON) {
00323             // check to see if the mouse is over our geometry...
00324             const SoPickedPoint * pp = this->getPickedPoint(action);
00325             SoFullPath *pPath = (pp != NULL) ? (SoFullPath *) pp->getPath() : NULL;
00326             ViewProvider *vp = 0;
00327             ViewProviderDocumentObject* vpd = 0;
00328             if (pPath && pPath->containsPath(action->getCurPath()))
00329                 vp = viewer->getViewProviderByPathFromTail(pPath);
00330             if (vp && vp->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
00331                 vpd = static_cast<ViewProviderDocumentObject*>(vp);
00332 
00333             SbBool old_state = highlighted;
00334             highlighted = FALSE;
00335             if (vpd && vpd->useNewSelectionModel() && vpd->isSelectable()) {
00336                 std::string documentName = vpd->getObject()->getDocument()->getName();
00337                 std::string objectName = vpd->getObject()->getNameInDocument();
00338                 std::string subElementName = vpd->getElement(pp);
00339 
00340                 static char buf[513];
00341                 snprintf(buf,512,"Preselected: %s.%s.%s (%f,%f,%f)",documentName.c_str()
00342                                            ,objectName.c_str()
00343                                            ,subElementName.c_str()
00344                                            ,pp->getPoint()[0]
00345                                            ,pp->getPoint()[1]
00346                                            ,pp->getPoint()[2]);
00347 
00348                 getMainWindow()->showMessage(QString::fromAscii(buf),3000);
00349 
00350                 if (Gui::Selection().setPreselect(documentName.c_str()
00351                                        ,objectName.c_str()
00352                                        ,subElementName.c_str()
00353                                        ,pp->getPoint()[0]
00354                                        ,pp->getPoint()[1]
00355                                        ,pp->getPoint()[2])){
00356 
00357                     SoSearchAction sa;
00358                     sa.setNode(vp->getRoot());
00359                     sa.apply(vp->getRoot());
00360                     if (sa.getPath()) {
00361                         highlighted = TRUE;
00362                         if (currenthighlight && currenthighlight->getTail() != sa.getPath()->getTail()) {
00363                             SoHighlightElementAction action;
00364                             action.setHighlighted(FALSE);
00365                             action.apply(currenthighlight);
00366                             currenthighlight->unref();
00367                             currenthighlight = 0;
00368                             old_state = !highlighted;
00369                         }
00370 
00371                         currenthighlight = static_cast<SoFullPath*>(sa.getPath()->copy());
00372                         currenthighlight->ref();
00373                     }
00374                 }
00375             }
00376 
00377             if (currenthighlight/* && old_state != highlighted*/) {
00378                 SoHighlightElementAction action;
00379                 action.setHighlighted(highlighted);
00380                 action.setColor(this->colorHighlight.getValue());
00381                 action.setElement(pp);
00382                 action.apply(currenthighlight);
00383                 if (!highlighted) {
00384                     currenthighlight->unref();
00385                     currenthighlight = 0;
00386                 }
00387                 this->touch();
00388             }
00389         }
00390     }
00391     // key press events
00392     else if (event->isOfType(SoKeyboardEvent ::getClassTypeId())) {
00393         SoKeyboardEvent  * const e = (SoKeyboardEvent  *) event;
00394         if (SoKeyboardEvent::isKeyPressEvent(e,SoKeyboardEvent::LEFT_SHIFT)     ||
00395             SoKeyboardEvent::isKeyPressEvent(e,SoKeyboardEvent::RIGHT_SHIFT)     )
00396             bShift = true;
00397         if (SoKeyboardEvent::isKeyReleaseEvent(e,SoKeyboardEvent::LEFT_SHIFT)   ||
00398             SoKeyboardEvent::isKeyReleaseEvent(e,SoKeyboardEvent::RIGHT_SHIFT)   )
00399             bShift = false;
00400         if (SoKeyboardEvent::isKeyPressEvent(e,SoKeyboardEvent::LEFT_CONTROL)   ||
00401             SoKeyboardEvent::isKeyPressEvent(e,SoKeyboardEvent::RIGHT_CONTROL)   )
00402             bCtrl = true;
00403         if (SoKeyboardEvent::isKeyReleaseEvent(e,SoKeyboardEvent::LEFT_CONTROL) ||
00404             SoKeyboardEvent::isKeyReleaseEvent(e,SoKeyboardEvent::RIGHT_CONTROL) )
00405             bCtrl = false;
00406     }
00407     // mouse press events for (de)selection
00408     else if (event->isOfType(SoMouseButtonEvent::getClassTypeId()) && 
00409              selectionMode.getValue() == SoFCUnifiedSelection::ON) {
00410         const SoMouseButtonEvent* e = static_cast<const SoMouseButtonEvent *>(event);
00411         if (SoMouseButtonEvent::isButtonReleaseEvent(e,SoMouseButtonEvent::BUTTON1)) {
00412             // check to see if the mouse is over a geometry...
00413             const SoPickedPoint * pp = this->getPickedPoint(action);
00414             SoFullPath *pPath = (pp != NULL) ? (SoFullPath *) pp->getPath() : NULL;
00415             ViewProvider *vp = 0;
00416             ViewProviderDocumentObject* vpd = 0;
00417             if (pPath && pPath->containsPath(action->getCurPath()))
00418                 vp = viewer->getViewProviderByPathFromTail(pPath);
00419             if (vp && vp->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
00420                 vpd = static_cast<ViewProviderDocumentObject*>(vp);
00421             if (vpd && vpd->useNewSelectionModel() && vpd->isSelectable()) {
00422                 SoSelectionElementAction::Type type = SoSelectionElementAction::None;
00423                 std::string documentName = vpd->getObject()->getDocument()->getName();
00424                 std::string objectName = vpd->getObject()->getNameInDocument();
00425                 std::string subElementName = vpd->getElement(pp);
00426                 if (bCtrl) {
00427                     if (Gui::Selection().isSelected(documentName.c_str()
00428                                          ,objectName.c_str()
00429                                          ,subElementName.c_str())) {
00430                         Gui::Selection().rmvSelection(documentName.c_str()
00431                                           ,objectName.c_str()
00432                                           ,subElementName.c_str());
00433                         type = SoSelectionElementAction::Remove;
00434                     }
00435                     else {
00436                         bool ok = Gui::Selection().addSelection(documentName.c_str()
00437                                           ,objectName.c_str()
00438                                           ,subElementName.c_str()
00439                                           ,pp->getPoint()[0]
00440                                           ,pp->getPoint()[1]
00441                                           ,pp->getPoint()[2]);
00442                         if (ok)
00443                             type = SoSelectionElementAction::Append;
00444                         if (mymode == OFF) {
00445                             snprintf(buf,512,"Selected: %s.%s.%s (%f,%f,%f)",documentName.c_str()
00446                                                        ,objectName.c_str()
00447                                                        ,subElementName.c_str()
00448                                                        ,pp->getPoint()[0]
00449                                                        ,pp->getPoint()[1]
00450                                                        ,pp->getPoint()[2]);
00451 
00452                             getMainWindow()->showMessage(QString::fromAscii(buf),3000);
00453                         }
00454                     }
00455                 }
00456                 else { // Ctrl
00457                     if (!Gui::Selection().isSelected(documentName.c_str()
00458                                          ,objectName.c_str()
00459                                          ,subElementName.c_str())) {
00460                         Gui::Selection().clearSelection(documentName.c_str());
00461                         bool ok = Gui::Selection().addSelection(documentName.c_str()
00462                                               ,objectName.c_str()
00463                                               ,subElementName.c_str()
00464                                               ,pp->getPoint()[0]
00465                                               ,pp->getPoint()[1]
00466                                               ,pp->getPoint()[2]);
00467                         if (ok)
00468                             type = SoSelectionElementAction::Append;
00469                     }
00470                     else {
00471                         Gui::Selection().clearSelection(documentName.c_str());
00472                         bool ok = Gui::Selection().addSelection(documentName.c_str()
00473                                               ,objectName.c_str()
00474                                               ,0
00475                                               ,pp->getPoint()[0]
00476                                               ,pp->getPoint()[1]
00477                                               ,pp->getPoint()[2]);
00478                         if (ok)
00479                             type = SoSelectionElementAction::All;
00480                     }
00481 
00482                     if (mymode == OFF) {
00483                         snprintf(buf,512,"Selected: %s.%s.%s (%f,%f,%f)",documentName.c_str()
00484                                                    ,objectName.c_str()
00485                                                    ,subElementName.c_str()
00486                                                    ,pp->getPoint()[0]
00487                                                    ,pp->getPoint()[1]
00488                                                    ,pp->getPoint()[2]);
00489 
00490                         getMainWindow()->showMessage(QString::fromAscii(buf),3000);
00491                     }
00492                 }
00493 
00494                 action->setHandled(); 
00495                 if (currenthighlight) {
00496                     SoSelectionElementAction action(type);
00497                     action.setColor(this->colorSelection.getValue());
00498                     action.setElement(pp);
00499                     action.apply(currenthighlight);
00500                     this->touch();
00501                 }
00502             } // picked point
00503         } // mouse release
00504     }
00505 
00506     inherited::handleEvent(action);
00507 }
00508 
00509 // ---------------------------------------------------------------
00510 
00511 SO_ACTION_SOURCE(SoHighlightElementAction);
00512 
00513 void SoHighlightElementAction::initClass()
00514 {
00515     SO_ACTION_INIT_CLASS(SoHighlightElementAction,SoAction);
00516 
00517     SO_ENABLE(SoHighlightElementAction, SoSwitchElement);
00518 
00519     SO_ACTION_ADD_METHOD(SoNode,nullAction);
00520 
00521     SO_ENABLE(SoHighlightElementAction, SoCoordinateElement);
00522 
00523     SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
00524     SO_ACTION_ADD_METHOD(SoIndexedLineSet,callDoAction);
00525     SO_ACTION_ADD_METHOD(SoIndexedFaceSet,callDoAction);
00526     SO_ACTION_ADD_METHOD(SoPointSet,callDoAction);
00527 }
00528 
00529 SoHighlightElementAction::SoHighlightElementAction () : _highlight(FALSE), _pp(0)
00530 {
00531     SO_ACTION_CONSTRUCTOR(SoHighlightElementAction);
00532 }
00533 
00534 SoHighlightElementAction::~SoHighlightElementAction()
00535 {
00536 }
00537 
00538 void SoHighlightElementAction::beginTraversal(SoNode *node)
00539 {
00540     traverse(node);
00541 }
00542 
00543 void SoHighlightElementAction::callDoAction(SoAction *action,SoNode *node)
00544 {
00545     node->doAction(action);
00546 }
00547 
00548 void SoHighlightElementAction::setHighlighted(SbBool ok)
00549 {
00550     this->_highlight = ok;
00551 }
00552 
00553 SbBool SoHighlightElementAction::isHighlighted() const
00554 {
00555     return this->_highlight;
00556 }
00557 
00558 void SoHighlightElementAction::setColor(const SbColor& c)
00559 {
00560     this->_color = c;
00561 }
00562 
00563 const SbColor& SoHighlightElementAction::getColor() const
00564 {
00565     return this->_color;
00566 }
00567 
00568 void SoHighlightElementAction::setElement(const SoPickedPoint* pp)
00569 {
00570     this->_pp = pp;
00571 }
00572 
00573 const SoPickedPoint* SoHighlightElementAction::getElement() const
00574 {
00575     return this->_pp;
00576 }
00577 
00578 // ---------------------------------------------------------------
00579 
00580 SO_ACTION_SOURCE(SoSelectionElementAction);
00581 
00582 void SoSelectionElementAction::initClass()
00583 {
00584     SO_ACTION_INIT_CLASS(SoSelectionElementAction,SoAction);
00585 
00586     SO_ENABLE(SoSelectionElementAction, SoSwitchElement);
00587 
00588     SO_ACTION_ADD_METHOD(SoNode,nullAction);
00589 
00590     SO_ENABLE(SoSelectionElementAction, SoCoordinateElement);
00591 
00592     SO_ACTION_ADD_METHOD(SoCoordinate3,callDoAction);
00593     SO_ACTION_ADD_METHOD(SoGroup,callDoAction);
00594     SO_ACTION_ADD_METHOD(SoIndexedLineSet,callDoAction);
00595     SO_ACTION_ADD_METHOD(SoIndexedFaceSet,callDoAction);
00596     SO_ACTION_ADD_METHOD(SoPointSet,callDoAction);
00597 }
00598 
00599 SoSelectionElementAction::SoSelectionElementAction (Type t) : _type(t), _select(FALSE), _pp(0)
00600 {
00601     SO_ACTION_CONSTRUCTOR(SoSelectionElementAction);
00602 }
00603 
00604 SoSelectionElementAction::~SoSelectionElementAction()
00605 {
00606 }
00607 
00608 void SoSelectionElementAction::beginTraversal(SoNode *node)
00609 {
00610     traverse(node);
00611 }
00612 
00613 void SoSelectionElementAction::callDoAction(SoAction *action,SoNode *node)
00614 {
00615     node->doAction(action);
00616 }
00617 
00618 SoSelectionElementAction::Type
00619 SoSelectionElementAction::getType() const
00620 {
00621     return this->_type;
00622 }
00623 
00624 void SoSelectionElementAction::setColor(const SbColor& c)
00625 {
00626     this->_color = c;
00627 }
00628 
00629 const SbColor& SoSelectionElementAction::getColor() const
00630 {
00631     return this->_color;
00632 }
00633 
00634 void SoSelectionElementAction::setElement(const SoPickedPoint* pp)
00635 {
00636     this->_pp = pp;
00637 }
00638 
00639 const SoPickedPoint* SoSelectionElementAction::getElement() const
00640 {
00641     return this->_pp;
00642 }

Generated on Wed Nov 23 19:00:40 2011 for FreeCAD by  doxygen 1.6.1