From: nds Date: Thu, 19 Jun 2014 08:56:56 +0000 (+0400) Subject: refs #80 - Sketch base GUI: create/draw point, circle and arc X-Git-Tag: V_0.4.4~280 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8887fbea231db0c1fd9089dd237b90595f6d78a4;p=modules%2Fshaper.git refs #80 - Sketch base GUI: create/draw point, circle and arc 1. Split init(feature, feature) on init(feature), setFeature(feature, selection mode). The cause is lenght constraint. 2. Mouse double click signal listen by operation. 3. Correct displayer to use the selection mode only in activateInLocalContext method. It was temporary realized in the redisplay(). 4. Increase selection tolerance for dimension text. --- diff --git a/src/PartSet/PartSet_FeatureLengthPrs.cpp b/src/PartSet/PartSet_FeatureLengthPrs.cpp index 24c798fb6..36bc766ea 100644 --- a/src/PartSet/PartSet_FeatureLengthPrs.cpp +++ b/src/PartSet/PartSet_FeatureLengthPrs.cpp @@ -174,18 +174,19 @@ boost::shared_ptr PartSet_FeatureLengthPrs::featurePoint return boost::shared_ptr(); } -void PartSet_FeatureLengthPrs::initFeature(FeaturePtr theSourceFeature) +bool PartSet_FeatureLengthPrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode) { - if (feature() && theSourceFeature && theSourceFeature->getKind() == SKETCH_LINE_KIND) + bool aResult = false; + if (feature() && theFeature && theFeature->getKind() == SKETCH_LINE_KIND && theMode == SM_FirstPoint) { // set length feature boost::shared_ptr aData = feature()->data(); boost::shared_ptr aRef = boost::dynamic_pointer_cast(aData->attribute(CONSTRAINT_ATTR_ENTITY_A)); - aRef->setFeature(theSourceFeature); + aRef->setFeature(theFeature); // set length value - aData = theSourceFeature->data(); + aData = theFeature->data(); boost::shared_ptr aPoint1 = boost::dynamic_pointer_cast(aData->attribute(LINE_ATTR_START)); boost::shared_ptr aPoint2 = @@ -193,5 +194,7 @@ void PartSet_FeatureLengthPrs::initFeature(FeaturePtr theSourceFeature) double aLenght = aPoint1->pnt()->distance(aPoint2->pnt()); PartSet_Tools::setFeatureValue(feature(), aLenght, CONSTRAINT_ATTR_VALUE); + aResult = true; } + return aResult; } diff --git a/src/PartSet/PartSet_FeatureLengthPrs.h b/src/PartSet/PartSet_FeatureLengthPrs.h index 2c39f38bc..1bd7f8c1f 100644 --- a/src/PartSet/PartSet_FeatureLengthPrs.h +++ b/src/PartSet/PartSet_FeatureLengthPrs.h @@ -39,6 +39,12 @@ public: virtual PartSet_SelectionMode setPoint(double theX, double theY, const PartSet_SelectionMode& theMode); + /// Sets the feature to to a feature attribute depending on the selection mode + /// \param theFeature a feature instance + /// \param theMode the selection mode + /// \return whether the feature is set + virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode); + /// Returns the feature attribute name for the selection mode /// \param theMode the current operation selection mode. The feature attribute depends on the mode virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const; @@ -69,10 +75,6 @@ protected: /// Returns the feature point in the selection mode position. /// \param theMode the current operation selection mode. The feature attribute depends on the mode virtual boost::shared_ptr featurePoint(const PartSet_SelectionMode& theMode); - - /// Initializes current feature by the given - /// \param theSourceFeature the feature, which attributes are used to initialize the current feature - virtual void initFeature(FeaturePtr theSourceFeature); }; #endif diff --git a/src/PartSet/PartSet_FeatureLinePrs.cpp b/src/PartSet/PartSet_FeatureLinePrs.cpp index bc7e2d144..ef6e7c005 100644 --- a/src/PartSet/PartSet_FeatureLinePrs.cpp +++ b/src/PartSet/PartSet_FeatureLinePrs.cpp @@ -35,24 +35,6 @@ std::string PartSet_FeatureLinePrs::getKind() return SKETCH_LINE_KIND; } -void PartSet_FeatureLinePrs::initFeature(FeaturePtr theFeature) -{ - if (feature() && theFeature) - { - // use the last point of the previous feature as the first of the new one - boost::shared_ptr aData = theFeature->data(); - boost::shared_ptr anInitPoint = boost::dynamic_pointer_cast - (aData->attribute(LINE_ATTR_END)); - PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_START); - PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_END); - - aData = feature()->data(); - boost::shared_ptr aPoint = boost::dynamic_pointer_cast - (aData->attribute(LINE_ATTR_START)); - PartSet_Tools::createConstraint(sketch(), anInitPoint, aPoint); - } -} - PartSet_SelectionMode PartSet_FeatureLinePrs::setPoint(double theX, double theY, const PartSet_SelectionMode& theMode) { @@ -76,6 +58,27 @@ PartSet_SelectionMode PartSet_FeatureLinePrs::setPoint(double theX, double theY, return aMode; } +bool PartSet_FeatureLinePrs::setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode) +{ + bool aResult = false; + if (feature() && theFeature && theMode == SM_FirstPoint) + { + // use the last point of the previous feature as the first of the new one + boost::shared_ptr aData = theFeature->data(); + boost::shared_ptr anInitPoint = boost::dynamic_pointer_cast + (aData->attribute(LINE_ATTR_END)); + PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_START); + PartSet_Tools::setFeaturePoint(feature(), anInitPoint->x(), anInitPoint->y(), LINE_ATTR_END); + + aData = feature()->data(); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast + (aData->attribute(LINE_ATTR_START)); + PartSet_Tools::createConstraint(sketch(), anInitPoint, aPoint); + aResult = true; + } + return aResult; +} + std::string PartSet_FeatureLinePrs::getAttribute(const PartSet_SelectionMode& theMode) const { std::string aAttribute; diff --git a/src/PartSet/PartSet_FeatureLinePrs.h b/src/PartSet/PartSet_FeatureLinePrs.h index 0f6fb051f..3ba436797 100644 --- a/src/PartSet/PartSet_FeatureLinePrs.h +++ b/src/PartSet/PartSet_FeatureLinePrs.h @@ -43,6 +43,12 @@ public: virtual PartSet_SelectionMode setPoint(double theX, double theY, const PartSet_SelectionMode& theMode); + /// Sets the feature to to a feature attribute depending on the selection mode + /// \param theFeature a feature instance + /// \param theMode the selection mode + /// \return whether the feature is set + virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode); + /// Returns the feature attribute name for the selection mode /// \param theMode the current operation selection mode. The feature attribute depends on the mode virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const; @@ -93,10 +99,6 @@ public: double& theX, double& theY); protected: - /// Initializes current feature by the given - /// \param theSourceFeature the feature, which attributes are used to initialize the current feature - virtual void initFeature(FeaturePtr theSourceFeature); - /// Returns the feature point in the selection mode position. /// \param theMode the current operation selection mode. The feature attribute depends on the mode virtual boost::shared_ptr featurePoint(const PartSet_SelectionMode& theMode); diff --git a/src/PartSet/PartSet_FeaturePrs.cpp b/src/PartSet/PartSet_FeaturePrs.cpp index 4712baf3a..9f2184d86 100644 --- a/src/PartSet/PartSet_FeaturePrs.cpp +++ b/src/PartSet/PartSet_FeaturePrs.cpp @@ -28,12 +28,9 @@ PartSet_FeaturePrs::~PartSet_FeaturePrs() { } -void PartSet_FeaturePrs::init(FeaturePtr theFeature, FeaturePtr theSourceFeature) +void PartSet_FeaturePrs::init(FeaturePtr theFeature) { myFeature = theFeature; - if (theSourceFeature) { - initFeature(theSourceFeature); - } } FeaturePtr PartSet_FeaturePrs::sketch() const diff --git a/src/PartSet/PartSet_FeaturePrs.h b/src/PartSet/PartSet_FeaturePrs.h index 6ba12c6d8..0acc2125d 100644 --- a/src/PartSet/PartSet_FeaturePrs.h +++ b/src/PartSet/PartSet_FeaturePrs.h @@ -29,8 +29,7 @@ public: /// Initializes some fields of feature accorging to the source feature /// Saves the fiature as the presentation internal feature /// \param theFeature the presentation feature - /// \param theSourceFeature the feature, which attributes are used to initialize the feature - void init(FeaturePtr theFeature, FeaturePtr theSourceFeature); + void init(FeaturePtr theFeature); /// Returns the operation sketch feature /// \returns the sketch instance @@ -44,6 +43,12 @@ public: virtual PartSet_SelectionMode setPoint(double theX, double theY, const PartSet_SelectionMode& theMode) = 0; + /// Sets the feature to to a feature attribute depending on the selection mode + /// \param theFeature a feature instance + /// \param theMode the selection mode + /// \return whether the feature is set + virtual bool setFeature(FeaturePtr theFeature, const PartSet_SelectionMode& theMode) { return false; }; + /// Returns the feature attribute name for the selection mode /// \param theMode the current operation selection mode. The feature attribute depends on the mode virtual std::string getAttribute(const PartSet_SelectionMode& theMode) const = 0; @@ -82,10 +87,6 @@ protected: /// \return the feature FeaturePtr feature() const; - /// Initializes current feature by the given - /// \param theSourceFeature the feature, which attributes are used to initialize the current feature - virtual void initFeature(FeaturePtr theSourceFeature) {}; - /// Returns the feature point in the selection mode position. /// \param theMode the current operation selection mode. The feature attribute depends on the mode virtual boost::shared_ptr featurePoint(const PartSet_SelectionMode& theMode) = 0; diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 8b683a169..7590e3b80 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -40,7 +40,7 @@ #include #include -#include +//#include #include #include @@ -81,6 +81,9 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop) this, SLOT(onMouseMoved(QMouseEvent*))); connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)), this, SLOT(onKeyRelease(QKeyEvent*))); + connect(myWorkshop->viewer(), SIGNAL(mouseDoubleClick(QMouseEvent*)), + this, SLOT(onMouseDoubleClick(QMouseEvent*))); + } PartSet_Module::~PartSet_Module() @@ -213,6 +216,20 @@ void PartSet_Module::onKeyRelease(QKeyEvent* theEvent) } } +void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent) +{ + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast( + myWorkshop->operationMgr()->currentOperation()); + if (aPreviewOp) + { + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + std::list aSelected = aDisplayer->getSelected(); + std::list aHighlighted = aDisplayer->getHighlighted(); + aPreviewOp->mouseDoubleClick(theEvent, myWorkshop->viewer()->activeView(), aSelected, + aHighlighted); + } +} + void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ) { myWorkshop->viewer()->setViewProjection(theX, theY, theZ); @@ -418,11 +435,7 @@ void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay, aPreview ? aPreview->impl() : TopoDS_Shape(), aDisplayer->getAISObject(theFeature)); - int aSelectionMode = -1; - if (theFeature->getKind() == SKETCH_CONSTRAINT_LENGTH_KIND) { - aSelectionMode = AIS_DSM_Text; - } - aDisplayer->redisplay(theFeature, anAIS, aSelectionMode, false); + aDisplayer->redisplay(theFeature, anAIS, false); } else aDisplayer->erase(theFeature, false); @@ -470,7 +483,7 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId) aPreview ? aPreview->impl() : TopoDS_Shape(), aDisplayer->getAISObject(aFeature)); if (!anAIS.IsNull()) - aDisplayer->redisplay(aFeature, anAIS, -1, false); + aDisplayer->redisplay(aFeature, anAIS, false); aDisplayer->activateInLocalContext(aFeature, aModes, false); } aDisplayer->updateViewer(); diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 31e410816..49fb587da 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -83,6 +83,10 @@ public slots: /// \param theEvent the mouse event void onKeyRelease(QKeyEvent* theEvent); + /// SLOT, that is called by the mouse double click in the viewer. + /// \param theEvent the mouse event + void onMouseDoubleClick(QMouseEvent* theEvent); + /// SLOT, to apply to the current viewer the operation /// \param theX the X projection value /// \param theY the Y projection value diff --git a/src/PartSet/PartSet_OperationConstraint.cpp b/src/PartSet/PartSet_OperationConstraint.cpp index e810cf390..9b1d2129e 100644 --- a/src/PartSet/PartSet_OperationConstraint.cpp +++ b/src/PartSet/PartSet_OperationConstraint.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -54,6 +55,11 @@ PartSet_OperationConstraint::~PartSet_OperationConstraint() { } +std::string PartSet_OperationConstraint::Type() +{ + return SKETCH_CONSTRAINT_LENGTH_KIND; +} + bool PartSet_OperationConstraint::isGranted(ModuleBase_IOperation* theOperation) const { return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type(); diff --git a/src/PartSet/PartSet_OperationConstraint.h b/src/PartSet/PartSet_OperationConstraint.h index 678964aaf..56ffe2629 100644 --- a/src/PartSet/PartSet_OperationConstraint.h +++ b/src/PartSet/PartSet_OperationConstraint.h @@ -9,8 +9,6 @@ #include -#include - #include /*! @@ -23,7 +21,7 @@ class PARTSET_EXPORT PartSet_OperationConstraint : public PartSet_OperationSketc public: /// Returns the operation type key - static std::string Type() { return SKETCH_CONSTRAINT_LENGTH_KIND; } + static std::string Type(); public: /// Constructor diff --git a/src/PartSet/PartSet_OperationCreateConstraint.cpp b/src/PartSet/PartSet_OperationCreateConstraint.cpp index ec9ae0662..bc4463b94 100644 --- a/src/PartSet/PartSet_OperationCreateConstraint.cpp +++ b/src/PartSet/PartSet_OperationCreateConstraint.cpp @@ -106,9 +106,10 @@ void PartSet_OperationCreateConstraint::mouseReleased(QMouseEvent* theEvent, Han XGUI_ViewerPrs aPrs = theSelected.front(); FeaturePtr aFeature = aPrs.feature(); - myFeaturePrs->init(feature(), aFeature); - flushUpdated(); - setPointSelectionMode(SM_SecondPoint); + if (myFeaturePrs->setFeature(aFeature, myPointSelectionMode)) { + flushUpdated(); + setPointSelectionMode(SM_SecondPoint); + } } } break; @@ -189,9 +190,15 @@ void PartSet_OperationCreateConstraint::keyReleased(const int theKey) // it start a new line creation at a free point restartOperation(feature()->getKind(), FeaturePtr()/*feature()*/); } - //else - // abort(); - //restartOperation(feature()->getKind(), FeaturePtr()); + // changed + // the modification is really need until the focus of editor do not accept the focus + if (myPointSelectionMode == SM_ThirdPoint) { + if (myEditor->isStarted()) + myEditor->stop(); + commit(); + // it start a new line creation at a free point + restartOperation(feature()->getKind(), FeaturePtr()/*feature()*/); + } } break; case Qt::Key_Escape: { @@ -246,7 +253,9 @@ FeaturePtr PartSet_OperationCreateConstraint::createFeature(const bool theFlushM aFeature->addSub(aNewFeature); } - myFeaturePrs->init(aNewFeature, myInitFeature); + myFeaturePrs->init(aNewFeature); + if (myInitFeature) + myFeaturePrs->setFeature(myInitFeature, SM_FirstPoint); emit featureConstructed(aNewFeature, FM_Activation); if (theFlushMessage) diff --git a/src/PartSet/PartSet_OperationCreateFeature.cpp b/src/PartSet/PartSet_OperationCreateFeature.cpp index 2bfca9f7c..23c746219 100644 --- a/src/PartSet/PartSet_OperationCreateFeature.cpp +++ b/src/PartSet/PartSet_OperationCreateFeature.cpp @@ -270,7 +270,8 @@ FeaturePtr PartSet_OperationCreateFeature::createFeature(const bool theFlushMess aFeature->addSub(aNewFeature); } - myFeaturePrs->init(aNewFeature, myInitFeature); + myFeaturePrs->init(aNewFeature); + myFeaturePrs->setFeature(myInitFeature, SM_FirstPoint); emit featureConstructed(aNewFeature, FM_Activation); if (theFlushMessage) diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index bc57e5068..c028eab6e 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -130,6 +130,38 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi } } +#include +void PartSet_OperationSketch::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted) +{ + return; + if (!hasSketchPlane()) + return; + if (!theSelected.empty()) { + XGUI_ViewerPrs aPrs = theSelected.front(); + if (!aPrs.owner().IsNull()) { + Handle(AIS_DimensionOwner) anOwner = Handle(AIS_DimensionOwner)::DownCast(aPrs.owner()); + if (!anOwner.IsNull() && anOwner->SelectionMode() == AIS_DSM_Text) { + Handle(SelectMgr_SelectableObject) anObject = anOwner->Selectable(); + double aValue = 0; + if (!anObject.IsNull()) { + Handle(AIS_LengthDimension) aLenDim = Handle(AIS_LengthDimension)::DownCast(anObject); + if (!aLenDim.IsNull()) + aValue = aLenDim->GetValue(); + } + + QLineEdit* aLine = new QLineEdit(); + QPoint aViewPos = theEvent->globalPos(); + QPoint aLinePos(aViewPos.x(), aViewPos.y()); + aLine->move(aLinePos); + aLine->setText(QString::number(aValue)); + aLine->show(); + } + } + } +} + void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) { if (!hasSketchPlane() || !(theEvent->buttons() & Qt::LeftButton) || myFeatures.empty()) diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h index 27c0d8641..161c76a87 100644 --- a/src/PartSet/PartSet_OperationSketch.h +++ b/src/PartSet/PartSet_OperationSketch.h @@ -72,6 +72,15 @@ public: /// \param theEvent the mouse event virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView); + /// Processes the mouse double click in the point + /// \param theEvent the mouse event + /// \param theView a viewer to have the viewer the eye position + /// \param theSelected the list of selected presentations + /// \param theHighlighted the list of highlighted presentations + virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted); + /// Returns the map of the operation previews including the nested feature previews /// \return the map of feature to the feature preview virtual std::map > diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp index 8bb9e3be2..767d7bf71 100644 --- a/src/PartSet/PartSet_OperationSketchBase.cpp +++ b/src/PartSet/PartSet_OperationSketchBase.cpp @@ -7,6 +7,7 @@ #include #include +#include #include @@ -42,11 +43,20 @@ std::map > return std::map >(); } +#include +#include std::list PartSet_OperationSketchBase::getSelectionModes(FeaturePtr theFeature) const { std::list aModes; - aModes.push_back(TopAbs_VERTEX); - aModes.push_back(TopAbs_EDGE); + if (theFeature->getKind() == SKETCH_CONSTRAINT_LENGTH_KIND) { + 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)); + } return aModes; } FeaturePtr PartSet_OperationSketchBase::createFeature(const bool theFlushMessage) @@ -71,6 +81,11 @@ void PartSet_OperationSketchBase::mouseReleased(QMouseEvent* theEvent, Handle_V3 void PartSet_OperationSketchBase::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView) { } +void PartSet_OperationSketchBase::mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted) +{ +} void PartSet_OperationSketchBase::keyReleased(const int theKey) { diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h index ff6f06847..5f4d556e0 100644 --- a/src/PartSet/PartSet_OperationSketchBase.h +++ b/src/PartSet/PartSet_OperationSketchBase.h @@ -88,6 +88,15 @@ public: /// \param theView a viewer to have the viewer the eye position virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView); + /// Processes the mouse double click in the point + /// \param theEvent the mouse event + /// \param theView a viewer to have the viewer the eye position + /// \param theSelected the list of selected presentations + /// \param theHighlighted the list of highlighted presentations + virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView, + const std::list& theSelected, + const std::list& theHighlighted); + /// Processes the key pressed in the view /// \param theKey a key value virtual void keyReleased(const int theKey); diff --git a/src/PartSet/PartSet_Presentation.cpp b/src/PartSet/PartSet_Presentation.cpp index 84dc7e3fe..a89383a7a 100644 --- a/src/PartSet/PartSet_Presentation.cpp +++ b/src/PartSet/PartSet_Presentation.cpp @@ -28,6 +28,9 @@ const Quantity_NameOfColor SKETCH_PLANE_COLOR = Quantity_NOC_CHOCOLATE; /// the plane edge color const int SKETCH_WIDTH = 4; /// the plane edge width +const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint +const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance + Handle(AIS_InteractiveObject) PartSet_Presentation::createPresentation( FeaturePtr theFeature, FeaturePtr theSketch, @@ -131,22 +134,23 @@ Handle(AIS_InteractiveObject) PartSet_Presentation::createSketchConstraintLength Handle(AIS_InteractiveObject) anAIS = thePrevPrs; if (anAIS.IsNull()) { - Handle(AIS_LengthDimension) aLenDim = new AIS_LengthDimension (aP1, aP2, aPlane); + Handle(AIS_LengthDimension) aDimAIS = new AIS_LengthDimension (aP1, aP2, aPlane); Handle(Prs3d_DimensionAspect) anAspect = new Prs3d_DimensionAspect(); anAspect->MakeArrows3d (Standard_False); anAspect->MakeText3d(false/*is text 3d*/); - anAspect->TextAspect()->SetHeight(28); + anAspect->TextAspect()->SetHeight(CONSTRAINT_TEXT_HEIGHT); anAspect->MakeTextShaded(false/*is test shaded*/); - aLenDim->DimensionAspect()->MakeUnitsDisplayed(false/*is units displayed*/); + aDimAIS->DimensionAspect()->MakeUnitsDisplayed(false/*is units displayed*/); /*if (isUnitsDisplayed) { - aLenDim->SetDisplayUnits (aDimDlg->GetUnits ()); + aDimAIS->SetDisplayUnits (aDimDlg->GetUnits ()); }*/ - aLenDim->SetDimensionAspect (anAspect); - aLenDim->SetFlyout(aFlyout); + aDimAIS->SetDimensionAspect (anAspect); + aDimAIS->SetFlyout(aFlyout); + aDimAIS->SetSelToleranceForText2d(CONSTRAINT_TEXT_SELECTION_TOLERANCE); - anAIS = aLenDim; + anAIS = aDimAIS; } else { // update presentation diff --git a/src/PartSet/PartSet_TestOCC.cpp b/src/PartSet/PartSet_TestOCC.cpp index 9de469570..9dd77583a 100644 --- a/src/PartSet/PartSet_TestOCC.cpp +++ b/src/PartSet/PartSet_TestOCC.cpp @@ -153,7 +153,7 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop) aFeature, aSketch, aPreview ? aPreview->impl() : TopoDS_Shape(), NULL); if (!anAIS.IsNull()) - aDisplayer->redisplay(aFeature, anAIS, -1, false); + aDisplayer->redisplay(aFeature, anAIS, false); std::list aModes; aModes.push_back(TopAbs_VERTEX); @@ -172,7 +172,7 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop) aFeature, aSketch, aPreview ? aPreview->impl() : TopoDS_Shape(), NULL); if (!anAIS.IsNull()) - aDisplayer->redisplay(aFeature, anAIS, -1, true); + aDisplayer->redisplay(aFeature, anAIS, true); int aVal = 90; for (int j = 0; j < 10000000; j++) @@ -211,7 +211,7 @@ void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop) aPreview ? aPreview->impl() : TopoDS_Shape(), aPrevAIS); if (!anAIS.IsNull()) - theWorkshop->displayer()->redisplay(aFeature, anAIS, -1, true); + theWorkshop->displayer()->redisplay(aFeature, anAIS, true); //std::list aModes; //aModes.clear(); //aModes.push_back(TopAbs_VERTEX); diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 02f216cfc..224183037 100644 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -159,7 +159,7 @@ boost::shared_ptr PartSet_Tools::createFeaturePrs(const std: } if (theFeature && aFeaturePrs) - aFeaturePrs->init(theFeature, FeaturePtr()); + aFeaturePrs->init(theFeature); return aFeaturePrs; } diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index c4d8b001e..f2ee9a196 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -144,7 +144,6 @@ void XGUI_Displayer::erase(FeaturePtr theFeature, bool XGUI_Displayer::redisplay(FeaturePtr theFeature, Handle(AIS_InteractiveObject) theAIS, - const int theSelectionMode, const bool isUpdateViewer) { bool isCreated = false; @@ -163,14 +162,7 @@ bool XGUI_Displayer::redisplay(FeaturePtr theFeature, } else { myFeature2AISObjectMap[theFeature] = theAIS; - if (theSelectionMode < 0) - { - aContext->Display(theAIS, false); - } - else - { - aContext->Display(theAIS, 0, theSelectionMode, false); - } + aContext->Display(theAIS, false); isCreated = true; } if (isUpdateViewer) @@ -205,9 +197,9 @@ void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature, aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/); } // display or redisplay presentation - Handle(AIS_Shape) anAIS; + Handle(AIS_InteractiveObject) anAIS; if (isVisible(theFeature)) - anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[theFeature]); + anAIS = Handle(AIS_InteractiveObject)::DownCast(myFeature2AISObjectMap[theFeature]); // Activate selection of objects from prs if (!anAIS.IsNull()) { @@ -217,7 +209,7 @@ void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature, std::list::const_iterator anIt = theModes.begin(), aLast = theModes.end(); for (; anIt != aLast; anIt++) { - aContext->Activate(anAIS, AIS_Shape::SelectionMode((TopAbs_ShapeEnum)*anIt)); + aContext->Activate(anAIS, (*anIt)); } } diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 7ca8150ae..d16b36279 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -81,8 +81,7 @@ public: /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly /// \returns true if the presentation is created bool redisplay(FeaturePtr theFeature, - Handle(AIS_InteractiveObject) theAIS, - const int theSelectionMode, const bool isUpdateViewer = true); + Handle(AIS_InteractiveObject) theAIS, const bool isUpdateViewer = true); /** Redisplay the shape if it was displayed * \param theFeature a feature instance