1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // SMESH SMESHGUI : GUI for SMESH component
23 // File : SMESHGUI_Helper.cxx
24 // Author : Oleg UVAROV
27 #include "SMESHGUI_Helper.h"
30 // SALOME GUI includes
31 #include <SUIT_Desktop.h>
32 #include <SUIT_MessageBox.h>
33 #include <SUIT_Session.h>
35 #include <SalomeApp_Application.h>
36 #include <SalomeApp_DoubleSpinBox.h>
37 #include <SalomeApp_IntSpinBox.h>
38 #include <SalomeApp_Notebook.h>
40 //=================================================================================
41 // name : SMESHGUI_Helper::SMESHGUI_Helper
43 //=================================================================================
44 SMESHGUI_Helper::SMESHGUI_Helper( SMESHGUI* theModule ) :
45 mySMESHGUI( theModule )
47 myNotebook = new SalomeApp_Notebook( mySMESHGUI->activeStudy() );
50 //=======================================================================
51 // name : SMESHGUI_Helper::~SMESHGUI_Helper
53 //=======================================================================
54 SMESHGUI_Helper::~SMESHGUI_Helper()
63 //================================================================
64 // Function : checkParameters
66 //================================================================
67 bool SMESHGUI_Helper::checkParameters( bool theMess, int theCount, QAbstractSpinBox* theFirstSpinBox, ... )
70 va_start( aSpins, theFirstSpinBox );
73 QList<QAbstractSpinBox*> aSpinBoxList;
74 QAbstractSpinBox* aSpinBox = theFirstSpinBox;
75 while( aSpinBox && aCounter < theCount )
77 aSpinBoxList.append( aSpinBox );
78 aSpinBox = va_arg( aSpins, QAbstractSpinBox* );
81 return checkParameters( theMess, aSpinBoxList );
84 //================================================================
85 // Function : checkParameters
87 //================================================================
88 bool SMESHGUI_Helper::checkParameters( bool theMess, const QList<QAbstractSpinBox*>& theSpinBoxList )
90 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
95 QStringList absentParams;
98 QListIterator<QAbstractSpinBox*> anIter( theSpinBoxList );
99 while( anIter.hasNext() )
101 QAbstractSpinBox* aSpinBox = anIter.next();
102 if( SalomeApp_DoubleSpinBox* aDoubleSpinBox = dynamic_cast<SalomeApp_DoubleSpinBox*>( aSpinBox ) )
103 ok = aDoubleSpinBox->isValid( msg, absentParams, theMess ) && ok;
104 else if( SalomeApp_IntSpinBox* anIntSpinBox = dynamic_cast<SalomeApp_IntSpinBox*>( aSpinBox ) )
105 ok = anIntSpinBox->isValid( msg, absentParams, theMess ) && ok;
110 if( !absentParams.isEmpty() )
111 app->defineAbsentParameters( absentParams );
114 QString str( QObject::tr( "SMESH_INCORRECT_INPUT" ) );
117 SUIT_MessageBox::critical( mySMESHGUI->desktop(), QObject::tr( "SMESH_ERROR" ), str );
123 //================================================================
124 // Function : getNotebook
126 //================================================================
127 SalomeApp_Notebook* SMESHGUI_Helper::getNotebook() const