X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Module.cpp;h=7d5751707a40a97f613130f259a244ecddf58538;hb=8a3b4b191015686eeadb52c6d8de1afc13b1c34f;hp=63f7a1a373a1aa1ada079af3a030afb43eb502fc;hpb=fdfc221732acbce4be6b2c9c444f7c3643812811;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 63f7a1a37..7d5751707 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -1,12 +1,16 @@ #include #include -#include +#include #include +#include #include #include #include +#include +#include #include +#include #include #include @@ -17,6 +21,11 @@ #include #include #include +#include +#include +#include + +#include #include #include @@ -28,6 +37,7 @@ #include #include +#include #include #include @@ -37,7 +47,6 @@ #include #endif - /*!Create and return new instance of XGUI_Module*/ extern "C" PARTSET_EXPORT XGUI_Module* createModule(XGUI_Workshop* theWshop) { @@ -51,9 +60,16 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop) XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr(); + connect(anOperationMgr, SIGNAL(operationStarted()), + this, SLOT(onOperationStarted())); + connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), this, SLOT(onOperationStopped(ModuleBase_Operation*))); + XGUI_ContextMenuMgr* aContextMenuMgr = myWorkshop->contextMenuMgr(); + connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), + this, SLOT(onContextMenuCommand(const QString&, bool))); + connect(myWorkshop->viewer(), SIGNAL(mousePress(QMouseEvent*)), this, SLOT(onMousePressed(QMouseEvent*))); connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)), @@ -100,6 +116,11 @@ std::string PartSet_Module::featureFile(const std::string& theFeatureId) */ void PartSet_Module::onFeatureTriggered() { + //PartSet_TestOCC::local_selection_change_shape(myWorkshop->viewer()->AISContext(), + // myWorkshop->viewer()->activeView()); + + //PartSet_TestOCC::local_selection_erase(myWorkshop->viewer()->AISContext(), + // myWorkshop->viewer()->activeView()); QAction* aCmd = dynamic_cast(sender()); //Do nothing on uncheck if(aCmd->isCheckable() && !aCmd->isChecked()) @@ -113,12 +134,26 @@ void PartSet_Module::launchOperation(const QString& theCmdId) sendOperation(anOperation); } +void PartSet_Module::onOperationStarted() +{ + PartSet_OperationSketchBase* aPreviewOp = dynamic_cast( + myWorkshop->operationMgr()->currentOperation()); + if (aPreviewOp) { + XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel(); + connect(aPreviewOp, SIGNAL(focusActivated(const std::string&)), + aPropPanel, SLOT(onFocusActivated(const std::string&))); + } +} + void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation) { if (!theOperation) return; PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(theOperation); if (aPreviewOp) { + XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel(); + disconnect(aPreviewOp, SIGNAL(focusActivated(const std::string&)), + aPropPanel, SLOT(onFocusActivated(const std::string&))); } } @@ -137,8 +172,8 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent) if (aPreviewOp) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - std::list aSelected = aDisplayer->GetSelected(); - std::list aHighlighted = aDisplayer->GetHighlighted(); + std::list aSelected = aDisplayer->getSelected(); + std::list aHighlighted = aDisplayer->getHighlighted(); aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted); } @@ -151,8 +186,8 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent) if (aPreviewOp) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - std::list aSelected = aDisplayer->GetSelected(); - std::list aHighlighted = aDisplayer->GetHighlighted(); + std::list aSelected = aDisplayer->getSelected(); + std::list aHighlighted = aDisplayer->getHighlighted(); aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted); } @@ -179,9 +214,16 @@ void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ) { myWorkshop->viewer()->setViewProjection(theX, theY, theZ); myWorkshop->actionsMgr()->update(); + + //PartSet_TestOCC::testSelection(myWorkshop); } -void PartSet_Module::onLaunchOperation(std::string theName, boost::shared_ptr theFeature) +void PartSet_Module::onFitAllView() +{ + myWorkshop->viewer()->fitAll(); +} + +void PartSet_Module::onLaunchOperation(std::string theName, FeaturePtr theFeature) { ModuleBase_Operation* anOperation = createOperation(theName.c_str()); PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); @@ -189,12 +231,14 @@ void PartSet_Module::onLaunchOperation(std::string theName, boost::shared_ptrdisplayer(); // refill the features list with avoiding of the features, obtained only by vertex shape (TODO) - std::list aSelected = aDisplayer->GetSelected(TopAbs_VERTEX); - std::list aHighlighted = aDisplayer->GetHighlighted(TopAbs_VERTEX); + std::list aSelected = aDisplayer->getSelected(TopAbs_VERTEX); + std::list aHighlighted = aDisplayer->getHighlighted(TopAbs_VERTEX); aPreviewOp->init(theFeature, aSelected, aHighlighted); + } else { + anOperation->setEditingFeature(theFeature); } - myWorkshop->actionsMgr()->updateCheckState(); sendOperation(anOperation); + myWorkshop->actionsMgr()->updateCheckState(); } void PartSet_Module::onMultiSelectionEnabled(bool theEnabled) @@ -208,54 +252,52 @@ void PartSet_Module::onStopSelection(const std::list& theFeature XGUI_Displayer* aDisplayer = myWorkshop->displayer(); if (!isStop) { std::list::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end(); - boost::shared_ptr aFeature; + FeaturePtr aFeature; for (; anIt != aLast; anIt++) { activateFeature((*anIt).feature(), false); } } - aDisplayer->StopSelection(theFeatures, isStop, false); + aDisplayer->stopSelection(theFeatures, isStop, false); XGUI_ViewerProxy* aViewer = myWorkshop->viewer(); aViewer->enableSelection(!isStop); - aDisplayer->UpdateViewer(); + aDisplayer->updateViewer(); } void PartSet_Module::onSetSelection(const std::list& theFeatures) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - aDisplayer->SetSelected(theFeatures, false); - aDisplayer->UpdateViewer(); + aDisplayer->setSelected(theFeatures, false); + aDisplayer->updateViewer(); } void PartSet_Module::onCloseLocalContext() { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - aDisplayer->CloseLocalContexts(); + aDisplayer->closeLocalContexts(); } -void PartSet_Module::onFeatureConstructed(boost::shared_ptr theFeature, - int theMode) +void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode) { bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide; visualizePreview(theFeature, isDisplay, false); if (!isDisplay) { ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation(); - boost::shared_ptr aSketch; + FeaturePtr aSketch; PartSet_OperationSketchBase* aPrevOp = dynamic_cast(aCurOperation); if (aPrevOp) { - std::map, boost::shared_ptr > - aList = aPrevOp->subPreview(); + std::map > aList = aPrevOp->subPreview(); XGUI_Displayer* aDisplayer = myWorkshop->displayer(); std::list aModes = aPrevOp->getSelectionModes(aPrevOp->feature()); - std::map, boost::shared_ptr >::const_iterator + std::map >::const_iterator anIt = aList.begin(), aLast = aList.end(); for (; anIt != aLast; anIt++) { - boost::shared_ptr aFeature = (*anIt).first; + FeaturePtr aFeature = (*anIt).first; visualizePreview(aFeature, false, false); } - aDisplayer->UpdateViewer(); + aDisplayer->updateViewer(); } } @@ -269,7 +311,7 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI // get operation xml description std::string aStdCmdId = theCmdId; if (aStdCmdId == PartSet_OperationEditLine::Type()) - aStdCmdId = PartSet_OperationSketchLine::Type(); + aStdCmdId = SKETCH_LINE_KIND; std::string aPluginFileName = featureFile(aStdCmdId); Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginFileName); aWdgReader.readAll(); @@ -277,23 +319,25 @@ 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; + FeaturePtr aSketch; PartSet_OperationSketchBase* aPrevOp = dynamic_cast(aCurOperation); if (aPrevOp) aSketch = aPrevOp->sketch(); - if (theCmdId == PartSet_OperationSketchLine::Type()) - anOperation = new PartSet_OperationSketchLine(theCmdId.c_str(), this, aSketch); - else + if (PartSet_OperationCreateFeature::canProcessKind(theCmdId)) + anOperation = new PartSet_OperationCreateFeature(theCmdId.c_str(), this, aSketch); + 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)); @@ -302,10 +346,10 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI // connect the operation PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); if (aPreviewOp) { - connect(aPreviewOp, SIGNAL(featureConstructed(boost::shared_ptr, int)), - this, SLOT(onFeatureConstructed(boost::shared_ptr, int))); - connect(aPreviewOp, SIGNAL(launchOperation(std::string, boost::shared_ptr)), - this, SLOT(onLaunchOperation(std::string, boost::shared_ptr))); + connect(aPreviewOp, SIGNAL(featureConstructed(FeaturePtr, int)), + this, SLOT(onFeatureConstructed(FeaturePtr, int))); + connect(aPreviewOp, SIGNAL(launchOperation(std::string, FeaturePtr)), + this, SLOT(onLaunchOperation(std::string, FeaturePtr))); connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)), this, SLOT(onMultiSelectionEnabled(bool))); @@ -323,6 +367,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())); } } @@ -338,7 +384,7 @@ void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation) Events_Loop::loop()->send(aMessage); } -void PartSet_Module::visualizePreview(boost::shared_ptr theFeature, bool isDisplay, +void PartSet_Module::visualizePreview(FeaturePtr theFeature, bool isDisplay, const bool isUpdateViewer) { ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); @@ -352,24 +398,31 @@ 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() == SKETCH_CONSTRAINT_LENGTH_KIND) { + aSelectionMode = AIS_DSM_Text; + } + aDisplayer->redisplay(theFeature, anAIS, aSelectionMode, false); } else - aDisplayer->Erase(theFeature, false); + aDisplayer->erase(theFeature, false); if (isUpdateViewer) - aDisplayer->UpdateViewer(); + aDisplayer->updateViewer(); } -void PartSet_Module::activateFeature(boost::shared_ptr theFeature, - const bool isUpdateViewer) +void PartSet_Module::activateFeature(FeaturePtr theFeature, const bool isUpdateViewer) { ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); if (aPreviewOp) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - aDisplayer->ActivateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature), + aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature), isUpdateViewer); } } @@ -384,34 +437,45 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId) if (!aPreviewOp) return; - boost::shared_ptr aFeature = aPreviewOp->feature(); + FeaturePtr aFeature = aPreviewOp->feature(); if (!aFeature || aFeature->getKind() != theCmdId) return; - std::map, boost::shared_ptr > - aList = aPreviewOp->subPreview(); + std::map > aList = aPreviewOp->subPreview(); XGUI_Displayer* aDisplayer = myWorkshop->displayer(); std::list aModes = aPreviewOp->getSelectionModes(aPreviewOp->feature()); - std::map, boost::shared_ptr >::const_iterator + std::map >::const_iterator anIt = aList.begin(), aLast = aList.end(); for (; anIt != aLast; anIt++) { - boost::shared_ptr aFeature = (*anIt).first; + FeaturePtr aFeature = (*anIt).first; boost::shared_ptr aPreview = (*anIt).second; - aDisplayer->Redisplay(aFeature, - aPreview ? aPreview->impl() : TopoDS_Shape(), false); - aDisplayer->ActivateInLocalContext(aFeature, aModes, 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(); + aDisplayer->updateViewer(); } void PartSet_Module::editFeature(FeaturePtr theFeature) { - /*if (!theFeature) + if (!theFeature) return; - if (theFeature->getKind() == "Sketch") { - onLaunchOperation(theFeature->getKind(), theFeature); - visualizePreview(theFeature, true); - }*/ +// if (theFeature->getKind() == SKETCH_KIND) { + 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()); + } +// } }