From ebd6d5ad1de9e679eb2b57c2935499dda3aa0059 Mon Sep 17 00:00:00 2001 From: gdd Date: Wed, 18 Feb 2009 14:09:28 +0000 Subject: [PATCH] Get geom selection tool if it already exists. --- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 24 +++++--- src/GUI/BLSURFPluginGUI_HypothesisCreator.h | 55 ++++++++++--------- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index 9f41e7d..747c61e 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -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(); diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h index 94f54ee..1794574 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -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 mySMPMap; + QMap mySMPMap; QMap mySMPShapeTypeMap; - GeomSelectionTools* GeomToolSelected; + GeomSelectionTools* GeomToolSelected; BLSURFPlugin::string_array_var myOptions; -- 2.39.2