4 * Copyright (C) 2005 CEA/DEN, EDF R&D
8 * File : SMESHGUI_CreateHypothesesOp.cxx
9 * Author : Sergey LITONIN
13 #include "SMESHGUI_CreateHypothesesOp.h"
15 #include "SMESHGUI_CreateHypothesesDlg.h"
16 #include "SMESHGUI_HypothesesUtils.h"
17 #include "SMESHGUI_Hypotheses.h"
20 #include "SALOME_ListIteratorOfListIO.hxx"
23 #include <qstringlist.h>
27 * \param theIsAlgo - If TRUE when operation is used for creation of gypotheses
29 * Constructor does nothing
31 SMESHGUI_CreateHypothesesOp::SMESHGUI_CreateHypothesesOp( const bool theIsAlgo )
32 : SMESHGUI_Operation(),
33 myIsAlgo( theIsAlgo ),
41 SMESHGUI_CreateHypothesesOp::~SMESHGUI_CreateHypothesesOp()
46 * \brief Start operation
48 * Virtual method redefined from the base class initializes and shows dialog
50 void SMESHGUI_CreateHypothesesOp::startOperation()
53 myDlg = new SMESHGUI_CreateHypothesesDlg( myIsAlgo );
55 SMESHGUI_Operation::startOperation();
57 QStringList aHypList, aPluginNames, aLabels, anIconIds;
59 aHypList = SMESH::GetAvailableHypotheses( myIsAlgo );
60 for ( int i = 0, n = aHypList.count(); i < n; ++i )
62 HypothesisData* aHypData = SMESH::GetHypothesisData( aHypList[i] );
65 aPluginNames.append( aHypData->PluginName );
66 aLabels.append( aHypData->Label );
67 anIconIds.append( aHypData->IconId );
71 aPluginNames.append( "" );
73 anIconIds.append( "" );
77 myDlg->init( aHypList, aPluginNames, aLabels, anIconIds );
83 * \return Pointer to the dialog used by this operation
85 * This pointer is used by base operation for its different purposes
87 SalomeApp_Dialog* SMESHGUI_CreateHypothesesOp::dlg() const
94 * \return TRUE if hypothesis or algorithm is created successfully, FALSE otherwise
96 * Virtual slot redefined from base class is called when "Apply" button clicked and
97 * creates hypothesis or algorithm
99 bool SMESHGUI_CreateHypothesesOp::onApply()
101 if ( isStudyLocked() )
104 QString aHypType = myDlg->hypName();
105 if ( aHypType == "" )
108 char* sHypType = ( char* )aHypType.latin1();
110 HypothesisData* aHypData = SMESH::GetHypothesisData( sHypType );
114 QString aClientLibName = aHypData->ClientLibName;
116 if ( aClientLibName == "" )
118 // Call hypothesis creation server method ( without GUI )
119 QString aHypName = aHypData->Label;
120 SMESH::CreateHypothesis( sHypType, aHypName, myIsAlgo );
124 // Get hypotheses creator client ( GUI )
125 SMESHGUI_GenericHypothesisCreator* aCreator =
126 SMESH::GetHypothesisCreator( sHypType );
128 // Create hypothesis/algorithm
129 aCreator->CreateHypothesis( myIsAlgo, dlg() );