]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Fri, 8 Aug 2014 06:39:24 +0000 (10:39 +0400)
committersbh <sergey.belash@opencascade.com>
Fri, 8 Aug 2014 06:39:24 +0000 (10:39 +0400)
1  2 
src/GeomAPI/GeomAPI_Shape.h
src/Model/Model_Validator.h
src/ModelAPI/ModelAPI_Feature.h
src/ModelAPI/ModelAPI_Validator.h
src/SketchPlugin/SketchPlugin_ConstraintDistance.h
src/SketchPlugin/SketchPlugin_Sketch.h
src/XGUI/XGUI_Workshop.cpp

index 7c058d5b31fe9243460f7ec5a0fc24e864caba3b,9866616ccf9ebccb0469db2d0c0a173c43bd2fb5..4b526589f22c85d9c032bfb06fa4e879c19d9b97
@@@ -2,8 -2,8 +2,8 @@@
  // Created:     23 Apr 2014
  // Author:      Mikhail PONIKAROV
  
 -#ifndef GeomAPI_Shape_HeaderFile
 -#define GeomAPI_Shape_HeaderFile
 +#ifndef GeomAPI_Shape_H_
 +#define GeomAPI_Shape_H_
  
  #include <GeomAPI_Interface.h>
  
@@@ -28,6 -28,7 +28,7 @@@ public
  
    /// Returns whether the shape is an edge
    virtual bool isEdge() const;
  };
  
  #endif
index a93f450a414ed4d5b421f7038117c07a04ff22b2,45ad05c14f8535e5275380d803f6f1b91685d4b8..f748c42ca7163560919e3899c79cc04b5149b1f0
@@@ -2,12 -2,13 +2,13 @@@
  // Created:     2 Jul 2014
  // Author:      Mikhail PONIKAROV
  
 -#ifndef Model_Validator_HeaderFile
 -#define Model_Validator_HeaderFile
 +#ifndef Model_Validator_H_
 +#define Model_Validator_H_
  
  #include <Model.h>
  #include <ModelAPI_Validator.h>
  #include <map>
+ #include <set>
  
  /**\class Model_ValidatorsFactory
   * \ingroup DataModel
   */
  class Model_ValidatorsFactory: public ModelAPI_ValidatorsFactory
  {
+ private:
    std::map<std::string, ModelAPI_Validator*> myIDs; ///< map from ID to registered validator
-   std::map<std::string, ModelAPI_Validator*> myFeatures; ///< validators by feature ID
-   std::map<std::string, std::map<std::string, std::pair<ModelAPI_Validator*, 
-     std::list<std::string> > > > myAttrs; ///< validators and arguments by feature and attribute IDs
+   /// validators IDs by feature ID
+   std::map<std::string, std::set<std::string> > myFeatures; 
+   /// set of pairs: validators IDs, list of arguments
+   typedef std::set<std::pair<std::string, std::list<std::string> > > AttrValidators;
+   /// validators IDs and arguments by feature and attribute IDs
+   std::map<std::string, std::map<std::string, AttrValidators> > myAttrs;
  public:
    /// Registers the instance of the validator by the ID
    MODEL_EXPORT virtual void registerValidator(
      const std::list<std::string>& theArguments);
  
    /// Provides a validator for the feature, returns NULL if no validator
-   MODEL_EXPORT virtual const ModelAPI_Validator* validator(const std::string& theFeatureID) const;
+   MODEL_EXPORT virtual void validators(const std::string& theFeatureID, 
+     std::list<ModelAPI_Validator*>& theResult) const;
    /// Provides a validator for the attribute, returns NULL if no validator
-   MODEL_EXPORT virtual const ModelAPI_Validator* validator(
-     const std::string& theFeatureID, const std::string& theAttrID) const;
+   MODEL_EXPORT virtual void validators(
+     const std::string& theFeatureID, const std::string& theAttrID,
+     std::list<ModelAPI_Validator*>& theValidators, 
+     std::list<std::list<std::string> >& theArguments) const;
+   /// Returns registered validator by its Id
+   virtual const ModelAPI_Validator* validator(const std::string& theID) const;
  
    /// Returns the result of "validate" method for attribute of validator.
    /// If validator is not exists, returns true: everything is valid by default.
index bf3f233acce848bbce2a22d9f3d7e742a79b0049,a1d048af378b7ef274a7ee1b3109eb45b57ee20f..9f989074b57cccc560b49814218b7ef6d51ee945
@@@ -2,8 -2,8 +2,8 @@@
  // Created:     21 Mar 2014
  // Author:      Mikhail PONIKAROV
  
 -#ifndef ModelAPI_Feature_HeaderFile
 -#define ModelAPI_Feature_HeaderFile
 +#ifndef ModelAPI_Feature_H_
 +#define ModelAPI_Feature_H_
  
  #include "ModelAPI_Object.h"
  #include "ModelAPI_PluginManager.h"
@@@ -62,6 -62,9 +62,9 @@@ public
  
    /// To virtually destroy the fields of successors
    MODELAPI_EXPORT virtual ~ModelAPI_Feature();
+   MODELAPI_EXPORT static boost::shared_ptr<ModelAPI_Feature> feature(ObjectPtr theObject);
  };
  
  //! Pointer on feature object
index 522945c3f1cfdbc661b7da7630385bab47b6b87e,88ab1574c31b7f49142df8c8b6783eb078555e1f..bd53ecc24a349811a09755317f6d3821002fa115
@@@ -2,8 -2,8 +2,8 @@@
  // Created:     2 Jul 2014
  // Author:      Mikhail PONIKAROV
  
 -#ifndef ModelAPI_Validator_HeaderFile
 -#define ModelAPI_Validator_HeaderFile
 +#ifndef ModelAPI_Validator_H_
 +#define ModelAPI_Validator_H_
  
  #include <ModelAPI.h>
  #include <boost/shared_ptr.hpp>
@@@ -65,11 -65,16 +65,16 @@@ public
      const std::list<std::string>& theArguments) = 0;
  
    /// Provides a validator for the feature, returns NULL if no validator
-   virtual const ModelAPI_Validator* validator(const std::string& theFeatureID) const = 0;
+   virtual void validators(const std::string& theFeatureID, 
+     std::list<ModelAPI_Validator*>& theResult) const = 0;
    /// Provides a validator for the attribute, returns NULL if no validator
-   virtual const ModelAPI_Validator* validator(
-     const std::string& theFeatureID, const std::string& theAttrID) const = 0;
+   virtual void validators(
+     const std::string& theFeatureID, const std::string& theAttrID,
+     std::list<ModelAPI_Validator*>& theValidators, 
+     std::list<std::list<std::string> >& theArguments) const = 0;
+   /// Returns registered validator by its Id
+   virtual const ModelAPI_Validator* validator(const std::string& theID) const = 0;
  
    /// Returns the result of "validate" method for attribute of validator.
    /// If validator is not exists, returns true: everything is valid by default.
index 2294ac6ef2be8483ab3d3c1339bbf0ce982223c7,6a229544dd5d82395983afcbb578e7cbe7ce9001..afb687d09c49f1caa24932f4b821b6e9a38f556d
@@@ -2,15 -2,19 +2,19 @@@
  // Created: 23 May 2014
  // Author:  Artem ZHIDKOV
  
 -#ifndef SketchPlugin_ConstraintDistance_HeaderFile
 -#define SketchPlugin_ConstraintDistance_HeaderFile
 +#ifndef SketchPlugin_ConstraintDistance_H_
 +#define SketchPlugin_ConstraintDistance_H_
  
  #include "SketchPlugin.h"
  #include "SketchPlugin_Constraint.h"
  #include "SketchPlugin_Sketch.h"
+ #include "ModelAPI_Data.h"
  
  #include <list>
  
+ class SketchPlugin_Line;
+ class GeomDataAPI_Point2D;
  /** \class SketchPlugin_ConstraintDistance
   *  \ingroup DataModel
   *  \brief Feature for creation of a new constraint which defines a distance
@@@ -52,4 -56,15 +56,15 @@@ public
    SketchPlugin_ConstraintDistance();
  };
  
+ /// Obtain the point object from specified constraint parameter
+ boost::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
+                                                        const std::string&  theAttribute);
+ boost::shared_ptr<SketchPlugin_Line> getFeatureLine(DataPtr theData, const std::string& theAttribute);
+ boost::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(const boost::shared_ptr<SketchPlugin_Line>& theLine, 
+                                                     const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
  #endif
index 9a2e31ee6ed0dca75d46c387f6cd42451ccf5914,8a1d22db4701ad7fa263979b921ebc1058e9b67b..3c71a6505c29a65eb616adc9a7791d6a97888eb3
@@@ -2,8 -2,8 +2,8 @@@
  // Created:     27 Mar 2014
  // Author:      Mikhail PONIKAROV
  
 -#ifndef SketchPlugin_Sketch_HeaderFile
 -#define SketchPlugin_Sketch_HeaderFile
 +#ifndef SketchPlugin_Sketch_H_
 +#define SketchPlugin_Sketch_H_
  
  #include "SketchPlugin.h"
  #include <SketchPlugin_Feature.h>
@@@ -96,8 -96,6 +96,6 @@@ public
    virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
                              boost::shared_ptr<GeomAPI_AISObject> thePrevious);
  
-   static FeaturePtr getFeature(ObjectPtr theObject);
  protected:
    /// Creates a plane and append it to the list
    /// \param theX the X normal value
index db0ab95fd7765e0d98f4b981f9b9aa9eec03e189,a18688e229ec8ecf090e2a8f4aab979cc9952291..49a1eade12b048118d17db0621a6fbd2dafe426b
@@@ -50,6 -50,8 +50,8 @@@
  #include <Config_PointerMessage.h>
  #include <Config_ModuleReader.h>
  
+ #include <SUIT_ResourceMgr.h>
  #include <QApplication>
  #include <QFileDialog>
  #include <QMessageBox>
@@@ -69,6 -71,7 +71,7 @@@
  #include <dlfcn.h>
  #endif
  
+ SUIT_ResourceMgr* XGUI_Workshop::myResourceMgr = 0;
  
  QMap<QString, QString> XGUI_Workshop::myIcons;
  
@@@ -89,6 -92,10 +92,10 @@@ XGUI_Workshop::XGUI_Workshop(XGUI_Salom
    myObjectBrowser(0),
    myDisplayer(0)
  {
+   if (!myResourceMgr) {
+     myResourceMgr = new SUIT_ResourceMgr("NewGeom");
+     myResourceMgr->setCurrentFormat("xml");
+   }
    myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
  
    myDisplayer = new XGUI_Displayer(this);
@@@ -168,8 -175,10 +175,8 @@@ void XGUI_Workshop::initMenu(
      salomeConnector()->addEditMenuSeparator();
      return;
    }
 -  XGUI_Workbench* aPage = myMainWindow->menuObject()->generalPage();
 -
    // File commands group
 -  XGUI_MenuGroupPanel* aGroup = aPage->addGroup("Default");
 +  XGUI_MenuGroupPanel* aGroup = myMainWindow->menuObject()->generalPage();
  
    XGUI_Command* aCommand;
  
                                  QIcon(":pictures/close.png"), QKeySequence::Close);
    aCommand->connectTo(this, SLOT(onExit()));
    //FIXME: SBH's test action. Can be used for some GUI tests.
 -  //#ifdef _DEBUG
 -  //  aCommand = aGroup->addFeature("TEST_CMD", "Test!", "Private debug button",
 -  //                                QIcon(":pictures/close.png"));
 -  //  aCommand->connectTo(myActionsMgr, SLOT(update()));
 -  //#endif
 +//  #ifdef _DEBUG
 +//    aCommand = aGroup->addFeature("TEST_CMD", "Test!", "Private debug button",
 +//                                  QIcon(":pictures/close.png"), QKeySequence(), true);
 +//    aCommand->connectTo(myMainWindow, SLOT(dockPythonConsole()));
 +//  #endif
  }
  
  //******************************************************
@@@ -262,10 -271,11 +269,11 @@@ void XGUI_Workshop::processEvent(const 
      return;
    }
  
-   if (theMessage->eventID() == Events_Loop::loop()->eventByName("LongOperation")) {
+   if (theMessage->eventID() == Events_LongOp::eventID()) {
      if (Events_LongOp::isPerformed())
        QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-     else
+       //QTimer::singleShot(10, this, SLOT(onStartWaiting()));
+     else 
        QApplication::restoreOverrideCursor();
      return;
    }
      if (myOperationMgr->startOperation(anOperation)) {
        myPropertyPanel->updateContentWidget(anOperation->feature());
        if (!anOperation->getDescription()->hasXmlRepresentation()) {
-         anOperation->commit();
-         updateCommandStatus();
+         if (anOperation->commit())
+           updateCommandStatus();
        }
      }
      return;
    }
  }
  
+ //******************************************************
+ void XGUI_Workshop::onStartWaiting()
+ {
+   if (Events_LongOp::isPerformed()) {
+     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+   }
+ }
  //******************************************************
  void XGUI_Workshop::onFeatureUpdatedMsg(const ModelAPI_ObjectUpdatedMessage* theMsg)
  {
@@@ -392,12 -410,15 +408,15 @@@ void XGUI_Workshop::onOperationStarted(
      ModuleBase_ModelWidget* aWidget;
      for (; anIt != aLast; anIt++) {
        aWidget = *anIt;
+       aWidget->setFeature(aOperation->feature());
        //QObject::connect(aWidget, SIGNAL(valuesChanged()),  aOperation, SLOT(storeCustomValue()));
        QObject::connect(aWidget, SIGNAL(valuesChanged()),
                         this, SLOT(onWidgetValuesChanged()));
        // Init default values
        if (!aOperation->isEditOperation() && aWidget->hasDefaultValue()) {
-         aWidget->storeValue(aOperation->feature());
+         //aWidget->storeValue(aOperation->feature());
+         
+         aWidget->storeValue();
        }
      }
  
@@@ -434,15 -455,15 +453,15 @@@ void XGUI_Workshop::addFeature(const Co
    QString aWchName = QString::fromStdString(theMessage->workbenchId());
    QString aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures());
    bool isUsePropPanel = theMessage->isUseInput();
 -  QString aId = QString::fromStdString(theMessage->id());
 +  QString aFeatureId = QString::fromStdString(theMessage->id());
    if (isSalomeMode()) {
      QAction* aAction = salomeConnector()->addFeature(aWchName,
 -                              aId,
 +                              aFeatureId,
                                QString::fromStdString(theMessage->text()),
                                QString::fromStdString(theMessage->tooltip()),
                                QIcon(theMessage->icon().c_str()),
                                QKeySequence(), isUsePropPanel);
 -    salomeConnector()->setNestedActions(aId, aNestedFeatures.split(" "));
 +    salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" "));
      myActionsMgr->addCommand(aAction);
      myModule->featureCreated(aAction);
    } else {
      if (!aGroup) {
        aGroup = aPage->addGroup(aGroupName);
      }
 -    //Create feature...
 -    XGUI_Command* aCommand = aGroup->addFeature(aId,
 +    // Check if hotkey sequence is already defined:
 +    QKeySequence aHotKey = myActionsMgr->registerShortcut(
 +        QString::fromStdString(theMessage->keysequence()));
 +    // Create feature...
 +    XGUI_Command* aCommand = aGroup->addFeature(aFeatureId,
                                                  QString::fromStdString(theMessage->text()),
                                                  QString::fromStdString(theMessage->tooltip()),
                                                  QIcon(theMessage->icon().c_str()),
 -                                                QKeySequence(), isUsePropPanel);
 +                                                aHotKey, isUsePropPanel);
      aCommand->setNestedCommands(aNestedFeatures.split(" ", QString::SkipEmptyParts));
      myActionsMgr->addCommand(aCommand);
      myModule->featureCreated(aCommand);
@@@ -773,8 -791,10 +792,8 @@@ QList<QAction*> XGUI_Workshop::getModul
    } else {
      XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
      foreach (XGUI_Workbench* aWb, aMenuBar->workbenches()) {
 -      if (aWb != aMenuBar->generalPage()) {
 -        foreach(XGUI_Command* aCmd, aWb->features())
 -          aCommands.append(aCmd);
 -      }
 +      foreach(XGUI_Command* aCmd, aWb->features())
 +        aCommands.append(aCmd);
      }
    }
    return aCommands;
@@@ -930,7 -950,8 +949,8 @@@ void XGUI_Workshop::onWidgetValuesChang
    for (; anIt != aLast; anIt++) {
      ModuleBase_ModelWidget* aCustom = *anIt;
      if (aCustom && (/*!aCustom->isInitialized(aFeature) ||*/ aCustom == aSenderWidget)) {
-       aCustom->storeValue(aFeature);
+       //aCustom->storeValue(aFeature);
+       aCustom->storeValue();
      }
    }
  }
@@@ -1012,12 -1033,16 +1032,16 @@@ void XGUI_Workshop::updateCommandsOnVie
    QList<QAction*> aActions = getModuleCommands();
    foreach(QAction* aAction, aActions) {
      QString aId = aAction->data().toString();
-     const ModelAPI_Validator* aValidator = aFactory->validator(aId.toStdString());
-     if (aValidator) {
-       const ModuleBase_SelectionValidator* aSelValidator = 
-         dynamic_cast<const ModuleBase_SelectionValidator*>(aValidator);
-       if (aSelValidator) {
-         aAction->setEnabled(aSelValidator->isValid(aSelection));
+     std::list<ModelAPI_Validator*> aValidators;
+     aFactory->validators(aId.toStdString(), aValidators);
+     std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
+     for(; aValidator != aValidators.end(); aValidator++) {
+       if (*aValidator) {
+         const ModuleBase_SelectionValidator* aSelValidator = 
+           dynamic_cast<const ModuleBase_SelectionValidator*>(*aValidator);
+         if (aSelValidator) {
+           aAction->setEnabled(aSelValidator->isValid(aSelection));
+         }
        }
      }
    }
@@@ -1029,10 -1054,6 +1053,6 @@@ void XGUI_Workshop::registerValidators(
  {
    PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
    ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-   aFactory->registerValidator("ModuleBase_ResulPointValidator", new ModuleBase_ResulPointValidator);
-   aFactory->registerValidator("ModuleBase_ResulLineValidator", new ModuleBase_ResulLineValidator);
-   aFactory->registerValidator("ModuleBase_ResulArcValidator", new ModuleBase_ResulArcValidator);
  }
  
  
@@@ -1062,4 -1083,4 +1082,4 @@@ void XGUI_Workshop::displayGroupResults
  {
    for (int i = 0; i < theDoc->size(theGroup); i++)
      myDisplayer->display(theDoc->object(theGroup, i), false);
 -}
 +}