-// SMESH SMESHGUI : GUI for SMESH component
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// Copyright (C) 2003-2007 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
// 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
-//
-//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// SMESH SMESHGUI : GUI for SMESH component
// File : SMESHGUI_AddMeshElementDlg.cxx
// Author : Nicolas REJNERI
// Module : SMESH
// $Header$
-
+//
#include "SMESHGUI_AddMeshElementDlg.h"
#include "SMESHGUI.h"
#include "SMESH_Actor.h"
#include "SUIT_Session.h"
+#include "SUIT_MessageBox.h"
+#include "LightApp_Application.h"
#include "SVTK_Selection.h"
#include "SVTK_Selector.h"
#include "utilities.h"
+#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
+
// OCCT Includes
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
#include <vtkUnsignedCharArray.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
+#include <vtkProperty.h>
// QT Includes
#include <qbuttongroup.h>
myPreviewActor->VisibilityOff();
myPreviewActor->SetMapper(myMapper);
+ vtkFloatingPointType anRGB[3];
vtkProperty* aProp = vtkProperty::New();
- float anRGB[3];
- anRGB[0] = GetFloat("SMESH:SettingsFillColorRed", 0)/255.;
- anRGB[1] = GetFloat("SMESH:SettingsFillColorGreen", 170)/255.;
- anRGB[2] = GetFloat("SMESH:SettingsFillColorBlue", 255)/255.;
- aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
- myPreviewActor->SetProperty(aProp);
+ 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();
- anRGB[0] = GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.;
- anRGB[1] = GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.;
- anRGB[2] = GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.;
- aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
- myPreviewActor->SetBackfaceProperty(aBackProp);
+ 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);
: 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() )
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
{
SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
(SUIT_Session::session()->activeApplication());
myIsPoly = false;
mySimulation = new SMESH::TElementSimulation (anApp);
+ mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
// verify nb nodes and type
myNbNodes = nbNodes;
}
QString elemName;
- if (myNbNodes == 2)
+ if (myNbNodes == 2) {
elemName = "EDGE";
- else if (myNbNodes == 3)
+ myHelpFileName = "adding_nodes_and_elements_page.html#adding_edges_anchor";
+ }
+ else if (myNbNodes == 3) {
elemName = "TRIANGLE";
+ myHelpFileName = "adding_nodes_and_elements_page.html#adding_triangles_anchor";
+ }
else if (myNbNodes == 4)
- if (myElementType == SMDSAbs_Face)
+ if (myElementType == SMDSAbs_Face) {
elemName = "QUADRANGLE";
- else
+ myHelpFileName = "adding_nodes_and_elements_page.html#adding_quadrangles_anchor";
+ }
+ else {
elemName = "TETRAS";
- else if (myNbNodes == 8)
+ myHelpFileName = "adding_nodes_and_elements_page.html#adding_tetrahedrons_anchor";
+ }
+ else if (myNbNodes == 8) {
elemName = "HEXAS";
- else if (myElementType == SMDSAbs_Face){
+ myHelpFileName = "adding_nodes_and_elements_page.html#adding_hexahedrons_anchor";
+ }
+ else if (myElementType == SMDSAbs_Face) {
elemName = "POLYGON";
myIsPoly = true;
+ myHelpFileName = "adding_nodes_and_elements_page.html#adding_polygons_anchor";
+ }
+ else if (myElementType == SMDSAbs_Volume) {
+ myHelpFileName = "adding_nodes_and_elements_page.html#adding_polyhedrons_anchor";
}
QString iconName = tr(QString("ICON_DLG_%1").arg(elemName));
QString caption = tr(QString("SMESH_ADD_%1_TITLE").arg(elemName));
QString grBoxTitle = tr(QString("SMESH_ADD_%1").arg(elemName));
- QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", iconName));
- QPixmap image1 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_SELECT")));
+ QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", iconName));
+ QPixmap image1 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_SELECT")));
if (!name)
setName("SMESHGUI_AddMeshElementDlg");
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->setText(tr("SMESH_BUT_APPLY_AND_CLOSE" ));
buttonOk->setAutoDefault(TRUE);
buttonOk->setDefault(TRUE);
GroupButtonsLayout->addWidget(buttonOk, 0, 0);
+ buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
+ buttonHelp->setText(tr("SMESH_BUT_HELP" ));
+ buttonHelp->setAutoDefault(TRUE);
+ GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
+
SMESHGUI_AddMeshElementDlgLayout->addWidget(GroupButtons, 2, 0);
/***************************************************************/
connect(buttonOk, SIGNAL(clicked()), SLOT(ClickOnOk()));
connect(buttonCancel, SIGNAL(clicked()), SLOT(ClickOnCancel()));
connect(buttonApply, SIGNAL(clicked()), SLOT(ClickOnApply()));
+ connect(buttonHelp, SIGNAL(clicked()), SLOT(ClickOnHelp()));
connect(SelectButtonC1A1, SIGNAL(clicked()), SLOT(SetEditCurrentArgument()));
connect(LineEditC1A1, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
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 );
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode( NodeSelection );
myBusy = false;
switch (myElementType) {
case SMDSAbs_Edge:
aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break;
- case SMDSAbs_Face:
- aMeshEditor->AddFace(anArrayOfIdeces.inout()); break;
+ case SMDSAbs_Face:{
+ if(myIsPoly)
+ aMeshEditor->AddPolygonalFace(anArrayOfIdeces.inout());
+ else
+ aMeshEditor->AddFace(anArrayOfIdeces.inout());
+ break;
+
+ }
case SMDSAbs_Volume:
aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break;
default:;
}
SALOME_ListIO aList; aList.Append( myActor->getIO() );
+ mySelector->ClearIndex();
mySelectionMgr->setSelectedObjects( aList, false );
SMESH::UpdateView();
//=================================================================================
void SMESHGUI_AddMeshElementDlg::ClickOnCancel()
{
- mySelectionMgr->clearSelected();
+ //mySelectionMgr->clearSelected();
mySimulation->SetVisibility(false);
SMESH::SetPointRepresentation(false);
- myViewWindow->SetSelectionMode( ActorSelection );
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode( ActorSelection );
disconnect(mySelectionMgr, 0, this, 0);
mySMESHGUI->ResetState();
reject();
return;
}
+//=================================================================================
+// function : ClickOnHelp()
+// purpose :
+//=================================================================================
+void SMESHGUI_AddMeshElementDlg::ClickOnHelp()
+{
+ LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app)
+ app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
+ else {
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
+ QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
+ QObject::tr("BUT_OK"));
+ }
+}
+
//=================================================================================
// function : onTextChange()
// purpose :
aMesh = myActor->GetObject()->GetMesh();
if (aMesh) {
- SALOME_ListIO aList; aList.Append( myActor->getIO() );
- mySelectionMgr->setSelectedObjects( aList, false );
-
- TColStd_IndexedMapOfInteger selectedIndices;
TColStd_MapOfInteger newIndices;
- mySelector->GetIndex(myActor->getIO(), selectedIndices);
-
+
QStringList aListId = QStringList::split(" ", theNewText, false);
+ bool allOk = true;
for (int i = 0; i < aListId.count(); i++) {
if( const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ) )
{
- if( selectedIndices.Add( n->GetID() ) )
- newIndices.Add( n->GetID() );
+ newIndices.Add( n->GetID() );
myNbOkNodes++;
}
+ else
+ allOk = false;
}
- if( newIndices.Extent()>0 )
- {
- mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, true );
- myViewWindow->highlight( myActor->getIO(), true, true );
- }
- bool aNodesOK = false;
- if (myIsPoly && myElementType == SMDSAbs_Face && aListId.count() >=3 ){
- myNbOkNodes = aListId.count();
- aNodesOK = true;
- }
+ mySelector->AddOrRemoveIndex( myActor->getIO(), newIndices, false );
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->highlight( myActor->getIO(), true, true );
+
+ myNbOkNodes = ( allOk && myNbNodes == aListId.count() );
+
+ if (myIsPoly)
+ {
+ if ( !allOk || myElementType != SMDSAbs_Face || aListId.count() < 3 )
+ myNbOkNodes = 0;
+ else
+ myNbOkNodes = aListId.count();
+ }
}
if(myNbOkNodes) {
}
mySimulation->SetPosition(myActor,aType,anIds);
+ SMESH::UpdateView();
}
}
SMESH::SetPointRepresentation(true);
- myViewWindow->SetSelectionMode( NodeSelection );
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode( NodeSelection );
SelectionIntoArgument();
}
displaySimulation();
}
}
+
+//=================================================================================
+// function : keyPressEvent()
+// purpose :
+//=================================================================================
+void SMESHGUI_AddMeshElementDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Key_F1 )
+ {
+ e->accept();
+ ClickOnHelp();
+ }
+}