// 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
//
//
//
#include "SUIT_ViewWindow.h"
#include "SUIT_ViewManager.h"
#include "SUIT_MessageBox.h"
+#include "SUIT_Desktop.h"
#include "SalomeApp_Study.h"
-#include "SalomeApp_Application.h"
+#include "LightApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "SVTK_Selector.h"
#include "SVTK_ViewWindow.h"
+#include "VTKViewer_CellLocationsArray.h"
#include "SALOME_Actor.h"
#include "SALOME_ListIO.hxx"
-#include "SVTK_Selection.h"
#include "utilities.h"
// VTK Includes
#include <vtkCell.h>
#include <vtkIdList.h>
-#include <vtkIntArray.h>
#include <vtkCellArray.h>
#include <vtkUnsignedCharArray.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
#include <vtkActorCollection.h>
#include <vtkRenderer.h>
+#include <vtkProperty.h>
// QT Includes
#include <qbuttongroup.h>
}
class TNodeSimulation {
- SalomeApp_Application* myApplication;
- SUIT_ViewWindow* myViewWindow;
- SVTK_ViewWindow* myVTKViewWindow;
+ SVTK_ViewWindow* myViewWindow;
SALOME_Actor *myPreviewActor;
vtkDataSetMapper* myMapper;
vtkPoints* myPoints;
public:
- TNodeSimulation (SalomeApp_Application* theApplication)
+ TNodeSimulation(SVTK_ViewWindow* theViewWindow):
+ myViewWindow(theViewWindow)
{
- myApplication = theApplication;
- SUIT_ViewManager* mgr = theApplication->activeViewManager();
- if (!mgr) return;
- myViewWindow = mgr->getActiveView();
- myVTKViewWindow = GetVtkViewWindow(myViewWindow);
-
vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
// Create points
aCells->InsertNextCell(anIdList);
aCellTypesArray->InsertNextValue(VTK_VERTEX);
- vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+ VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
aCellLocationsArray->SetNumberOfComponents(1);
aCellLocationsArray->SetNumberOfTuples(1);
vtkProperty* aProp = vtkProperty::New();
aProp->SetRepresentationToPoints();
- float anRGB[3];
- anRGB[0] = GetFloat("SMESH:SettingsNodeColorRed",0)/255.;
- anRGB[1] = GetFloat("SMESH:SettingsNodeColorGreen",255)/255.;
- anRGB[2] = GetFloat("SMESH:SettingsNodeColorBlue",0)/255.;
- aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
+ vtkFloatingPointType anRGB[3];
+ GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
+ aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
- float aPointSize = GetFloat("SMESH:SettingsNodesSize",3);
- aProp->SetPointSize(aPointSize);
+ vtkFloatingPointType aPointSize = GetFloat( "SMESH:node_size", 3 );
+ aProp->SetPointSize( aPointSize );
- myPreviewActor->SetProperty(aProp);
+ myPreviewActor->SetProperty( aProp );
aProp->Delete();
- myVTKViewWindow->AddActor(myPreviewActor);
+ myViewWindow->AddActor(myPreviewActor);
}
void SetPosition (float x, float y, float z)
~TNodeSimulation()
{
- if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) {
- myVTKViewWindow->RemoveActor(myPreviewActor);
- }
+ myViewWindow->RemoveActor(myPreviewActor);
myPreviewActor->Delete();
myMapper->RemoveAllInputs();
// class : SMESHGUI_NodesDlg()
// purpose :
//=================================================================================
-SMESHGUI_NodesDlg::SMESHGUI_NodesDlg (QWidget* parent,
+SMESHGUI_NodesDlg::SMESHGUI_NodesDlg (SMESHGUI* theModule,
const char* name,
- SalomeApp_SelectionMgr* Sel,
bool modal,
- WFlags fl)
- : QDialog(parent, name, modal, WStyle_Customize | WStyle_NormalBorder |
- WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose)
+ WFlags fl):
+ QDialog(SMESH::GetDesktop(theModule),
+ name,
+ modal,
+ WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
+ mySelector(SMESH::GetViewWindow(theModule)->GetSelector()),
+ mySelectionMgr(SMESH::GetSelectionMgr(theModule)),
+ mySMESHGUI(theModule)
{
- SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
- (SUIT_Session::session()->activeApplication());
- mySimulation = new SMESH::TNodeSimulation (anApp);
+ mySimulation = new SMESH::TNodeSimulation(SMESH::GetViewWindow( mySMESHGUI ));
- QPixmap image0 (SMESHGUI::resourceMgr()->loadPixmap("SMESH", tr("ICON_DLG_NODE")));
+ QPixmap image0 (SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap("SMESH", tr("ICON_DLG_NODE")));
if (!name)
setName("SMESHGUI_NodesDlg");
resize(303, 185);
GroupButtonsLayout->setAlignment(Qt::AlignTop);
GroupButtonsLayout->setSpacing(6);
GroupButtonsLayout->setMargin(11);
+ buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
+ buttonHelp->setText(tr("SMESH_BUT_HELP" ));
+ buttonHelp->setAutoDefault(TRUE);
+ GroupButtonsLayout->addWidget(buttonHelp, 0, 4);
buttonCancel = new QPushButton(GroupButtons, "buttonCancel");
buttonCancel->setText(tr("SMESH_BUT_CLOSE" ));
buttonCancel->setAutoDefault(TRUE);
SMESHGUI_NodesDlgLayout->addWidget(GroupCoordinates, 1, 0);
+ myHelpFileName = "/files/adding_nodes_and_elements.htm#Adding_nodes";
+
/* Initialisation and display */
- Init(Sel);
+ Init();
}
//=======================================================================
// function : Init()
// purpose :
//=================================================================================
-void SMESHGUI_NodesDlg::Init (SalomeApp_SelectionMgr* Sel)
+void SMESHGUI_NodesDlg::Init ()
{
/* Get setting of step value from file configuration */
double step;
step = 25.0;
/* min, max, step and decimals for spin boxes */
- SpinBox_X->RangeStepAndValidator(-999.999, +999.999, step, 3);
- SpinBox_Y->RangeStepAndValidator(-999.999, +999.999, step, 3);
- SpinBox_Z->RangeStepAndValidator(-999.999, +999.999, step, 3);
+ SpinBox_X->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
+ SpinBox_Y->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
+ SpinBox_Z->RangeStepAndValidator(COORD_MIN, COORD_MAX, step, 3);
SpinBox_X->SetValue(0.0);
SpinBox_Y->SetValue(0.0);
SpinBox_Z->SetValue(0.0);
- mySelectionMgr = Sel;
- myMeshGUI = SMESHGUI::GetSMESHGUI();
- myMeshGUI->SetActiveDialogBox((QDialog*)this);
+ mySMESHGUI->SetActiveDialogBox((QDialog*)this);
/* signals and slots connections */
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
+ connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
connect(SpinBox_X, SIGNAL (valueChanged(double)), SLOT(ValueChangedInSpinBox(double)));
connect(SpinBox_Y, SIGNAL (valueChanged(double)), SLOT(ValueChangedInSpinBox(double)));
connect(SpinBox_Z, SIGNAL (valueChanged(double)), SLOT(ValueChangedInSpinBox(double)));
connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(SelectionIntoArgument()));
- connect(myMeshGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
+ connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), SLOT(DeactivateActiveDialog()));
/* to close dialog if study frame change */
- connect(myMeshGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel()));
+ connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), SLOT(ClickOnCancel()));
- /* Move widget on the botton right corner of main widget */
- int x, y;
- myMeshGUI->DefineDlgPosition(this, x, y);
- this->move(x, y);
this->show();
// set selection mode
SMESH::SetPointRepresentation(true);
-#ifdef NEW_GUI
- mySelectionMgr->setSelectionModes(NodeSelection, true);
-#else
- mySelectionMgr->setSelectionModes(NodeSelection);
-#endif
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(NodeSelection);
SelectionIntoArgument();
}
//=================================================================================
bool SMESHGUI_NodesDlg::ClickOnApply()
{
- if (myMeshGUI->isActiveStudyLocked())
+ if (mySMESHGUI->isActiveStudyLocked())
return false;
if (myMesh->_is_nil()) {
if (anActor->hasIO()) {
if (SMESH_MeshObj *aMeshObj = dynamic_cast<SMESH_MeshObj*>(anActor->GetObject().get())) {
if (myMesh->_is_equivalent(aMeshObj->GetMeshServer())) {
-#ifdef NEW_GUI
- mySelectionMgr->clearSelected();
- mySelectionMgr->AddIObject(anActor->getIO(), false);
-#else
aList.Clear();
aList.Append(anActor->getIO());
mySelectionMgr->setSelectedObjects(aList, false);
-#endif
break;
}
}
//=================================================================================
void SMESHGUI_NodesDlg::ClickOnCancel()
{
- MESSAGE("SMESHGUI_NodesDlg::ClickOnCancel() 1");
disconnect(mySelectionMgr, 0, this, 0);
- mySelectionMgr->clearSelected();
- mySelectionMgr->setSelectionModes(ActorSelection);
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(ActorSelection);
- MESSAGE("SMESHGUI_NodesDlg::ClickOnCancel() 2");
mySimulation->SetVisibility(false);
SMESH::SetPointRepresentation(false);
- myMeshGUI->ResetState();
+ mySMESHGUI->ResetState();
reject();
- MESSAGE("SMESHGUI_NodesDlg::ClickOnCancel() 3");
+}
+
+//=================================================================================
+// function : ClickOnHelp()
+// purpose :
+//=================================================================================
+void SMESHGUI_NodesDlg::ClickOnHelp()
+{
+ LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app)
+ app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
+ else {
+ SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
+ QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
+ QObject::tr("BUT_OK"));
+ }
}
//=================================================================================
mySimulation->SetVisibility(false);
SMESH::SetPointRepresentation(true);
- SALOME_ListIO aList;
- mySelectionMgr->selectedObjects(aList);
+ const SALOME_ListIO& aList = mySelector->StoredIObjects();
if (aList.Extent() == 1) {
Handle(SALOME_InteractiveObject) anIO = aList.First();
if (anIO->hasEntry()) {
myMesh = SMESH::GetMeshByIO(anIO);
if (myMesh->_is_nil()) return;
QString aText;
- if (SMESH::GetNameOfSelectedNodes(mySelectionMgr, aText) == 1) {
+ if (SMESH::GetNameOfSelectedNodes(mySelector,anIO,aText) == 1) {
if (SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh.in())) {
if (SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh()) {
if (const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) {
GroupCoordinates->setEnabled(false);
GroupButtons->setEnabled(false);
mySimulation->SetVisibility(false);
- myMeshGUI->ResetState();
- myMeshGUI->SetActiveDialogBox(0);
+ mySMESHGUI->ResetState();
+ mySMESHGUI->SetActiveDialogBox(0);
}
}
//=================================================================================
void SMESHGUI_NodesDlg::ActivateThisDialog()
{
- myMeshGUI->EmitSignalDeactivateDialog();
+ mySMESHGUI->EmitSignalDeactivateDialog();
GroupConstructors->setEnabled(true);
GroupCoordinates->setEnabled(true);
GroupButtons->setEnabled(true);
SMESH::SetPointRepresentation(true);
-#ifdef NEW_GUI
- mySelectionMgr->setSelectionModes(NodeSelection, true);
-#else
- mySelectionMgr->setSelectionModes(NodeSelection);
-#endif
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode(NodeSelection);
SelectionIntoArgument();
}
+
+//=================================================================================
+// function : keyPressEvent()
+// purpose :
+//=================================================================================
+void SMESHGUI_NodesDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Key_F1 )
+ {
+ e->accept();
+ ClickOnHelp();
+ }
+}