]> SALOME platform Git repositories - plugins/blsurfplugin.git/commitdiff
Salome HOME
Get geom selection tool if it already exists.
authorgdd <gdd>
Wed, 18 Feb 2009 14:09:28 +0000 (14:09 +0000)
committergdd <gdd>
Wed, 18 Feb 2009 14:09:28 +0000 (14:09 +0000)
src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx
src/GUI/BLSURFPluginGUI_HypothesisCreator.h

index 9f41e7df52a51a6d13a03f75f4d8e50feddc57c7..747c61e4c54dfab51dd833d0a421793a747bbb5b 100644 (file)
@@ -208,8 +208,7 @@ BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QStr
   cout << "BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator" << endl; 
   this->mySMPMap.clear();
 
-  _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
-  GeomToolSelected = new GeomSelectionTools(aStudy);
+  this->getGeomSelectionTool();
 
   /* Initialize the Python interpreter */
   assert(Py_IsInitialized());
@@ -230,6 +229,17 @@ BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
 {
 }
 
+GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool()
+{
+  BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
+  if (that->GeomToolSelected == NULL) {
+    cout << "GeomToolSelected is created" << endl;
+    _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+    that->GeomToolSelected = new GeomSelectionTools(aStudy);
+  }
+  return that->GeomToolSelected;
+}
+
 namespace {
   inline bool isDouble( const QString& theText, const bool emptyOK=false ) {
     QString str = theText.trimmed();
@@ -586,7 +596,7 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
   while (i.hasNext()) {
     i.next();
     const QString entry = i.key();
-    string shapeName = GeomToolSelected->getNameFromEntry(entry.toStdString());
+    string shapeName = that->getGeomSelectionTool()->getNameFromEntry(entry.toStdString());
     const QString sizeMap = i.value();
     int row = mySizeMapTable->rowCount();
     mySizeMapTable->setRowCount( row+1 );
@@ -671,7 +681,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
        int pos = fullSizeMap.find("return")+7;
        QString sizeMap = QString::fromStdString(fullSizeMap.substr(pos, fullSizeMap.size()-pos));
        that->mySMPMap[entry_sm[0]] = sizeMap;
-       that->mySMPShapeTypeMap[entry_sm[0]] = GeomToolSelected->entryToShape(entry_sm[0].toStdString()).ShapeType();
+       that->mySMPShapeTypeMap[entry_sm[0]] = that->getGeomSelectionTool()->entryToShape(entry_sm[0].toStdString()).ShapeType();
        MESSAGE("mySMPMap[" << entry_sm[0].toStdString() << "] = " << sizeMap.toStdString());
        MESSAGE("mySMPShapeTypeMap[" << entry_sm[0].toStdString() << "] = " << that->mySMPShapeTypeMap[entry_sm[0]]);
       }
@@ -1058,7 +1068,7 @@ void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeS
 
   TopoDS_Shape S;
   string entry, shapeName;
-  LightApp_SelectionMgr* aSel = GeomToolSelected->selectionMgr();
+  LightApp_SelectionMgr* aSel = that->getGeomSelectionTool()->selectionMgr();
   SALOME_ListIO ListSelectedObjects;
   aSel->selectedObjects(ListSelectedObjects, NULL, false );
   if (!ListSelectedObjects.IsEmpty())
@@ -1067,9 +1077,9 @@ void BLSURFPluginGUI_HypothesisCreator::insertElementType(TopAbs_ShapeEnum typeS
     for (; Object_It.More(); Object_It.Next()) 
     {
       Handle(SALOME_InteractiveObject) anObject = Object_It.Value();
-      entry     = GeomToolSelected->getEntryOfObject(anObject);
+      entry     = that->getGeomSelectionTool()->getEntryOfObject(anObject);
       shapeName = anObject->getName();
-      S         = GeomToolSelected->entryToShape(entry);
+      S         = that->getGeomSelectionTool()->entryToShape(entry);
       if ((! S.IsNull()) && (S.ShapeType() == typeShapeAsked)) 
       { 
         mySizeMapTable->setFocus();
index 94f54eed50d943d1322d4a4d18aefa9a39cf762c..17945748fe35d6c6ad17db11d1a91f9717f6fabf 100644 (file)
@@ -81,39 +81,40 @@ public:
   BLSURFPluginGUI_HypothesisCreator( const QString& );
   virtual ~BLSURFPluginGUI_HypothesisCreator();
 
-  virtual bool     checkParams() const;
-  virtual QString  helpPage() const;
-  void             insertElementType( TopAbs_ShapeEnum );
+  virtual bool        checkParams() const;
+  virtual QString     helpPage() const;
+  void                insertElementType( TopAbs_ShapeEnum );
   static LightApp_SelectionMgr* selectionMgr();
 
 protected:
-  virtual QFrame*  buildFrame    ();
-  virtual void     retrieveParams() const;
-  virtual QString  storeParams   () const;
+  virtual QFrame*     buildFrame    ();
+  virtual void        retrieveParams() const;
+  virtual QString     storeParams   () const;
   
-  virtual QString  caption() const;
-  virtual QPixmap  icon() const;
-  virtual QString  type() const;
+  virtual QString     caption() const;
+  virtual QPixmap     icon() const;
+  virtual QString     type() const;
 
 protected slots:
-  void             onPhysicalMeshChanged();
-  void             onGeometricMeshChanged();
-  void             onAddOption();
-  void             onDeleteOption();
-  void             onOptionChosenInPopup( QAction* );
-  void             onAddMapOnSurface();
-  void             onAddMapOnEdge();
-  void             onAddMapOnPoint();
-  void             onRemoveMap();
-  void             onSetSizeMap(int,int);
+  void                onPhysicalMeshChanged();
+  void                onGeometricMeshChanged();
+  void                onAddOption();
+  void                onDeleteOption();
+  void                onOptionChosenInPopup( QAction* );
+  void                onAddMapOnSurface();
+  void                onAddMapOnEdge();
+  void                onAddMapOnPoint();
+  void                onRemoveMap();
+  void                onSetSizeMap(int,int);
 
 private:
-  bool             readParamsFromHypo( BlsurfHypothesisData& ) const;
-  QString          readParamsFromWidgets( BlsurfHypothesisData& ) const;
-  bool             storeParamsToHypo( const BlsurfHypothesisData& ) const;
-  bool             sizeMapsValidation();
-  bool             sizeMapValidationFromRow(int);
-  bool             sizeMapValidationFromEntry(QString);
+  bool                readParamsFromHypo( BlsurfHypothesisData& ) const;
+  QString             readParamsFromWidgets( BlsurfHypothesisData& ) const;
+  bool                storeParamsToHypo( const BlsurfHypothesisData& ) const;
+  bool                sizeMapsValidation();
+  bool                sizeMapValidationFromRow(int);
+  bool                sizeMapValidationFromEntry(QString);
+  GeomSelectionTools* getGeomSelectionTool();
 
 private:
   QWidget*            myStdGroup;
@@ -144,9 +145,9 @@ private:
   QPushButton         *removeButton;
 
   // map =  entry , size map
-  QMap<QString, QString> mySMPMap;
+  QMap<QString, QString>          mySMPMap;
   QMap<QString, TopAbs_ShapeEnum> mySMPShapeTypeMap;
-  GeomSelectionTools* GeomToolSelected;
+  GeomSelectionTools*             GeomToolSelected;
 
   BLSURFPlugin::string_array_var myOptions;