X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Module.cpp;h=79edcc6a1c598e0d8786581ad2c9de181f87a037;hb=47933cff9cf39f2d420b8a772ac125d2a969d2b5;hp=374b1d503bb2607c30e30610eeaeb09e4395df78;hpb=46c278a1438e8998efa453854471b8dbd78d4277;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 374b1d503..79edcc6a1 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -2,12 +2,15 @@ #include #include #include +#include #include #include #include #include +#include #include +#include #include #include @@ -20,6 +23,7 @@ #include #include #include +#include #include #include @@ -31,6 +35,7 @@ #include #include +#include #include #include @@ -211,6 +216,11 @@ void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ) //PartSet_TestOCC::testSelection(myWorkshop); } +void PartSet_Module::onFitAllView() +{ + myWorkshop->viewer()->fitAll(); +} + void PartSet_Module::onLaunchOperation(std::string theName, boost::shared_ptr theFeature) { ModuleBase_Operation* anOperation = createOperation(theName.c_str()); @@ -307,12 +317,11 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI std::string aDescription = aWdgReader.featureDescription(aStdCmdId); // create the operation - ModuleBase_Operation* anOperation; + ModuleBase_Operation* anOperation = 0; if (theCmdId == PartSet_OperationSketch::Type()) { anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this); } - else if(theCmdId == PartSet_OperationSketchLine::Type() || - theCmdId == PartSet_OperationEditLine::Type()) { + else { ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation(); boost::shared_ptr aSketch; PartSet_OperationSketchBase* aPrevOp = dynamic_cast(aCurOperation); @@ -320,10 +329,13 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI aSketch = aPrevOp->sketch(); if (theCmdId == PartSet_OperationSketchLine::Type()) anOperation = new PartSet_OperationSketchLine(theCmdId.c_str(), this, aSketch); - else + else if (theCmdId == PartSet_OperationEditLine::Type()) anOperation = new PartSet_OperationEditLine(theCmdId.c_str(), this, aSketch); + else if (theCmdId == PartSet_OperationConstraint::Type()) + anOperation = new PartSet_OperationConstraint(theCmdId.c_str(), this, aSketch); } - else { + + if (!anOperation) { anOperation = new ModuleBase_Operation(theCmdId.c_str(), this); } anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg)); @@ -353,6 +365,8 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI if (aSketchOp) { connect(aSketchOp, SIGNAL(planeSelected(double, double, double)), this, SLOT(onPlaneSelected(double, double, double))); + connect(aSketchOp, SIGNAL(fitAllView()), + this, SLOT(onFitAllView())); } } @@ -382,8 +396,16 @@ void PartSet_Module::visualizePreview(boost::shared_ptr theFea XGUI_Displayer* aDisplayer = myWorkshop->displayer(); if (isDisplay) { boost::shared_ptr aPreview = aPreviewOp->preview(theFeature); - aDisplayer->Redisplay(theFeature, - aPreview ? aPreview->impl() : TopoDS_Shape(), false); + Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation( + theFeature, aPreviewOp->sketch(), + aPreview ? aPreview->impl() : TopoDS_Shape(), + aDisplayer->GetAISObject(theFeature)); + + int aSelectionMode = -1; + if (theFeature->getKind() == "SketchConstraintLength") { + aSelectionMode = AIS_DSM_Text; + } + aDisplayer->Redisplay(theFeature, anAIS, aSelectionMode, false); } else aDisplayer->Erase(theFeature, false); @@ -428,8 +450,12 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId) for (; anIt != aLast; anIt++) { boost::shared_ptr aFeature = (*anIt).first; boost::shared_ptr aPreview = (*anIt).second; - aDisplayer->Redisplay(aFeature, - aPreview ? aPreview->impl() : TopoDS_Shape(), false); + Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation( + aFeature, aPreviewOp->sketch(), + aPreview ? aPreview->impl() : TopoDS_Shape(), + aDisplayer->GetAISObject(aFeature)); + if (!anAIS.IsNull()) + aDisplayer->Redisplay(aFeature, anAIS, -1, false); aDisplayer->ActivateInLocalContext(aFeature, aModes, false); } aDisplayer->UpdateViewer(); @@ -441,7 +467,15 @@ void PartSet_Module::editFeature(FeaturePtr theFeature) return; if (theFeature->getKind() == "Sketch") { - onLaunchOperation(theFeature->getKind(), theFeature); - updateCurrentPreview(theFeature->getKind()); + FeaturePtr aFeature = theFeature; + if (XGUI_Tools::isModelObject(aFeature)) { + ObjectPtr aObject = boost::dynamic_pointer_cast(aFeature); + aFeature = aObject->featureRef(); + } + + if (aFeature) { + onLaunchOperation(aFeature->getKind(), aFeature); + updateCurrentPreview(aFeature->getKind()); + } } }