#include "SVTK_RenderWindowInteractor.h"
#include "VVTK_Renderer.h"
+#include "VVTK_PickingDlg.h"
#include "VVTK_SegmentationCursorDlg.h"
#include "SUIT_ResourceMgr.h"
connect(anAction, SIGNAL(toggled(bool)), this, SLOT(OnSelectionModeSwitch(bool)));
anAction->addTo( myPtsToolBar );
+ myPickingDlg = new VVTK_PickingDlg( this, "PickingDlg" );
+ myPickingDlg->SetAction( anAction );
+
aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_PLANE_SEGMENTATION_SWITCH"));
anAction = new QtxAction(tr("MNU_VVTK_PLANE_SEGMENTATION_SWITCH"),
aPixmap,
theName,
theResourceMgr,
this,
- myStyleSwitchAction);
+ myStyleSwitchAction,
+ myPickingDlg);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_MainWindow1
+::OnSelectionModeSwitch(bool theIsSelectionOn)
+{
+ VVTK_MainWindow::OnSelectionModeSwitch(theIsSelectionOn);
+
+ if( theIsSelectionOn )
+ {
+ myPickingDlg->Update();
+ myPickingDlg->show();
+ }
+ else
+ myPickingDlg->hide();
}
::AddActor(VTKViewer_Actor* theActor,
bool theIsUpdate)
{
- if(VISU_GaussPtsAct1* anActor = dynamic_cast<VISU_GaussPtsAct1*>(theActor))
- mySegmentationCursorDlg->AddActor( anActor );
+ if(VISU_GaussPtsAct1* anActor1 = dynamic_cast<VISU_GaussPtsAct1*>(theActor))
+ mySegmentationCursorDlg->AddActor( anActor1 );
+
+ if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor))
+ myPickingDlg->AddActor( anActor );
SVTK_MainWindow::AddActor( theActor, theIsUpdate );
}
::RemoveActor(VTKViewer_Actor* theActor,
bool theIsUpdate)
{
- if(VISU_GaussPtsAct1* anActor = dynamic_cast<VISU_GaussPtsAct1*>(theActor))
- mySegmentationCursorDlg->RemoveActor( anActor );
+ if(VISU_GaussPtsAct1* anActor1 = dynamic_cast<VISU_GaussPtsAct1*>(theActor))
+ mySegmentationCursorDlg->RemoveActor( anActor1 );
+
+ if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor))
+ myPickingDlg->RemoveActor( anActor );
SVTK_MainWindow::RemoveActor( theActor, theIsUpdate );
}
const char* theName,
SUIT_ResourceMgr* theResourceMgr,
VVTK_MainWindow1* theMainWindow,
- QtxAction* theStyleSwitchAction):
+ QtxAction* theStyleSwitchAction,
+ VVTK_PickingDlg* thePickingDlg):
VVTK_MainWindow(theParent,theName,theResourceMgr),
- myMainWindow(theMainWindow)
+ myMainWindow(theMainWindow),
+ myPickingDlg(thePickingDlg)
{
connect(theStyleSwitchAction, SIGNAL(toggled(bool)), this, SLOT(OnInteractorStyleSwitch(bool)));
}
::~VVTK_MainWindow2()
{}
+//----------------------------------------------------------------------------
+void
+VVTK_MainWindow2
+::AddActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate)
+{
+ if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor))
+ myPickingDlg->AddActor( anActor );
+
+ SVTK_MainWindow::AddActor( theActor, theIsUpdate );
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_MainWindow2
+::RemoveActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate)
+{
+ if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor))
+ myPickingDlg->RemoveActor( anActor );
+
+ SVTK_MainWindow::RemoveActor( theActor, theIsUpdate );
+}
+
//----------------------------------------------------------------------------
QSize
VVTK_MainWindow2
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : VVTK_PickingDlg.cxx
+// Author : Oleg Uvarov
+// Module : VISU
+
+#include "VVTK_PickingDlg.h"
+
+#include "VISU_GaussPtsAct.h"
+
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+
+#include <vtkActorCollection.h>
+#include <vtkCallbackCommand.h>
+#include <vtkObjectFactory.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkSmartPointer.h>
+
+#include "utilities.h"
+
+#include <qcombobox.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qvbox.h>
+
+#include "QtxAction.h"
+#include "QtxDblSpinBox.h"
+#include "QtxIntSpinBox.h"
+
+using namespace std;
+
+VVTK_PickingDlg::VVTK_PickingDlg( QWidget* parent, const char* name )
+ :QDialog( parent, name, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
+ myPickingSettings( VISU_PickingSettings::New() )
+{
+ SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+
+ setCaption( tr( "PICKING_DLG_TITLE" ) );
+ setSizeGripEnabled(TRUE);
+
+ QVBoxLayout* TopLayout = new QVBoxLayout( this );
+ TopLayout->setSpacing(6);
+ TopLayout->setMargin(11);
+
+ QVBox* aBox = new QVBox( this );
+ aBox->setMargin(0);
+ aBox->setSpacing(6);
+
+ // Cursor
+ QGroupBox* CursorGroup = new QGroupBox( tr( "CURSOR_TITLE" ), aBox, "CursorGroup" );
+ CursorGroup->setColumnLayout(0, Qt::Vertical );
+ CursorGroup->layout()->setSpacing( 0 );
+ CursorGroup->layout()->setMargin( 0 );
+
+ QGridLayout* CursorGroupLayout = new QGridLayout (CursorGroup->layout());
+ CursorGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ CursorGroupLayout->setSpacing(6);
+ CursorGroupLayout->setMargin(11);
+
+ QLabel* PyramidHeightLabel = new QLabel( tr( "PYRAMID_HEIGHT" ), CursorGroup );
+ myPyramidHeightSpinBox = new QtxDblSpinBox( 1.0, 100.0, 1.0, CursorGroup );
+ myPyramidHeightSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ CursorGroupLayout->addWidget( PyramidHeightLabel, 0, 0 );
+ CursorGroupLayout->addWidget( myPyramidHeightSpinBox, 0, 1 );
+
+ // Information window
+ QGroupBox* InfoWindowGroup = new QGroupBox( tr( "INFO_WINDOW_TITLE" ), aBox, "InfoWindowGroup" );
+ InfoWindowGroup->setColumnLayout(0, Qt::Vertical );
+ InfoWindowGroup->layout()->setSpacing( 0 );
+ InfoWindowGroup->layout()->setMargin( 0 );
+
+ QGridLayout* InfoWindowGroupLayout = new QGridLayout (InfoWindowGroup->layout());
+ InfoWindowGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ InfoWindowGroupLayout->setSpacing(6);
+ InfoWindowGroupLayout->setMargin(11);
+
+ QLabel* TransparencyLabel = new QLabel( tr( "TRANSPARENCY" ), InfoWindowGroup );
+ myTransparencySpinBox = new QtxDblSpinBox( 0.0, 1.0, 0.1, InfoWindowGroup );
+ myTransparencySpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 );
+ InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 );
+
+ QLabel* PositionLabel = new QLabel( tr( "POSITION" ), InfoWindowGroup );
+ myPositionComboBox = new QComboBox( InfoWindowGroup );
+ myPositionComboBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ myPositionComboBox->insertItem( tr( "BELOW_POINT" ) );
+ myPositionComboBox->insertItem( tr( "TOP_LEFT_CORNER" ) );
+
+ InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 );
+ InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 );
+ InfoWindowGroupLayout->addWidget( PositionLabel, 0, 2 );
+ InfoWindowGroupLayout->addWidget( myPositionComboBox, 0, 3 );
+
+ // Movement of the camera
+ QGroupBox* CameraGroup = new QGroupBox( tr( "CAMERA_TITLE" ), aBox, "CameraGroup" );
+ CameraGroup->setColumnLayout(0, Qt::Vertical );
+ CameraGroup->layout()->setSpacing( 0 );
+ CameraGroup->layout()->setMargin( 0 );
+
+ QGridLayout* CameraGroupLayout = new QGridLayout (CameraGroup->layout());
+ CameraGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ CameraGroupLayout->setSpacing(6);
+ CameraGroupLayout->setMargin(11);
+
+ QLabel* ZoomFactorLabel = new QLabel( tr( "ZOOM_FACTOR" ), CameraGroup );
+ myZoomFactorSpinBox = new QtxDblSpinBox( 0.1, 10.0, 0.1, CameraGroup );
+ myZoomFactorSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ QLabel* StepNumberLabel = new QLabel( tr( "STEP_NUMBER" ), CameraGroup );
+ myStepNumberSpinBox = new QtxIntSpinBox( 1, 100, 1, CameraGroup );
+ myStepNumberSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ CameraGroupLayout->addWidget( ZoomFactorLabel, 0, 0 );
+ CameraGroupLayout->addWidget( myZoomFactorSpinBox, 0, 1 );
+ CameraGroupLayout->addWidget( StepNumberLabel, 1, 0 );
+ CameraGroupLayout->addWidget( myStepNumberSpinBox, 1, 1 );
+
+
+ // Common buttons ===========================================================
+ QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
+ GroupButtons->setColumnLayout(0, Qt::Vertical );
+ GroupButtons->layout()->setSpacing( 0 );
+ GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );
+ GroupButtonsLayout->setSpacing( 6 );
+ GroupButtonsLayout->setMargin( 11 );
+
+ QPushButton* buttonApply = new QPushButton( tr( "&Apply" ), GroupButtons, "buttonApply" );
+ buttonApply->setAutoDefault( TRUE );
+ buttonApply->setDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonApply, 0, 0 );
+ GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
+
+ QPushButton* buttonClose = new QPushButton( tr( "&Close" ) , GroupButtons, "buttonClose" );
+ buttonClose->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonClose, 0, 2 );
+
+ TopLayout->addWidget( aBox );
+ TopLayout->addWidget( GroupButtons );
+
+ connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onClickApply() ) );
+ connect( buttonClose, SIGNAL( clicked() ), this, SLOT( onClickClose() ) );
+}
+
+VVTK_PickingDlg::~VVTK_PickingDlg()
+{
+}
+
+void VVTK_PickingDlg::AddActor( VISU_GaussPtsAct* theActor )
+{
+ theActor->SetPickingSettings( myPickingSettings.GetPointer() );
+}
+
+void VVTK_PickingDlg::RemoveActor( VISU_GaussPtsAct* theActor )
+{
+ theActor->SetPickingSettings( NULL );
+}
+
+void VVTK_PickingDlg::Update()
+{
+ float aPyramidHeight = 10.0;
+ float anInfoWindowTransparency = 0.5;
+ int anInfoWindowPosition = VISU_PickingSettings::BelowPoint;
+ float aZoomFactor = 1.5;
+ int aStepNumber = 10;
+
+ if( !myPickingSettings->GetInitial() )
+ {
+ myPyramidHeightSpinBox->setValue( myPickingSettings->GetPyramidHeight() );
+ myTransparencySpinBox->setValue( myPickingSettings->GetInfoWindowTransparency() );
+ myPositionComboBox->setCurrentItem( myPickingSettings->GetInfoWindowPosition() );
+ myZoomFactorSpinBox->setValue( myPickingSettings->GetZoomFactor() );
+ myStepNumberSpinBox->setValue( myPickingSettings->GetStepNumber() );
+
+ return;
+ }
+
+ SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+
+ aPyramidHeight = aResourceMgr->doubleValue( "VISU", "picking_pyramid_height", aPyramidHeight );
+ myPyramidHeightSpinBox->setValue( aPyramidHeight );
+
+ anInfoWindowTransparency = aResourceMgr->doubleValue( "VISU", "picking_transparency", anInfoWindowTransparency );
+ myTransparencySpinBox->setValue( anInfoWindowTransparency );
+
+ anInfoWindowPosition = aResourceMgr->integerValue( "VISU", "picking_position", anInfoWindowPosition );
+ myPositionComboBox->setCurrentItem( anInfoWindowPosition );
+
+ aZoomFactor = aResourceMgr->doubleValue( "VISU", "picking_zoom_factor", aZoomFactor );
+ myZoomFactorSpinBox->setValue( aZoomFactor );
+
+ aStepNumber = aResourceMgr->integerValue( "VISU", "picking_step_number", aStepNumber );
+ myStepNumberSpinBox->setValue( aStepNumber );
+
+ onClickApply();
+}
+
+void VVTK_PickingDlg::onClickApply()
+{
+ myPickingSettings->SetInitial( false );
+
+ myPickingSettings->SetPyramidHeight( myPyramidHeightSpinBox->value() );
+ myPickingSettings->SetInfoWindowTransparency( myTransparencySpinBox->value() );
+ myPickingSettings->SetInfoWindowPosition( myPositionComboBox->currentItem() );
+ myPickingSettings->SetZoomFactor( myZoomFactorSpinBox->value() );
+ myPickingSettings->SetStepNumber( myStepNumberSpinBox->value() );
+
+ myPickingSettings->InvokeEvent(vtkCommand::ModifiedEvent,NULL);
+}
+
+void VVTK_PickingDlg::onClickClose()
+{
+ myAction->setOn( false );
+
+ reject();
+}
+
+void VVTK_PickingDlg::closeEvent( QCloseEvent* )
+{
+ myAction->setOn( false );
+}