From: vsv Date: Fri, 18 Jul 2014 14:48:17 +0000 (+0400) Subject: Provide selection synchronisation X-Git-Tag: V_0.4.4~169 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cb9afcaeb3a576dcc428d4fe1741be99347ed486;p=modules%2Fshaper.git Provide selection synchronisation --- diff --git a/src/ModuleBase/ModuleBase_ViewerPrs.h b/src/ModuleBase/ModuleBase_ViewerPrs.h index a365c753a..40ec66613 100644 --- a/src/ModuleBase/ModuleBase_ViewerPrs.h +++ b/src/ModuleBase/ModuleBase_ViewerPrs.h @@ -69,7 +69,7 @@ public: bool aResult = (myResult.get() == thePrs.object().get()); bool aOwner = (myOwner.Access() == thePrs.owner().Access()); bool aShape = myShape.IsEqual(thePrs.shape()); - bool aIO = myInteractive == thePrs.interactive(); + bool aIO = (myInteractive == thePrs.interactive()); return aResult && aOwner && aShape && aIO; } diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp index 2a65062b0..7bf014ed3 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeature.cpp @@ -28,7 +28,7 @@ ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent, : ModuleBase_ModelWidget(theParent, theData) { QString aKinds = QString::fromStdString(theData->getProperty(FEATURE_KEYSEQUENCE)); - myFeatureKinds = aKinds.split(" "); + myObjectKinds = aKinds.split(" "); myContainer = new QWidget(theParent); QHBoxLayout* aControlLay = new QHBoxLayout(myContainer); @@ -62,20 +62,20 @@ bool ModuleBase_WidgetFeature::setValue(ModuleBase_WidgetValue* theValue) if (theValue) { ModuleBase_WidgetValueFeature* aFeatureValue = dynamic_cast(theValue); - // TODO -// if (aFeatureValue) -// isDone = setFeature(aFeatureValue->feature()); + if (aFeatureValue) + isDone = setObject(aFeatureValue->object()); } return isDone; } -bool ModuleBase_WidgetFeature::setFeature(const FeaturePtr& theFeature) +bool ModuleBase_WidgetFeature::setObject(const ObjectPtr& theObject) { - if (!myFeatureKinds.contains(theFeature->getKind().c_str())) - return false; + // TODO + //if (!myObjectKinds.contains(theObject->getKind().c_str())) + // return false; - myFeature = theFeature; - myEditor->setText(theFeature ? theFeature->data()->name().c_str() : ""); + myObject = theObject; + myEditor->setText(theObject ? theObject->data()->name().c_str() : ""); emit valuesChanged(); return true; } @@ -90,7 +90,7 @@ bool ModuleBase_WidgetFeature::storeValue(ObjectPtr theObject) const boost::dynamic_pointer_cast(aData->attribute(attributeID())); ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this; - aRef->setObject(myFeature); + aRef->setObject(myObject); aFeature->execute(); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); @@ -105,8 +105,8 @@ bool ModuleBase_WidgetFeature::restoreValue(ObjectPtr theObject) FeaturePtr aFeature = boost::dynamic_pointer_cast(aRef->object()); if (aFeature) { - myFeature = aFeature; - myEditor->setText(myFeature ? myFeature->data()->name().c_str() : ""); + myObject = aFeature; + myEditor->setText(myObject ? myObject->data()->name().c_str() : ""); return true; } return false; diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.h b/src/ModuleBase/ModuleBase_WidgetFeature.h index c57bd531e..8cfd499a6 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.h +++ b/src/ModuleBase/ModuleBase_WidgetFeature.h @@ -56,11 +56,11 @@ protected: /// Fill the widget values by given point /// \param thePoint the point /// \return the boolean result of the feature set - bool setFeature(const FeaturePtr& theObject); + bool setObject(const ObjectPtr& theObject); /// Returns current widget feature /// \return the feature - const FeaturePtr feature() const { return myFeature; } + const ObjectPtr object() const { return myObject; } /// Returns the widget editor /// \return the editor @@ -68,11 +68,11 @@ protected: /// Returns the possible feature kinds /// \return the list of kinds - const QStringList& featureKinds() const { return myFeatureKinds; } + const QStringList& featureKinds() const { return myObjectKinds; } private: - FeaturePtr myFeature; ///< the current widget feature - QStringList myFeatureKinds; ///< the kinds of possible features + ObjectPtr myObject; ///< the current widget feature + QStringList myObjectKinds; ///< the kinds of possible features QWidget* myContainer; /// the parent top control QLabel* myLabel; /// the editor information label diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp index 87a1a88c2..70c0fe959 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.cpp @@ -47,10 +47,9 @@ bool ModuleBase_WidgetFeatureOrAttribute::setValue(ModuleBase_WidgetValue* theVa dynamic_cast(theValue); if (aFeatureValue) { boost::shared_ptr aValuePoint = aFeatureValue->point(); - //TODO -/* FeaturePtr aValueFeature = aFeatureValue->feature(); + ObjectPtr aValueFeature = aFeatureValue->object(); if (aValueFeature) { - isDone = setFeature(aValueFeature); + isDone = setObject(aValueFeature); } if (!isDone && aValuePoint) { // find the given point in the feature attributes @@ -67,7 +66,7 @@ bool ModuleBase_WidgetFeatureOrAttribute::setValue(ModuleBase_WidgetValue* theVa } if (aFPoint) isDone = setAttribute(aFPoint); - }*/ + } } } return isDone; @@ -80,8 +79,8 @@ bool ModuleBase_WidgetFeatureOrAttribute::storeValue(FeaturePtr theFeature) cons boost::dynamic_pointer_cast(aData->attribute(attributeID())); ModuleBase_WidgetFeatureOrAttribute* that = (ModuleBase_WidgetFeatureOrAttribute*) this; - if (feature()) - aRef->setObject(feature()); + if (object()) + aRef->setObject(object()); else if (myAttribute) aRef->setAttr(myAttribute); @@ -99,7 +98,7 @@ bool ModuleBase_WidgetFeatureOrAttribute::restoreValue(FeaturePtr theFeature) FeaturePtr aFeature = boost::dynamic_pointer_cast(aRef->object()); if (aFeature) { - setFeature(aFeature); + setObject(aFeature); myAttribute = aRef->attr(); std::string aText = ""; diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp index e43f341e5..871654bd2 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2dDistance.cpp @@ -33,12 +33,12 @@ bool ModuleBase_WidgetPoint2dDistance::setValue(ModuleBase_WidgetValue* theValue dynamic_cast(theValue); if (aFeatureValue) { boost::shared_ptr aPnt = aFeatureValue->point(); - // TODO - /*FeaturePtr aFeature = aFeatureValue->feature(); + ObjectPtr aObject = aFeatureValue->object(); + FeaturePtr aFeature = boost::dynamic_pointer_cast(aObject); if (aFeature && aPnt) { setPoint(aFeature, aPnt); isDone = true; - }*/ + } } } return isDone; diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 8e05584b9..a5c40e7e8 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -240,7 +240,8 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent) Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAIS); aSketchOp->setSketchPlane(aAISShape->Shape()); } - } + } else + aSketchOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted); } else aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted); } @@ -318,25 +319,24 @@ void PartSet_Module::onMultiSelectionEnabled(bool theEnabled) aViewer->enableMultiselection(theEnabled); } -void PartSet_Module::onStopSelection(const QFeatureList& theFeatures, const bool isStop) +void PartSet_Module::onStopSelection(const QList& theFeatures, const bool isStop) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); if (!isStop) { - QFeatureList::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end(); - for (; anIt != aLast; anIt++) { - activateFeature((*anIt), false); + foreach(ObjectPtr aObject, theFeatures) { + activateFeature(aObject, false); } } - QResultList aResults; - foreach(FeaturePtr aFeature, theFeatures) { - if (aFeature->results().size() > 0) { + //ObjectPtr aResults; + //foreach(ObjectPtr aFeature, theFeatures) { +/* TODO if (aFeature->results().size() > 0) { const std::list& aResList = aFeature->results(); std::list::const_iterator aIt; for (aIt = aResList.cbegin(); aIt != aResList.cend(); ++aIt) aResults.append(*aIt); } - } - aDisplayer->stopSelection(aResults, isStop, false); + }*/ + aDisplayer->stopSelection(theFeatures, isStop, false); XGUI_ViewerProxy* aViewer = myWorkshop->viewer(); aViewer->enableSelection(!isStop); @@ -344,7 +344,7 @@ void PartSet_Module::onStopSelection(const QFeatureList& theFeatures, const bool aDisplayer->updateViewer(); } -void PartSet_Module::onSetSelection(const QResultList& theFeatures) +void PartSet_Module::onSetSelection(const QList& theFeatures) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); aDisplayer->setSelected(theFeatures, false); @@ -440,10 +440,10 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this, SLOT(onMultiSelectionEnabled(bool))); - connect(aPreviewOp, SIGNAL(stopSelection(const QFeatureList&, const bool)), - this, SLOT(onStopSelection(const QFeatureList&, const bool))); - connect(aPreviewOp, SIGNAL(setSelection(const QFeatureList&)), - this, SLOT(onSetSelection(const QFeatureList&))); + connect(aPreviewOp, SIGNAL(stopSelection(const QList&, const bool)), + this, SLOT(onStopSelection(const QList&, const bool))); + connect(aPreviewOp, SIGNAL(setSelection(const QList&)), + this, SLOT(onSetSelection(const QList&))); connect(aPreviewOp, SIGNAL(closeLocalContext()), this, SLOT(onCloseLocalContext())); @@ -532,10 +532,9 @@ void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay, boost::shared_ptr aSPFeature = boost::dynamic_pointer_cast(theFeature); if (aSPFeature) { - showPlanes(); - //boost::shared_ptr anAIS = - // aSPFeature->getAISObject(aDisplayer->getAISObject(aResult)); - //aDisplayer->redisplay(aResult, anAIS, false); + PartSet_OperationSketch* aSketchOp = dynamic_cast(aPreviewOp); + if (aSketchOp && !aSketchOp->hasSketchPlane()) + showPlanes(); } } else @@ -545,15 +544,18 @@ void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay, aDisplayer->updateViewer(); } -void PartSet_Module::activateFeature(FeaturePtr theFeature, const bool isUpdateViewer) +void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer) { ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); -/* TODO if (aPreviewOp) { - XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - aDisplayer->activateInLocalContext(theFeature->firstResult(), aPreviewOp->getSelectionModes(theFeature), - isUpdateViewer); - }*/ + if (aPreviewOp) { + PartSet_OperationSketch* aOp = dynamic_cast(aPreviewOp); + if (!aOp) { + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature), + isUpdateViewer); + } + } } void PartSet_Module::updateCurrentPreview(const std::string& theCmdId) diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 83bb0b2d0..d95a75ebe 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -62,7 +62,7 @@ public: /// Activates the feature in the displayer /// \param theFeature the feature instance to be displayed /// \param isUpdateViewer the flag whether the viewer should be updated - void activateFeature(FeaturePtr theFeature, + void activateFeature(ObjectPtr theFeature, const bool isUpdateViewer); /// Updates current operation preview, if it has it. @@ -122,11 +122,11 @@ public slots: /// SLOT, to stop or start selection mode for the features /// \param theFeatures a list of features to be disabled /// \param theToStop the boolean state whether it it stopped or non stopped - void onStopSelection(const QFeatureList& theFeatures, const bool isStop); + void onStopSelection(const QList& theFeatures, const bool isStop); /// SLOT, to set selection /// \param theFeatures a list of features to be selected - void onSetSelection(const QResultList& theFeatures); + void onSetSelection(const QList& theFeatures); /// SLOT, to close the viewer local context void onCloseLocalContext(); diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index 2e96339ff..44cf5e5a3 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -75,7 +75,7 @@ bool PartSet_OperationFeatureCreate::isGranted(ModuleBase_IOperation* theOperati return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type(); } -std::list PartSet_OperationFeatureCreate::getSelectionModes(FeaturePtr theFeature) const +std::list PartSet_OperationFeatureCreate::getSelectionModes(ObjectPtr theFeature) const { std::list aModes; if (theFeature != feature()) @@ -149,17 +149,14 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle if (!theSelected.empty()) { ModuleBase_ViewerPrs aPrs = theSelected.front(); aFeature = aPrs.object(); - } - // TODO - //else - // aFeature = feature(); // for the widget distance only + } else + aFeature = feature(); // for the widget distance only - // TODO - /*bool isApplyed = setWidgetValue(aFeature, aX, anY); + bool isApplyed = setWidgetValue(aFeature, aX, anY); if (isApplyed) { flushUpdated(); emit activateNextWidget(myActiveWidget); - }*/ + } } void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) @@ -280,7 +277,7 @@ FeaturePtr PartSet_OperationFeatureCreate::createFeature(const bool theFlushMess return aNewFeature; } -bool PartSet_OperationFeatureCreate::setWidgetValue(FeaturePtr theFeature, double theX, double theY) +bool PartSet_OperationFeatureCreate::setWidgetValue(ObjectPtr theFeature, double theX, double theY) { ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature(); aValue->setObject(theFeature); diff --git a/src/PartSet/PartSet_OperationFeatureCreate.h b/src/PartSet/PartSet_OperationFeatureCreate.h index f5823d6c1..b0d991887 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.h +++ b/src/PartSet/PartSet_OperationFeatureCreate.h @@ -52,7 +52,7 @@ public: /// Returns the operation local selection mode /// \param theFeature the feature object to get the selection mode /// \return the selection mode - virtual std::list getSelectionModes(FeaturePtr theFeature) const; + virtual std::list getSelectionModes(ObjectPtr theFeature) const; /// Initializes the operation with previously created feature. It is used in sequental operations virtual void initFeature(FeaturePtr theFeature); @@ -120,7 +120,7 @@ protected: /// \param theX the horizontal coordinate /// \param theY the vertical coordinate /// \return true if the point is set - bool setWidgetValue(FeaturePtr theFeature, double theX, double theY); + bool setWidgetValue(ObjectPtr theFeature, double theX, double theY); private: FeaturePtr myInitFeature; ///< the initial feature diff --git a/src/PartSet/PartSet_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp index 5b107d34d..7975baa65 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.cpp +++ b/src/PartSet/PartSet_OperationFeatureEdit.cpp @@ -53,7 +53,7 @@ bool PartSet_OperationFeatureEdit::isGranted(ModuleBase_IOperation* theOperation return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type(); } -std::list PartSet_OperationFeatureEdit::getSelectionModes(FeaturePtr theFeature) const +std::list PartSet_OperationFeatureEdit::getSelectionModes(ObjectPtr theFeature) const { return PartSet_OperationSketchBase::getSelectionModes(theFeature); } @@ -78,25 +78,21 @@ void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3 aFeature = theHighlighted.front().object(); if (!aFeature && !theSelected.empty()) // changed for a constrain aFeature = theSelected.front().object(); - // TODO - /*if (!aFeature || aFeature != feature()) - { + if (!aFeature || aFeature != feature()) { commit(); emit featureConstructed(feature(), FM_Deactivation); bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); if(aHasShift && !theHighlighted.empty()) { - QResultList aSelected; - // TODO + QList aSelected; aSelected.push_back(feature()); - aSelected.push_back(theHighlighted.front().result()); + aSelected.push_back(theHighlighted.front().object()); emit setSelection(aSelected); } - // TODO else if (aFeature) { restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature); } - }*/ + } } void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) @@ -175,11 +171,11 @@ void PartSet_OperationFeatureEdit::blockSelection(bool isBlocked, const bool isR return; myIsBlockedSelection = isBlocked; - QFeatureList aFeatureList; + QList aFeatureList; aFeatureList.append(feature()); if (isBlocked) { - emit setSelection(QFeatureList()); + emit setSelection(QList()); emit stopSelection(aFeatureList, true); } else { diff --git a/src/PartSet/PartSet_OperationFeatureEdit.h b/src/PartSet/PartSet_OperationFeatureEdit.h index f64e25ab1..f893a964e 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.h +++ b/src/PartSet/PartSet_OperationFeatureEdit.h @@ -68,7 +68,7 @@ public: /// Returns the operation local selection mode /// \param theFeature the feature object to get the selection mode /// \return the selection mode - virtual std::list getSelectionModes(FeaturePtr theFeature) const; + virtual std::list getSelectionModes(ObjectPtr theFeature) const; /// Initializes the operation with previously created feature. It is used in sequental operations virtual void initFeature(FeaturePtr theFeature); diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp index d66acf804..b08818ec7 100644 --- a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp +++ b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp @@ -165,13 +165,13 @@ void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, const boo return; myIsBlockedSelection = isBlocked; - QFeatureList aFeatureList; + QList aFeatureList; std::list::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end(); /*for(; anIt != aLast; anIt++) aFeatureList.append((*anIt).feature());*/ if (isBlocked) { - emit setSelection(QFeatureList()); + emit setSelection(QList()); emit stopSelection(aFeatureList, true); } else { diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index c209af34b..88a0e156e 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -86,10 +86,10 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie if (theHighlighted.size() == 1) { ObjectPtr aFeature = theHighlighted.front().object(); if (aFeature) { - std::string anOperationType = PartSet_OperationFeatureEdit::Type(); - if (theSelected.size() > 1) - anOperationType = PartSet_OperationFeatureEditMulti::Type(); - // TODO restartOperation(anOperationType, aFeature); + std::string anOperationType = (theSelected.size() > 1)? + PartSet_OperationFeatureEditMulti::Type() : + PartSet_OperationFeatureEdit::Type(); + restartOperation(anOperationType, aFeature); } } else @@ -109,9 +109,8 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi /// for these objects if (theSelected.size() == 1) { ObjectPtr aFeature = theSelected.front().object(); - // TODO - //if (aFeature) - // restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature); + if (aFeature) + restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature); } } } diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index 7c6864f7c..d82aae96b 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -50,18 +50,20 @@ std::list PartSet_OperationSketchBase::subFeatures() const return std::list(); } -std::list PartSet_OperationSketchBase::getSelectionModes(FeaturePtr theFeature) const +std::list PartSet_OperationSketchBase::getSelectionModes(ObjectPtr theFeature) const { std::list aModes; - if (PartSet_Tools::isConstraintFeature(theFeature->getKind())) { - aModes.clear(); - aModes.push_back(AIS_DSM_Text); - aModes.push_back(AIS_DSM_Line); - } - else { - aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_VERTEX)); - aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_EDGE)); + FeaturePtr aFeature = boost::dynamic_pointer_cast(theFeature); + if (aFeature) { + if (PartSet_Tools::isConstraintFeature(aFeature->getKind())) { + aModes.clear(); + aModes.push_back(AIS_DSM_Text); + aModes.push_back(AIS_DSM_Line); + return aModes; + } } + aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_VERTEX)); + aModes.push_back(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)TopAbs_EDGE)); return aModes; } FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage) @@ -118,7 +120,7 @@ void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* th } void PartSet_OperationSketchBase::restartOperation(const std::string& theType, - FeaturePtr theFeature) + ObjectPtr theFeature) { emit launchOperation(theType, theFeature); } diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index 449d65834..7916815d0 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -58,7 +58,7 @@ public: /// Returns the operation local selection mode /// \param theFeature the feature object to get the selection mode /// \return the selection mode - virtual std::list getSelectionModes(FeaturePtr theFeature) const; + virtual std::list getSelectionModes(ObjectPtr theFeature) const; /// Initializes the operation with previously created feature. It is used in sequental operations virtual void initFeature(FeaturePtr theFeature) {} @@ -116,13 +116,13 @@ public: /// \param theType a type of an operation started /// theFeature the operation argument void restartOperation(const std::string& theType, - FeaturePtr theFeature = FeaturePtr()); + ObjectPtr theFeature = ObjectPtr()); signals: /// signal about the request to launch operation /// theName the operation name /// theFeature the operation argument - void launchOperation(std::string theName, FeaturePtr theFeature); + void launchOperation(std::string theName, ObjectPtr theFeature); /// Signal about the feature construing is finished /// \param theFeature the result feature /// \param theMode the mode of the feature modification @@ -138,10 +138,10 @@ signals: /// signal to enable/disable selection in the viewer /// \param theFeatures a list of features to be disabled /// \param theToStop the boolean state whether it it stopped or non stopped - void stopSelection(const QFeatureList& theFeatures, const bool theToStop); + void stopSelection(const QList& theFeatures, const bool theToStop); /// signal to set selection in the viewer /// \param theFeatures a list of features to be disabled - void setSelection(const QFeatureList& theFeatures); + void setSelection(const QList& theFeatures); /// signal to close the operation local context if it is opened void closeLocalContext(); diff --git a/src/PartSet/PartSet_TestOCC.cpp b/src/PartSet/PartSet_TestOCC.cpp index 47e3cf870..fbf819b15 100644 --- a/src/PartSet/PartSet_TestOCC.cpp +++ b/src/PartSet/PartSet_TestOCC.cpp @@ -185,7 +185,7 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop) //aDisplayer->activateInLocalContext(aFeature, aModes, true); myTestObject = aFeature->firstResult(); - QResultList aFeatureList; + QList aFeatureList; aFeatureList.append(myTestObject); aDisplayer->setSelected(aFeatureList, true); } diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 92ae9d2a4..f124270b5 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -152,7 +152,7 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) } } -void XGUI_Displayer::activateInLocalContext(ResultPtr theResult, +void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, const std::list& theModes, const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); @@ -186,14 +186,14 @@ void XGUI_Displayer::activateInLocalContext(ResultPtr theResult, updateViewer(); } -void XGUI_Displayer::stopSelection(const QResultList& theResults, const bool isStop, +void XGUI_Displayer::stopSelection(const QList& theResults, const bool isStop, const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); Handle(AIS_Shape) anAIS; - QResultList::const_iterator anIt = theResults.begin(), aLast = theResults.end(); - ResultPtr aFeature; + QList::const_iterator anIt = theResults.begin(), aLast = theResults.end(); + ObjectPtr aFeature; for (; anIt != aLast; anIt++) { aFeature = *anIt; if (isVisible(aFeature)) @@ -216,7 +216,7 @@ void XGUI_Displayer::stopSelection(const QResultList& theResults, const bool isS updateViewer(); } -void XGUI_Displayer::setSelected(const QResultList& theResults, const bool isUpdateViewer) +void XGUI_Displayer::setSelected(const QList& theResults, const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); // we need to unhighligth objects manually in the current local context @@ -226,13 +226,12 @@ void XGUI_Displayer::setSelected(const QResultList& theResults, const bool isUpd aLocalContext->UnhilightLastDetected(myWorkshop->viewer()->activeView()); aContext->ClearSelected(); - foreach(ResultPtr aResult, theResults) { + foreach(ObjectPtr aResult, theResults) { if (myResult2AISObjectMap.find(aResult) == myResult2AISObjectMap.end()) - return; + continue; boost::shared_ptr anObj = myResult2AISObjectMap[aResult]; - if (anObj) - { + if (anObj) { Handle(AIS_InteractiveObject) anAIS = anObj->impl(); if (!anAIS.IsNull()) aContext->AddOrRemoveSelected(anAIS, false); diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index df65443a8..226a18c7b 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -70,14 +70,14 @@ public: /// \param theShape a shape /// \param theMode a list of local selection modes /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - void activateInLocalContext(ResultPtr theFeature, + void activateInLocalContext(ObjectPtr theFeature, const std::list& theModes, const bool isUpdateViewer = true); /// Stop the current selection and color the given features to the selection color /// \param theFeatures a list of features to be disabled /// \param theToStop the boolean state whether it it stopped or non stopped /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - void stopSelection(const QResultList& theFeatures, const bool isStop, + void stopSelection(const QList& theFeatures, const bool isStop, const bool isUpdateViewer); /** @@ -85,7 +85,7 @@ public: * \param theFeatures a list of features to be selected * isUpdateViewer the parameter whether the viewer should be update immediatelly */ - void setSelected(const QResultList& theFeatures, bool isUpdateViewer = true); + void setSelected(const QList& theFeatures, bool isUpdateViewer = true); /// Erase the feature and a shape. /// \param theFeature a feature instance diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index 45788794f..7b4db2366 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -531,12 +531,15 @@ QModelIndex XGUI_DocumentDataModel::objectIndex(const ObjectPtr theObject) const DocumentPtr aDoc = theObject->document(); if (aDoc == aRootDoc) { // This feature belongs to histrory or top model - if (theObject->isInHistory()) { + FeaturePtr aFeature = boost::dynamic_pointer_cast(theObject); + if (aFeature) { int aId; - for (aId = 0; aId < aRootDoc->size(ModelAPI_Feature::group()); aId++) { + int aNb = aRootDoc->size(ModelAPI_Feature::group()); + for (aId = 0; aId < aNb; aId++) { if (theObject == aRootDoc->object(ModelAPI_Feature::group(), aId)) break; } + Q_ASSERT(aId < aNb); return index(aId + historyOffset(), 0, QModelIndex()); } else { QModelIndex aIndex = myModel->objectIndex(theObject); diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index 481db7336..caf78cede 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -43,14 +43,8 @@ void XGUI_SelectionMgr::connectViewers() void XGUI_SelectionMgr::onObjectBrowserSelection() { QList aObjects = myWorkshop->objectBrowser()->selectedObjects(); - QResultList aResults; - foreach(ObjectPtr aObject, aObjects) { - ResultPtr aRes = boost::dynamic_pointer_cast(aObject); - if (aRes) - aResults.append(aRes); - } XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - aDisplayer->setSelected(aResults); + aDisplayer->setSelected(aObjects); emit selectionChanged(); } @@ -65,7 +59,10 @@ void XGUI_SelectionMgr::onViewerSelection() if (aResult) aFeatures.append(aResult); } + bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true); myWorkshop->objectBrowser()->setObjectsSelected(aFeatures); + myWorkshop->objectBrowser()->blockSignals(aBlocked); + emit selectionChanged(); }