Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 11 Dec 2014 13:54:29 +0000 (16:54 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 11 Dec 2014 13:54:29 +0000 (16:54 +0300)
1  2 
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 619fe0bbbb321b97324f08c80886af2bd385c8dc,9f7da7a38f3a7bd69213e6a8f05dd7ec36feaeda..99f2fa15ff9b69122d0b7edcce30d823dac34c22
@@@ -1,5 -1,3 +1,5 @@@
 +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 +
  
  #include "ModuleBase_IModule.h"
  #include "ModuleBase_IViewer.h"
  ModuleBase_IModule::ModuleBase_IModule(ModuleBase_IWorkshop* theParent)
    : QObject(theParent), myWorkshop(theParent) 
  {
-   connect(myWorkshop, SIGNAL(operationStarted(ModuleBase_Operation*)), 
-           SLOT(onOperationStarted(ModuleBase_Operation*)));
    connect(myWorkshop, SIGNAL(operationStopped(ModuleBase_Operation*)), 
            SLOT(onOperationStopped(ModuleBase_Operation*)));
  
-   connect(myWorkshop, SIGNAL(operationResumed(ModuleBase_Operation*)), 
-           SLOT(onOperationResumed(ModuleBase_Operation*)));
    connect(myWorkshop, SIGNAL(operationComitted(ModuleBase_Operation*)), 
            SLOT(onOperationComitted(ModuleBase_Operation*)));
  
index 4216a76dc2f0f03f5839f245601ef457c67d0c9d,bf1675bfaa9e4ac32f9ec5dc7e8fe7ed0073b6ea..e0d693a59a8e8579925e9365db93c716dbb441fe
@@@ -1,5 -1,3 +1,5 @@@
 +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
 +\r
  #ifndef ModuleBase_IModule_H\r
  #define ModuleBase_IModule_H\r
  \r
@@@ -47,6 -45,14 +47,14 @@@ class MODULEBASE_EXPORT ModuleBase_IMod
    /// \param theCmdId the operation name\r
    virtual void launchOperation(const QString& theCmdId);\r
  \r
+   /// Realizes some functionality by an operation start\r
+   /// \param theOperation a started operation\r
+   virtual void operationStarted(ModuleBase_Operation* theOperation) {}\r
\r
+   /// Realizes some functionality by an operation resume\r
+   /// \param theOperation a resumed operation\r
+   virtual void operationResumed(ModuleBase_Operation* theOperation) {}\r
\r
    /// Called when it is necessary to update a command state (enable or disable it)\r
    //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;\r
  \r
@@@ -68,14 -74,10 +76,10 @@@ public slots
    void onFeatureTriggered();\r
  \r
  protected slots:\r
-   /// SLOT, that is called after the operation is started. Connect on the focus activated signal\r
-   virtual void onOperationStarted(ModuleBase_Operation* theOperation) {}\r
-   \r
    /// SLOT, that is called after the operation is stopped. Switched off the modfications performed\r
    /// by the operation start\r
    virtual void onOperationStopped(ModuleBase_Operation* theOperation) {}\r
  \r
-   virtual void onOperationResumed(ModuleBase_Operation* theOperation) {}\r
  \r
    virtual void onOperationComitted(ModuleBase_Operation* theOperation) {}\r
  \r
index 516430bd04270fdf20b6874a86eb30022d7cb6b5,798a8298747c4a43b96dc0d83cf7e1832ce9a6ad..301fbcca5f8da76c26bc5b829f0f55d7f810870c
@@@ -1,5 -1,3 +1,5 @@@
 +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 +
  /*
   * ModuleBase_Operation.cpp
   *
@@@ -171,6 -169,7 +171,7 @@@ void ModuleBase_Operation::start(
  
    startOperation();
    emit started();
  }
  
  void ModuleBase_Operation::postpone()
@@@ -232,16 -231,16 +233,16 @@@ void ModuleBase_Operation::setRunning(b
    }
  }
  
bool ModuleBase_Operation::activateByPreselection()
void ModuleBase_Operation::activateByPreselection()
  {
    if (!myPropertyPanel || myPreSelection.empty()) {
      myPropertyPanel->activateNextWidget(NULL);
-     return false;
+     return;
    }
    const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
    if (aWidgets.empty()) {
      myPropertyPanel->activateNextWidget(NULL);
-     return false;
+     return;
    }
    
    ModuleBase_ModelWidget* aWgt, *aFilledWgt = 0;
      }
    }
  
-   if (aFilledWgt) {
-     myPropertyPanel->activateNextWidget(aFilledWgt);
+   myPropertyPanel->activateNextWidget(aFilledWgt);
+   if (aFilledWgt)
      emit activatedByPreselection();
-     return true;
-   }
-   else
-     myPropertyPanel->activateNextWidget(NULL);
-   return false;
  }
  
  void ModuleBase_Operation::initSelection(ModuleBase_ISelection* theSelection,
@@@ -357,6 -352,11 +354,11 @@@ void ModuleBase_Operation::setPropertyP
    myPropertyPanel->setEditingMode(isEditOperation());
    //connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this,
    //        SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
+   // Do not activate widgets by default if the current operation is editing operation
+   // Because we don't know which widget is going to be edited. 
+   if (!isEditOperation())
+     activateByPreselection();
  }
  
  bool ModuleBase_Operation::isGranted(QString theId) const
index e617cf24309371e106221d1c10277d7092e6cc7d,f20c7f4762ecfdd185247985b31e4a05b6862627..4e76077f249ac3872ca617d237320f1987d07547
@@@ -1,5 -1,3 +1,5 @@@
 +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 +
  /*
   * ModuleBase_Operation.h
   *
@@@ -128,8 -126,8 +128,8 @@@ Q_OBJEC
  
    ModuleBase_IPropertyPanel* propertyPanel() const { return myPropertyPanel; }
  
-   /// Activates widgets by preselection if it is accepted
-   virtual bool activateByPreselection();
+   /// Activates widgets by preselection if it is accepted. Emits signal if the activation is correct
+   virtual void activateByPreselection();
  
    /// If the operation works with feature which is sub-feature of another one
    /// then this variable has to be initialised by parent feature 
index 5c5da75d0921818bcee77ddb1fd50b5d8165b6d1,bffa6148d710e82f1beaddc82f3598790845a595..cb053cf47768c8b941db5d5c53e218a8c5a1dce2
@@@ -1,5 -1,3 +1,5 @@@
 +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 +
  #include "PartSet_Module.h"
  #include <PartSet_OperationSketch.h>
  #include <PartSet_WidgetSketchLabel.h>
@@@ -180,7 -178,7 +180,7 @@@ void PartSet_Module::onOperationAborted
    breakOperationSequence();
  }
  
- void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
+ void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
  {
    if (theOperation->id().toStdString() == SketchPlugin_Sketch::ID()) {
      // Display all sketcher sub-Objects
index 1837a2c8ab20a46f61075997d92dd11d1fe3d62f,e9a145ebb2c947f6a26d6c0e060ef004421d6dee..ed87e7700d2c980d3ab448ecb6615017f9825d10
@@@ -1,5 -1,3 +1,5 @@@
 +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 +
  #ifndef PartSet_Module_H
  #define PartSet_Module_H
  
@@@ -51,6 -49,10 +51,10 @@@ public
  
    QStringList sketchOperationIdList() const;
  
+   /// Realizes some functionality by an operation start
+   /// \param theOperation a started operation
+   virtual void operationStarted(ModuleBase_Operation* theOperation);
  public slots:
    /// SLOT, that is called by no more widget signal emitted by property panel
    /// Set a specific flag to restart the sketcher operation
@@@ -62,8 -64,6 +66,6 @@@ protected slots
  
    virtual void onOperationAborted(ModuleBase_Operation* theOperation);
  
-   virtual void onOperationStarted(ModuleBase_Operation* theOperation);
    virtual void onOperationStopped(ModuleBase_Operation* theOperation);
  
    /// Called when previous operation is finished
index 29ea660daff7c41ed3ab06a868107e358e075791,e788d15da4cee0b63b2ff942a069a4e3c4142e29..8a3cf8bf19fe89e4bb24f6b509dcd29cf1d53f9d
@@@ -1,5 -1,3 +1,5 @@@
 +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
 +
  /*
   * XGUI_PropertyPanel.cpp
   *
@@@ -79,6 -77,7 +79,7 @@@ void XGUI_PropertyPanel::cleanContent(
    myWidgets.clear();
    qDeleteAll(myCustomWidget->children());
    myActiveWidget = NULL;
+   setWindowTitle(tr("Property Panel"));
  }
  
  void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
index 58d0f8844e07fc20aee6a044b387a58595ab89b5,f8fe475ca68e19a063172b064c081518237062fd..1661d6564939b50c7f5bac4061dfb4e812a00f2f
@@@ -1,5 -1,3 +1,5 @@@
 +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
 +
  //#include "XGUI_Constants.h"
  #include "XGUI_Tools.h"
  #include "XGUI_Workshop.h"
@@@ -148,8 -146,9 +148,9 @@@ XGUI_Workshop::XGUI_Workshop(XGUI_Salom
    myModuleConnector = new XGUI_ModuleConnector(this);
  
    connect(myOperationMgr, SIGNAL(operationStarted(ModuleBase_Operation*)), 
-           SLOT(onOperationStarted()));
-   connect(myOperationMgr, SIGNAL(operationResumed(ModuleBase_Operation*)), SLOT(onOperationStarted()));
+           SLOT(onOperationStarted(ModuleBase_Operation*)));
+   connect(myOperationMgr, SIGNAL(operationResumed(ModuleBase_Operation*)),
+           SLOT(onOperationResumed(ModuleBase_Operation*)));
    connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
            SLOT(onOperationStopped(ModuleBase_Operation*)));
    connect(myMainWindow, SIGNAL(exitKeySequence()), SLOT(onExit()));
@@@ -559,56 -558,34 +560,34 @@@ void XGUI_Workshop::onObjectDeletedMsg(
  }
  
  //******************************************************
- void XGUI_Workshop::onOperationStarted()
+ void XGUI_Workshop::onOperationStarted(ModuleBase_Operation* theOperation)
  {
-   ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
-   if (this->isSalomeMode()) 
-     aOperation->setNestedFeatures(mySalomeConnector->nestedActions(aOperation->id()));
-   else 
-     aOperation->setNestedFeatures(myActionsMgr->nestedCommands(aOperation->id()));
-   
-   if (aOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
-     connectWithOperation(aOperation);
-     showPropertyPanel();
-     QString aXmlRepr = aOperation->getDescription()->xmlRepresentation();
-     ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
-                                                                  myModuleConnector);
-     myPropertyPanel->cleanContent();
-     aFactory.createWidget(myPropertyPanel->contentWidget());
-     ModuleBase_Tools::zeroMargins(myPropertyPanel->contentWidget());
-     QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
-     foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
-       aWidget->setFeature(aOperation->feature());
-       aWidget->enableFocusProcessing();
-       QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
-       // Init default values
-       if (!aOperation->isEditOperation() && !aWidget->isComputedDefault()) {
-         aWidget->storeValue();
-       }
-     }
+   setNestedFeatures(theOperation);
  
-     myPropertyPanel->setModelWidgets(aWidgets);
-     aOperation->setPropertyPanel(myPropertyPanel);
-     // Do not activate widgets by default if the current operation is editing operation
-     // Because we don't know which widget is going to be edited. 
-     if ((!aOperation->isEditOperation())) {
-       aOperation->activateByPreselection();
-     }
-     // Set final definitions if they are necessary
-     myModule->propertyPanelDefined(aOperation);
+   if (theOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
+     connectWithOperation(theOperation);
+     setPropertyPanel(theOperation);
+   }
+   updateCommandStatus();
  
-     // Widget activation (from the previous method) may commit the current operation
-     // if pre-selection is enougth for it. So we shouldn't update prop panel's title
-     if(myOperationMgr->isCurrentOperation(aOperation)) {
-       myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
-     }
+   myModule->operationStarted(theOperation);
+ }
+ //******************************************************
+ void XGUI_Workshop::onOperationResumed(ModuleBase_Operation* theOperation)
+ {
+   setNestedFeatures(theOperation);
+   if (theOperation->getDescription()->hasXmlRepresentation()) {  //!< No need for property panel
+     connectWithOperation(theOperation);
+     setPropertyPanel(theOperation);
    }
    updateCommandStatus();
+   myModule->operationResumed(theOperation);
  }
  
  //******************************************************
  void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
  {
    }
  }
  
+ void XGUI_Workshop::setNestedFeatures(ModuleBase_Operation* theOperation)
+ {
+   if (this->isSalomeMode()) 
+     theOperation->setNestedFeatures(mySalomeConnector->nestedActions(theOperation->id()));
+   else 
+     theOperation->setNestedFeatures(myActionsMgr->nestedCommands(theOperation->id()));
+ }
+ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation)
+ {
+   showPropertyPanel();
+   QString aXmlRepr = theOperation->getDescription()->xmlRepresentation();
+   ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
+                                                                 myModuleConnector);
+   myPropertyPanel->cleanContent();
+   aFactory.createWidget(myPropertyPanel->contentWidget());
+   ModuleBase_Tools::zeroMargins(myPropertyPanel->contentWidget());
+   QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
+   foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
+     aWidget->setFeature(theOperation->feature());
+     aWidget->enableFocusProcessing();
+     QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
+     // Init default values
+     if (!theOperation->isEditOperation() && !aWidget->isComputedDefault()) {
+       aWidget->storeValue();
+     }
+   }
+   
+   myPropertyPanel->setModelWidgets(aWidgets);
+   theOperation->setPropertyPanel(myPropertyPanel);
+   myModule->propertyPanelDefined(theOperation);
+   myPropertyPanel->setWindowTitle(theOperation->getDescription()->description());
+ }
  bool XGUI_Workshop::event(QEvent * theEvent)
  {
    PostponeMessageQtEvent* aPostponedEv = dynamic_cast<PostponeMessageQtEvent*>(theEvent);
diff --combined src/XGUI/XGUI_Workshop.h
index 80232d6bbb2b1604f2a4d74e42a4fb75d975058c,f8c293c5e9744a3812cae58774c4d292da0b1f33..97dc5d64cb43e91c2f020c0b0aba6fc6bc3bce2e
@@@ -1,5 -1,3 +1,5 @@@
 +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
 +
  #ifndef XGUI_WORKSHOP_H
  #define XGUI_WORKSHOP_H
  
@@@ -221,6 -219,14 +221,14 @@@ signals
    void closeDocument();
  
   protected:
+   // Find the nested features and set them into the operation
+   // \param theOperation an operation
+   void setNestedFeatures(ModuleBase_Operation* theOperation);
+   // Update the property panel content by the XML description of the operation and set the panel
+   // into the operation
+   // \param theOperation an operation
+   void setPropertyPanel(ModuleBase_Operation* theOperation);
    bool event(QEvent * theEvent);
    //Event-loop processing methods:
    void addFeature(const std::shared_ptr<Config_FeatureMessage>&);
   private slots:
    /// SLOT, that is called after the operation is started. Update workshop state according to
    /// the started operation, e.g. visualizes the property panel and connect to it.
-   void onOperationStarted();
+   /// \param theOpertion a started operation
+   void onOperationStarted(ModuleBase_Operation* theOperation);
+   /// SLOT, that is called after the operation is resumed. Update workshop state according to
+   /// the started operation, e.g. visualizes the property panel and connect to it.
+   /// \param theOpertion a resumed operation
+   virtual void onOperationResumed(ModuleBase_Operation* theOperation);
  
    /// SLOT, that is called after the operation is stopped. Update workshop state, e.g.
    /// hides the property panel and udpate the command status.