From 1a9c873645580822c23f4abcd374b6c639d5b9cf Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 22 Jun 2016 11:19:19 +0300 Subject: [PATCH] Arc problems fixing: 1. reentrant of the tangent arc should not fill center point before start arc point(problem is reproduced on several sketch point entities created) 2. Issue #1578 arc problems (constraint to passed point of existing arc in sketch which is not in the case of the arc) --- src/ModelAPI/ModelAPI_Events.h | 2 -- src/ModuleBase/ModuleBase_IModule.cpp | 14 ++++++------- src/ModuleBase/ModuleBase_IModule.h | 6 ++++-- src/ModuleBase/ModuleBase_IWorkshop.h | 4 ++++ src/PartSet/PartSet_Module.cpp | 5 +++-- src/PartSet/PartSet_Module.h | 3 ++- src/PartSet/PartSet_SketcherReetntrantMgr.cpp | 6 +++++- src/PartSet/PartSet_Tools.cpp | 9 ++++++-- src/XGUI/XGUI_ModuleConnector.cpp | 21 +++++++++++++++++++ src/XGUI/XGUI_ModuleConnector.h | 5 +++++ src/XGUI/XGUI_WorkshopListener.cpp | 21 ------------------- 11 files changed, 57 insertions(+), 39 deletions(-) diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h index f80dd6240..3aa459424 100644 --- a/src/ModelAPI/ModelAPI_Events.h +++ b/src/ModelAPI/ModelAPI_Events.h @@ -34,8 +34,6 @@ static const char * EVENT_OBJECT_RENAMED = "ObjectRenamed"; static const char * EVENT_OBJECT_MOVED = "ObjectsMoved"; /// Event ID that visualization must be redisplayed (comes with ModelAPI_ObjectUpdatedMessage) static const char * EVENT_OBJECT_TO_REDISPLAY = "ObjectsToRedisplay"; -/// Event ID that visualization must be redisplayed (comes with ModelAPI_ObjectUpdatedMessage) -static const char * EVENT_OPERATION_LAUNCHED = "OperationLaunched"; /// Event ID that plugin is loaded (comes with ModelAPI_ObjectUpdatedMessage) static const char * EVENT_PLUGIN_LOADED = "PluginLoaded"; // diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index 942d9ec65..fb7805fa6 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -69,7 +69,8 @@ void ModuleBase_IModule::launchModal(const QString& theCmdId) } -void ModuleBase_IModule::launchOperation(const QString& theCmdId) +void ModuleBase_IModule::launchOperation(const QString& theCmdId, + const bool isUpdatePropertyPanel) { if (!myWorkshop->canStartOperation(theCmdId)) return; @@ -80,18 +81,15 @@ void ModuleBase_IModule::launchOperation(const QString& theCmdId) ModuleBase_ISelection* aSelection = myWorkshop->selection(); // Initialise operation with preliminary selection aFOperation->initSelection(aSelection, myWorkshop->viewer()); - sendOperation(aFOperation); + sendOperation(aFOperation, isUpdatePropertyPanel); } } -void ModuleBase_IModule::sendOperation(ModuleBase_Operation* theOperation) +void ModuleBase_IModule::sendOperation(ModuleBase_Operation* theOperation, + const bool isUpdatePropertyPanel) { - static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED); - std::shared_ptr aMessage = - std::shared_ptr(new Config_PointerMessage(aModuleEvent, this)); - aMessage->setPointer(theOperation); - Events_Loop::loop()->send(aMessage); + workshop()->processLaunchOperation(theOperation, isUpdatePropertyPanel); } Handle(AIS_InteractiveObject) ModuleBase_IModule::createPresentation(const ResultPtr& theResult) diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index f12b751f3..78f48a39f 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -82,7 +82,8 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// Creates an operation and send it to loop /// \param theCmdId the operation name - virtual void launchOperation(const QString& theCmdId); + /// \param isUpdatePropertyPanel if false, the property panel filling might be postponed + virtual void launchOperation(const QString& theCmdId, const bool isUpdatePropertyPanel = true); /// Executes feature as a modal dialog box /// \param theCmdId the operation name @@ -240,7 +241,8 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// Sends the operation for launching /// \param theOperation the operation - virtual void sendOperation(ModuleBase_Operation* theOperation); + /// \param isUpdatePropertyPanel if false, the property panel filling might be postponed + virtual void sendOperation(ModuleBase_Operation* theOperation, const bool isUpdatePropertyPanel = true); /// Create specific for the module presentation /// \param theResult an object for presentation diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h index c7ff4ceee..432b5accd 100644 --- a/src/ModuleBase/ModuleBase_IWorkshop.h +++ b/src/ModuleBase/ModuleBase_IWorkshop.h @@ -76,6 +76,10 @@ Q_OBJECT //! Returns true if the operation with id theId can be started virtual bool canStartOperation(QString theId) = 0; + //! Performs the operation launch + //! \param theOperation an operation to be launched + virtual void processLaunchOperation(ModuleBase_Operation* theOperation, const bool isUpdatePropertyPanel) = 0; + //! Returns started operation by the operation identifier //! \param theId an operation id //! \return an operation instance or NULL diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 1892f8b0a..1b182cdf3 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -828,12 +828,13 @@ bool PartSet_Module::canCommitOperation() const return true; } -void PartSet_Module::launchOperation(const QString& theCmdId) +void PartSet_Module::launchOperation(const QString& theCmdId, + const bool isUpdatePropertyPanel) { storeConstraintsState(theCmdId.toStdString()); updateConstraintsState(theCmdId.toStdString()); - ModuleBase_IModule::launchOperation(theCmdId); + ModuleBase_IModule::launchOperation(theCmdId, isUpdatePropertyPanel); } void PartSet_Module::storeConstraintsState(const std::string& theFeatureKind) diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index f6d8fa921..c71187fcb 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -102,7 +102,8 @@ public: /// Creates an operation and send it to loop /// \param theCmdId the operation name - virtual void launchOperation(const QString& theCmdId); + /// \param isUpdatePropertyPanel if false, the property panel filling might be postponed + virtual void launchOperation(const QString& theCmdId, const bool isUpdatePropertyPanel = true); /// Realizes some functionality by an operation start /// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index cc5f7602a..eb0432ff4 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -451,12 +451,16 @@ void PartSet_SketcherReetntrantMgr::restartOperation() myIsFlagsBlocked = true; FeaturePtr aPrevFeature = aFOperation->feature(); aFOperation->commit(); - module()->launchOperation(aFOperation->id()); + module()->launchOperation(aFOperation->id(), false); // allow the same attribute values in restarted operation ModuleBase_OperationFeature* aCurrentOperation = dynamic_cast( myWorkshop->currentOperation()); copyReetntrantAttributes(aPrevFeature, aCurrentOperation->feature()); + // update property panel: it should be done because in launchOperation, the 'false' is given + workshop()->propertyPanel()->updateContentWidget(aCurrentOperation->feature()); + workshop()->propertyPanel()->createContentPanel(aCurrentOperation->feature()); + myIsFlagsBlocked = false; resetFlags(); // we should avoid processing of the signal about no more widgets attributes and diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index a08190d7b..a4e44a736 100755 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -333,10 +334,14 @@ std::shared_ptr PartSet_Tools::findFirstEqualPoint(const Fe theFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); std::list >::const_iterator anIt = anAttiributes.begin(), aLast = anAttiributes.end(); + ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators(); + for (; anIt != aLast && !aFPoint; anIt++) { std::shared_ptr aCurPoint = - std::dynamic_pointer_cast(*anIt); - if (aCurPoint && (aCurPoint->pnt()->distance(thePoint) < Precision::Confusion())) { + std::dynamic_pointer_cast(*anIt); + if (aCurPoint && aCurPoint->isInitialized() && + aValidators->isCase(theFeature, aCurPoint->id()) && + (aCurPoint->pnt()->distance(thePoint) < Precision::Confusion())) { aFPoint = aCurPoint; break; } diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp index a01004ceb..6312c827b 100644 --- a/src/XGUI/XGUI_ModuleConnector.cpp +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -16,6 +16,7 @@ #include #include +#include #include @@ -129,6 +130,26 @@ bool XGUI_ModuleConnector::canStartOperation(QString theId) return myWorkshop->operationMgr()->canStartOperation(theId); } +void XGUI_ModuleConnector::processLaunchOperation(ModuleBase_Operation* theOperation, + const bool isUpdatePropertyPanel) +{ + XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr(); + + if (anOperationMgr->startOperation(theOperation)) { + if (isUpdatePropertyPanel) { + ModuleBase_OperationFeature* aFOperation = dynamic_cast(theOperation); + if (aFOperation) { + workshop()->propertyPanel()->updateContentWidget(aFOperation->feature()); + workshop()->propertyPanel()->createContentPanel(aFOperation->feature()); + } + } + if (!theOperation->getDescription()->hasXmlRepresentation()) { + if (theOperation->commit()) + workshop()->updateCommandStatus(); + } + } +} + ModuleBase_Operation* XGUI_ModuleConnector::findStartedOperation(const QString& theId) { return myWorkshop->operationMgr()->findOperation(theId); diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h index 89f5625dd..423bcbdcd 100644 --- a/src/XGUI/XGUI_ModuleConnector.h +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -57,6 +57,11 @@ Q_OBJECT //! Returns true if the operation with id theId can be started virtual bool canStartOperation(QString theId); + //! Performs the operation launch + //! \param theOperation an operation to be launched + virtual void processLaunchOperation(ModuleBase_Operation* theOperation, + const bool isUpdatePropertyPanel); + //! Returns started operation by the operation identifier. The operation manager is called. //! \param theId an operation id //! \return an operation instance or NULL diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index 984388b5c..dff5b6209 100755 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -85,7 +85,6 @@ void XGUI_WorkshopListener::initializeEventListening() //Initialize event listening Events_Loop* aLoop = Events_Loop::loop(); aLoop->registerListener(this, Events_InfoMessage::errorID()); //!< Listening application errors. - aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); @@ -158,26 +157,6 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& QApplication::restoreOverrideCursor(); } } - //An operation passed by message. Start it, process and commit. - else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) { - std::shared_ptr aPartSetMsg = - std::dynamic_pointer_cast(theMessage); - //myPropertyPanel->cleanContent(); - ModuleBase_Operation* anOperation = (ModuleBase_Operation*) aPartSetMsg->pointer(); - XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr(); - - if (anOperationMgr->startOperation(anOperation)) { - ModuleBase_OperationFeature* aFOperation = dynamic_cast(anOperation); - if (aFOperation) { - workshop()->propertyPanel()->updateContentWidget(aFOperation->feature()); - workshop()->propertyPanel()->createContentPanel(aFOperation->feature()); - } - if (!anOperation->getDescription()->hasXmlRepresentation()) { - if (anOperation->commit()) - workshop()->updateCommandStatus(); - } - } - } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_SELFILTER_LOADED)) { std::shared_ptr aMsg = std::dynamic_pointer_cast(theMessage); -- 2.39.2