From: vsv Date: Fri, 4 Jul 2014 13:57:09 +0000 (+0400) Subject: Sketcher bugfixing X-Git-Tag: V_0.4.4~207 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b731456e3013002d4f40c7bcc8b3e00928c485b0;p=modules%2Fshaper.git Sketcher bugfixing --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index b12db997b..990c9e44b 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -183,8 +183,7 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent) { PartSet_OperationSketchBase* aPreviewOp = dynamic_cast( myWorkshop->operationMgr()->currentOperation()); - if (aPreviewOp) - { + if (aPreviewOp) { XGUI_Displayer* aDisplayer = myWorkshop->displayer(); std::list aSelected = aDisplayer->getSelected(); std::list aHighlighted = aDisplayer->getHighlighted(); diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index a1652fc48..b2f445505 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -113,9 +113,9 @@ void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle return; } - double aX = 0, anY = 0; - gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView); + double aX = aPoint.X(), anY = aPoint.Y(); + if (theSelected.empty()) { PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY); } diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp index 87f7635a5..eff5a65ee 100644 --- a/src/PartSet/PartSet_OperationSketch.cpp +++ b/src/PartSet/PartSet_OperationSketch.cpp @@ -226,7 +226,7 @@ void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape) boost::shared_ptr aDir = aPlane->direction(); flushUpdated(); - + emit featureConstructed(feature(), FM_Hide); emit closeLocalContext(); emit planeSelected(aDir->x(), aDir->y(), aDir->z()); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index fe49f7442..fc9159a91 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -41,7 +41,7 @@ bool XGUI_Displayer::isVisible(FeaturePtr theFeature) return myFeature2AISObjectMap.find(aFeature) != myFeature2AISObjectMap.end(); } -void XGUI_Displayer::display(FeaturePtr theFeature, bool isUpdateViewer) +bool XGUI_Displayer::display(FeaturePtr theFeature, bool isUpdateViewer) { FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature); boost::shared_ptr aShapePtr = aFeature->data()->shape(); @@ -49,20 +49,23 @@ void XGUI_Displayer::display(FeaturePtr theFeature, bool isUpdateViewer) if (aShapePtr) { boost::shared_ptr anAIS(new GeomAPI_AISObject()); anAIS->createShape(aShapePtr); - display(aFeature, anAIS, isUpdateViewer); + return display(aFeature, anAIS, isUpdateViewer); } + return false; } -void XGUI_Displayer::display(FeaturePtr theFeature, +bool XGUI_Displayer::display(FeaturePtr theFeature, boost::shared_ptr theAIS, bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); - myFeature2AISObjectMap[theFeature] = theAIS; - Handle(AIS_InteractiveObject) anAISIO = theAIS->impl(); - if (!anAISIO.IsNull()) + if (!anAISIO.IsNull()) { + myFeature2AISObjectMap[theFeature] = theAIS; aContext->Display(anAISIO, isUpdateViewer); + return true; + } + return false; } @@ -136,11 +139,12 @@ void XGUI_Displayer::erase(FeaturePtr theFeature, Handle(AIS_InteractiveContext) aContext = AISContext(); boost::shared_ptr anObject = myFeature2AISObjectMap[aFeature]; - if (anObject) - { + if (anObject) { Handle(AIS_InteractiveObject) anAIS = anObject->impl(); - if (!anAIS.IsNull()) + if (!anAIS.IsNull()) { aContext->Erase(anAIS, isUpdateViewer); + + } } myFeature2AISObjectMap.erase(aFeature); } @@ -178,22 +182,23 @@ bool XGUI_Displayer::redisplay(FeaturePtr theFeature, return isCreated; } -void XGUI_Displayer::redisplay(FeaturePtr theFeature, bool isUpdateViewer) +bool XGUI_Displayer::redisplay(FeaturePtr theFeature, bool isUpdateViewer) { FeaturePtr aFeature = XGUI_Tools::realFeature(theFeature); if (!isVisible(aFeature)) - return; + return false; boost::shared_ptr aShapePtr = aFeature->data()->shape(); if (aShapePtr) { boost::shared_ptr aAISObj = getAISObject(aFeature); Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl()); - if (aAISShape.IsNull()) - return; - - aAISShape->Set(aShapePtr->impl()); - AISContext()->Redisplay(aAISShape); + if (!aAISShape.IsNull()) { + aAISShape->Set(aShapePtr->impl()); + AISContext()->Redisplay(aAISShape); + return true; + } } + return false; } void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature, diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 2ce31b14d..a9a7fb36f 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -54,13 +54,15 @@ public: /// Display the feature. Obtain the visualized object from the feature. /// \param theFeature a feature instance /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - void display(FeaturePtr theFeature, bool isUpdateViewer = true); + /// Returns true if the Feature succesfully displayed + bool display(FeaturePtr theFeature, bool isUpdateViewer = true); /// Display the feature and a shape. This shape would be associated to the given feature /// \param theFeature a feature instance /// \param theAIS AIS presentation /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly - void display(FeaturePtr theFeature, boost::shared_ptr theAIS, bool isUpdateViewer = true); + /// Returns true if the Feature succesfully displayed + bool display(FeaturePtr theFeature, boost::shared_ptr theAIS, bool isUpdateViewer = true); /// Returns a list of viewer selected presentations /// \param theShapeTypeToSkip the shapes with this type will be skipped during the result list build @@ -90,7 +92,7 @@ public: * \param theFeature a feature instance * \param isUpdateViewer the parameter whether the viewer should be update immediatelly */ - void redisplay(FeaturePtr theFeature, bool isUpdateViewer = true); + bool redisplay(FeaturePtr theFeature, bool isUpdateViewer = true); /// Redisplay the shape and activate selection of sub-shapes /// \param theFeature a feature instance diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index e9383b4d7..adf7b2748 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -72,17 +72,8 @@ XGUI_PropertyPanel::~XGUI_PropertyPanel() void XGUI_PropertyPanel::cleanContent() { - myWidgets.clear(); - - QLayoutItem* aItem = myMainLayout->takeAt(myMainLayout->count() - 1); - delete aItem; - - myMainLayout->removeWidget(myCustomWidget); - delete myCustomWidget; - - myCustomWidget = new QWidget(widget()); - myMainLayout->addWidget(myCustomWidget); - myMainLayout->addStretch(1); + myWidgets.clear(); + qDeleteAll(myCustomWidget->children()); } void XGUI_PropertyPanel::setModelWidgets(const QList& theWidgets) @@ -165,8 +156,7 @@ void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget) QList::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end(); bool isFoundWidget = false; - for (;anIt != aLast && !aNextWidget; anIt++) - { + for (;anIt != aLast && !aNextWidget; anIt++) { if (isFoundWidget || !theWidget) { if ((*anIt)->focusTo()) { aNextWidget = *anIt; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index ed05647f4..0b13ba514 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -245,7 +245,7 @@ void XGUI_Workshop::processEvent(const Events_Message* theMessage) //An operation passed by message. Start it, process and commit. if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) { const Config_PointerMessage* aPartSetMsg = dynamic_cast(theMessage); - myPropertyPanel->cleanContent(); + //myPropertyPanel->cleanContent(); ModuleBase_Operation* anOperation = (ModuleBase_Operation*)aPartSetMsg->pointer(); if (myOperationMgr->startOperation(anOperation)) { @@ -287,16 +287,15 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const Model_FeatureUpdatedMessage* the { std::set aFeatures = theMsg->features(); std::set::const_iterator aIt; + bool isDisplayed = false; for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) { FeaturePtr aFeature = (*aIt); if (aFeature->getKind() != PARTSET_PART_KIND) { - if (myDisplayer->isVisible(aFeature)) - myDisplayer->redisplay(aFeature, false); - else - myDisplayer->display(aFeature, false); + isDisplayed = myDisplayer->redisplay(aFeature, false); } } - myDisplayer->updateViewer(); + if (isDisplayed) + myDisplayer->updateViewer(); } //****************************************************** @@ -306,16 +305,18 @@ void XGUI_Workshop::onFeatureCreatedMsg(const Model_FeatureUpdatedMessage* theMs std::set::const_iterator aIt; bool aHasPart = false; + bool isDisplayed = false; for (aIt = aFeatures.begin(); aIt != aFeatures.end(); ++aIt) { FeaturePtr aFeature = (*aIt); if (aFeature->getKind() == PARTSET_PART_KIND) { aHasPart = true; //break; } else { - myDisplayer->display(aFeature, false); + isDisplayed = myDisplayer->display(aFeature, false); } } - myDisplayer->updateViewer(); + if (isDisplayed) + myDisplayer->updateViewer(); if (aHasPart) { //The created part will be created in Object Browser later and we have to activate it // only when it is created everywere @@ -334,9 +335,9 @@ void XGUI_Workshop::onOperationStarted() showPropertyPanel(); QString aXmlRepr = aOperation->getDescription()->xmlRepresentation(); ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(), myModuleConnector); - QWidget* aContent = myPropertyPanel->contentWidget(); - qDeleteAll(aContent->children()); - aFactory.createWidget(aContent); + + myPropertyPanel->cleanContent(); + aFactory.createWidget(myPropertyPanel->contentWidget()); QList aWidgets = aFactory.getModelWidgets(); QList::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end(); @@ -364,7 +365,7 @@ void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation) //!< No need for property panel updateCommandStatus(); hidePropertyPanel(); - //myPropertyPanel->cleanContent(); + myPropertyPanel->cleanContent(); } /*