Portation on new based dialog

This commit is contained in:
sln 2005-07-15 14:05:43 +00:00
parent d097f4c8ff
commit da5ab2d0d1
17 changed files with 408 additions and 300 deletions

View File

@ -44,7 +44,9 @@ EXPORT_HEADERS= SMESHGUI_Swig.hxx \
SMESHGUI_SpinBox.h \ SMESHGUI_SpinBox.h \
SMESHGUI_aParameter.h \ SMESHGUI_aParameter.h \
SMESHGUI_aParameterDlg.h \ SMESHGUI_aParameterDlg.h \
SMESHGUI_Selection.h SMESHGUI_Selection.h \
SMESHGUI_Operation.h \
SMESHGUI_Dialog.h
# .po files to transform in .qm # .po files to transform in .qm
PO_FILES = \ PO_FILES = \
@ -84,6 +86,7 @@ LIB_SRC = SMESHGUI.cxx \
SMESHGUI_EditHypothesesDlg.cxx \ SMESHGUI_EditHypothesesDlg.cxx \
SMESHGUI_EditHypothesesOp.cxx \ SMESHGUI_EditHypothesesOp.cxx \
SMESHGUI_CreateHypothesesDlg.cxx \ SMESHGUI_CreateHypothesesDlg.cxx \
SMESHGUI_CreateHypothesesOp.cxx \
SMESHGUI_XmlHandler.cxx \ SMESHGUI_XmlHandler.cxx \
SMESHGUI_Filter.cxx \ SMESHGUI_Filter.cxx \
SMESHGUI_FilterDlg.cxx \ SMESHGUI_FilterDlg.cxx \
@ -154,6 +157,7 @@ LIB_MOC = \
SMESHGUI_EditHypothesesDlg.h \ SMESHGUI_EditHypothesesDlg.h \
SMESHGUI_EditHypothesesOp.h \ SMESHGUI_EditHypothesesOp.h \
SMESHGUI_CreateHypothesesDlg.h \ SMESHGUI_CreateHypothesesDlg.h \
SMESHGUI_CreateHypothesesOp.h \
SMESHGUI_FilterDlg.h \ SMESHGUI_FilterDlg.h \
SMESHGUI_FilterLibraryDlg.h \ SMESHGUI_FilterLibraryDlg.h \
SMESHGUI_SingleEditDlg.h \ SMESHGUI_SingleEditDlg.h \

View File

@ -44,7 +44,7 @@
#include "SMESHGUI_MoveNodesOp.h" #include "SMESHGUI_MoveNodesOp.h"
#include "SMESHGUI_AddMeshElementOp.h" #include "SMESHGUI_AddMeshElementOp.h"
#include "SMESHGUI_EditHypothesesOp.h" #include "SMESHGUI_EditHypothesesOp.h"
#include "SMESHGUI_CreateHypothesesDlg.h" #include "SMESHGUI_CreateHypothesesOp.h"
#include "SMESHGUI_FilterDlg.h" #include "SMESHGUI_FilterDlg.h"
#include "SMESHGUI_FilterLibraryDlg.h" #include "SMESHGUI_FilterLibraryDlg.h"
#include "SMESHGUI_SingleEditDlg.h" #include "SMESHGUI_SingleEditDlg.h"
@ -751,7 +751,6 @@ void SMESHGUI::ResetState()
//============================================================================= //=============================================================================
void SMESHGUI::EmitSignalDeactivateDialog() void SMESHGUI::EmitSignalDeactivateDialog()
{ {
printf( "sln: EmitSignalDeactivateDialog EmitSignalDeactivateDialog EmitSignalDeactivateDialog\n" );
emit SignalDeactivateActiveDialog(); emit SignalDeactivateActiveDialog();
} }
@ -1956,20 +1955,11 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case 5000: // HYPOTHESIS case 5000: // HYPOTHESIS
{ startOperation( 5000 );
if(checkLock(aStudy)) break; break;
EmitSignalDeactivateDialog();
new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, false );
break;
}
case 5010: // ALGO case 5010: // ALGO
{ startOperation( 5010 );
if(checkLock(aStudy)) break; break;
EmitSignalDeactivateDialog();
new SMESHGUI_CreateHypothesesDlg ( this, "", FALSE, true);
break;
}
case 5105: // Library of selection filters case 5105: // Library of selection filters
{ {
static QValueList<int> aTypes; static QValueList<int> aTypes;
@ -3180,6 +3170,14 @@ SalomeApp_Operation* SMESHGUI::createOperation( const int id ) const
op = new SMESHGUI_ExtrusionOp(); op = new SMESHGUI_ExtrusionOp();
break; break;
case 5000:
op = new SMESHGUI_CreateHypothesesOp( false );
break;
case 5010:
op = new SMESHGUI_CreateHypothesesOp( true );
break;
/* case 900: /* case 900:
op = new SMESHGUI_MeshInfosOp(); op = new SMESHGUI_MeshInfosOp();
break;*/ break;*/

View File

@ -43,7 +43,7 @@
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg() SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg()
: SMESHGUI_Dialog( false, true ) : SMESHGUI_Dialog( 0, false, true )
{ {
setCaption(tr("SMESH_ADD_SUBMESH")); setCaption(tr("SMESH_ADD_SUBMESH"));

View File

@ -27,11 +27,6 @@
#include "SMESHGUI_CreateHypothesesDlg.h" #include "SMESHGUI_CreateHypothesesDlg.h"
#include "SMESHGUI_HypothesesUtils.h"
#include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI.h"
#include "SUIT_Desktop.h" #include "SUIT_Desktop.h"
#include "SUIT_ResourceMgr.h" #include "SUIT_ResourceMgr.h"
@ -47,248 +42,144 @@
#include <qlistview.h> #include <qlistview.h>
#include <qheader.h> #include <qheader.h>
using namespace std; /*!
* \brief Constructor
//================================================================================= * \param theIsAlgo - If TRUE when operator is used for creation of gypotheses
// function : SMESHGUI_CreateHypothesesDlg() *
// purpose : Constructs a SMESHGUI_CreateHypothesesDlg which is a child of 'parent', with the * Constructor does nothing
// name 'name' and widget flags set to 'f'. */
// The dialog will by default be modeless, unless you set 'modal' to SMESHGUI_CreateHypothesesDlg::SMESHGUI_CreateHypothesesDlg ( bool isAlgo )
// TRUE to construct a modal dialog. : SMESHGUI_Dialog( 0, false, true, Apply | Cancel ),
//================================================================================= myIsAlgo(isAlgo)
SMESHGUI_CreateHypothesesDlg::SMESHGUI_CreateHypothesesDlg (SMESHGUI* theModule,
const char* name,
bool modal,
bool isAlgo)
: QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
WStyle_Title | WStyle_SysMenu | WDestructiveClose),
myIsAlgo(isAlgo),
mySMESHGUI( theModule )
{ {
if (!name) setCaption( isAlgo ? tr( "SMESH_CREATE_ALGORITHMS" ) : tr( "SMESH_CREATE_HYPOTHESES" ) );
setName("SMESHGUI_CreateHypothesesDlg"); setSizeGripEnabled( TRUE );
setCaption(isAlgo ? tr("SMESH_CREATE_ALGORITHMS" ) : tr("SMESH_CREATE_HYPOTHESES" ));
setSizeGripEnabled(TRUE);
QGridLayout* SMESHGUI_CreateHypothesesDlgLayout = new QGridLayout(this); QGridLayout* SMESHGUI_CreateHypothesesDlgLayout = new QGridLayout( mainFrame() );
SMESHGUI_CreateHypothesesDlgLayout->setSpacing(6); SMESHGUI_CreateHypothesesDlgLayout->setSpacing( 6 );
SMESHGUI_CreateHypothesesDlgLayout->setMargin(11); SMESHGUI_CreateHypothesesDlgLayout->setMargin( 11 );
/***************************************************************/ /***************************************************************/
GroupAlgorithms = new QGroupBox(this, "GroupAlgorithms"); QGroupBox* GroupAlgorithms = new QGroupBox( mainFrame(), "GroupAlgorithms" );
GroupAlgorithms->setTitle(isAlgo ? tr("SMESH_AVAILABLE_ALGORITHMS") : tr("SMESH_AVAILABLE_HYPOTHESES")); GroupAlgorithms->setTitle( isAlgo ? tr( "SMESH_AVAILABLE_ALGORITHMS" ) : tr( "SMESH_AVAILABLE_HYPOTHESES" ) );
GroupAlgorithms->setColumnLayout(0, Qt::Vertical); GroupAlgorithms->setColumnLayout( 0, Qt::Vertical );
GroupAlgorithms->layout()->setSpacing(0); GroupAlgorithms->layout()->setSpacing( 0 );
GroupAlgorithms->layout()->setMargin(0); GroupAlgorithms->layout()->setMargin( 0 );
QGridLayout* hypLayout = new QGridLayout(GroupAlgorithms->layout()); QGridLayout* hypLayout = new QGridLayout( GroupAlgorithms->layout() );
hypLayout->setGeometry(QRect(12, 18, 139, 250)); hypLayout->setGeometry( QRect( 12, 18, 139, 250 ) );
hypLayout->setAlignment(Qt::AlignTop); hypLayout->setAlignment( Qt::AlignTop );
hypLayout->setSpacing(6); hypLayout->setSpacing( 6 );
hypLayout->setMargin(11); hypLayout->setMargin( 11 );
ListAlgoDefinition = new QListView(GroupAlgorithms, "ListAlgoDefinition"); myList = new QListView( GroupAlgorithms, "myList" );
ListAlgoDefinition->setMinimumSize(400, 200); myList->setMinimumSize( 400, 200 );
ListAlgoDefinition->addColumn(""); myList->addColumn( "" );
ListAlgoDefinition->header()->hide(); myList->header()->hide();
ListAlgoDefinition->setSelectionMode(QListView::Single); myList->setSelectionMode( QListView::Single );
ListAlgoDefinition->setResizeMode(QListView::AllColumns); myList->setResizeMode( QListView::AllColumns );
ListAlgoDefinition->setRootIsDecorated(true); myList->setRootIsDecorated( true );
hypLayout->addWidget(ListAlgoDefinition, 0, 0); hypLayout->addWidget( myList, 0, 0 );
SMESHGUI_CreateHypothesesDlgLayout->addWidget(GroupAlgorithms, 0, 0); SMESHGUI_CreateHypothesesDlgLayout->addWidget( GroupAlgorithms, 0, 0 );
/***************************************************************/ setButtonText( Apply, tr( "SMESH_BUT_CREATE" ) );
GroupButtons = new QGroupBox(this, "GroupButtons");
GroupButtons->setColumnLayout(0, Qt::Vertical);
GroupButtons->layout()->setSpacing(0);
GroupButtons->layout()->setMargin(0);
QGridLayout* GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
GroupButtonsLayout->setAlignment(Qt::AlignTop);
GroupButtonsLayout->setSpacing(6);
GroupButtonsLayout->setMargin(11);
buttonApply = new QPushButton(GroupButtons, "buttonApply"); // connect signals and slots
buttonApply->setText(tr("SMESH_BUT_CREATE" )); connect( myList, SIGNAL( selectionChanged() ), SLOT( onHypSelected() ) );
buttonApply->setAutoDefault(TRUE); connect( myList, SIGNAL( doubleClicked( QListViewItem* ) ), SLOT( onDoubleClicked( QListViewItem* ) ) );
buttonApply->setDefault(FALSE);
buttonApply->setEnabled(FALSE);
GroupButtonsLayout->addWidget(buttonApply, 0, 1);
QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); // update button state
GroupButtonsLayout->addItem(spacer_9, 0, 2); onHypSelected();
buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
buttonCancel->setAutoDefault(TRUE);
buttonCancel->setDefault(TRUE);
buttonCancel->setEnabled(TRUE);
GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
SMESHGUI_CreateHypothesesDlgLayout->addWidget(GroupButtons, 1, 0);
/***************************************************************/
Init();
} }
//================================================================================= /*!
// function : ~SMESHGUI_CreateHypothesesDlg() * \brief Destructor
// purpose : Destroys the object and frees any allocated resources */
//=================================================================================
SMESHGUI_CreateHypothesesDlg::~SMESHGUI_CreateHypothesesDlg() SMESHGUI_CreateHypothesesDlg::~SMESHGUI_CreateHypothesesDlg()
{ {
// no need to delete child widgets, Qt does it all for us
} }
//================================================================================= /*!
// function : Init() * \brief Get Name of hypotheses or algorithm
// purpose : * \return Name of hypotheses or algorithm
//================================================================================= */
void SMESHGUI_CreateHypothesesDlg::Init() QString SMESHGUI_CreateHypothesesDlg::hypName() const
{ {
mySMESHGUI->SetActiveDialogBox((QDialog*)this); QListViewItem* item = myList->selectedItem();
return item ? item->text( 1 ) : "";
InitAlgoDefinition();
/* signals and slots connections */
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
connect(buttonApply , SIGNAL(clicked()), this, SLOT(ClickOnApply()));
// connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
connect(ListAlgoDefinition, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
connect(ListAlgoDefinition, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(onDoubleClicked(QListViewItem*)));
int x, y;
mySMESHGUI->DefineDlgPosition(this, x, y);
this->move(x, y);
this->show();
} }
//================================================================================= /*!
// function : ClickOnCancel() * \brief Enable/Disable "Apply" button
// purpose : *
//================================================================================= * Private slot called when selection in list box changed enables/disables "Apply" button
void SMESHGUI_CreateHypothesesDlg::ClickOnCancel() */
void SMESHGUI_CreateHypothesesDlg::onHypSelected()
{ {
close(); QListViewItem* item = myList->selectedItem();
setButtonEnabled( item && item->depth() > 0, Apply );
} }
//================================================================================= /*!
// function : ClickOnApply() * \brief Emits dlgApply signal
// purpose : * \param i - clicked item
//================================================================================= *
void SMESHGUI_CreateHypothesesDlg::ClickOnApply() * Private slot called when item of list box is double clicked emits dlgApply signal
*/
void SMESHGUI_CreateHypothesesDlg::onDoubleClicked ( QListViewItem* i )
{ {
if (mySMESHGUI->isActiveStudyLocked()) if ( i && i->depth() > 0 )
return; emit dlgApply();
QListViewItem* item = ListAlgoDefinition->selectedItem();
if (!item)
return;
QString aHypType = item->text(1);
MESSAGE("Apply " << aHypType);
char* sHypType = (char*)aHypType.latin1();
HypothesisData* aHypData = SMESH::GetHypothesisData(sHypType);
if (!aHypData)
return;
QString aClientLibName = aHypData->ClientLibName;
MESSAGE("Client lib name = " << aClientLibName);
if (aClientLibName == "") {
// Call hypothesis creation server method (without GUI)
QString aHypName = aHypData->Label;
SMESH::CreateHypothesis(sHypType, aHypName, myIsAlgo);
} else {
// Get hypotheses creator client (GUI)
SMESHGUI_GenericHypothesisCreator* aCreator =
SMESH::GetHypothesisCreator(sHypType);
// Create hypothesis/algorithm
aCreator->CreateHypothesis(myIsAlgo, this);
}
// buttonApply->setEnabled(FALSE);
return;
} }
//================================================================================= /*!
// function : ActivateThisDialog() * \brief Initialize dialog
// purpose : * \param theHypList - List of hypotheses
//================================================================================= * \param theHypList - Plugin names
void SMESHGUI_CreateHypothesesDlg::ActivateThisDialog() * \param theHypList - Labels
* \param theHypList - Icons' identifiers
*
* Initializes dialog with parameters. This method is called by operation before showing
* dialog
*/
void SMESHGUI_CreateHypothesesDlg::init( const QStringList& theHypList,
const QStringList& thePluginNames,
const QStringList& theLabels,
const QStringList& theIconIds )
{ {
mySMESHGUI->EmitSignalDeactivateDialog(); myList->clear();
GroupButtons->setEnabled(true); for ( int i = 0; i < theHypList.count(); ++i )
return; {
}
//=================================================================================
// function : enterEvent()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::enterEvent (QEvent*)
{
ActivateThisDialog();
return;
}
//=================================================================================
// function : closeEvent()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::closeEvent (QCloseEvent* e)
{
mySMESHGUI->ResetState();
QDialog::closeEvent(e);
}
//=================================================================================
// function : onSelectionChanged()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::onSelectionChanged()
{
QListViewItem* item = ListAlgoDefinition->selectedItem();
buttonApply->setEnabled(item && item->depth() > 0);
}
//=================================================================================
// function : onDoubleClicked()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::onDoubleClicked (QListViewItem* i)
{
if (i && i->depth() > 0)
this->ClickOnApply();
}
//=================================================================================
// function : InitAlgoDefinition()
// purpose :
//=================================================================================
void SMESHGUI_CreateHypothesesDlg::InitAlgoDefinition()
{
ListAlgoDefinition->clear();
QStringList HypList = SMESH::GetAvailableHypotheses(myIsAlgo);
for (int i = 0; i < HypList.count(); ++i) {
HypothesisData* aHypData = SMESH::GetHypothesisData(HypList[i]);
QListViewItem* parentItem = 0; QListViewItem* parentItem = 0;
QListViewItem* childItem = ListAlgoDefinition->firstChild(); QListViewItem* childItem = myList->firstChild();
while (childItem) { while ( childItem )
if (childItem->text(0) == aHypData->PluginName) { {
parentItem = childItem; if ( childItem->text( 0 ) == thePluginNames[ i ] )
break; {
parentItem = childItem;
break;
} }
childItem = childItem->nextSibling(); childItem = childItem->nextSibling();
} }
if (!parentItem)
parentItem = new QListViewItem(ListAlgoDefinition, aHypData->PluginName); if ( !parentItem )
parentItem->setOpen(true); parentItem = new QListViewItem( myList, thePluginNames[ i ] );
QListViewItem* aItem = new QListViewItem(parentItem, aHypData->Label, HypList[i]); parentItem->setOpen( true );
QPixmap aPixMap (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr(aHypData->IconId))); QListViewItem* aItem =
if (!aPixMap.isNull()) new QListViewItem( parentItem, theLabels[ i ], theHypList[ i ] );
aItem->setPixmap(0, aPixMap); QPixmap aPixMap( resMgr()->loadPixmap( "SMESH", tr( theIconIds[ i ] ) ) );
if ( !aPixMap.isNull() )
aItem->setPixmap( 0, aPixMap );
} }
} }

View File

@ -28,67 +28,42 @@
#ifndef DIALOGBOX_CREATE_HYPOTHESES_H #ifndef DIALOGBOX_CREATE_HYPOTHESES_H
#define DIALOGBOX_CREATE_HYPOTHESES_H #define DIALOGBOX_CREATE_HYPOTHESES_H
// QT Includes #include "SMESHGUI_Dialog.h"
#include <qvariant.h>
#include <qdialog.h>
#include <qstringlist.h>
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(SMESH_Mesh)
#include <map>
#include <string>
class QButtonGroup;
class QGroupBox;
class QPushButton;
class QListView; class QListView;
class QListViewItem; class QListViewItem;
class SMESHGUI;
//================================================================================= /*!
// class : SMESHGUI_CreateHypothesesDlg * \brief Dialog for creation of hypotheses and algorithms
// purpose : */
//================================================================================= class SMESHGUI_CreateHypothesesDlg : public SMESHGUI_Dialog
class SMESHGUI_CreateHypothesesDlg : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_CreateHypothesesDlg (SMESHGUI*,
const char* name = 0,
bool modal = FALSE,
bool isAlgo = FALSE);
~SMESHGUI_CreateHypothesesDlg ();
private: SMESHGUI_CreateHypothesesDlg ( bool isAlgo );
virtual ~SMESHGUI_CreateHypothesesDlg();
void Init() ; void init( const QStringList& theHypList,
void closeEvent( QCloseEvent* e ) ; const QStringList& thePluginNames,
void enterEvent ( QEvent * ) ; const QStringList& theLabels,
const QStringList& theIconIds );
void InitAlgoDefinition(); QString hypName() const;
SMESHGUI* mySMESHGUI;
bool myIsAlgo;
QGroupBox* GroupButtons;
QPushButton* buttonCancel;
QPushButton* buttonApply;
QGroupBox* GroupAlgorithms;
QListView* ListAlgoDefinition;
private slots: private slots:
void ClickOnCancel(); void onHypSelected();
void ClickOnApply(); void onDoubleClicked( QListViewItem* );
void ActivateThisDialog() ;
void onSelectionChanged(); private:
void onDoubleClicked(QListViewItem*);
QListView* myList;
bool myIsAlgo;
}; };
#endif // DIALOGBOX_CREATE_HYPOTHESES_H #endif // DIALOGBOX_CREATE_HYPOTHESES_H

View File

@ -0,0 +1,151 @@
/**
* SALOME SMESHGUI
*
* Copyright (C) 2005 CEA/DEN, EDF R&D
*
*
*
* File : SMESHGUI_CreateHypothesesOp.cxx
* Author : Sergey LITONIN
* Module : SALOME
*/
#include "SMESHGUI_CreateHypothesesOp.h"
#include "SMESHGUI_CreateHypothesesDlg.h"
#include "SMESHGUI_HypothesesUtils.h"
#include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI.h"
#include "SALOME_ListIteratorOfListIO.hxx"
#include <qstring.h>
#include <qstringlist.h>
/*!
* \brief Constructor
* \param theIsAlgo - If TRUE when operation is used for creation of gypotheses
*
* Constructor does nothing
*/
SMESHGUI_CreateHypothesesOp::SMESHGUI_CreateHypothesesOp( const bool theIsAlgo )
: SMESHGUI_Operation(),
myIsAlgo( theIsAlgo ),
myDlg( 0 )
{
}
/*!
* \brief Destructor
*/
SMESHGUI_CreateHypothesesOp::~SMESHGUI_CreateHypothesesOp()
{
}
/*!
* \brief Start operation
*
* Virtual method redefined from the base class initializes and shows dialog
*/
void SMESHGUI_CreateHypothesesOp::startOperation()
{
if ( myDlg == 0 )
myDlg = new SMESHGUI_CreateHypothesesDlg( myIsAlgo );
SMESHGUI_Operation::startOperation();
QStringList aHypList, aPluginNames, aLabels, anIconIds;
aHypList = SMESH::GetAvailableHypotheses( myIsAlgo );
for ( int i = 0, n = aHypList.count(); i < n; ++i )
{
HypothesisData* aHypData = SMESH::GetHypothesisData( aHypList[i] );
if ( aHypData )
{
aPluginNames.append( aHypData->PluginName );
aLabels.append( aHypData->Label );
anIconIds.append( aHypData->IconId );
}
else
{
aPluginNames.append( "" );
aLabels.append( "" );
anIconIds.append( "" );
}
}
myDlg->init( aHypList, aPluginNames, aLabels, anIconIds );
myDlg->show();
}
/*!
* \brief Gets dialog
* \return Pointer to the dialog used by this operation
*
* This pointer is used by base operation for its different purposes
*/
SalomeApp_Dialog* SMESHGUI_CreateHypothesesOp::dlg() const
{
return myDlg;
}
/*!
* \brief onApply
* \return TRUE if hypothesis or algorithm is created successfully, FALSE otherwise
*
* Virtual slot redefined from base class is called when "Apply" button clicked and
* creates hypothesis or algorithm
*/
bool SMESHGUI_CreateHypothesesOp::onApply()
{
if ( isStudyLocked() )
return false;
QString aHypType = myDlg->hypName();
if ( aHypType == "" )
return false;
char* sHypType = ( char* )aHypType.latin1();
HypothesisData* aHypData = SMESH::GetHypothesisData( sHypType );
if ( !aHypData )
return false;
QString aClientLibName = aHypData->ClientLibName;
if ( aClientLibName == "" )
{
// Call hypothesis creation server method ( without GUI )
QString aHypName = aHypData->Label;
SMESH::CreateHypothesis( sHypType, aHypName, myIsAlgo );
}
else
{
// Get hypotheses creator client ( GUI )
SMESHGUI_GenericHypothesisCreator* aCreator =
SMESH::GetHypothesisCreator( sHypType );
// Create hypothesis/algorithm
aCreator->CreateHypothesis( myIsAlgo, dlg() );
}
return true;
}

View File

@ -0,0 +1,55 @@
/**
* SALOME SMESHGUI
*
* Copyright (C) 2005 CEA/DEN, EDF R&D
*
*
*
* File : SMESHGUI_CreateHypothesesOp.h
* Author : Sergey LITONIN
* Module : SALOME
*/
#ifndef SMESHGUI_CreateHypothesesOp_H
#define SMESHGUI_CreateHypothesesOp_H
#include "SMESHGUI_Operation.h"
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(SMESH_Mesh)
class SMESHGUI_CreateHypothesesDlg;
/*!
* \brief Operation for creation of hypotheses and algorithms
*/
class SMESHGUI_CreateHypothesesOp : public SMESHGUI_Operation
{
Q_OBJECT
public:
SMESHGUI_CreateHypothesesOp( const bool theIsAlgo );
virtual ~SMESHGUI_CreateHypothesesOp();
virtual SalomeApp_Dialog* dlg() const;
protected slots:
virtual bool onApply();
protected:
virtual void startOperation();
private:
SMESHGUI_CreateHypothesesDlg* myDlg;
bool myIsAlgo;
};
#endif

View File

@ -35,8 +35,9 @@
// function : SMESHGUI_Dialog // function : SMESHGUI_Dialog
// purpose : Constructor // purpose : Constructor
//================================================================================= //=================================================================================
SMESHGUI_Dialog::SMESHGUI_Dialog( const bool modal, const bool allowResize, const int flags ) SMESHGUI_Dialog::SMESHGUI_Dialog( QWidget* parent, const bool modal,
: SalomeApp_Dialog( desktop(), "", modal, allowResize, flags ) const bool allowResize, const int flags )
: SalomeApp_Dialog( parent == 0 ? desktop() : parent, "", modal, allowResize, flags )
{ {
int pr = prefix( "SMESH" ); int pr = prefix( "SMESH" );
typeName( pr + MESH ) = tr( "DLG_MESH" ); typeName( pr + MESH ) = tr( "DLG_MESH" );
@ -107,3 +108,4 @@ int SMESHGUI_Dialog::prefix( const QString& name )
else else
return 0; return 0;
} }

View File

@ -43,13 +43,13 @@ class SMESHGUI_Dialog : public SalomeApp_Dialog
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_Dialog( const bool = false, const bool = false, const int = OK | Cancel | Apply ); SMESHGUI_Dialog( QWidget* = 0, const bool = false, const bool = false, const int = OK | Cancel | Apply );
virtual ~SMESHGUI_Dialog(); virtual ~SMESHGUI_Dialog();
virtual void show(); virtual void show();
//! set all content to enable (parameter is true) or disable state //! set all content to enable (parameter is true) or disable state
void setContentActive( const bool ) const; virtual void setContentActive( const bool ) const;
//! Return hard-coded prefix using to differ overlapping types //! Return hard-coded prefix using to differ overlapping types
static int prefix( const QString& ); static int prefix( const QString& );

View File

@ -44,7 +44,7 @@
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg() SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg()
: SMESHGUI_Dialog( false, true ) : SMESHGUI_Dialog( 0, false, true )
{ {
setName("SMESHGUI_EditHypothesesDlg"); setName("SMESHGUI_EditHypothesesDlg");
setCaption(tr("SMESH_EDIT_HYPOTHESES")); setCaption(tr("SMESH_EDIT_HYPOTHESES"));

View File

@ -47,7 +47,7 @@
// purpose : constructor // purpose : constructor
//================================================================================= //=================================================================================
SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg() SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg()
: SMESHGUI_Dialog( false, true, OK | Apply | Close ) : SMESHGUI_Dialog( 0, false, true, OK | Apply | Close )
{ {
QPixmap image0( resMgr()->loadPixmap( "SMESH", tr( "ICON_DLG_EDGE") ) ), QPixmap image0( resMgr()->loadPixmap( "SMESH", tr( "ICON_DLG_EDGE") ) ),
image1( resMgr()->loadPixmap( "SMESH", tr( "ICON_DLG_TRIANGLE") ) ); image1( resMgr()->loadPixmap( "SMESH", tr( "ICON_DLG_TRIANGLE") ) );

View File

@ -45,7 +45,7 @@
// Purpose : Constructor // Purpose : Constructor
//======================================================================= //=======================================================================
SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( const int aMode ) SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( const int aMode )
: SMESHGUI_Dialog( false, true ) : SMESHGUI_Dialog( 0, false, true )
{ {
QString caption; QString caption;
if( aMode == 0 ) if( aMode == 0 )

View File

@ -44,7 +44,7 @@
// TRUE to construct a modal dialog. // TRUE to construct a modal dialog.
//================================================================================= //=================================================================================
SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg() SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg()
: SMESHGUI_Dialog( false, true ) : SMESHGUI_Dialog( 0, false, true )
{ {
setCaption(tr("SMESH_INIT_MESH")); setCaption(tr("SMESH_INIT_MESH"));

View File

@ -42,7 +42,7 @@
// purpose : // purpose :
//================================================================================= //=================================================================================
SMESHGUI_NodesDlg::SMESHGUI_NodesDlg() SMESHGUI_NodesDlg::SMESHGUI_NodesDlg()
: SMESHGUI_Dialog( false, false, OK | Apply | Close ) : SMESHGUI_Dialog( 0, false, false, OK | Apply | Close )
{ {
QPixmap image0( resMgr()->loadPixmap("SMESH", tr("ICON_DLG_NODE"))); QPixmap image0( resMgr()->loadPixmap("SMESH", tr("ICON_DLG_NODE")));
setName("SMESHGUI_NodesDlg"); setName("SMESHGUI_NodesDlg");

View File

@ -17,6 +17,8 @@
#include <SUIT_MessageBox.h> #include <SUIT_MessageBox.h>
#include <SUIT_Desktop.h> #include <SUIT_Desktop.h>
#include <qstringlist.h>
/* /*
Class : SMESHGUI_Operation Class : SMESHGUI_Operation
Description : Base class for all SMESH operations Description : Base class for all SMESH operations
@ -94,6 +96,8 @@ bool SMESHGUI_Operation::isReadyToStart() const
tr( "NO_MODULE" ), tr( "SMESH_BUT_OK" ) ); tr( "NO_MODULE" ), tr( "SMESH_BUT_OK" ) );
return false; return false;
} }
else if ( isStudyLocked() )
return false;
return true; return true;
} }
@ -184,11 +188,39 @@ bool SMESHGUI_Operation::isStudyLocked( const bool theMess ) const
return false; return false;
} }
//======================================================================= /*!
// name : isValid * \brief Verifies whether given operator is valid for this one
// Purpose : * \param theOtherOp - other operation
//======================================================================= * \return Returns TRUE if the given operator is valid for this one, FALSE otherwise
bool SMESHGUI_Operation::isValid( SUIT_Operation* op ) const *
* Virtual method redefined from base class verifies whether given operator is valid for
* this one (i.e. can be started "above" this operator). In current implementation method
* retuns false if theOtherOp operation is not intended for deleting objects or mesh
* elements.
*/
bool SMESHGUI_Operation::isValid( SUIT_Operation* theOtherOp ) const
{ {
return( op && op->inherits( "SMESHGUI_Operation" ) ); static QStringList anOps;
if ( anOps.count() == 0 )
{
anOps.append( "SMESHGUI_DeleteOp" );
// to do add other operations here
}
return theOtherOp && theOtherOp->inherits( "SMESHGUI_Operation" ) &&
( !anOps.contains( theOtherOp->className() ) || anOps.contains( className() ) );
return true;
} }

View File

@ -42,7 +42,7 @@
// purpose : // purpose :
//================================================================================= //=================================================================================
SMESHGUI_RemoveDlg::SMESHGUI_RemoveDlg( const bool elem ) SMESHGUI_RemoveDlg::SMESHGUI_RemoveDlg( const bool elem )
: SMESHGUI_Dialog( false, true, OK | Apply | Close ) : SMESHGUI_Dialog( 0, false, true, OK | Apply | Close )
{ {
QString entity = elem ? "ELEMENT" : "NODE"; QString entity = elem ? "ELEMENT" : "NODE";
QString name = QString( "ICON_DLG_REM_%1" ).arg( entity ); QString name = QString( "ICON_DLG_REM_%1" ).arg( entity );

View File

@ -42,7 +42,7 @@
*/ */
//================================================================================= //=================================================================================
SMESHGUI_StandardMeshInfosDlg::SMESHGUI_StandardMeshInfosDlg() SMESHGUI_StandardMeshInfosDlg::SMESHGUI_StandardMeshInfosDlg()
: SMESHGUI_Dialog( false, false, OK ) : SMESHGUI_Dialog( 0, false, false, OK )
{ {
setCaption(tr("SMESH_STANDARD_MESHINFO_TITLE" )); setCaption(tr("SMESH_STANDARD_MESHINFO_TITLE" ));