SMESHGUI_SpinBox.cxx \
SMESHGUI_NodesDlg.cxx \
SMESHGUI_NodesOp.cxx \
+ SMESHGUI_AddMeshElementDlg.cxx \
+ SMESHGUI_AddMeshElementOp.cxx \
SMESHGUI_InitMeshDlg.cxx \
SMESHGUI_InitMeshOp.cxx \
SMESHGUI_AddSubMeshDlg.cxx \
SMESHGUI_aParameterDlg.cxx \
SMESHGUI_Swig.cxx \
SMESHGUI_MoveNodesDlg.cxx \
- SMESHGUI_AddMeshElementDlg.cxx \
SMESHGUI_EditHypothesesDlg.cxx \
SMESHGUI_EditHypothesesOp.cxx \
SMESHGUI_CreateHypothesesDlg.cxx \
SMESHGUI_CreatePatternDlg.h \
SMESHGUI_NodesDlg.h \
SMESHGUI_NodesOp.h \
+ SMESHGUI_AddMeshElementDlg.h \
+ SMESHGUI_AddMeshElementOp.h \
SMESHGUI_SpinBox.h \
SMESHGUI_InitMeshDlg.h \
SMESHGUI_InitMeshOp.h \
SMESHGUI_Preferences_SelectionDlg.h \
SMESHGUI_aParameterDlg.h \
SMESHGUI_MoveNodesDlg.h \
- SMESHGUI_AddMeshElementDlg.h \
SMESHGUI_EditHypothesesDlg.h \
SMESHGUI_EditHypothesesOp.h \
SMESHGUI_CreateHypothesesDlg.h \
#include "SMESHGUI.h"
#include "SMESHGUI_InitMeshOp.h"
#include "SMESHGUI_AddSubMeshOp.h"
-#include "SMESHGUI_NodesDlg.h"
+#include "SMESHGUI_NodesOp.h"
#include "SMESHGUI_TransparencyDlg.h"
#include "SMESHGUI_ClippingDlg.h"
#include "SMESHGUI_GroupDlg.h"
#include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI_HypothesesUtils.h"
#include "SMESHGUI_MoveNodesDlg.h"
-#include "SMESHGUI_AddMeshElementDlg.h"
-#include "SMESHGUI_EditHypothesesDlg.h"
+#include "SMESHGUI_AddMeshElementOp.h"
+#include "SMESHGUI_EditHypothesesOp.h"
#include "SMESHGUI_CreateHypothesesDlg.h"
#include "SMESHGUI_FilterDlg.h"
#include "SMESHGUI_FilterLibraryDlg.h"
#include "SMESHGUI_SingleEditDlg.h"
#include "SMESHGUI_MultiEditDlg.h"
-#include "SMESHGUI_GroupOpDlg.h"
+#include "SMESHGUI_GroupOp.h"
#include "SMESHGUI_DeleteGroupDlg.h"
#include "SMESHGUI_SmoothingDlg.h"
#include "SMESHGUI_RenumberingDlg.h"
case 400: // NODES
{
if(checkLock(aStudy)) break;
-
+ startOperation( 400 );
+/*
if ( vtkwnd ) {
EmitSignalDeactivateDialog();
tr("SMESH_WRN_WARNING"),
tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
- }
+ } */
break;
}
case 704: // EDIT Hypothesis
{
if(checkLock(aStudy)) break;
- EmitSignalDeactivateDialog();
- new SMESHGUI_EditHypothesesDlg( this );
+ startOperation( 704 );
break;
}
case 705: // EDIT Global Hypothesis
{
if(checkLock(aStudy)) break;
- EmitSignalDeactivateDialog();
- new SMESHGUI_EditHypothesesDlg( this );
+ startOperation( 704 );
break;
}
case 706: // EDIT Local Hypothesis
{
if(checkLock(aStudy)) break;
- EmitSignalDeactivateDialog();
- new SMESHGUI_EditHypothesesDlg( this );
+ startOperation( 704 );
break;
}
*/
EmitSignalDeactivateDialog();
if ( theCommandID == 407 )
- new SMESHGUI_TrianglesInversionDlg(this);
+ startOperation( 407 );
else
- new SMESHGUI_UnionOfTwoTrianglesDlg(this);
+ startOperation( 408 );
break;
}
case 409: // Change orientation
case 811: // Intersect groups
case 812: // Cut groups
{
- if ( !vtkwnd )
- {
- SUIT_MessageBox::warn1( desktop(), tr( "SMESH_WRN_WARNING" ),
- tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) );
- break;
- }
-
- if ( checkLock( aStudy ) )
- break;
-
- EmitSignalDeactivateDialog();
-
- int aMode;
- if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION;
- else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT;
- else aMode = SMESHGUI_GroupOpDlg::CUT;
-
- ( new SMESHGUI_GroupOpDlg( this, aMode ) )->show();
+ if( !checkLock( aStudy ) )
+ startOperation( theCommandID );
break;
}
case 4032: // HEXA
{
if(checkLock(aStudy)) break;
- if ( vtkwnd ) {
+ startOperation( theCommandID );
+/* if ( vtkwnd ) {
EmitSignalDeactivateDialog();
SMDSAbs_ElementType type = SMDSAbs_Edge;
int nbNodes = 2;
SUIT_MessageBox::warn1(desktop(),
tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"),
tr("SMESH_BUT_OK"));
- }
+ }*/
break;
}
case 4033: // POLYHEDRON
{
SalomeApp_Operation* op = 0;
switch( id )
- {
+ {
+ case 400:
+ op = new SMESHGUI_NodesOp();
+ break;
+
+ case 401:
+ op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Edge, 2 );
+ break;
+
+ case 4021:
+ op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 3 );
+ break;
+
+ case 4022:
+ op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 4 );
+ break;
+
+ case 4023:
+ op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Face, 5 ); // 5 - identificator for POLYGON
+ break;
+
+ case 4031:
+ op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 4 );
+ break;
+
+ case 4032:
+ op = new SMESHGUI_AddMeshElementOp( SMDSAbs_Volume, 8 );
+ break;
+
case 702:
op = new SMESHGUI_AddSubMeshOp();
break;
case 703:
op = new SMESHGUI_InitMeshOp();
break;
+
+ case 704:
+ op = new SMESHGUI_EditHypothesesOp();
+ break;
+
+ case 810:
+ op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::UNION );
+ break;
+
+ case 811:
+ op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::INTERSECT );
+ break;
+
+ case 812:
+ op = new SMESHGUI_GroupOp( SMESHGUI_GroupOp::CUT );
+ break;
default:
op = SalomeApp_Module::createOperation( id );
// $Header$
#include "SMESHGUI_AddMeshElementDlg.h"
+#include <SMESHGUI_Operation.h>
-#include "SMESHGUI.h"
-#include "SMESHGUI_Utils.h"
-#include "SMESHGUI_VTKUtils.h"
-#include "SMESHGUI_MeshUtils.h"
-#include "SMESHGUI_IdValidator.h"
-#include "SMESH_ActorUtils.h"
+#include <SUIT_ResourceMgr.h>
-#include "SMDS_Mesh.hxx"
-#include "SMESH_Actor.h"
+#include <SMDSAbs_ElementType.hxx>
-#include "SUIT_Session.h"
-
-#include "SVTK_Selection.h"
-#include "SVTK_Selector.h"
-#include "SALOME_ListIO.hxx"
-#include "SALOME_ListIteratorOfListIO.hxx"
-
-#include "SalomeApp_Study.h"
-#include "SalomeApp_Application.h"
-
-#include "SVTK_ViewModel.h"
-#include "SVTK_ViewWindow.h"
-
-#include "utilities.h"
-
-// OCCT Includes
-#include <TColStd_MapOfInteger.hxx>
-#include <TColStd_IndexedMapOfInteger.hxx>
-
-// VTK Includes
-#include <vtkCell.h>
-#include <vtkIdList.h>
-#include <vtkIntArray.h>
-#include <vtkCellArray.h>
-#include <vtkUnsignedCharArray.h>
-#include <vtkUnstructuredGrid.h>
-#include <vtkDataSetMapper.h>
-
-// QT Includes
-#include <qbuttongroup.h>
+#include <qlayout.h>
#include <qgroupbox.h>
-#include <qlabel.h>
-#include <qlineedit.h>
-#include <qpushbutton.h>
+#include <qbuttongroup.h>
#include <qradiobutton.h>
-#include <qlayout.h>
-#include <qvariant.h>
-#include <qtooltip.h>
-#include <qwhatsthis.h>
-#include <qimage.h>
-#include <qpixmap.h>
#include <qcheckbox.h>
-#include <qregexp.h>
-
-// STL includes
-#include <list>
-
-using namespace std;
-
-namespace SMESH {
-
- class TElementSimulation {
- SalomeApp_Application* myApplication;
- SUIT_ViewWindow* myViewWindow;
- SVTK_ViewWindow* myVTKViewWindow;
-
- SALOME_Actor* myPreviewActor;
- vtkDataSetMapper* myMapper;
- vtkUnstructuredGrid* myGrid;
-
- public:
- TElementSimulation (SalomeApp_Application* theApplication)
- {
- myApplication = theApplication;
- SUIT_ViewManager* mgr = theApplication->activeViewManager();
- if (!mgr) return;
- myViewWindow = mgr->getActiveView();
- myVTKViewWindow = GetVtkViewWindow(myViewWindow);
-
- myGrid = vtkUnstructuredGrid::New();
-
- // Create and display actor
- myMapper = vtkDataSetMapper::New();
- myMapper->SetInput(myGrid);
-
- myPreviewActor = SALOME_Actor::New();
- myPreviewActor->PickableOff();
- myPreviewActor->VisibilityOff();
- myPreviewActor->SetMapper(myMapper);
-
- float anRGB[3];
- vtkProperty* aProp = vtkProperty::New();
- GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
- aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
- myPreviewActor->SetProperty( aProp );
- aProp->Delete();
-
- vtkProperty* aBackProp = vtkProperty::New();
- GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
- aBackProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
- myPreviewActor->SetBackfaceProperty( aBackProp );
- aBackProp->Delete();
-
- myVTKViewWindow->AddActor(myPreviewActor);
- }
-
- typedef std::vector<vtkIdType> TVTKIds;
- void SetPosition (SMESH_Actor* theActor,
- vtkIdType theType,
- const TVTKIds& theIds)
- {
- vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
- myGrid->SetPoints(aGrid->GetPoints());
-
- const int* aConn = NULL;
- switch (theType) {
- case VTK_TETRA:
- {
- static int anIds[] = {0,2,1,3};
- aConn = anIds;
- break;
- }
- case VTK_PYRAMID:
- {
- static int anIds[] = {0,3,2,1,4};
- aConn = anIds;
- break;
- }
- case VTK_HEXAHEDRON:
- {
- static int anIds[] = {0,3,2,1,4,7,6,5};
- aConn = anIds;
- break;
- }
- }
-
- myGrid->Reset();
- vtkIdList *anIds = vtkIdList::New();
-
- if(aConn)
- for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
- anIds->InsertId(i,theIds[aConn[i]]);
- else
- for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
- anIds->InsertId(i,theIds[i]);
-
- myGrid->InsertNextCell(theType,anIds);
- anIds->Delete();
-
- myGrid->Modified();
-
- SetVisibility(true);
- }
-
-
- void SetVisibility (bool theVisibility)
- {
- myPreviewActor->SetVisibility(theVisibility);
- RepaintCurrentView();
- }
-
-
- ~TElementSimulation()
- {
- if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) {
- myVTKViewWindow->RemoveActor(myPreviewActor);
- }
- myPreviewActor->Delete();
-
- myMapper->RemoveAllInputs();
- myMapper->Delete();
-
- myGrid->Delete();
- }
- };
-}
//=================================================================================
// function : SMESHGUI_AddMeshElementDlg()
// purpose : constructor
//=================================================================================
-SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( SMESHGUI* theModule,
- const char* name,
- SMDSAbs_ElementType ElementType, int nbNodes,
- bool modal, WFlags fl)
- : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
- WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
- mySMESHGUI( theModule ),
- mySelectionMgr( SMESH::GetSelectionMgr( theModule ) ),
- myViewWindow( SMESH::GetViewWindow( theModule ) ),
- mySelector( myViewWindow->GetSelector() )
+SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( const QString& elemName, const bool reverse )
+: SMESHGUI_Dialog()
{
- SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
- (SUIT_Session::session()->activeApplication());
- myIsPoly = false;
- mySimulation = new SMESH::TElementSimulation (anApp);
-
- // verify nb nodes and type
- myNbNodes = nbNodes;
- myElementType = ElementType;
- switch (ElementType) {
- case SMDSAbs_Face:
-// if (myNbNodes != 3 && myNbNodes != 4)
-// myNbNodes = 3;
-// break;
- case SMDSAbs_Volume:
-// if (myNbNodes != 4 && myNbNodes != 8) //(nbNodes < 4 || nbNodes > 8 || nbNodes == 7)
-// myNbNodes = 4;
- break;
- default:
- myElementType = SMDSAbs_Edge;
- myNbNodes = 2;
- }
-
- QString elemName;
- if (myNbNodes == 2)
- elemName = "EDGE";
- else if (myNbNodes == 3)
- elemName = "TRIANGLE";
- else if (myNbNodes == 4)
- if (myElementType == SMDSAbs_Face)
- elemName = "QUADRANGLE";
- else
- elemName = "TETRAS";
- else if (myNbNodes == 8)
- elemName = "HEXAS";
- else if (myElementType == SMDSAbs_Face){
- elemName = "POLYGON";
- myIsPoly = true;
- }
-
QString iconName = tr(QString("ICON_DLG_%1").arg(elemName));
QString buttonGrTitle = tr(QString("SMESH_%1").arg(elemName));
QString caption = tr(QString("SMESH_ADD_%1_TITLE").arg(elemName));
QString grBoxTitle = tr(QString("SMESH_ADD_%1").arg(elemName));
- QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", iconName));
- QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
+ QPixmap image0 ( resMgr()->loadPixmap("SMESH", iconName));
+ QPixmap image1 ( resMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
- if (!name)
- setName("SMESHGUI_AddMeshElementDlg");
+ setName("SMESHGUI_AddMeshElementDlg");
resize(303, 185);
setCaption(caption);
setSizeGripEnabled(TRUE);
- SMESHGUI_AddMeshElementDlgLayout = new QGridLayout(this);
- SMESHGUI_AddMeshElementDlgLayout->setSpacing(6);
- SMESHGUI_AddMeshElementDlgLayout->setMargin(11);
+ QVBoxLayout* main = new QVBoxLayout( mainFrame() );
/***************************************************************/
- GroupConstructors = new QButtonGroup(this, "GroupConstructors");
+ QButtonGroup* GroupConstructors = new QButtonGroup(mainFrame(), "GroupConstructors");
GroupConstructors->setTitle(buttonGrTitle);
GroupConstructors->setExclusive(TRUE);
GroupConstructors->setColumnLayout(0, Qt::Vertical);
GroupConstructors->layout()->setSpacing(0);
GroupConstructors->layout()->setMargin(0);
- GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
+ QGridLayout* GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
GroupConstructorsLayout->setAlignment(Qt::AlignTop);
GroupConstructorsLayout->setSpacing(6);
GroupConstructorsLayout->setMargin(11);
- Constructor1 = new QRadioButton(GroupConstructors, "Constructor1");
+ QRadioButton* Constructor1 = new QRadioButton(GroupConstructors, "Constructor1");
Constructor1->setText(tr("" ));
Constructor1->setPixmap(image0);
Constructor1->setChecked(TRUE);
GroupConstructorsLayout->addWidget(Constructor1, 0, 0);
QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
GroupConstructorsLayout->addItem(spacer, 0, 1);
- SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupConstructors, 0, 0);
+ main->addWidget(GroupConstructors);
/***************************************************************/
- GroupButtons = new QGroupBox(this, "GroupButtons");
- GroupButtons->setGeometry(QRect(10, 10, 281, 48));
- GroupButtons->setTitle(tr("" ));
- GroupButtons->setColumnLayout(0, Qt::Vertical);
- GroupButtons->layout()->setSpacing(0);
- GroupButtons->layout()->setMargin(0);
- GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
- GroupButtonsLayout->setAlignment(Qt::AlignTop);
- GroupButtonsLayout->setSpacing(6);
- GroupButtonsLayout->setMargin(11);
- buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
- buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
- buttonCancel->setAutoDefault(TRUE);
- GroupButtonsLayout->addWidget(buttonCancel, 0, 3);
- buttonApply = new QPushButton(GroupButtons, "buttonApply");
- buttonApply->setText(tr("SMESH_BUT_APPLY" ));
- buttonApply->setAutoDefault(TRUE);
- GroupButtonsLayout->addWidget(buttonApply, 0, 1);
- QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
- GroupButtonsLayout->addItem(spacer_9, 0, 2);
- buttonOk = new QPushButton(GroupButtons, "buttonOk");
- buttonOk->setText(tr("SMESH_BUT_OK" ));
- buttonOk->setAutoDefault(TRUE);
- buttonOk->setDefault(TRUE);
- GroupButtonsLayout->addWidget(buttonOk, 0, 0);
- SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupButtons, 2, 0);
-
- /***************************************************************/
- GroupC1 = new QGroupBox(this, "GroupC1");
+ QGroupBox* GroupC1 = new QGroupBox( mainFrame(), "GroupC1");
GroupC1->setTitle(grBoxTitle);
GroupC1->setMinimumSize(QSize(0, 0));
GroupC1->setFrameShape(QGroupBox::Box);
GroupC1->setFrameShadow(QGroupBox::Sunken);
- GroupC1->setColumnLayout(0, Qt::Vertical);
- GroupC1->layout()->setSpacing(0);
- GroupC1->layout()->setMargin(0);
- GroupC1Layout = new QGridLayout(GroupC1->layout());
- GroupC1Layout->setAlignment(Qt::AlignTop);
- GroupC1Layout->setSpacing(6);
- GroupC1Layout->setMargin(11);
- TextLabelC1A1 = new QLabel(GroupC1, "TextLabelC1A1");
- TextLabelC1A1->setText(tr("SMESH_ID_NODES" ));
- TextLabelC1A1->setMinimumSize(QSize(50, 0));
- TextLabelC1A1->setFrameShape(QLabel::NoFrame);
- TextLabelC1A1->setFrameShadow(QLabel::Plain);
- GroupC1Layout->addWidget(TextLabelC1A1, 0, 0);
- SelectButtonC1A1 = new QPushButton(GroupC1, "SelectButtonC1A1");
- SelectButtonC1A1->setText(tr("" ));
- SelectButtonC1A1->setPixmap(image1);
- SelectButtonC1A1->setToggleButton(FALSE);
- GroupC1Layout->addWidget(SelectButtonC1A1, 0, 1);
- LineEditC1A1 = new QLineEdit(GroupC1, "LineEditC1A1");
-// LineEditC1A1->setReadOnly(TRUE);
- if (!myIsPoly)
- LineEditC1A1->setValidator(new SMESHGUI_IdValidator(this, "validator", myNbNodes));
- GroupC1Layout->addWidget(LineEditC1A1, 0, 2);
+ GroupC1->setColumnLayout(3, Qt::Horizontal);
- if (myElementType == SMDSAbs_Face) {
- Reverse = new QCheckBox(GroupC1, "Reverse");
- Reverse->setText(tr("SMESH_REVERSE" ));
- GroupC1Layout->addWidget(Reverse, 1, 0);
- }
- else
- Reverse = 0;
+ createObject( tr( "SMESH_ID_NODES" ), GroupC1, 0 );
+ setNameIndication( 0, ListOfNames );
+ setReadOnly( 0, false );
+ setObjectType( 0, SMESHGUI_Operation::prefix( "SMESH element" ) + SMDSAbs_Node, -1 );
- SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupC1, 1, 0);
+ myReverse = 0;
+ if ( reverse ) {
+ myReverse = new QCheckBox(GroupC1, "Reverse");
+ myReverse->setText(tr("SMESH_REVERSE" ));
+ }
- Init(); /* Initialisations */
+ if( myReverse )
+ connect( myReverse, SIGNAL(stateChanged(int)), this, SIGNAL(reverse(int)));
+
+ main->addWidget(GroupC1);
}
//=================================================================================
//=================================================================================
SMESHGUI_AddMeshElementDlg::~SMESHGUI_AddMeshElementDlg()
{
- // no need to delete child widgets, Qt does it all for us
- delete mySimulation;
-}
-
-//=================================================================================
-// function : Init()
-// purpose :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::Init()
-{
- GroupC1->show();
- Constructor1->setChecked(TRUE);
- myEditCurrentArgument = LineEditC1A1;
- mySMESHGUI->SetActiveDialogBox((QDialog*)this);
-
- myNbOkNodes = 0;
- myActor = 0;
-
- /* signals and slots connections */
- connect(buttonOk, SIGNAL(clicked()), SLOT(ClickOnOk()));
- connect(buttonCancel, SIGNAL(clicked()), SLOT(ClickOnCancel()));
- connect(buttonApply, SIGNAL(clicked()), SLOT(ClickOnApply()));
-
- connect(SelectButtonC1A1, SIGNAL(clicked()), SLOT(SetEditCurrentArgument()));
- connect(LineEditC1A1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
- connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
- connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument()));
- /* to close dialog if study frame change */
- connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel()));
-
- if (Reverse)
- connect(Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)));
-
- // Move widget on the botton right corner of main widget
- int x, y;
- mySMESHGUI->DefineDlgPosition(this, x, y);
- this->move(x, y);
- this->show(); // displays Dialog
-
- // set selection mode
- SMESH::SetPointRepresentation(true);
-
- myViewWindow->SetSelectionMode( NodeSelection );
-
- myBusy = false;
-
- SelectionIntoArgument();
-}
-
-//=================================================================================
-// function : ClickOnApply()
-// purpose :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::ClickOnApply()
-{
- if (myNbOkNodes && !mySMESHGUI->isActiveStudyLocked()) {
- myBusy = true;
- SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
- anArrayOfIdeces->length(myNbNodes);
- bool reverse = (Reverse && Reverse->isChecked());
- QStringList aListId = QStringList::split(" ", myEditCurrentArgument->text(), false);
- for (int i = 0; i < aListId.count(); i++)
- if (reverse)
- anArrayOfIdeces[i] = aListId[ myNbNodes - i - 1 ].toInt();
- else
- anArrayOfIdeces[i] = aListId[ i ].toInt();
-
- SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
- switch (myElementType) {
- case SMDSAbs_Edge:
- aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break;
- case SMDSAbs_Face:
- aMeshEditor->AddFace(anArrayOfIdeces.inout()); break;
- case SMDSAbs_Volume:
- aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break;
- default:;
- }
-
- SALOME_ListIO aList; aList.Append( myActor->getIO() );
- mySelectionMgr->setSelectedObjects( aList, false );
-
- SMESH::UpdateView();
- mySimulation->SetVisibility(false);
-
- buttonOk->setEnabled(false);
- buttonApply->setEnabled(false);
-
- myEditCurrentArgument->setText("");
-
- myBusy = false;
- }
-}
-
-//=================================================================================
-// function : ClickOnOk()
-// purpose :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::ClickOnOk()
-{
- this->ClickOnApply();
- this->ClickOnCancel();
- return;
-}
-
-//=================================================================================
-// function : ClickOnCancel()
-// purpose :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::ClickOnCancel()
-{
- mySelectionMgr->clearSelected();
- mySimulation->SetVisibility(false);
- SMESH::SetPointRepresentation(false);
- myViewWindow->SetSelectionMode( ActorSelection );
- disconnect(mySelectionMgr, 0, this, 0);
- mySMESHGUI->ResetState();
- reject();
- return;
-}
-
-//=================================================================================
-// function : onTextChange()
-// purpose :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::onTextChange (const QString& theNewText)
-{
- if (myBusy) return;
- myBusy = true;
-
- myNbOkNodes = 0;
-
- buttonOk->setEnabled(false);
- buttonApply->setEnabled(false);
-
- mySimulation->SetVisibility(false);
-
- // hilight entered nodes
- SMDS_Mesh* aMesh = 0;
- if (myActor)
- aMesh = myActor->GetObject()->GetMesh();
-
- if (aMesh) {
- TColStd_MapOfInteger newIndices;
-
- QStringList aListId = QStringList::split(" ", theNewText, false);
- for (int i = 0; i < aListId.count(); i++) {
- if( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) )
- {
- newIndices.Add( n->GetID() );
- myNbOkNodes++;
- }
- }
-
- mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false );
- myViewWindow->highlight( myActor->getIO(), true, true );
-
- bool aNodesOK = false;
- if (myIsPoly && myElementType == SMDSAbs_Face && aListId.count() >=3 ){
- myNbOkNodes = aListId.count();
- aNodesOK = true;
- }
- }
-
- if(myNbOkNodes) {
- buttonOk->setEnabled(true);
- buttonApply->setEnabled(true);
- displaySimulation();
- }
-
- myBusy = false;
-}
-
-//=================================================================================
-// function : SelectionIntoArgument()
-// purpose : Called when selection has changed
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::SelectionIntoArgument()
-{
- if (myBusy) return;
-
- // clear
- myNbOkNodes = 0;
- myActor = 0;
-
- myBusy = true;
- myEditCurrentArgument->setText("");
- myBusy = false;
-
- if (!GroupButtons->isEnabled()) // inactive
- return;
-
- buttonOk->setEnabled(false);
- buttonApply->setEnabled(false);
-
- mySimulation->SetVisibility(false);
-// SMESH::SetPointRepresentation(true);
-
- // get selected mesh
- SALOME_ListIO aList;
- mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
-
- if (aList.Extent() != 1)
- return;
-
- Handle(SALOME_InteractiveObject) anIO = aList.First();
- myMesh = SMESH::GetMeshByIO(anIO);
- if (myMesh->_is_nil())
- return;
-
- myActor = SMESH::FindActorByEntry(anIO->getEntry());
- if (!myActor)
- return;
-
- // get selected nodes
- QString aString = "";
- int nbNodes = SMESH::GetNameOfSelectedNodes(mySelector,myActor->getIO(),aString);
- myBusy = true;
- myEditCurrentArgument->setText(aString);
- myBusy = false;
- if (myIsPoly && myElementType == SMDSAbs_Face && nbNodes >= 3 ) {
- myNbNodes = nbNodes;
- } else if (myNbNodes != nbNodes) {
- return;
- }
-
- // OK
- myNbOkNodes = nbNodes;
-
- buttonOk->setEnabled(true);
- buttonApply->setEnabled(true);
-
- displaySimulation();
-}
-
-//=================================================================================
-// function : displaySimulation()
-// purpose :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::displaySimulation()
-{
- if (myNbOkNodes && GroupButtons->isEnabled()) {
- SMESH::TElementSimulation::TVTKIds anIds;
- QStringList aListId = QStringList::split(" ", myEditCurrentArgument->text(), false);
- for (int i = 0; i < aListId.count(); i++)
- anIds.push_back(myActor->GetObject()->GetNodeVTKId(aListId[ i ].toInt()));
-
- if (Reverse && Reverse->isChecked())
- reverse(anIds.begin(),anIds.end());
-
- vtkIdType aType = 0;
- if (myIsPoly)
- switch ( myElementType ) {
- case SMDSAbs_Face : aType = VTK_POLYGON; break;
- default: return;
- }
- else {
- switch (myNbNodes) {
- case 2: aType = VTK_LINE; break;
- case 3: aType = VTK_TRIANGLE; break;
- case 4: aType = myElementType == SMDSAbs_Face ? VTK_QUAD : VTK_TETRA; break;
- case 8: aType = VTK_HEXAHEDRON; break;
- default: return;
- }
- }
-
- mySimulation->SetPosition(myActor,aType,anIds);
- SMESH::UpdateView();
- }
}
//=================================================================================
-// function : SetEditCurrentArgument()
-// purpose :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::SetEditCurrentArgument()
-{
- QPushButton* send = (QPushButton*)sender();
- if (send == SelectButtonC1A1) {
- LineEditC1A1->setFocus();
- myEditCurrentArgument = LineEditC1A1;
- }
- SelectionIntoArgument();
-}
-
-//=================================================================================
-// function : DeactivateActiveDialog()
-// purpose :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::DeactivateActiveDialog()
-{
- if (GroupConstructors->isEnabled()) {
- GroupConstructors->setEnabled(false);
- GroupC1->setEnabled(false);
- GroupButtons->setEnabled(false);
- mySimulation->SetVisibility(false);
- mySMESHGUI->ResetState();
- mySMESHGUI->SetActiveDialogBox(0);
- }
-}
-
-//=================================================================================
-// function : ActivateThisDialog()
-// purpose :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::ActivateThisDialog()
-{
- /* Emit a signal to deactivate the active dialog */
- mySMESHGUI->EmitSignalDeactivateDialog();
-
- GroupConstructors->setEnabled(true);
- GroupC1->setEnabled(true);
- GroupButtons->setEnabled(true);
-
- SMESH::SetPointRepresentation(true);
-
- myViewWindow->SetSelectionMode( NodeSelection );
- SelectionIntoArgument();
-}
-
-//=================================================================================
-// function : enterEvent()
-// purpose :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::enterEvent (QEvent*)
-{
- if (GroupConstructors->isEnabled())
- return;
- ActivateThisDialog();
- return;
-}
-
-//=================================================================================
-// function : closeEvent()
-// purpose :
-//=================================================================================
-void SMESHGUI_AddMeshElementDlg::closeEvent (QCloseEvent*)
-{
- /* same than click on cancel button */
- this->ClickOnCancel();
- return;
-}
-
-//=================================================================================
-// function : hideEvent()
-// purpose : caused by ESC key
+// function : ~SMESHGUI_AddMeshElementDlg()
+// purpose : Destroys the object and frees any allocated resources
//=================================================================================
-void SMESHGUI_AddMeshElementDlg::hideEvent (QHideEvent*)
+bool SMESHGUI_AddMeshElementDlg::isReverse() const
{
- if (!isMinimized())
- ClickOnCancel();
+ if( myReverse )
+ return myReverse->isChecked();
+ else
+ return false;
}
//=================================================================================
-// function : CheckBox()
-// purpose :
+// function : ~SMESHGUI_AddMeshElementDlg()
+// purpose : Destroys the object and frees any allocated resources
//=================================================================================
-void SMESHGUI_AddMeshElementDlg::CheckBox (int state)
+void SMESHGUI_AddMeshElementDlg::setBusy( const bool b )
{
- if (!myNbOkNodes)
- return;
-
- if (state >= 0) {
- mySimulation->SetVisibility(false);
- displaySimulation();
- }
+ myIsBusy = b;
}
#ifndef DIALOGBOX_ADD_FACE_H
#define DIALOGBOX_ADD_FACE_H
-#include "SalomeApp_SelectionMgr.h"
+#include <SMESHGUI_Dialog.h>
-#include "SMDSAbs_ElementType.hxx"
-
-
-// QT Includes
-#include <qvariant.h>
-#include <qdialog.h>
-
-class QVBoxLayout;
-class QHBoxLayout;
-class QGridLayout;
-class QButtonGroup;
-class QGroupBox;
-class QLabel;
-class QLineEdit;
-class QPushButton;
-class QRadioButton;
class QCheckBox;
-class SMESHGUI;
-class SMESH_Actor;
-class SMDS_Mesh;
-class SVTK_ViewWindow;
-class SVTK_Selector;
-
-namespace SMESH{
- struct TElementSimulation;
-}
-
-// IDL Headers
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SMESH_Mesh)
//=================================================================================
// class : SMESHGUI_AddMeshElementDlg
// purpose :
//=================================================================================
-class SMESHGUI_AddMeshElementDlg : public QDialog
+class SMESHGUI_AddMeshElementDlg : public SMESHGUI_Dialog
{
Q_OBJECT
public:
- SMESHGUI_AddMeshElementDlg( SMESHGUI*,
- const char* = 0,
- SMDSAbs_ElementType ElementType = SMDSAbs_Edge,
- int nbNodes = 2, bool modal = FALSE, WFlags fl = 0 );
+ SMESHGUI_AddMeshElementDlg( const QString&, const bool );
~SMESHGUI_AddMeshElementDlg();
-private:
- void Init ();
- void closeEvent (QCloseEvent*);
- void hideEvent (QHideEvent*); /* ESC key */
- void enterEvent (QEvent*); /* mouse enter the QWidget */
- void displaySimulation();
-
- SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
- SalomeApp_SelectionMgr* mySelectionMgr; /* User shape selection */
- int myNbOkNodes; /* to check when arguments is defined */
- bool myBusy;
- SVTK_ViewWindow* myViewWindow;
- SVTK_Selector* mySelector;
+ bool isReverse() const;
+ void setBusy( const bool );
- QLineEdit* myEditCurrentArgument; /* Current LineEdit */
+signals:
+ void reverse( int );
- int myElementType;
- int myNbNodes;
- bool myIsPoly;
-
- SMESH::SMESH_Mesh_var myMesh;
- SMESH_Actor* myActor;
- SMESH::TElementSimulation* mySimulation;
-
- QButtonGroup* GroupConstructors;
- QRadioButton* Constructor1;
- QGroupBox * GroupButtons;
- QPushButton * buttonOk;
- QPushButton * buttonCancel;
- QPushButton * buttonApply;
- QGroupBox * GroupC1;
- QLabel * TextLabelC1A1;
- QPushButton * SelectButtonC1A1;
- QLineEdit * LineEditC1A1;
-
- QCheckBox * Reverse;
-
-private slots:
-
- void ClickOnOk();
- void ClickOnCancel();
- void ClickOnApply();
- void SetEditCurrentArgument() ;
- void SelectionIntoArgument() ;
- void DeactivateActiveDialog() ;
- void ActivateThisDialog() ;
- void CheckBox( int );
- void onTextChange(const QString&);
-
-protected:
- QGridLayout* SMESHGUI_AddMeshElementDlgLayout;
- QGridLayout* GroupConstructorsLayout;
- QGridLayout* GroupButtonsLayout;
- QGridLayout* GroupC1Layout;
+private:
+ QCheckBox* myReverse;
};
#endif // DIALOGBOX_ADD_FACE_H
--- /dev/null
+// SMESH SMESHGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMESHGUI_AddMeshElementOp.cxx
+// Author : Alexander SOLOVYOV
+// Module : SMESH
+// $Header$
+
+#include "SMESHGUI_AddMeshElementOp.h"
+#include <SMESHGUI_AddMeshElementDlg.h>
+#include <SMESHGUI.h>
+
+#include <SalomeApp_SelectionMgr.h>
+
+#include <SVTK_ViewWindow.h>
+#include <SVTK_ViewModel.h>
+#include <SVTK_Selector.h>
+#include <SMESH_Actor.h>
+#include <SMESH_ActorUtils.h>
+#include <SMESHGUI_Utils.h>
+#include <SMESHGUI_VTKUtils.h>
+#include <SMESHGUI_MeshUtils.h>
+
+#include <SALOME_ListIO.hxx>
+
+#include <vtkCell.h>
+#include <vtkDataSetMapper.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkIdList.h>
+
+#include <TColStd_MapOfInteger.hxx>
+
+#include <SMDS_Mesh.hxx>
+#include <SMDS_MeshNode.hxx>
+
+namespace SMESH {
+
+ class TElementSimulation {
+ SVTK_ViewWindow* myVTKViewWindow;
+ SALOME_Actor* myPreviewActor;
+ vtkDataSetMapper* myMapper;
+ vtkUnstructuredGrid* myGrid;
+
+ public:
+ TElementSimulation( SVTK_ViewWindow* wnd )
+ {
+ myVTKViewWindow = wnd;
+
+ myGrid = vtkUnstructuredGrid::New();
+
+ // Create and display actor
+ myMapper = vtkDataSetMapper::New();
+ myMapper->SetInput(myGrid);
+
+ myPreviewActor = SALOME_Actor::New();
+ myPreviewActor->PickableOff();
+ myPreviewActor->VisibilityOff();
+ myPreviewActor->SetMapper(myMapper);
+
+ float anRGB[3];
+ vtkProperty* aProp = vtkProperty::New();
+ GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
+ aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
+ myPreviewActor->SetProperty( aProp );
+ aProp->Delete();
+
+ vtkProperty* aBackProp = vtkProperty::New();
+ GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
+ aBackProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
+ myPreviewActor->SetBackfaceProperty( aBackProp );
+ aBackProp->Delete();
+
+ myVTKViewWindow->AddActor(myPreviewActor);
+ }
+
+ typedef std::vector<vtkIdType> TVTKIds;
+ void SetPosition (SMESH_Actor* theActor,
+ vtkIdType theType,
+ const TVTKIds& theIds)
+ {
+ vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
+ myGrid->SetPoints(aGrid->GetPoints());
+
+ const int* aConn = NULL;
+ switch (theType) {
+ case VTK_TETRA:
+ {
+ static int anIds[] = {0,2,1,3};
+ aConn = anIds;
+ break;
+ }
+ case VTK_PYRAMID:
+ {
+ static int anIds[] = {0,3,2,1,4};
+ aConn = anIds;
+ break;
+ }
+ case VTK_HEXAHEDRON:
+ {
+ static int anIds[] = {0,3,2,1,4,7,6,5};
+ aConn = anIds;
+ break;
+ }
+ }
+
+ myGrid->Reset();
+ vtkIdList *anIds = vtkIdList::New();
+
+ if(aConn)
+ for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
+ anIds->InsertId(i,theIds[aConn[i]]);
+ else
+ for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
+ anIds->InsertId(i,theIds[i]);
+
+ myGrid->InsertNextCell(theType,anIds);
+ anIds->Delete();
+
+ myGrid->Modified();
+
+ SetVisibility(true);
+ }
+
+
+ void SetVisibility (bool theVisibility)
+ {
+ myPreviewActor->SetVisibility(theVisibility);
+ RepaintCurrentView();
+ }
+
+
+ ~TElementSimulation()
+ {
+ SetVisibility( false );
+ if( myVTKViewWindow )
+ myVTKViewWindow->RemoveActor(myPreviewActor);
+
+ myPreviewActor->Delete();
+
+ myMapper->RemoveAllInputs();
+ myMapper->Delete();
+
+ myGrid->Delete();
+ }
+ };
+}
+
+//=================================================================================
+// function : SMESHGUI_AddMeshElementDlg()
+// purpose : constructor
+//=================================================================================
+SMESHGUI_AddMeshElementOp::SMESHGUI_AddMeshElementOp( const SMDSAbs_ElementType t, const int nbNodes )
+: SMESHGUI_SelectionOp( NodeSelection ),
+ myElementType( t ),
+ myNbNodes( nbNodes ),
+ myIsPoly( myElementType==SMDSAbs_Face && myNbNodes==5 ),
+ mySimulation( 0 ),
+ myDlg( 0 )
+{
+}
+
+//=================================================================================
+// function : ~SMESHGUI_AddMeshElementDlg()
+// purpose : destructor
+//=================================================================================
+SMESHGUI_AddMeshElementOp::~SMESHGUI_AddMeshElementOp()
+{
+ if( myDlg )
+ delete myDlg;
+}
+
+//=================================================================================
+// function : dlg()
+// purpose :
+//=================================================================================
+SalomeApp_Dialog* SMESHGUI_AddMeshElementOp::dlg() const
+{
+ return myDlg;
+}
+
+//=================================================================================
+// function : startOperation()
+// purpose :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::startOperation()
+{
+ if( !myDlg )
+ {
+ QString elemName;
+ switch( myNbNodes )
+ {
+ case 2: elemName = "EDGE"; break;
+ case 3: elemName = "TRIANGLE"; break;
+ case 4: if (myElementType == SMDSAbs_Face)
+ elemName = "QUADRANGLE";
+ else
+ elemName = "TETRAS";
+ break;
+ case 5: elemName = "POLYGON"; break;
+ case 8: elemName = "HEXAS"; break;
+ }
+
+ myDlg = new SMESHGUI_AddMeshElementDlg( elemName, myElementType == SMDSAbs_Face );
+ connect( myDlg, SIGNAL( objectChanged( int, const QStringList& ) ),
+ this, SLOT( onTextChanged( int, const QStringList& ) ) );
+ connect( myDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
+ connect( myDlg, SIGNAL( reverse( int ) ), this, SLOT( onReverse( int ) ) );
+ }
+
+ SMESHGUI_SelectionOp::startOperation();
+
+ mySimulation = new SMESH::TElementSimulation( viewWindow() );
+ updateDialog();
+ myDlg->show();
+}
+
+//=================================================================================
+// function : selectionDone()
+// purpose :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::selectionDone()
+{
+ if( !mySimulation )
+ return;
+
+ mySimulation->SetVisibility(false);
+
+ // get selected mesh
+ SALOME_ListIO aList;
+ selectionMgr()->selectedObjects(aList,SVTK_Viewer::Type());
+
+ if( aList.Extent() != 1)
+ return;
+
+ Handle(SALOME_InteractiveObject) anIO = aList.First();
+ myMesh = SMESH::GetMeshByIO(anIO);
+
+ QStringList names, ids; SalomeApp_Dialog::TypesList types;
+ selected( names, types, ids );
+ myDlg->selectObject( names, types, ids );
+
+ updateDialog();
+ displaySimulation();
+}
+
+//=================================================================================
+// function : commitOperation()
+// purpose :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::commitOperation()
+{
+ if( mySimulation )
+ delete mySimulation;
+ mySimulation = 0;
+ SMESHGUI_SelectionOp::commitOperation();
+}
+
+//=================================================================================
+// function : abortOperation()
+// purpose :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::abortOperation()
+{
+ if( mySimulation )
+ delete mySimulation;
+ mySimulation = 0;
+ SMESHGUI_SelectionOp::abortOperation();
+}
+
+//=================================================================================
+// function : onApply()
+// purpose :
+//=================================================================================
+bool SMESHGUI_AddMeshElementOp::onApply()
+{
+ if( !mySimulation )
+ return false;
+
+ QStringList ids; myDlg->selectedObject( 0, ids );
+ if( ids.count()>=myNbNodes && !getSMESHGUI()->isActiveStudyLocked() ) {
+ //myBusy = true;
+ SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array;
+ anArrayOfIdeces->length(myNbNodes);
+ bool reverse = myDlg->isReverse();
+
+ for (int i = 0; i < myNbNodes; i++)
+ {
+ QString id_str = ids[ i ];
+ int pos = id_str.find( idChar() );
+ int id = -1;
+ if( pos>=0 )
+ id = id_str.mid( pos+1 ).toInt();
+
+ if( id==-1 )
+ {
+ printf( "SMESHGUI_AddMeshElementOp::onApply(): Error!!!\n" );
+ return false;
+ }
+
+ if (reverse)
+ anArrayOfIdeces[ myNbNodes - i - 1 ] = id;
+ else
+ anArrayOfIdeces[i] = id;
+ }
+
+ SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor();
+ switch (myElementType) {
+ case SMDSAbs_Edge:
+ aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break;
+ case SMDSAbs_Face:
+ aMeshEditor->AddFace(anArrayOfIdeces.inout()); break;
+ case SMDSAbs_Volume:
+ aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break;
+ default:;
+ }
+
+ //SALOME_ListIO aList; aList.Append( myActor->getIO() );
+ //mySelectionMgr->setSelectedObjects( aList, false );
+
+ SMESH::UpdateView();
+ mySimulation->SetVisibility(false);
+
+ initDialog();
+ updateDialog();
+
+ return true;
+ }
+ return false;
+}
+
+//=================================================================================
+// function : onTextChanged()
+// purpose :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::onTextChanged( int, const QStringList& aListId )
+{
+ myDlg->setBusy( true );
+ TColStd_MapOfInteger newIndices;
+ SALOME_ListIO list; selectionMgr()->selectedObjects( list );
+ if( list.Extent()==0 )
+ return;
+
+ SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh.in() );
+ if( !anActor )
+ return;
+
+ SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh();
+
+ for (int i = 0; i < aListId.count(); i++)
+ if( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) )
+ newIndices.Add( n->GetID() );
+
+ selector()->AddOrRemoveIndex( list.First(), newIndices, false );
+ highlight( list.First(), true, true );
+
+ selectionDone();
+ myDlg->setBusy( false );
+}
+
+//=================================================================================
+// function : displaySimulation()
+// purpose :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::displaySimulation()
+{
+ QStringList ids; myDlg->selectedObject( 0, ids );
+ if( ids.count()>=myNbNodes ) {
+ SMESH::TElementSimulation::TVTKIds anIds;
+
+ SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh.in() );
+ if( !anActor )
+ return;
+
+ for (int i = 0; i < myNbNodes; i++)
+ {
+ QString id_str = ids[ i ];
+ int pos = id_str.find( idChar() );
+ int id = -1;
+ if( pos>=0 )
+ id = id_str.mid( pos+1 ).toInt();
+
+ if( id==-1 )
+ {
+ printf( "SMESHGUI_AddMeshElementOp::displaySimulation(): Error!!!\n" );
+ return;
+ }
+
+ anIds.push_back( anActor->GetObject()->GetNodeVTKId( id ) );
+ }
+
+ if( myDlg->isReverse() )
+ reverse( anIds.begin(), anIds.end() );
+
+ vtkIdType aType = 0;
+ if (myIsPoly)
+ switch ( myElementType ) {
+ case SMDSAbs_Face : aType = VTK_POLYGON; break;
+ default: return;
+ }
+ else {
+ switch (myNbNodes) {
+ case 2: aType = VTK_LINE; break;
+ case 3: aType = VTK_TRIANGLE; break;
+ case 4: aType = myElementType == SMDSAbs_Face ? VTK_QUAD : VTK_TETRA; break;
+ case 8: aType = VTK_HEXAHEDRON; break;
+ default: return;
+ }
+ }
+
+ mySimulation->SetPosition( anActor, aType, anIds );
+ SMESH::UpdateView();
+ }
+}
+
+//=================================================================================
+// function : onReverse()
+// purpose :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::onReverse( int )
+{
+ if( mySimulation )
+ {
+ mySimulation->SetVisibility( false );
+ displaySimulation();
+ }
+}
+
+//=================================================================================
+// function : updateDialog()
+// purpose :
+//=================================================================================
+void SMESHGUI_AddMeshElementOp::updateDialog()
+{
+ if( myDlg )
+ {
+ QStringList ids; myDlg->selectedObject( 0, ids );
+ myDlg->setButtonEnabled( ids.count()>=myNbNodes, QtxDialog::OK | QtxDialog::Apply );
+ }
+}
--- /dev/null
+// SMESH SMESHGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMESHGUI_AddMeshElementOp.h
+// Author : Nicolas REJNERI
+// Module : SMESH
+// $Header$
+
+#ifndef OPERATION_ADD_FACE_H
+#define OPERATION_ADD_FACE_H
+
+namespace SMESH{
+ struct TElementSimulation;
+}
+
+// IDL Headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
+#include <SMESHGUI_SelectionOp.h>
+#include <SMDSAbs_ElementType.hxx>
+
+class SMESHGUI_AddMeshElementDlg;
+
+//=================================================================================
+// class : SMESHGUI_AddMeshElementOp
+// purpose :
+//=================================================================================
+class SMESHGUI_AddMeshElementOp : public SMESHGUI_SelectionOp
+{
+ Q_OBJECT
+
+public:
+ SMESHGUI_AddMeshElementOp( const SMDSAbs_ElementType, const int );
+ ~SMESHGUI_AddMeshElementOp();
+
+ virtual SalomeApp_Dialog* dlg() const;
+
+protected:
+ virtual void startOperation();
+ virtual void selectionDone();
+ virtual void commitOperation();
+ virtual void abortOperation();
+
+ void updateDialog();
+
+protected slots:
+ virtual bool onApply();
+ void onTextChanged( int, const QStringList& );
+ void onReverse( int );
+
+private:
+ void displaySimulation();
+
+private:
+ int myElementType;
+ int myNbNodes;
+ bool myIsPoly;
+
+ SMESH::SMESH_Mesh_var myMesh;
+ SMESH::TElementSimulation* mySimulation;
+
+ SMESHGUI_AddMeshElementDlg* myDlg;
+};
+
+#endif // DIALOGBOX_ADD_FACE_H
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
-SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( SMESHGUI* theModule )
-: SMESHGUI_Dialog( theModule, false, true )
+SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg()
+: SMESHGUI_Dialog( false, true )
{
setCaption(tr("SMESH_ADD_SUBMESH"));
enum { MeshObj, GeomObj, Hypo, Algo };
public:
- SMESHGUI_AddSubMeshDlg( SMESHGUI* );
+ SMESHGUI_AddSubMeshDlg();
~SMESHGUI_AddSubMeshDlg();
void setSubMeshName( const QString& );
//
//
//
-// File : SMESHGUI_AddSubMeshDlg.cxx
+// File : SMESHGUI_AddSubMeshOp.cxx
// Author : Nicolas REJNERI
// Module : SMESH
// $Header$
// purpose :
//=================================================================================
SMESHGUI_AddSubMeshOp::SMESHGUI_AddSubMeshOp()
-: SMESHGUI_Operation(),
- myDlg( 0 ),
- myMeshFilter( 0 ),
- myGeomFilter( 0 ),
- myHypothesisFilter( 0 ),
- myAlgorithmFilter( 0 )
+: SMESHGUI_SelectionOp(),
+ myDlg( 0 )
{
setAutoResumed( true );
}
{
if( myDlg )
delete myDlg;
-
- if( myMeshFilter )
- delete myMeshFilter;
-
- if( myGeomFilter )
- delete myGeomFilter;
-
- if( myAlgorithmFilter )
- delete myAlgorithmFilter;
-
- if( myHypothesisFilter )
- delete myHypothesisFilter;
}
//=================================================================================
{
if( !myDlg )
{
- myDlg = new SMESHGUI_AddSubMeshDlg( getSMESHGUI() );
- connect( myDlg, SIGNAL( objectActivated( int ) ), this, SLOT( onActivateObject( int ) ) );
- connect( myDlg, SIGNAL( selectionChanged( int ) ), this, SLOT( onSelectionChanged( int ) ) );
- }
-
- SMESHGUI_Operation::startOperation();
-
- if( !myGeomFilter )
- {
- TColStd_MapOfInteger allTypesMap;
- for (int i = 0; i < 10; i++)
- allTypesMap.Add(i);
- myGeomFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap);
+ myDlg = new SMESHGUI_AddSubMeshDlg();
+ connect( myDlg, SIGNAL( nameChanged( const QString& ) ), this, SLOT( onNameChanged( const QString& ) ) );
}
- if( !myMeshFilter )
- myMeshFilter = new SMESH_TypeFilter (MESH);
-
- if( !myAlgorithmFilter )
- myAlgorithmFilter = new SMESH_TypeFilter (ALGORITHM);
+ SMESHGUI_SelectionOp::startOperation();
- if( !myHypothesisFilter )
- myHypothesisFilter = new SMESH_TypeFilter (HYPOTHESIS);
-
- init();
myDlg->show();
}
//=================================================================================
void SMESHGUI_AddSubMeshOp::selectionDone()
{
- QStringList names, ids;
- SMESHGUI_Dialog::TypesList types;
- selected( names, types, ids );
+ SMESHGUI_SelectionOp::selectionDone();
if( myDlg )
- {
- myDlg->selectObject( names, types, ids );
- myDlg->updateControlState( isValid() );
- }
+ updateDialog();
}
//=================================================================================
-// function : onActivateObject
+// function : createFilter
// purpose :
//=================================================================================
-void SMESHGUI_AddSubMeshOp::onActivateObject( int obj )
+SUIT_SelectionFilter* SMESHGUI_AddSubMeshOp::createFilter( const int id ) const
{
- SalomeApp_SelectionMgr* mgr = selectionMgr();
+ if( id==SMESHGUI_AddSubMeshDlg::GeomObj )
+ {
+ TColStd_MapOfInteger allTypesMap;
+ for (int i = 0; i < 10; i++)
+ allTypesMap.Add(i);
+ return new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap);
+ }
- if( !mgr )
- return;
-
- mgr->clearFilters();
+ if( id==SMESHGUI_AddSubMeshDlg::MeshObj )
+ return new SMESH_TypeFilter (MESH);
- if( obj==SMESHGUI_AddSubMeshDlg::MeshObj )
- mgr->installFilter( myMeshFilter );
+ else if( id==SMESHGUI_AddSubMeshDlg::Algo )
+ return new SMESH_TypeFilter (ALGORITHM);
- else if( obj==SMESHGUI_AddSubMeshDlg::GeomObj )
- mgr->installFilter( myGeomFilter );
-
- else if( obj==SMESHGUI_AddSubMeshDlg::Hypo )
- mgr->installFilter( myHypothesisFilter );
+ else if( id==SMESHGUI_AddSubMeshDlg::Hypo )
+ return new SMESH_TypeFilter (HYPOTHESIS);
- else if( obj==SMESHGUI_AddSubMeshDlg::Algo )
- mgr->installFilter( myAlgorithmFilter );
+ else
+ return 0;
}
//=================================================================================
}
update( UF_Model | UF_ObjBrowser );
- init();
+ initDialog();
return (nbSuccess > 0);
}
//=================================================================================
-// function : init()
+// function : initDialog()
// purpose :
//=================================================================================
-void SMESHGUI_AddSubMeshOp::init()
+void SMESHGUI_AddSubMeshOp::initDialog()
{
+ SMESHGUI_SelectionOp::initDialog();
if( myDlg )
- {
- myDlg->init();
- myDlg->updateControlState( false );
+ {
+ myDlg->setSubMeshName( tr( "SMESH_SUBMESH" ) );
+ updateDialog();
}
}
-//=================================================================================
-// function : isValid()
-// purpose :
-//=================================================================================
-bool SMESHGUI_AddSubMeshOp::isValid() const
-{
- bool isEnabled = !myDlg->subMeshName().isEmpty() &&
- myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::MeshObj ) &&
- myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::GeomObj ) &&
- myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::Hypo ) &&
- myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::Algo );
-
- bool isImportedMesh = false;
-
- QStringList selMesh;
- myDlg->selectedObject( SMESHGUI_AddSubMeshDlg::MeshObj, selMesh );
- _PTR(SObject) SO = studyDS()->FindObjectID( selMesh.first() );
- GEOM::GEOM_Object_var myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(SO);
- isImportedMesh = myGeomShape->_is_nil();
-
- return isEnabled && !isImportedMesh;
-}
-
//=================================================================================
// function : IsFatherOf()
// purpose :
}
//=================================================================================
-// function : onSelectionChanged()
+// function : addSubMesh()
// purpose :
//=================================================================================
SMESH::SMESH_subMesh_var SMESHGUI_AddSubMeshOp::addSubMesh( SMESH::SMESH_Mesh_ptr theMesh,
return aSubMesh._retn();
}
+//=================================================================================
+// function : updateDialog()
+// purpose :
+//=================================================================================
+void SMESHGUI_AddSubMeshOp::updateDialog()
+{
+ if( !myDlg )
+ return;
+
+ bool isEnabled = !myDlg->subMeshName().isEmpty() &&
+ myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::MeshObj ) &&
+ myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::GeomObj ) &&
+ myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::Hypo ) &&
+ myDlg->hasSelection( SMESHGUI_AddSubMeshDlg::Algo );
+
+ bool isImportedMesh = false;
+
+ QStringList selMesh;
+ myDlg->selectedObject( SMESHGUI_AddSubMeshDlg::MeshObj, selMesh );
+ _PTR(SObject) SO = studyDS()->FindObjectID( selMesh.first() );
+ GEOM::GEOM_Object_var myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(SO);
+ isImportedMesh = myGeomShape->_is_nil();
+
+ isEnabled = isEnabled && !isImportedMesh;
+
+ myDlg->setButtonEnabled( isEnabled, QtxDialog::OK | QtxDialog::Apply );
+}
+
+//=================================================================================
+// function : onNameChanged()
+// purpose :
+//=================================================================================
+void SMESHGUI_AddSubMeshOp::onNameChanged( const QString& )
+{
+ updateDialog();
+}
+
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool SMESHGUI_AddSubMeshOp::isValid( SUIT_Operation* theOtherOp ) const
{
- if ( theOtherOp && theOtherOp->inherits( "SMESHGUI_InitMeshOp" ) )
+ //if ( theOtherOp && theOtherOp->inherits( "SMESHGUI_InitMeshOp" ) )
return true;
- else
- return false;
-
+ /*else
+ return false;*/
}
#ifndef OPERATION_ADD_SUB_MESH_H
#define OPERATION_ADD_SUB_MESH_H
-#include <SMESHGUI_Operation.h>
+#include <SMESHGUI_SelectionOp.h>
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
// class : SMESHGUI_AddSubMeshOp
// purpose :
//=================================================================================
-class SMESHGUI_AddSubMeshOp : public SMESHGUI_Operation
+class SMESHGUI_AddSubMeshOp : public SMESHGUI_SelectionOp
{
Q_OBJECT
~SMESHGUI_AddSubMeshOp();
virtual SalomeApp_Dialog* dlg() const;
- void init();
+ virtual void initDialog();
virtual bool isValid( SUIT_Operation* theOtherOp ) const;
protected:
virtual void startOperation();
virtual void selectionDone();
+ virtual SUIT_SelectionFilter* createFilter( const int ) const;
- bool isValid() const;
+ void updateDialog();
SMESH::SMESH_subMesh_var addSubMesh( SMESH::SMESH_Mesh_ptr,
GEOM::GEOM_Object_ptr,
protected slots:
virtual bool onApply();
+ virtual void onSelectionChanged( int );
private slots:
- void onActivateObject( int );
- void onSelectionChanged( int );
+ void onNameChanged( const QString& );
private:
SMESHGUI_AddSubMeshDlg *myDlg;
- SUIT_SelectionFilter *myMeshFilter, *myGeomFilter, *myHypothesisFilter, *myAlgorithmFilter;
};
#endif // OPERATION_INIT_MESH_H
+// SMESH SMESHGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMESHGUI_Dialog.cxx
+// Author : Alexander SOLOVYOV
+// Module : SMESH
+// $Header$
#include <SMESHGUI_Dialog.h>
-#include <SMESHGUI_Utils.h>
#include <SMESHGUI_Operation.h>
#include <SMESH_Type.h>
-#include <SMESHGUI.h>
+#include <SUIT_Session.h>
+#include <SalomeApp_Application.h>
-#include <SUIT_Desktop.h>
-
-SMESHGUI_Dialog::SMESHGUI_Dialog( SMESHGUI* theModule, const bool modal, const bool allowResize,
- const int flags )
-: SalomeApp_Dialog( SMESH::GetDesktop( theModule ), "", modal, allowResize, flags ),
- mySMESHGUI( theModule )
+//=================================================================================
+// function : SMESHGUI_Dialog
+// purpose : Constructor
+//=================================================================================
+SMESHGUI_Dialog::SMESHGUI_Dialog( const bool modal, const bool allowResize, const int flags )
+: SalomeApp_Dialog( desktop(), "", modal, allowResize, flags )
{
int prefix = SMESHGUI_Operation::prefix( "SMESH" );
typeName( prefix + MESH ) = tr( "DLG_MESH" );
typeName( prefix + ALGORITHM ) = tr( "DLG_ALGO" );
}
+//=================================================================================
+// function : ~SMESHGUI_Dialog
+// purpose : Destructor
+//=================================================================================
SMESHGUI_Dialog::~SMESHGUI_Dialog()
{
}
+//=================================================================================
+// function : show
+// purpose :
+//=================================================================================
void SMESHGUI_Dialog::show()
{
- int x, y;
- mySMESHGUI->DefineDlgPosition(this, x, y);
+ adjustSize();
+ SUIT_Desktop *PP = desktop();
+ int x = abs( PP->x() + PP->size().width() - size().width() - 10 ),
+ y = abs( PP->y() + PP->size().height() - size().height() - 10 );
move(x, y);
SalomeApp_Dialog::show();
}
+//=================================================================================
+// function : setContentActive
+// purpose :
+//=================================================================================
void SMESHGUI_Dialog::setContentActive( const bool active ) const
{
mainFrame()->setEnabled( active );
}
+
+//=================================================================================
+// function : desktop
+// purpose :
+//=================================================================================
+SUIT_Desktop* SMESHGUI_Dialog::desktop() const
+{
+ SUIT_Desktop* d = 0;
+ SUIT_Session* s = SUIT_Session::session();
+ if( s )
+ {
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( s->activeApplication() );
+ if( app )
+ d = app->desktop();
+ }
+ return d;
+}
+// SMESH SMESHGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SMESHGUI_Dialog.h
+// Author : Alexander SOLOVYOV
+// Module : SMESH
+// $Header$
+
#ifndef SMESHGUI_DIALOG_H
#define SMESHGUI_DIALOG_H
#include <SalomeApp_Dialog.h>
-class SMESHGUI;
+class SUIT_Desktop;
+//=================================================================================
+// class : SMESHGUI_Dialog
+// purpose : Base dialog for all SMESHGUI dialogs
+//=================================================================================
class SMESHGUI_Dialog : public SalomeApp_Dialog
{
Q_OBJECT
public:
- SMESHGUI_Dialog( SMESHGUI*, const bool = false, const bool = false, const int = OK | Cancel | Apply );
+ SMESHGUI_Dialog( const bool = false, const bool = false, const int = OK | Cancel | Apply );
virtual ~SMESHGUI_Dialog();
virtual void show();
//! set all content to enable (parameter is true) or disable state
void setContentActive( const bool ) const;
-private:
- SMESHGUI* mySMESHGUI;
+protected:
+ //! find desktop of active application
+ SUIT_Desktop* desktop() const;
};
#endif
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
-SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg( SMESHGUI* theModule )
-: SMESHGUI_Dialog( theModule, false, true )
+SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg()
+: SMESHGUI_Dialog( false, true )
{
setName("SMESHGUI_EditHypothesesDlg");
setCaption(tr("SMESH_EDIT_HYPOTHESES"));
typedef enum { HypoDef, HypoAssign, AlgoDef, AlgoAssign } ListType;
public:
- SMESHGUI_EditHypothesesDlg( SMESHGUI* );
+ SMESHGUI_EditHypothesesDlg();
~SMESHGUI_EditHypothesesDlg();
void setListsEnabled( const bool );
{
if( !myDlg )
{
- myDlg = new SMESHGUI_EditHypothesesDlg( getSMESHGUI() );
+ myDlg = new SMESHGUI_EditHypothesesDlg();
connect( myDlg, SIGNAL( needToUpdate() ), this, SLOT( onUpdate() ) );
}
// name : SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg
// Purpose : Constructor
//=======================================================================
-SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( SMESHGUI* theModule, const int aMode )
-: SMESHGUI_Dialog( theModule, false, true )
+SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( const int aMode )
+: SMESHGUI_Dialog( false, true )
{
QString caption;
if( aMode == 0 )
Q_OBJECT
public:
- SMESHGUI_GroupOpDlg( SMESHGUI*, const int );
+ SMESHGUI_GroupOpDlg( const int );
virtual ~SMESHGUI_GroupOpDlg();
void setName( const QString& );
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
-SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg( SMESHGUI* theModule )
-: SMESHGUI_Dialog( theModule, false, true )
+SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg()
+: SMESHGUI_Dialog( false, true )
{
setCaption(tr("SMESH_INIT_MESH"));
enum { GeomObj, Hypo, Algo };
public:
- SMESHGUI_InitMeshDlg( SMESHGUI* );
+ SMESHGUI_InitMeshDlg();
~SMESHGUI_InitMeshDlg();
void setMeshName( const QString& );
// purpose :
//=================================================================================
SMESHGUI_InitMeshOp::SMESHGUI_InitMeshOp()
-: SMESHGUI_Operation(),
- myDlg( 0 ),
- myGeomFilter( 0 ),
- myHypothesisFilter( 0 ),
- myAlgorithmFilter( 0 )
+: SMESHGUI_SelectionOp(),
+ myDlg( 0 )
{
setAutoResumed( true );
}
{
if( myDlg )
delete myDlg;
-
- if( myGeomFilter )
- delete myGeomFilter;
-
- if( myAlgorithmFilter )
- delete myAlgorithmFilter;
-
- if( myHypothesisFilter )
- delete myHypothesisFilter;
}
//=================================================================================
{
if( !myDlg )
{
- myDlg = new SMESHGUI_InitMeshDlg( getSMESHGUI() );
- connect( myDlg, SIGNAL( objectActivated( int ) ), this, SLOT( onActivateObject( int ) ) );
- }
-
- SMESHGUI_Operation::startOperation();
-
- if( !myGeomFilter )
- {
- TColStd_MapOfInteger allTypesMap;
- for (int i = 0; i < 10; i++)
- allTypesMap.Add(i);
- myGeomFilter = new SMESH_NumberFilter ("GEOM", TopAbs_SHAPE, 0, allTypesMap);
+ myDlg = new SMESHGUI_InitMeshDlg();
+ connect( myDlg, SIGNAL( nameChanged( const QString& ) ), this, SLOT( onNameChanged( const QString& ) ) );
}
- if( !myAlgorithmFilter )
- myAlgorithmFilter = new SMESH_TypeFilter (ALGORITHM);
+ SMESHGUI_SelectionOp::startOperation();
- if( !myHypothesisFilter )
- myHypothesisFilter = new SMESH_TypeFilter (HYPOTHESIS);
-
- init();
myDlg->show();
}
//=================================================================================
void SMESHGUI_InitMeshOp::selectionDone()
{
- QStringList names, ids;
- SMESHGUI_Dialog::TypesList types;
- selected( names, types, ids );
+ SMESHGUI_SelectionOp::selectionDone();
if( myDlg )
- {
- myDlg->selectObject( names, types, ids );
- myDlg->updateControlState();
- }
+ updateDialog();
}
//=================================================================================
-// function : onActivateObject
+// function : createFilter
// purpose :
//=================================================================================
-void SMESHGUI_InitMeshOp::onActivateObject( int obj )
+SUIT_SelectionFilter* SMESHGUI_InitMeshOp::createFilter( const int id ) const
{
- SalomeApp_SelectionMgr* mgr = selectionMgr();
+ if( id==SMESHGUI_InitMeshDlg::GeomObj )
+ {
+ TColStd_MapOfInteger allTypesMap;
+ for (int i = 0; i < 10; i++)
+ allTypesMap.Add(i);
+ return new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, 0, allTypesMap );
+ }
- if( !mgr )
- return;
-
- mgr->clearFilters();
- if( obj==SMESHGUI_InitMeshDlg::GeomObj )
- mgr->installFilter( myGeomFilter );
-
- else if( obj==SMESHGUI_InitMeshDlg::Hypo )
- mgr->installFilter( myHypothesisFilter );
+ else if( id==SMESHGUI_InitMeshDlg::Hypo )
+ return new SMESH_TypeFilter (HYPOTHESIS);
+
+ else if( id==SMESHGUI_InitMeshDlg::Algo )
+ return new SMESH_TypeFilter (ALGORITHM);
- else if( obj==SMESHGUI_InitMeshDlg::Algo )
- mgr->installFilter( myAlgorithmFilter );
+ else
+ return 0;
}
//=================================================================================
update( UF_Model | UF_ObjBrowser );
- init();
+ initDialog();
return true;
}
// function : init()
// purpose :
//=================================================================================
-void SMESHGUI_InitMeshOp::init()
+void SMESHGUI_InitMeshOp::initDialog()
{
+ SMESHGUI_SelectionOp::initDialog();
if( myDlg )
{
myDlg->setMeshName( defaultMeshName() );
- myDlg->clearSelection();
- myDlg->updateControlState();
+ updateDialog();
}
}
}
}
+//=================================================================================
+// function : onNameChanged()
+// purpose :
+//=================================================================================
+void SMESHGUI_InitMeshOp::onNameChanged( const QString& )
+{
+ updateDialog();
+}
+
+//=================================================================================
+// function : updateDialog()
+// purpose :
+//=================================================================================
+void SMESHGUI_InitMeshOp::updateDialog()
+{
+ if( !myDlg )
+ return;
+
+ bool isEnabled = !myDlg->meshName().isEmpty() &&
+ myDlg->hasSelection( SMESHGUI_InitMeshDlg::GeomObj ) &&
+ myDlg->hasSelection( SMESHGUI_InitMeshDlg::Hypo ) &&
+ myDlg->hasSelection( SMESHGUI_InitMeshDlg::Algo );
+ myDlg->setButtonEnabled( isEnabled, QtxDialog::OK | QtxDialog::Apply );
+}
+
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool SMESHGUI_InitMeshOp::isValid( SUIT_Operation* theOtherOp ) const
{
- if ( theOtherOp && theOtherOp->inherits( "SMESHGUI_AddSubMeshOp" ) )
+ //if ( theOtherOp && theOtherOp->inherits( "SMESHGUI_AddSubMeshOp" ) )
return true;
- else
+ /*else
return false;
-
+ */
}
-
-
-
-
-
-
-
-
-
-
-
-
-
#ifndef OPERATION_INIT_MESH_H
#define OPERATION_INIT_MESH_H
-#include <SMESHGUI_Operation.h>
+#include <SMESHGUI_SelectionOp.h>
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include CORBA_SERVER_HEADER(SMESH_Gen)
class SMESHGUI_InitMeshDlg;
-class SUIT_SelectionFilter;
//=================================================================================
// class : SMESHGUI_InitMeshOp
// purpose :
//=================================================================================
-class SMESHGUI_InitMeshOp : public SMESHGUI_Operation
+class SMESHGUI_InitMeshOp : public SMESHGUI_SelectionOp
{
Q_OBJECT
~SMESHGUI_InitMeshOp();
virtual SalomeApp_Dialog* dlg() const;
- void init();
+ virtual void initDialog();
+
QString defaultMeshName() const;
virtual bool isValid( SUIT_Operation* theOtherOp ) const;
protected:
virtual void startOperation();
virtual void selectionDone();
+ virtual SUIT_SelectionFilter* createFilter( const int ) const;
SMESH::SMESH_Mesh_var initMesh( GEOM::GEOM_Object_ptr, const QString& );
+ void updateDialog();
+
protected slots:
virtual bool onApply();
+ virtual void onSelectionChanged( int );
private slots:
- void onActivateObject( int );
- void onSelectionChanged( int );
+ void onNameChanged( const QString& );
private:
SMESHGUI_InitMeshDlg *myDlg;
- SUIT_SelectionFilter *myGeomFilter, *myHypothesisFilter, *myAlgorithmFilter;
};
#endif // OPERATION_INIT_MESH_H
// class : SMESHGUI_NodesDlg()
// purpose :
//=================================================================================
-SMESHGUI_NodesDlg::SMESHGUI_NodesDlg( SMESHGUI* theModule )
-: SMESHGUI_Dialog( theModule, false, false, OK | Apply | Close )
+SMESHGUI_NodesDlg::SMESHGUI_NodesDlg()
+: SMESHGUI_Dialog( false, false, OK | Apply | Close )
{
QPixmap image0( resMgr()->loadPixmap("SMESH", tr("ICON_DLG_NODE")));
setName("SMESHGUI_NodesDlg");
connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SIGNAL(valueChanged(double)));
SMESHGUI_NodesDlgLayout->addWidget(GroupCoordinates, 1, 0);
+
+ setFocusProxy( SpinBox_X );
}
//=======================================================================
SpinBox_X->setValue( x );
SpinBox_Y->setValue( y );
SpinBox_Z->setValue( z );
- SpinBox_X->clearFocus();
- SpinBox_Y->clearFocus();
- SpinBox_Z->clearFocus();
}
Q_OBJECT
public:
- SMESHGUI_NodesDlg( SMESHGUI* );
+ SMESHGUI_NodesDlg();
~SMESHGUI_NodesDlg();
void coords( double&, double&, double& ) const;
{
if( !myDlg )
{
- myDlg = new SMESHGUI_NodesDlg( getSMESHGUI() );
+ myDlg = new SMESHGUI_NodesDlg();
connect( myDlg, SIGNAL( valueChanged( double ) ), this, SLOT( onValueChanged( double ) ) );
connect( myDlg, SIGNAL( dlgClose() ), this, SLOT( onCancel() ) );
}
SMESHGUI_SelectionOp::startOperation();
-
+
mySimulation = new SMESH::TNodeSimulation( viewWindow() );
myDlg->show();
}
//=================================================================================
void SMESHGUI_NodesOp::commitOperation()
{
- delete mySimulation;
+ if( mySimulation )
+ delete mySimulation;
mySimulation = 0;
SMESHGUI_SelectionOp::commitOperation();
}
//=================================================================================
void SMESHGUI_NodesOp::abortOperation()
{
- delete mySimulation;
+ if( mySimulation )
+ delete mySimulation;
mySimulation = 0;
SMESHGUI_SelectionOp::abortOperation();
}
virtual void commitOperation();
virtual void abortOperation();
- void initDialog();
+ virtual void initDialog();
protected slots:
virtual bool onApply();