VisuGUI.cxx \
VisuGUI_Factory.cxx \
VisuGUI_Module.cxx \
- VisuGUI_Selection.cxx \
+ VisuGUI_InputPanel.cxx \
+ VisuGUI_BasePanel.cxx \
+ VisuGUI_SelectionPanel.cxx \
+ VisuGUI_GaussPointsSelectionPane.cxx \
VisuGUI_Tools.cxx \
VisuGUI_ViewTools.cxx \
- VisuGUI_PopupTools.cxx \
+ VisuGUI_Selection.cxx \
VisuGUI_NameDlg.cxx \
VisuGUI_FileDlg.cxx \
VisuGUI_CursorDlg.cxx \
MOC_FILES= \
VisuGUI_moc.cxx \
VisuGUI_Module_moc.cxx \
- VisuGUI_Selection_moc.cxx \
+ VisuGUI_InputPanel_moc.cxx \
+ VisuGUI_BasePanel_moc.cxx \
+ VisuGUI_SelectionPanel_moc.cxx \
+ VisuGUI_GaussPointsSelectionPane_moc.cxx \
VisuGUI_NameDlg_moc.cxx \
VisuGUI_FileDlg_moc.cxx \
VisuGUI_CursorDlg_moc.cxx \
<translation>Vertical</translation>
</message>
</context>
+ <context>
+ <name>VisuGUI_GaussPointsSelectionPane</name>
+ <message>
+ <source>BELOW_POINT</source>
+ <translation>Centered below the point</translation>
+ </message>
+ <message>
+ <source>CAMERA_TITLE</source>
+ <translation>Movement of the camera</translation>
+ </message>
+ <message>
+ <source>CURSOR_SIZE</source>
+ <translation>Size of the cursor :</translation>
+ </message>
+ <message>
+ <source>CURSOR_TITLE</source>
+ <translation>Cursor</translation>
+ </message>
+ <message>
+ <source>DISPLAY_PARENT_MESH</source>
+ <translation>Display parent mesh element</translation>
+ </message>
+ <message>
+ <source>INFO_WINDOW_TITLE</source>
+ <translation>Information window</translation>
+ </message>
+ <message>
+ <source>PARENT_MESH_TITLE</source>
+ <translation>Parent mesh element</translation>
+ </message>
+ <message>
+ <source>PICKING_DLG_TITLE</source>
+ <translation>Picking</translation>
+ </message>
+ <message>
+ <source>POINT_TOLERANCE</source>
+ <translation>Point tolerance :</translation>
+ </message>
+ <message>
+ <source>POSITION</source>
+ <translation>Position :</translation>
+ </message>
+ <message>
+ <source>PYRAMID_HEIGHT</source>
+ <translation>Height of the pyramids :</translation>
+ </message>
+ <message>
+ <source>SELECTION_COLOR</source>
+ <translation>Selection cursor color :</translation>
+ </message>
+ <message>
+ <source>STEP_NUMBER</source>
+ <translation>Number of steps between two positions :</translation>
+ </message>
+ <message>
+ <source>TOLERANCE_TITLE</source>
+ <translation>Tolerance</translation>
+ </message>
+ <message>
+ <source>TOP_LEFT_CORNER</source>
+ <translation>Top-left corner of the 3D view</translation>
+ </message>
+ <message>
+ <source>TRANSPARENCY</source>
+ <translation>Transparency :</translation>
+ </message>
+ <message>
+ <source>ZOOM_FACTOR</source>
+ <translation>Zoom at first selected point (ratio) :</translation>
+ </message>
+ <message>
+ <source>DATA_POSITION</source>
+ <translation>Position</translation>
+ </message>
+ <message>
+ <source>PARENT_ELEMENT</source>
+ <translation>Parent mesh element ID:</translation>
+ </message>
+ <message>
+ <source>LOCAL_POINT</source>
+ <translation>Local Gauss Point ID:</translation>
+ </message>
+ </context>
+ <context>
+ <name>VisuGUI_InputPanel</name>
+ <message>
+ <source>WINDOW_TITLE</source>
+ <translation>Input Panel</translation>
+ </message>
+ </context>
<context>
<name>VisuGUI_InputPane</name>
<message>
</message>
</context>
<context>
- <name>VisuGUI_SelectionDlg</name>
+ <name>VisuGUI_SelectionPanel</name>
<message>
<source>WINDOW_TITLE</source>
<translation>Data on elements</translation>
<source>MODE_TITLE</source>
<translation>Selection</translation>
</message>
+ <message>
+ <source>MODE_GAUSS_POINT</source>
+ <translation>Gauss point</translation>
+ </message>
<message>
<source>MODE_POINT</source>
<translation>Point</translation>
#include "SVTK_ViewWindow.h"
#include "SVTK_ViewModel.h"
#include "SVTK_Functor.h"
+#include "SVTK_MainWindow.h"
#include "SPlot2d_ViewModel.h"
#include "VisuGUI_SetupPlot2dDlg.h"
#include "VisuGUI_Prs3dTools.h"
#include "VisuGUI_Tools.h"
-#include "VisuGUI_PopupTools.h"
+#include "VisuGUI_SelectionPanel.h"
#include "VisuGUI_NameDlg.h"
#include "VisuGUI_CursorDlg.h"
#include "VisuGUI_Selection.h"
#include "VisuGUI_BuildProgressDlg.h"
#include "VisuGUI_TransparencyDlg.h"
#include "VisuGUI_CacheDlg.h"
+#include "VisuGUI_InputPanel.h"
#include "VISU_ScalarMap_i.hh"
#include "VisuGUI_ScalarBarDlg.h"
::VisuGUI():
SalomeApp_Module( "VISU" ),
mySlider( NULL ),
- myDisplayer( 0 )
-{}
-
+ myDisplayer( 0 ),
+ myInputPanel( 0 ),
+ mySelectionPanel( 0 )
+{
+}
VisuGUI
::~VisuGUI()
::OnSelectionInfo()
{
if (GetActiveViewWindow<SVTK_ViewWindow>(this))
- (new VisuGUI_SelectionDlg(this))->show();
+ {
+ if( !mySelectionPanel )
+ mySelectionPanel = new VisuGUI_SelectionPanel( this );
+ inputPanel()->showPanel( mySelectionPanel );
+ }
else
SUIT_MessageBox::warning(GetDesktop(this),
tr("WRN_VISU"),
createMenus();
createToolBars();
createPopupMenus();
+ createInputPanel();
}
void
}
}
+void VisuGUI::createInputPanel()
+{
+ myInputPanel = new VisuGUI_InputPanel();
+ //myInputPanel->resize( getApp()->objectBrowser()->width(), myInputPanel->height() );
+ GetDesktop(this)->addDockWidget( Qt::RightDockWidgetArea, myInputPanel );
+}
+
//***************************************************************************
void VisuGUI::contextMenuPopup( const QString& theClient, QMenu* theMenu, QString& theTitle )
{
setMenuShown( true );
setToolShown( true );
+ myInputPanel->show();
+
// Reset actions accelerator keys
QList<QKeySequence> shortcuts;
shortcuts.append( QKeySequence(Qt::CTRL + Qt::Key_I) );
setMenuShown( false );
setToolShown( false );
+ myInputPanel->clear();
+ myInputPanel->hide();
+
// Unset actions accelerator keys
action(VISU_IMPORT_FROM_FILE)->setShortcuts(QKeySequence::UnknownKey);
class SUIT_ViewManager;
class SVTK_ViewWindow;
class VisuGUI_Slider;
+class VisuGUI_InputPanel;
+class VisuGUI_SelectionPanel;
namespace VISU
{
VISU::TViewToPrs3d&
getScalarBarsMap();
+
+ VisuGUI_InputPanel* inputPanel() const { return myInputPanel; }
signals:
void moduleDeactivated();
void createMenus();
void createToolBars();
void createPopupMenus();
+ void createInputPanel();
private:
- VisuGUI_Slider* mySlider;
- LightApp_Displayer* myDisplayer;
- VISU::TViewToPrs3d myScalarBarsMap;
+ VisuGUI_InputPanel* myInputPanel;
+ VisuGUI_SelectionPanel* mySelectionPanel;
+ VisuGUI_Slider* mySlider;
+
+ LightApp_Displayer* myDisplayer;
+ VISU::TViewToPrs3d myScalarBarsMap;
};
#endif
--- /dev/null
+// VISU VISUGUI : GUI of VISU 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : VisuGUI_BasePanel.cxx
+// Author : Oleg Uvarov
+// Module : VISU
+
+#include <VisuGUI_BasePanel.h>
+
+#include <QScrollArea>
+#include <QPushButton>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QApplication>
+
+/*!
+ \class MainFrame
+ \internal
+ \brief Frame inserted in viewport with redefined sizeHint method
+ in order to avoid unreasonable increasing of viewport size
+*/
+class VisuGUI_BasePanel::MainFrame : public QFrame
+{
+public:
+ /*!
+ \brief Constructor.
+ \param theParent parent widget
+ */
+ MainFrame( QWidget* theParent )
+ : QFrame( theParent )
+ {
+ }
+
+ /*!
+ \brief Gets frame size hint
+ \return frame size hint
+ */
+ virtual QSize sizeHint() const
+ {
+ return minimumSizeHint();
+ }
+};
+
+/*!
+ \class VisuGUI_BasePanel
+ \brief Base class for VISU interactive sub-panels.
+
+ Set of classes is derived from this class and are intended for representing widgets
+ (GUI controls) for different operations. VisuGUI_BasePanel consists of main frame
+ inserted in scroll view and four push buttons. So all widgets of derived sub-panels
+ should be inherited from mainframe() instead of \93this\94 pointer.
+*/
+
+/*!
+ \brief Constructor creates panels look and feel
+ \param theName name of the panel
+ \param theParent parent widget
+*/
+VisuGUI_BasePanel::VisuGUI_BasePanel( const QString& theName,
+ QWidget* theParent,
+ const int theBtns )
+: QGroupBox( theName, theParent )
+{
+ // Create scroll view
+ //myView = new QScrollArea( this );
+ //myView->setFrameStyle( QFrame::NoFrame );
+
+ //myView->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
+ //myView->viewport()->setBackgroundMode( Qt::PaletteButton );
+ //myView->setResizePolicy( QScrollView::AutoOneFit );
+
+ // Create main frame
+ myMainFrame = new MainFrame( this/*myView->viewport()*/ );
+ //myView->setViewport( myMainFrame );
+
+ // Create buttons
+ QWidget* aBtnWg = new QWidget( this );
+ QHBoxLayout* aBtnWgLayout = new QHBoxLayout( aBtnWg );
+ aBtnWgLayout->setSpacing( 5 );
+
+ aBtnWgLayout->addStretch();
+
+ if( theBtns & OKBtn )
+ {
+ myOK = new QPushButton( tr( "BUT_OK" ), aBtnWg );
+ aBtnWgLayout->addWidget( myOK );
+ connect( myOK, SIGNAL( clicked() ), SLOT( onOK() ) );
+ }
+ if( theBtns & ApplyBtn )
+ {
+ myApply = new QPushButton( tr( "BUT_APPLY" ), aBtnWg );
+ aBtnWgLayout->addWidget( myApply );
+ connect( myApply, SIGNAL( clicked() ), SLOT( onApply() ) );
+ }
+ if( theBtns & CloseBtn )
+ {
+ myClose = new QPushButton( tr( "BUT_CLOSE" ), aBtnWg );
+ aBtnWgLayout->addWidget( myClose );
+ connect( myClose, SIGNAL( clicked() ), SLOT( onClose() ) );
+ }
+ if( theBtns & HelpBtn )
+ {
+ myHelp = new QPushButton( tr( "BUT_HELP" ), aBtnWg );
+ aBtnWgLayout->addWidget( myHelp );
+ connect( myHelp, SIGNAL( clicked() ), SLOT( onHelp() ) );
+ }
+
+ aBtnWgLayout->addStretch();
+
+ // fill layout
+ QVBoxLayout* aLay = new QVBoxLayout( this );
+ aLay->setContentsMargins( 0, 0, 0, 0 );
+ aLay->setSpacing( 5 );
+ aLay->addWidget( myMainFrame/*myView*/ );
+ aLay->addWidget( aBtnWg );
+}
+
+/*!
+ \brief Destructor
+*/
+VisuGUI_BasePanel::~VisuGUI_BasePanel()
+{
+}
+
+/*!
+ \brief Verifies validity of input data
+
+ This virtual method should be redefined in derived classes. Usually operator
+ corresponding to the sub-panel calls this method to check validity of input
+ data when Apply/OK button is pressed.
+
+ \param theErrMsg Error message.
+
+ If data is invalid when panel can return message using this parameter given
+ clear explanation what is wrong
+
+ \return TRUE if data is valid, FALSE otherwise
+*/
+bool VisuGUI_BasePanel::isValid( QString& /*theErrMsg*/ )
+{
+ return true;
+}
+/*!
+ \brief Virtual methods should be redefined in derived classes and
+ clears all GUI controls
+*/
+void VisuGUI_BasePanel::clear()
+{
+}
+
+/*!
+ \brief Virtual slot called when \93OK\94 button pressed emits corresponding signal.
+
+ This slot moves focus in OK button before emitting signal. Mainly it provides
+ application with correct moving data from currently edited controls to internal
+ structure. For example QTable moves data from cell editor to table item when
+ focus is out.
+
+*/
+void VisuGUI_BasePanel::onOK()
+{
+ if ( myOK )
+ {
+ myOK->setFocus();
+ qApp->processEvents();
+ }
+ emit bpOk();
+}
+
+/*!
+ \brief Virtual slot called when \93Apply\94 button pressed emits corresponding signal.
+ \sa onOK
+*/
+void VisuGUI_BasePanel::onApply()
+{
+ if ( myApply )
+ {
+ myApply->setFocus();
+ qApp->processEvents();
+ }
+ emit bpApply();
+}
+
+/*!
+ \brief Virtual slot called when \93Close\94 button pressed emits corresponding signal.
+ \sa onOK
+*/
+void VisuGUI_BasePanel::onClose()
+{
+ if ( myClose )
+ myClose->setFocus();
+ emit bpClose();
+}
+
+/*!
+ \brief Virtual slot called when \93Help\94 button pressed emits corresponding signal.
+ \sa onOK
+*/
+void VisuGUI_BasePanel::onHelp()
+{
+ if ( myHelp )
+ myHelp->setFocus();
+ emit bpHelp();
+}
+
+/*!
+ \brief Gets frame inserted in scroll view. All controls of derived
+ panels should use it as parent
+ \return QFrame* object
+*/
+QFrame* VisuGUI_BasePanel::mainFrame()
+{
+ return myMainFrame;
+}
--- /dev/null
+// VISU VISUGUI : GUI of VISU 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : VisuGUI_BasePanel.cxx
+// Author : Oleg Uvarov
+// Module : VISU
+
+#ifndef VISUGUI_BASEPANEL_H
+#define VISUGUI_BASEPANEL_H
+
+#include <QGroupBox>
+
+class QScrollArea;
+class QPushButton;
+
+class VisuGUI_BasePanel : public QGroupBox
+{
+ Q_OBJECT
+
+ class MainFrame;
+
+public:
+ enum { OKBtn = 0x0001,
+ ApplyBtn = 0x0002,
+ CloseBtn = 0x0004,
+ HelpBtn = 0x0008,
+ AllBtn = OKBtn | ApplyBtn | CloseBtn | HelpBtn
+ };
+
+public:
+ VisuGUI_BasePanel( const QString& theName, QWidget* theParent, const int theBtns = AllBtn );
+ virtual ~VisuGUI_BasePanel();
+
+ virtual bool isValid( QString& theMessage );
+ virtual void clear();
+
+signals:
+ void bpOk();
+ void bpApply();
+ void bpClose();
+ void bpHelp();
+
+protected slots:
+ virtual void onOK();
+ virtual void onApply();
+ virtual void onClose();
+ virtual void onHelp();
+
+protected:
+ QFrame* mainFrame();
+
+protected:
+ //QScrollArea* myView;
+ QFrame* myMainFrame;
+
+ QPushButton* myOK;
+ QPushButton* myApply;
+ QPushButton* myClose;
+ QPushButton* myHelp;
+};
+
+#endif
--- /dev/null
+// VISU VISUGUI : GUI of VISU 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : VisuGUI_GaussPointsSelectionPane.cxx
+// Author : Oleg Uvarov
+// Module : VISU
+
+#include "VisuGUI_GaussPointsSelectionPane.h"
+#include "VisuGUI_ViewTools.h"
+
+#include "VISU_GaussPtsAct.h"
+#include "VISU_GaussPtsSettings.h"
+#include "VISU_GaussPointsPL.hxx"
+
+#include "SUIT_MessageBox.h"
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+
+#include "CAM_Module.h"
+
+#include "SVTK_Selector.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_MainWindow.h"
+#include "SVTK_RenderWindowInteractor.h"
+
+#include "VTKViewer_Algorithm.h"
+#include "SVTK_Functor.h"
+
+#include <vtkActorCollection.h>
+#include <vtkCallbackCommand.h>
+#include <vtkObjectFactory.h>
+#include <vtkRenderer.h>
+#include <vtkGenericRenderWindowInteractor.h>
+#include <vtkSmartPointer.h>
+
+#include "utilities.h"
+
+#include <QCheckBox>
+#include <QComboBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QKeyEvent>
+#include <QIntValidator>
+
+#include "QtxAction.h"
+#include "QtxDoubleSpinBox.h"
+#include "QtxIntSpinBox.h"
+#include "QtxColorButton.h"
+
+#include "LightApp_Application.h"
+
+namespace
+{
+ struct SelectorHelper
+ {
+ public:
+ SelectorHelper( const SalomeApp_Module* theModule ):
+ myModule( theModule )
+ {}
+
+ bool
+ get()
+ {
+ bool aResult = false;
+ myMapIndex.Clear();
+ mySelector = NULL;
+ myPipeLine = NULL;
+ myActor = NULL;
+
+ SVTK_RenderWindowInteractor* anInteractor = NULL;
+ if( SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>( myModule ) )
+ if( SVTK_MainWindow* aMainWindow = aViewWindow->getMainWindow() )
+ anInteractor = aMainWindow->GetInteractor();
+
+ if ( !anInteractor )
+ return aResult;
+
+ mySelector = anInteractor->GetSelector();
+ if ( !mySelector )
+ return aResult;
+
+ const SALOME_ListIO& aListIO = mySelector->StoredIObjects();
+ if ( aListIO.Extent() != 1 )
+ return aResult;
+
+ myIO = aListIO.First();
+ if ( mySelector->HasIndex( myIO ) )
+ mySelector->GetIndex(myIO, myMapIndex);
+
+ myActor = SVTK::Find<VISU_GaussPtsAct>(anInteractor->getRenderer()->GetActors(),
+ SVTK::TIsSameIObject<VISU_GaussPtsAct>( myIO ));
+ if ( !myActor )
+ return aResult;
+
+ myPipeLine = myActor->GetGaussPointsPL();
+
+ return true;
+ }
+
+ const SalomeApp_Module* myModule;
+ TColStd_IndexedMapOfInteger myMapIndex;
+ Handle(SALOME_InteractiveObject) myIO;
+ SVTK_Selector* mySelector;
+
+ VISU_GaussPointsPL* myPipeLine;
+ VISU_GaussPtsAct* myActor;
+ };
+
+
+
+ class GaussPtsIDValidator: public QIntValidator
+ {
+ public:
+ GaussPtsIDValidator( const SalomeApp_Module* theModule,
+ QObject * theParent ):
+ QIntValidator( 0, VTK_LARGE_ID, theParent ),
+ myHelper(theModule)
+ {}
+
+ virtual
+ State
+ validate ( QString & theInput, int & thePos ) const
+ {
+ if ( QIntValidator::validate( theInput, thePos ) == QValidator::Invalid)
+ return QValidator::Invalid;
+
+ if ( !myHelper.get() )
+ return QValidator::Invalid;
+
+ return QValidator::Acceptable;
+ }
+
+ protected:
+ mutable SelectorHelper myHelper;
+ };
+
+
+ class GaussCellIDValidator: public GaussPtsIDValidator
+ {
+ public:
+ GaussCellIDValidator( QLineEdit* theLocalPointLabel,
+ const SalomeApp_Module* theModule,
+ QObject * theParent ):
+ GaussPtsIDValidator( theModule, theParent ),
+ myLocalPointLineEdit( theLocalPointLabel )
+ {}
+
+ virtual
+ State
+ validate ( QString & theInput, int & thePos ) const
+ {
+ if ( GaussPtsIDValidator::validate( theInput, thePos ) == QValidator::Invalid)
+ return QValidator::Invalid;
+
+ VISU::TCellID aCellID = theInput.toInt();
+ VISU::TLocalPntID aLocalPntID = myLocalPointLineEdit->text().toInt();
+ VISU::PGaussPtsIDMapper anIDMapper = myHelper.myPipeLine->GetGaussPtsIDMapper();
+ if ( anIDMapper->GetVTKID( VISU::TGaussPointID( aCellID, aLocalPntID ) ) < 0 )
+ return QValidator::Intermediate;
+
+ return QValidator::Acceptable;
+ }
+
+ private:
+ QLineEdit* myLocalPointLineEdit;
+ };
+
+
+ class GaussLocalPointIDValidator: public GaussPtsIDValidator
+ {
+ public:
+ GaussLocalPointIDValidator( QLineEdit* theParentElementLineEdit,
+ const SalomeApp_Module* theModule,
+ QObject * theParent ):
+ GaussPtsIDValidator( theModule, theParent ),
+ myParentElementLineEdit( theParentElementLineEdit )
+ {}
+
+ virtual
+ State
+ validate ( QString & theInput, int & thePos ) const
+ {
+ if ( GaussPtsIDValidator::validate( theInput, thePos ) == QValidator::Invalid)
+ return QValidator::Invalid;
+
+ VISU::TLocalPntID aLocalPntID = theInput.toInt();
+ VISU::TCellID aCellID = myParentElementLineEdit->text().toInt();
+ VISU::PGaussPtsIDMapper anIDMapper = myHelper.myPipeLine->GetGaussPtsIDMapper();
+ if ( anIDMapper->GetVTKID( VISU::TGaussPointID( aCellID, aLocalPntID ) ) < 0 )
+ return QValidator::Intermediate;
+
+ return QValidator::Acceptable;
+ }
+
+ private:
+ QLineEdit* myParentElementLineEdit;
+ };
+}
+
+
+VisuGUI_ValidatedLineEdit::VisuGUI_ValidatedLineEdit( QWidget* parent ):
+ QLineEdit( parent )
+{
+ connect( this, SIGNAL( textChanged( const QString& ) ), this, SLOT( MarkValidated( const QString& ) ) );
+}
+
+void VisuGUI_ValidatedLineEdit::MarkValidated( const QString& theText )
+{
+ if ( !validator() )
+ return;
+
+ int aPos;
+ QString aText( theText );
+ QPalette pal = palette();
+ switch ( validator()->validate( aText, aPos ) ) {
+ case QValidator::Invalid:
+ case QValidator::Intermediate:
+ pal.setColor( foregroundRole(), QColor( 255, 0, 0 ));
+ setPalette( pal );
+ break;
+ case QValidator::Acceptable:
+ pal.setColor( foregroundRole(), QColor( 0, 0, 0 ));
+ setPalette( pal );
+ break;
+ }
+}
+
+//---------------------------------------------------------------------------------
+
+VisuGUI_GaussPointsSelectionPane::VisuGUI_GaussPointsSelectionPane( const SalomeApp_Module* theModule,
+ QWidget* theParent ) :
+ QWidget( theParent ),
+ myModule( theModule ),
+ myEventCallbackCommand( vtkCallbackCommand::New() )
+{
+ myPriority = 0.0;
+ myEventCallbackCommand->Delete();
+ myEventCallbackCommand->SetClientData(this);
+ myEventCallbackCommand->SetCallback(VisuGUI_GaussPointsSelectionPane::ProcessEvents);
+
+ //setWindowTitle( tr( "PICKING_DLG_TITLE" ) );
+ //setSizeGripEnabled(TRUE);
+
+ QVBoxLayout* TopLayout = new QVBoxLayout( this );
+ TopLayout->setSpacing(6);
+ TopLayout->setMargin(11);
+
+ QWidget* aBox = new QWidget( this );
+ QVBoxLayout* BoxLayout = new QVBoxLayout( aBox );
+ BoxLayout->setMargin(0);
+ BoxLayout->setSpacing(6);
+
+ // Cursor
+ QGroupBox* CursorGroup = new QGroupBox( tr( "CURSOR_TITLE" ), aBox );
+ QGridLayout* CursorGroupLayout = new QGridLayout (CursorGroup);
+ CursorGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ CursorGroupLayout->setSpacing(6);
+ CursorGroupLayout->setMargin(11);
+
+ QLabel* CursorSizeLabel = new QLabel( tr( "CURSOR_SIZE" ), CursorGroup );
+ myCursorSizeSpinBox = new QtxDoubleSpinBox( 0, 1, 0.1, CursorGroup );
+ myCursorSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ QLabel* PyramidHeightLabel = new QLabel( tr( "PYRAMID_HEIGHT" ), CursorGroup );
+ double aHeightMin=1.e-7;
+ double aHeightMax=10.;
+ double aHeightStep=0.1;
+ myPyramidHeightSpinBox = new QtxDoubleSpinBox(aHeightMin, aHeightMax, aHeightStep, CursorGroup );
+ myPyramidHeightSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ QLabel* SelectionColorLabel = new QLabel( tr( "SELECTION_COLOR" ), CursorGroup );
+ mySelectionColorButton = new QtxColorButton( CursorGroup );
+ mySelectionColorButton->setColor( Qt::blue );
+
+ CursorGroupLayout->addWidget( CursorSizeLabel, 0, 0 );
+ CursorGroupLayout->addWidget( myCursorSizeSpinBox, 0, 1 );
+ CursorGroupLayout->addWidget( PyramidHeightLabel, 1, 0 );
+ CursorGroupLayout->addWidget( myPyramidHeightSpinBox, 1, 1 );
+ CursorGroupLayout->addWidget( SelectionColorLabel, 2, 0 );
+ CursorGroupLayout->addWidget( mySelectionColorButton, 2, 1 );
+
+ BoxLayout->addWidget( CursorGroup );
+
+ // Tolerance
+ QGroupBox* ToleranceGroup = new QGroupBox( tr( "TOLERANCE_TITLE" ), aBox );
+ QGridLayout* ToleranceGroupLayout = new QGridLayout (ToleranceGroup);
+ ToleranceGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ ToleranceGroupLayout->setSpacing(6);
+ ToleranceGroupLayout->setMargin(11);
+
+ QLabel* PointToleranceLabel = new QLabel( tr( "POINT_TOLERANCE" ), ToleranceGroup );
+ myPointToleranceSpinBox = new QtxDoubleSpinBox( 0.001, 10.0, 0.01, ToleranceGroup );
+ myPointToleranceSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ ToleranceGroupLayout->addWidget( PointToleranceLabel, 0, 0 );
+ ToleranceGroupLayout->addWidget( myPointToleranceSpinBox, 0, 1 );
+
+ BoxLayout->addWidget( ToleranceGroup );
+
+ // Information window
+ QGroupBox* InfoWindowGroup = new QGroupBox( tr( "INFO_WINDOW_TITLE" ), aBox );
+ QGridLayout* InfoWindowGroupLayout = new QGridLayout (InfoWindowGroup);
+ InfoWindowGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ InfoWindowGroupLayout->setSpacing(6);
+ InfoWindowGroupLayout->setMargin(11);
+
+ QLabel* TransparencyLabel = new QLabel( tr( "TRANSPARENCY" ), InfoWindowGroup );
+ myTransparencySpinBox = new QtxIntSpinBox( 0, 100, 10, 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->addItem( tr( "BELOW_POINT" ) );
+ myPositionComboBox->addItem( tr( "TOP_LEFT_CORNER" ) );
+
+ InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 );
+ InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 );
+ InfoWindowGroupLayout->addWidget( PositionLabel, 1, 0 );
+ InfoWindowGroupLayout->addWidget( myPositionComboBox, 1, 1 );
+
+ BoxLayout->addWidget( InfoWindowGroup );
+
+ // Movement of the camera
+ QGroupBox* CameraGroup = new QGroupBox( tr( "CAMERA_TITLE" ), aBox );
+ QGridLayout* CameraGroupLayout = new QGridLayout (CameraGroup);
+ CameraGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ CameraGroupLayout->setSpacing(6);
+ CameraGroupLayout->setMargin(11);
+
+ QLabel* ZoomFactorLabel = new QLabel( tr( "ZOOM_FACTOR" ), CameraGroup );
+ myZoomFactorSpinBox = new QtxDoubleSpinBox( 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 );
+
+ BoxLayout->addWidget( CameraGroup );
+
+ // Display parent mesh element
+ QGroupBox* PositionGroup = new QGroupBox( tr( "DATA_POSITION" ), aBox );
+ QGridLayout* PositionGroupLayout = new QGridLayout (PositionGroup);
+ PositionGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
+ PositionGroupLayout->setSpacing(6);
+ PositionGroupLayout->setMargin(11);
+
+ QLabel* ParentElementLabel = new QLabel( tr( "PARENT_ELEMENT" ), PositionGroup );
+ myParentElementLineEdit = new VisuGUI_ValidatedLineEdit( PositionGroup );
+ connect( myParentElementLineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onSelectionValidate() ) );
+ connect( myParentElementLineEdit, SIGNAL( returnPressed() ), this, SLOT( onSelectionApply() ) );
+
+ QLabel* LocalPointLabel = new QLabel( tr( "LOCAL_POINT" ), PositionGroup );
+ myLocalPointLineEdit = new VisuGUI_ValidatedLineEdit( PositionGroup );
+ connect( myLocalPointLineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onSelectionValidate() ) );
+ connect( myLocalPointLineEdit, SIGNAL( returnPressed() ), this, SLOT( onSelectionApply() ) );
+
+ myCellIDValidator = new GaussCellIDValidator( myLocalPointLineEdit, myModule, myParentElementLineEdit );
+ myParentElementLineEdit->setValidator( myCellIDValidator );
+
+ myLocalPointIDValidator = new GaussLocalPointIDValidator( myParentElementLineEdit, myModule, myLocalPointLineEdit );
+ myLocalPointLineEdit->setValidator( myLocalPointIDValidator );
+
+ myDisplayParentMeshCheckBox = new QCheckBox( tr( "DISPLAY_PARENT_MESH" ), PositionGroup );
+
+ PositionGroupLayout->addWidget( ParentElementLabel, 0, 0, 1, 3 );
+ PositionGroupLayout->addWidget( myParentElementLineEdit, 0, 3 );
+ PositionGroupLayout->addWidget( LocalPointLabel, 1, 0, 1, 3 );
+ PositionGroupLayout->addWidget( myLocalPointLineEdit, 1, 3 );
+ PositionGroupLayout->addWidget( myDisplayParentMeshCheckBox, 2, 0, 1, 4 );
+
+ BoxLayout->addWidget( PositionGroup );
+
+ TopLayout->addWidget( aBox );
+}
+
+VisuGUI_GaussPointsSelectionPane::~VisuGUI_GaussPointsSelectionPane()
+{
+}
+
+void VisuGUI_GaussPointsSelectionPane::AddActor( VISU_GaussPtsAct* theActor )
+{
+ theActor->SetPickingSettings( myPickingSettings.GetPointer() );
+}
+
+void VisuGUI_GaussPointsSelectionPane::RemoveActor( VISU_GaussPtsAct* theActor )
+{
+ theActor->SetPickingSettings( NULL );
+}
+
+void VisuGUI_GaussPointsSelectionPane::Update()
+{
+ //printf( "VisuGUI_GaussPointsSelectionPane::Update()\n" );
+ myPickingSettings = VISU_PickingSettings::Get();
+
+ float aCursorSize = 0.5;
+ float aPyramidHeight = 10.0;
+ float aPointTolerance = 0.1;
+ QColor aColor = Qt::yellow;
+ int anInfoWindowTransparency = 50;
+ int anInfoWindowPosition = VISU_PickingSettings::BelowPoint;
+ float aZoomFactor = 1.5;
+ int aStepNumber = 10;
+ bool aDisplayParentMesh = false;
+
+ if( !myPickingSettings->GetInitial() )
+ {
+ myCursorSizeSpinBox->setValue( myPickingSettings->GetCursorSize() );
+ myPyramidHeightSpinBox->setValue( myPickingSettings->GetPyramidHeight() );
+ myPointToleranceSpinBox->setValue( myPickingSettings->GetPointTolerance() );
+ myTransparencySpinBox->setValue( int(myPickingSettings->GetInfoWindowTransparency() * 100.0) );
+ myPositionComboBox->setCurrentIndex( myPickingSettings->GetInfoWindowPosition() );
+ myZoomFactorSpinBox->setValue( myPickingSettings->GetZoomFactor() );
+ myStepNumberSpinBox->setValue( myPickingSettings->GetStepNumber() );
+ myDisplayParentMeshCheckBox->setChecked( myPickingSettings->GetDisplayParentMesh() );
+
+ vtkFloatingPointType* aColor = myPickingSettings->GetColor();
+ mySelectionColorButton->setColor(
+ QColor( ( int )( aColor[0] * 255.0 ),
+ ( int )( aColor[1] * 255.0 ),
+ ( int )( aColor[2] * 255.0 ) ) );
+
+ return;
+ }
+
+ SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+
+ aCursorSize = aResourceMgr->doubleValue( "VISU", "picking_cursor_size", aCursorSize );
+ myCursorSizeSpinBox->setValue( aCursorSize );
+
+ aPyramidHeight = aResourceMgr->doubleValue( "VISU", "picking_pyramid_height", aPyramidHeight );
+ myPyramidHeightSpinBox->setValue( aPyramidHeight );
+
+ aPointTolerance = aResourceMgr->doubleValue( "VISU", "picking_point_tolerance", aPointTolerance );
+ myPointToleranceSpinBox->setValue( aPointTolerance );
+
+ aColor = aResourceMgr->colorValue( "VISU", "picking_selection_color", aColor );
+ mySelectionColorButton->setColor( aColor );
+
+ anInfoWindowTransparency = aResourceMgr->integerValue( "VISU", "picking_transparency", anInfoWindowTransparency );
+ myTransparencySpinBox->setValue( anInfoWindowTransparency );
+
+ anInfoWindowPosition = aResourceMgr->integerValue( "VISU", "picking_position", anInfoWindowPosition );
+ myPositionComboBox->setCurrentIndex( anInfoWindowPosition );
+
+ aZoomFactor = aResourceMgr->doubleValue( "VISU", "picking_zoom_factor", aZoomFactor );
+ myZoomFactorSpinBox->setValue( aZoomFactor );
+
+ aStepNumber = aResourceMgr->integerValue( "VISU", "picking_step_number", aStepNumber );
+ myStepNumberSpinBox->setValue( aStepNumber );
+
+ aDisplayParentMesh = aResourceMgr->booleanValue( "VISU", "picking_display_parent_mesh", aDisplayParentMesh );
+ myDisplayParentMeshCheckBox->setChecked( aDisplayParentMesh );
+
+ Apply();
+}
+
+VISU_PickingSettings*
+VisuGUI_GaussPointsSelectionPane
+::GetPickingSettings()
+{
+ return myPickingSettings.GetPointer();
+}
+
+void VisuGUI_GaussPointsSelectionPane::SetInteractor( SVTK_RenderWindowInteractor* theInteractor )
+{
+ //printf( "VisuGUI_GaussPointsSelectionPane::SetInteractor( %p )\n", theInteractor );
+ vtkGenericRenderWindowInteractor* aDevice = theInteractor->GetDevice();
+ if( !aDevice->HasObserver(vtkCommand::KeyPressEvent) )
+ {
+ //printf( "AddObserver(vtkCommand::KeyPressEvent)\n" );
+ aDevice->AddObserver(vtkCommand::KeyPressEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+ }
+
+ if( !aDevice->HasObserver(vtkCommand::EndPickEvent) )
+ {
+ //printf( "AddObserver(vtkCommand::EndPickEvent)\n" );
+ aDevice->AddObserver(vtkCommand::EndPickEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+ }
+}
+
+SVTK_RenderWindowInteractor* VisuGUI_GaussPointsSelectionPane::GetInteractor()
+{
+ if( SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>( myModule ) )
+ {
+ if( SVTK_MainWindow* aMainWindow = aViewWindow->getMainWindow() )
+ {
+ SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
+ return anInteractor;
+ }
+ }
+ return 0;
+}
+
+void VisuGUI_GaussPointsSelectionPane::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* vtkNotUsed(theCallData))
+{
+ VisuGUI_GaussPointsSelectionPane* self = reinterpret_cast<VisuGUI_GaussPointsSelectionPane*>(theClientData);
+
+ switch(theEvent){
+ case vtkCommand::KeyPressEvent:
+ self->KeyPressed();
+ break;
+ case vtkCommand::EndPickEvent:
+ self->SelectionEvent();
+ break;
+ }
+}
+
+void VisuGUI_GaussPointsSelectionPane::KeyPressed()
+{
+ if( GetInteractor()->GetDevice()->GetKeyCode() == 'P' )
+ {
+ bool aDisplayParentMesh = !myPickingSettings->GetDisplayParentMesh();
+ myPickingSettings->SetDisplayParentMesh( aDisplayParentMesh );
+
+ myDisplayParentMeshCheckBox->setChecked( aDisplayParentMesh );
+
+ myPickingSettings->InvokeEvent(VISU::UpdatePickingSettingsEvent,NULL);
+ }
+}
+
+void VisuGUI_GaussPointsSelectionPane::SelectionEvent()
+{
+ //printf( "VisuGUI_GaussPointsSelectionPane::SelectionEvent()\n" );
+ SelectorHelper aHelper( myModule );
+ if ( !aHelper.get() )
+ return;
+
+ const TColStd_IndexedMapOfInteger& aMapIndex = aHelper.myMapIndex;
+ if ( aMapIndex.Extent() != 1 )
+ return;
+
+ int anObjId = aHelper.myMapIndex(1);
+
+ VISU::TGaussPointID aGaussPointID = aHelper.myPipeLine->GetObjID( anObjId );
+
+ VISU::TCellID aCellId = aGaussPointID.first;
+ myParentElementLineEdit->setText( QString::number( aCellId ) );
+
+ VISU::TLocalPntID aLocalPntId = aGaussPointID.second;
+ myLocalPointLineEdit->setText( QString::number( aLocalPntId ) );
+
+ myPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL );
+
+ SetSelected( aCellId, aLocalPntId );
+}
+
+void VisuGUI_GaussPointsSelectionPane::onSelectionValidate()
+{
+ myParentElementLineEdit->MarkValidated( myParentElementLineEdit->text() );
+ myLocalPointLineEdit->MarkValidated( myLocalPointLineEdit->text() );
+}
+
+void VisuGUI_GaussPointsSelectionPane::onSelectionApply()
+{
+ //printf( "VisuGUI_GaussPointsSelectionPane::onSelectionApply()\n" );
+ VISU::TCellID aCellId = myParentElementLineEdit->text().toInt();
+ VISU::TLocalPntID aLocalPntId = myLocalPointLineEdit->text().toInt();
+ SetSelected( aCellId, aLocalPntId );
+}
+
+void VisuGUI_GaussPointsSelectionPane::SetSelected( VISU::TCellID theCellId, VISU::TLocalPntID theLocalPntId )
+{
+ //printf( "VisuGUI_GaussPointsSelectionPane::SetSelected( %d, %d )\n", theCellId, theLocalPntId );
+ SelectorHelper aHelper( myModule );
+ if ( !aHelper.get() )
+ return;
+
+ VISU::PGaussPtsIDMapper anIDMapper = aHelper.myPipeLine->GetGaussPtsIDMapper();
+ vtkIdType anObjVtkId = anIDMapper->GetVTKID( VISU::TGaussPointID( theCellId, theLocalPntId ) );
+ if ( anObjVtkId < 0 )
+ return;
+
+ aHelper.myMapIndex.Clear();
+ aHelper.myMapIndex.Add( anObjVtkId );
+ aHelper.mySelector->AddOrRemoveIndex( aHelper.myIO, aHelper.myMapIndex, false );
+ aHelper.myActor->Highlight( aHelper.myIO );
+ GetInteractor()->GetDevice()->CreateTimer( VTKI_TIMER_FIRST );
+}
+
+void VisuGUI_GaussPointsSelectionPane::Apply()
+{
+ myPickingSettings->SetInitial( false );
+
+ myPickingSettings->SetCursorSize( myCursorSizeSpinBox->value() );
+ myPickingSettings->SetPyramidHeight( myPyramidHeightSpinBox->value() );
+ myPickingSettings->SetPointTolerance( myPointToleranceSpinBox->value() );
+ myPickingSettings->SetInfoWindowTransparency( myTransparencySpinBox->value() / 100.0 );
+ myPickingSettings->SetInfoWindowPosition( myPositionComboBox->currentIndex() );
+ myPickingSettings->SetZoomFactor( myZoomFactorSpinBox->value() );
+ myPickingSettings->SetStepNumber( myStepNumberSpinBox->value() );
+ myPickingSettings->SetDisplayParentMesh( myDisplayParentMeshCheckBox->isChecked() );
+
+ QColor aButtonColor = mySelectionColorButton->color();
+ vtkFloatingPointType aColor[3];
+ aColor[0] = aButtonColor.red() / 255.0;
+ aColor[1] = aButtonColor.green() / 255.0;
+ aColor[2] = aButtonColor.blue() / 255.0;
+ myPickingSettings->SetColor( aColor );
+
+ myPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL );
+
+ onSelectionApply();
+}
+
+void VisuGUI_GaussPointsSelectionPane::Close()
+{
+ //printf( "VisuGUI_GaussPointsSelectionPane::Close()\n" );
+ SelectorHelper aHelper( myModule );
+ if( aHelper.get() )
+ {
+ const TColStd_IndexedMapOfInteger& aMapIndex = aHelper.myMapIndex;
+ if( aMapIndex.Extent() == 1 )
+ {
+ int anObjId = aHelper.myMapIndex(1);
+ VISU::TGaussPointID aGaussPointID = aHelper.myPipeLine->GetObjID( anObjId );
+ VISU::TCellID aCellID = aGaussPointID.first;
+ VISU::TLocalPntID aLocalPntID = aGaussPointID.second;
+
+ VISU::PGaussPtsIDMapper anIDMapper = aHelper.myPipeLine->GetGaussPtsIDMapper();
+ vtkIdType anObjVtkId = anIDMapper->GetVTKID( VISU::TGaussPointID( aCellID, aLocalPntID ) );
+ if( anObjVtkId >= 0 )
+ {
+ aHelper.myActor->Highlight( false );
+ aHelper.myMapIndex.Clear();
+ }
+ }
+ }
+}
+/*
+void VisuGUI_GaussPointsSelectionPane::Help()
+{
+ QString aHelpFileName = "picking.htm";
+ LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app)
+ app->onHelpContextModule(app->activeModule() ? app->moduleName(app->activeModule()->moduleName()) : QString(""), aHelpFileName);
+ else {
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ SUIT_MessageBox::warning( 0,
+ QObject::tr("WRN_WARNING"),
+ QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName),
+ QObject::tr("BUT_OK"));
+ }
+}
+
+void VisuGUI_GaussPointsSelectionPane::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 )
+ {
+ e->accept();
+ Help();
+ }
+}
+*/
--- /dev/null
+// VISU VISUGUI : GUI of VISU 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : VisuGUI_GaussPointsSelectionPane.h
+// Author : Oleg Uvarov
+// Module : VISU
+
+#ifndef VISUGUI_GAUSSPOINTSSELECTIONPANE_H
+#define VISUGUI_GAUSSPOINTSSELECTIONPANE_H
+
+#include "VISU_IDMapper.hxx"
+
+#include <vtkObject.h>
+#include <vtkSmartPointer.h>
+
+#include <QLineEdit>
+
+class vtkActorCollection;
+class vtkCallbackCommand;
+class vtkImageData;
+
+class QLabel;
+class QComboBox;
+class QCheckBox;
+class QPushButton;
+
+class QtxAction;
+class QtxDoubleSpinBox;
+class QtxIntSpinBox;
+class QtxColorButton;
+
+class VISU_GaussPtsAct;
+class VISU_PickingSettings;
+
+class SalomeApp_Module;
+class SVTK_RenderWindowInteractor;
+class VisuGUI_ValidatedLineEdit;
+
+//! Picking Dialog.
+/*!
+ * Uses for set up picking preferenses and apply
+ * them to all actors in the current renderer.
+ */
+class VisuGUI_GaussPointsSelectionPane : public QWidget
+{
+ Q_OBJECT
+
+public:
+ VisuGUI_GaussPointsSelectionPane( const SalomeApp_Module* theModule, QWidget* theParent );
+
+ ~VisuGUI_GaussPointsSelectionPane();
+
+ //! Make an actor to listen the event of Update Picking Settings event.
+ void AddActor( VISU_GaussPtsAct* );
+ void RemoveActor( VISU_GaussPtsAct* );
+
+ //! Update dialog contents.
+ void Update();
+
+ VISU_PickingSettings* GetPickingSettings();
+
+ void SetInteractor( SVTK_RenderWindowInteractor* );
+
+ void Apply();
+ void Close();
+ //void Help();
+
+protected:
+ SVTK_RenderWindowInteractor* GetInteractor();
+
+protected slots:
+ void onSelectionValidate();
+ void onSelectionApply();
+
+private:
+ static void ProcessEvents(vtkObject* theObject,
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData);
+
+ void KeyPressed();
+ void SelectionEvent();
+ //void keyPressEvent( QKeyEvent* e );
+
+ void SetSelected( VISU::TCellID, VISU::TLocalPntID );
+
+private:
+ const SalomeApp_Module* myModule;
+
+ QtxDoubleSpinBox* myCursorSizeSpinBox;
+ QtxDoubleSpinBox* myPyramidHeightSpinBox;
+ QtxColorButton* mySelectionColorButton;
+ QtxDoubleSpinBox* myPointToleranceSpinBox;
+ QtxIntSpinBox* myTransparencySpinBox;
+ QComboBox* myPositionComboBox;
+ QtxDoubleSpinBox* myZoomFactorSpinBox;
+ QtxIntSpinBox* myStepNumberSpinBox;
+ QCheckBox* myDisplayParentMeshCheckBox;
+
+ QtxAction* myAction;
+ vtkSmartPointer<VISU_PickingSettings> myPickingSettings;
+
+ VisuGUI_ValidatedLineEdit* myParentElementLineEdit;
+ VisuGUI_ValidatedLineEdit* myLocalPointLineEdit;
+
+ QValidator* myCellIDValidator;
+ QValidator* myLocalPointIDValidator;
+
+ float myPriority;
+ vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
+};
+
+class VisuGUI_ValidatedLineEdit : public QLineEdit
+{
+ Q_OBJECT;
+public:
+ VisuGUI_ValidatedLineEdit( QWidget* parent );
+
+public slots:
+ void MarkValidated( const QString& theText );
+};
+
+#endif
--- /dev/null
+// VISU VISUGUI : GUI of VISU 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : VisuGUI_InputPanel.cxx
+// Author : Oleg Uvarov
+// Module : VISU
+
+#include "VisuGUI_InputPanel.h"
+#include "VisuGUI_BasePanel.h"
+#include "VisuGUI_Module.h"
+
+#include <SalomeApp_Application.h>
+
+#include <QVBoxLayout>
+
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
+/*!
+ * \brief Constructor creates enmpty docable window with invisible QVBox
+ to be used as container of child widgets
+ */
+VisuGUI_InputPanel::VisuGUI_InputPanel( QWidget* theParent )
+: QtxDockWidget( tr( "WINDOW_TITLE" ), theParent ),
+ myCurrentPanel( 0 )
+{
+ myGrp = new QWidget( this );
+ new QVBoxLayout( myGrp );
+ setWidget( myGrp );
+}
+
+/*!
+ * \brief Destructor: VisuGUI_InputPanel
+ */
+VisuGUI_InputPanel::~VisuGUI_InputPanel()
+{
+}
+
+/*!
+ \brief Shows thePanel in input panel. If there is visible
+ panel then it is hidden
+ \param thePanel widget
+*/
+void VisuGUI_InputPanel::showPanel( VisuGUI_BasePanel* thePanel )
+{
+ if ( !thePanel )
+ return;
+
+ setUpdatesEnabled( false );
+
+ if ( myCurrentPanel )
+ myCurrentPanel->hide();
+
+ if ( !myPanels.contains( thePanel ) )
+ {
+ myPanels.insert( thePanel, true );
+ thePanel->setParent( myGrp );
+ myGrp->layout()->addWidget( thePanel );
+ connect( thePanel, SIGNAL( bpClose() ), this, SLOT( onClosePanel() ) );
+ }
+
+ thePanel->show();
+ myCurrentPanel = thePanel;
+
+ setUpdatesEnabled( true );
+ repaint();
+}
+
+/*!
+ \brief Hides thePanel in input panel.
+ \param thePanel widget
+*/
+void VisuGUI_InputPanel::hidePanel( VisuGUI_BasePanel* thePanel )
+{
+ if ( !thePanel || myCurrentPanel != thePanel )
+ return;
+
+ thePanel->hide();
+ myCurrentPanel = 0;
+}
+
+/*!
+ \brief Hide all children panels
+*/
+void VisuGUI_InputPanel::clear()
+{
+ if ( myCurrentPanel )
+ hidePanel( myCurrentPanel );
+}
+
+/*!
+ \brief Close panel which emits signal close().
+*/
+void VisuGUI_InputPanel::onClosePanel()
+{
+ if( VisuGUI_BasePanel* aPanel = dynamic_cast<VisuGUI_BasePanel*>( sender() ) )
+ hidePanel( aPanel );
+}
--- /dev/null
+// VISU VISUGUI : GUI of VISU 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : VisuGUI_InputPanel.cxx
+// Author : Oleg Uvarov
+// Module : VISU
+
+#ifndef VISUGUI_INPUTPANEL_H
+#define VISUGUI_INPUTPANEL_H
+
+#include <QtxDockWidget.h>
+
+#include <QMap>
+
+class VisuGUI_BasePanel;
+
+/*!
+ * class VisuGUI_InputPanel
+ * Dockable window. Container for GUI controls
+ */
+class VisuGUI_InputPanel : public QtxDockWidget
+{
+ Q_OBJECT
+
+public:
+ VisuGUI_InputPanel( QWidget* theParent = 0 );
+ virtual ~VisuGUI_InputPanel();
+
+ void showPanel( VisuGUI_BasePanel* thePanel );
+ void hidePanel( VisuGUI_BasePanel* thePanel );
+ void clear();
+
+ VisuGUI_BasePanel* getCurrentPanel() const;
+
+protected slots:
+ void onClosePanel();
+
+private:
+ QWidget* myGrp;
+ QMap< VisuGUI_BasePanel*, bool > myPanels;
+ VisuGUI_BasePanel* myCurrentPanel;
+};
+
+#endif
+
+
--- /dev/null
+// VISU VISUGUI : GUI of VISU 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : VisuGUI_SelectionPanel.h
+// Author : Laurent CORNABE & Hubert ROLLAND
+// Module : VISU
+// $Header$
+
+#include "VisuGUI_SelectionPanel.h"
+
+#include "VisuGUI.h"
+#include "VisuGUI_Tools.h"
+#include "VisuGUI_ViewTools.h"
+#include "VisuGUI_GaussPointsSelectionPane.h"
+
+#include "VISU_Event.h"
+
+#include "VISU_Actor.h"
+#include "VISU_PrsObject_i.hh"
+#include "VISU_Prs3d_i.hh"
+#include "VISU_PipeLine.hxx"
+
+#include "SalomeApp_Study.h"
+#include "SalomeApp_Application.h"
+#include "LightApp_Application.h"
+#include "LightApp_SelectionMgr.h"
+#include "LightApp_VTKSelector.h"
+
+#include "SUIT_Desktop.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_ViewWindow.h"
+#include "SUIT_Session.h"
+#include "SUIT_ResourceMgr.h"
+
+#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
+
+#include "SVTK_ViewWindow.h"
+#include "SVTK_MainWindow.h"
+#include "SVTK_Selector.h"
+#include "SVTK_RenderWindowInteractor.h"
+
+#include "utilities.h"
+
+// OCCT Includes
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <TColStd_MapOfInteger.hxx>
+
+// QT Includes
+#include <QLabel>
+#include <QSpinBox>
+#include <QListWidget>
+#include <QLayout>
+#include <QButtonGroup>
+#include <QRadioButton>
+#include <QValidator>
+#include <QPushButton>
+#include <QGroupBox>
+#include <QLineEdit>
+#include <QValidator>
+#include <QTableWidget>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QKeyEvent>
+#include <QHeaderView>
+#include <QTabWidget>
+
+// VTK Includes
+#include <vtkDataSetMapper.h>
+#include <vtkDataSet.h>
+#include <vtkPointData.h>
+#include <vtkCellData.h>
+#include <vtkCell.h>
+
+// STL Includes
+#include <map>
+
+using namespace std;
+
+VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const SalomeApp_Module* theModule, QWidget* theParent ) :
+ VisuGUI_BasePanel( tr("WINDOW_TITLE" ), theParent, ApplyBtn | CloseBtn | HelpBtn ),
+ myModule( theModule ),
+ mySelectionMgr( 0 )
+{
+ QVBoxLayout* TopLayout = new QVBoxLayout ( mainFrame() );
+ TopLayout->setSpacing(6);
+ TopLayout->setMargin(11);
+
+ QWidget* aNamePane = new QWidget (mainFrame());
+ QGridLayout* aNameLay = new QGridLayout (aNamePane);
+
+ QLabel* aMeshLbl = new QLabel (tr("MESH_NAME_LBL"), aNamePane);
+ myMeshName = new QLabel (aNamePane);
+ myMeshName->setText(tr("WRN_NO_AVAILABLE_DATA"));
+
+ QLabel* aFieldLbl = new QLabel (tr("FIELD_NAME_LBL"), aNamePane);
+ myFieldName = new QLabel (aNamePane);
+
+ aNameLay->addWidget(aMeshLbl, 0, 0);
+ aNameLay->addWidget(myMeshName, 0, 1);
+ aNameLay->addWidget(aFieldLbl, 1, 0);
+ aNameLay->addWidget(myFieldName, 1, 1);
+
+ TopLayout->addWidget(aNamePane);
+
+ myTabWidget = new QTabWidget( mainFrame() );
+
+ // Create Points pane
+ myPointsPane = new QWidget (mainFrame());
+ QVBoxLayout* aVBoxLayout = new QVBoxLayout(myPointsPane);
+
+ QGroupBox* aDataGrp = new QGroupBox ( tr("POINT_DATA_TITLE"), myPointsPane);
+ QGridLayout* aGridLay = new QGridLayout (aDataGrp);
+ aGridLay->setSpacing(6);
+
+ aGridLay->addWidget( new QLabel (tr("DATA_ID_LBL"), aDataGrp) , 0, 0 );
+ aGridLay->addWidget( new QLabel (tr("DATA_SCALAR_LBL"), aDataGrp), 1, 0 );
+ aGridLay->addWidget( new QLabel (tr("DATA_VECTOR_LBL"), aDataGrp), 2, 0 );
+
+ myIDValLbl = new QLineEdit ("", aDataGrp);
+ aGridLay->addWidget( myIDValLbl, 0, 1 );
+ QIntValidator* aIntValidator = new QIntValidator (myIDValLbl);
+ aIntValidator->setBottom(0);
+ myIDValLbl->setValidator(aIntValidator);
+ connect(myIDValLbl, SIGNAL(returnPressed()), this, SLOT(onPointIdEdit()));
+
+ myScalarValLbl = new QLabel ("", aDataGrp);
+ aGridLay->addWidget( myScalarValLbl, 1, 1 );
+
+ myVectorValLbl = new QLabel ("", aDataGrp);
+ myVectorValLbl->setMinimumWidth(150);
+ aGridLay->addWidget( myVectorValLbl, 2, 1 );
+
+ aVBoxLayout->addWidget( aDataGrp );
+
+ QGroupBox* aCoordGrp = new QGroupBox ( tr("POINT_COORD_TITLE"), myPointsPane);
+ aGridLay = new QGridLayout (aCoordGrp);
+ aGridLay->setSpacing(6);
+
+ aGridLay->addWidget( new QLabel ("X:", aCoordGrp), 0, 0 );
+ myXValLbl = new QLabel ("", aCoordGrp);
+ aGridLay->addWidget( myXValLbl, 0, 1 );
+ //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
+ aGridLay->addWidget( new QLabel ("I:", aCoordGrp), 0, 2 );
+ myIValLbl = new QLabel ("-", aCoordGrp);
+ aGridLay->addWidget( myIValLbl, 0, 3 );
+ //ENK: 23.11.2006
+ aGridLay->addWidget( new QLabel ("Y:", aCoordGrp), 1, 0 );
+ myYValLbl = new QLabel ("", aCoordGrp);
+ aGridLay->addWidget( myYValLbl, 1, 1 );
+ //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
+ aGridLay->addWidget( new QLabel ("J:", aCoordGrp), 1, 2 );
+ myJValLbl = new QLabel ("-", aCoordGrp);
+ aGridLay->addWidget( myJValLbl, 1, 3 );
+ //ENK: 23.11.2006
+ aGridLay->addWidget( new QLabel ("Z:",aCoordGrp ), 2, 0 );
+ myZValLbl = new QLabel ("", aCoordGrp);
+ aGridLay->addWidget( myZValLbl, 2, 1 );
+ //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
+ aGridLay->addWidget( new QLabel ("K:", aCoordGrp), 2, 2 );
+ myKValLbl = new QLabel ("-", aCoordGrp);
+ aGridLay->addWidget( myKValLbl, 2, 3 );
+ //ENK: 23.11.2006
+
+ aVBoxLayout->addWidget( aCoordGrp );
+ aVBoxLayout->addStretch();
+
+ // Create Cells pane
+ myCellsPane = new QWidget (mainFrame());
+ QGridLayout* aCellLayout = new QGridLayout (myCellsPane);
+ aCellLayout->setSpacing(6);
+ aCellLayout->setRowStretch(0, 0);
+ aCellLayout->setRowStretch(1, 1);
+
+ QGroupBox* aCellGrp = new QGroupBox( tr("CELL_DATA_TITLE"), myCellsPane);
+ aGridLay = new QGridLayout (aCellGrp);
+
+ aGridLay->addWidget( new QLabel (tr("DATA_ID_LBL"), aCellGrp), 0, 0);
+ myCellIDValLbl = new QLineEdit ("", aCellGrp);
+ myCellIDValLbl->setValidator(aIntValidator);
+ aGridLay->addWidget( myCellIDValLbl, 0, 1);
+ connect(myCellIDValLbl, SIGNAL(returnPressed()), this, SLOT(onCellIdEdit()));
+
+ aGridLay->addWidget( new QLabel (tr("DATA_SCALAR_LBL"), aCellGrp), 1, 0);
+ myCellScalarValLbl = new QLabel ("", aCellGrp);
+ aGridLay->addWidget( myCellScalarValLbl, 1, 1);
+ aGridLay->addWidget( new QLabel (tr("DATA_VECTOR_LBL"), aCellGrp), 2, 0);
+ myCellVectorValLbl = new QLabel ("", aCellGrp);
+ aGridLay->addWidget(myCellVectorValLbl , 2, 1);
+
+ aCellLayout->addWidget(aCellGrp, 0, 0);
+
+ myListPoints = new QTableWidget (myCellsPane);
+ myListPoints->setEditTriggers( QAbstractItemView::NoEditTriggers );
+ myListPoints->setColumnCount(9);
+ myListPoints->setRowCount(0);
+ myListPoints->setColumnWidth(0, 40);
+ myListPoints->setColumnWidth(1, 40);
+ myListPoints->setColumnWidth(2, 40);
+ myListPoints->setColumnWidth(3, 40);
+ myListPoints->setColumnWidth(4, 40);//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
+ myListPoints->setColumnWidth(5, 40);//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
+ myListPoints->setColumnWidth(6, 40);//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
+ myListPoints->setSelectionMode(QAbstractItemView::NoSelection);
+
+ QStringList aLabels;
+ aLabels.append( "ID" );
+ aLabels.append( "X" );
+ aLabels.append( "Y" );
+ aLabels.append( "Z" );
+ aLabels.append( "I" );//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
+ aLabels.append( "J" );//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
+ aLabels.append( "K" );//ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
+ aLabels.append( tr("CELL_DATA_SCALAR_HDR") );
+ aLabels.append( tr("CELL_DATA_VECTOR_HDR") );
+ myListPoints->setHorizontalHeaderLabels( aLabels );
+
+ aCellLayout->addWidget(myListPoints, 1, 0);
+
+ // Actor Pane
+ myActorsPane = new QWidget (mainFrame());
+ aVBoxLayout = new QVBoxLayout(myActorsPane);
+ aVBoxLayout->setSpacing(6);
+
+ QGroupBox* aPosGrp = new QGroupBox (tr("ACTOR_DATA_POSITION_TITLE"), myActorsPane);
+ aGridLay = new QGridLayout (aPosGrp);
+ aGridLay->setSpacing(6);
+ aGridLay->addWidget( new QLabel ("X:", aPosGrp), 0, 0);
+ myXPosLbl = new QLabel ("0", aPosGrp);
+ aGridLay->addWidget( myXPosLbl, 0, 1);
+ aGridLay->addWidget( new QLabel ("Y:", aPosGrp), 1, 0);
+ myYPosLbl = new QLabel ("0", aPosGrp);
+ aGridLay->addWidget( myYPosLbl, 1, 1);
+ aGridLay->addWidget( new QLabel ("Z:", aPosGrp), 2, 0);
+ myZPosLbl = new QLabel ("0", aPosGrp);
+ aGridLay->addWidget( myZPosLbl, 2, 1);
+
+ aVBoxLayout->addWidget( aPosGrp );
+
+ QGroupBox* aSizeGrp = new QGroupBox ( tr("ACTOR_DATA_SIZE_TITLE"), myActorsPane);
+ aGridLay = new QGridLayout (aSizeGrp);
+ aGridLay->setSpacing(6);
+ aGridLay->addWidget( new QLabel ("dX:", aSizeGrp ), 0, 0);
+ myDXLbl = new QLabel ("0", aSizeGrp);
+ aGridLay->addWidget( myDXLbl, 0, 1);
+ aGridLay->addWidget( new QLabel ("dY:", aSizeGrp ), 1, 0);
+ myDYLbl = new QLabel ("0", aSizeGrp);
+ aGridLay->addWidget( myDYLbl, 1, 1);
+ aGridLay->addWidget( new QLabel ("dZ:", aSizeGrp ), 2, 0);
+ myDZLbl = new QLabel ("0", aSizeGrp);
+ aGridLay->addWidget( myDZLbl, 2, 1);
+
+ aVBoxLayout->addWidget( aSizeGrp );
+ aVBoxLayout->addStretch();
+
+ // Gauss Points Pane
+ myGaussPointsPane = new VisuGUI_GaussPointsSelectionPane( myModule, mainFrame() );
+
+ // Add panes to tab widget
+ myTabWidget->addTab(myActorsPane, tr("MODE_ACTOR"));
+ myTabWidget->addTab(myCellsPane, tr("MODE_CELL"));
+ myTabWidget->addTab(myPointsPane, tr("MODE_POINT"));
+ myTabWidget->addTab(myGaussPointsPane, tr("MODE_GAUSS_POINT"));
+
+ connect(myTabWidget, SIGNAL(currentChanged(int)), this, SLOT(onSelectionModeChanged(int)));
+
+ TopLayout->addWidget(myTabWidget);
+
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
+ (SUIT_Session::session()->activeApplication());
+ mySelectionMgr = anApp->selectionMgr();
+ connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionEvent()));
+
+ //connect(visuGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(close()));
+
+ myFl = false;
+
+ // Activate Points pane
+ myTabWidget->setCurrentWidget(myActorsPane);
+ if (SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule))
+ aViewWindow->SetSelectionMode(ActorSelection);
+ onSelectionEvent();
+}
+
+VisuGUI_SelectionPanel::~VisuGUI_SelectionPanel()
+{
+}
+
+void VisuGUI_SelectionPanel::onSelectionModeChanged (int theId)
+{
+ //printf( "VisuGUI_SelectionPanel::onSelectionModeChanged( %d )\n", theId );
+ SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule);
+ if (!aViewWindow) return;
+
+ myGaussPointsPane->Close(); // unselect gauss points
+
+ switch (theId) {
+ case 0: // Actor
+ aViewWindow->SetSelectionMode(ActorSelection);
+ onSelectionEvent();
+ break;
+ case 1: // Cells
+ aViewWindow->SetSelectionMode(CellSelection);
+ onCellIdEdit();
+ break;
+ case 2: // Points
+ aViewWindow->SetSelectionMode(NodeSelection);
+ onPointIdEdit();
+ break;
+ case 3: // Gauss Points
+ aViewWindow->SetSelectionMode(GaussPointSelection);
+ myGaussPointsPane->Update();
+ onSelectionEvent();
+ break;
+ }
+}
+
+
+void VisuGUI_SelectionPanel::closeEvent (QCloseEvent* theEvent)
+{
+ myTabWidget->setCurrentWidget(myActorsPane);
+
+ VisuGUI_BasePanel::closeEvent(theEvent);
+}
+
+template<class TData> QString getValue(TData* theData, int theId){
+ if (vtkDataArray *aScalar = theData->GetScalars()){
+ vtkFloatingPointType aVal = aScalar->GetTuple1(theId);
+ return QString::number(aVal);
+ } else {
+ return QString("No data");
+ }
+}
+
+template<class TData> QString getVector(TData* theData, int theId){
+ if (vtkDataArray *aVector = theData->GetVectors()) {
+ vtkFloatingPointType *aVal = aVector->GetTuple3(theId);
+ return QString("%1; %2; %3").arg(aVal[0]).arg(aVal[1]).arg(aVal[2]);
+ } else {
+ return QString("No data");
+ }
+}
+
+#define ABS(a) (a>=0)?a:-a
+
+void VisuGUI_SelectionPanel::onSelectionEvent() {
+ SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule);
+ if (!aViewWindow)
+ return;
+
+ switch (aViewWindow->SelectionMode()) {
+ case ActorSelection:
+ case CellSelection:
+ case NodeSelection:
+ case GaussPointSelection:
+ break;
+ default:
+ close();
+ //delete this;
+ return;
+ }
+
+ if (myFl)
+ return;
+ myFl = true;
+
+ int aType = myTabWidget->currentIndex();
+
+ if(SVTK_MainWindow* aMainWindow = aViewWindow->getMainWindow())
+ {
+ SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
+ myGaussPointsPane->SetInteractor(anInteractor);
+ }
+
+ SVTK_Selector* aSelector = aViewWindow->GetSelector();
+
+ _PTR(SObject) aSObject;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ Handle(SALOME_InteractiveObject) anIO;
+
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(myModule);
+ if(aSelectionInfo.size() == 1){
+ // Get selected SObject
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ VISU::TObjectInfo anObjectInfo = aSelectionItem.myObjectInfo;
+ aPrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
+ if(aPrs3d){
+ anIO = aSelectionItem.myIO;
+ aSObject = anObjectInfo.mySObject;
+ }
+ }
+
+
+ if (aPrs3d) {
+ QString aMeshName("NULL"), aFieldName("NULL");
+ if (aSObject) {
+ VISU::Storable::TRestoringMap aMap = VISU::Storable::GetStorableMap(aSObject);
+ if (!aMap.empty()) {
+ aMeshName = VISU::Storable::FindValue(aMap, "myMeshName");
+ aFieldName = VISU::Storable::FindValue(aMap, "myFieldName");
+ }
+ }
+
+ myMeshName ->setText((aMeshName == "NULL") ? QString("No name") : aMeshName);
+ myFieldName->setText((aFieldName == "NULL") ? QString("No name") : aFieldName);
+
+ VISU_Actor* anVISUActor =
+ VISU::FindActor(VISU::GetAppStudy(myModule), aViewWindow, aSObject->GetID().c_str());
+ if (anVISUActor) {
+ vtkFloatingPointType aCoord[6];
+ anVISUActor->GetBounds(aCoord);
+ myXPosLbl->setText(QString::number( aCoord[0] ));
+ myYPosLbl->setText(QString::number( aCoord[2] ));
+ myZPosLbl->setText(QString::number( aCoord[4] ));
+
+ myDXLbl->setText(QString::number( ABS(aCoord[1]-aCoord[0]) ));
+ myDYLbl->setText(QString::number( ABS(aCoord[3]-aCoord[2]) ));
+ myDZLbl->setText(QString::number( ABS(aCoord[5]-aCoord[4]) ));
+
+ TColStd_IndexedMapOfInteger aMapIndex;
+ typedef std::vector<vtkFloatingPointType> TCoordArray;
+ typedef map<int, TCoordArray> TPointCoordsMap;
+ TPointCoordsMap aPointCoordsMap;
+
+ aSelector->GetIndex(anIO, aMapIndex);
+
+ vtkDataSet* aDataSet = anVISUActor->GetMapper()->GetInput();
+ vtkPointData* aPntData = aDataSet->GetPointData();
+
+ for (int ind = 1; ind <= aMapIndex.Extent(); ind++) {
+ int anID = aMapIndex(ind);
+
+ switch (aType) {
+ case 2:
+ {
+ int aVTKID = anVISUActor->GetNodeVTKID(anID);
+ if(aVTKID >= 0){
+ vtkFloatingPointType* aCoord = anVISUActor->GetNodeCoord(anID);
+ myXValLbl->setText( QString::number( aCoord[0] ) );
+ myYValLbl->setText( QString::number( aCoord[1] ) );
+ myZValLbl->setText( QString::number( aCoord[2] ) );
+ myIDValLbl->setText( QString::number(anID) );
+ myScalarValLbl->setText(getValue(aPntData, aVTKID));
+ myVectorValLbl->setText(getVector(aPntData, aVTKID));
+ //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
+ const VISU::PIDMapper& aMapper = aPrs3d->GetPipeLine()->GetIDMapper();
+ VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(anID);
+ switch(aVec.size()){
+ case 3:
+ myKValLbl->setText(QString::number(aVec[2]));
+ case 2:
+ myJValLbl->setText(QString::number(aVec[1]));
+ case 1:
+ myIValLbl->setText(QString::number(aVec[0]));
+ break;
+ default:
+ myIValLbl->setText("-");
+ myJValLbl->setText("-");
+ myKValLbl->setText("-");
+ }
+ //ENK: 23.11.2006
+ }
+ }
+ break;
+ case 1:
+ {
+ vtkCellData* aCellData = aDataSet->GetCellData();
+ vtkCell* aCell = anVISUActor->GetElemCell(anID);
+ int aVTKID = anVISUActor->GetElemVTKID(anID);
+ if (aCell != NULL) {
+ int aNbOfPoints = aCell->GetNumberOfPoints();
+ if ( aNbOfPoints > 0 ) {
+ myCellIDValLbl->setText( QString::number(anID) );
+ myCellScalarValLbl->setText(getValue(aCellData, aVTKID));
+ myCellVectorValLbl->setText(getVector(aCellData, aVTKID));
+
+ vtkIdList *aPointList = aCell->GetPointIds();
+ for (int i = 0; i < aNbOfPoints; i++) {
+ int aNodeVTKId = aPointList->GetId(i);
+ vtkFloatingPointType* aCoord = aDataSet->GetPoint(aNodeVTKId);
+ vtkIdType aNodeObjId = anVISUActor->GetNodeObjId(aNodeVTKId);
+ TCoordArray aCoordArray(aCoord, aCoord + 3);
+ aPointCoordsMap[aNodeObjId] = aCoordArray;
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+
+ myListPoints->setRowCount(aPointCoordsMap.size());
+ TPointCoordsMap::const_iterator anIter = aPointCoordsMap.begin();
+
+ const VISU::PIDMapper& aMapper = aPrs3d->GetPipeLine()->GetIDMapper();
+ for (int i = 0; anIter != aPointCoordsMap.end() && i < myListPoints->rowCount(); anIter++, i++) {
+ myListPoints->model()->setHeaderData( i, Qt::Vertical, QVariant(QString::number( i )), Qt::DisplayRole );
+ vtkIdType aNodeObjId = anIter->first;
+ //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
+ VISU::TIdTypeVector aVec = aMapper->GetIndexesOfNode(aNodeObjId);
+ QString aI,aJ,aK;
+ aI = "-";
+ aJ = "-";
+ aK = "-";
+ switch(aVec.size()){
+ case 3:
+ aK = QString::number(aVec[2]);
+ case 2:
+ aJ = QString::number(aVec[1]);
+ case 1:
+ aI = QString::number(aVec[0]);
+ break;
+ }
+ //ENK: 23.11.2006
+
+ QAbstractItemModel* aModel = myListPoints->model();
+ aModel->setData( aModel->index(i,0), QVariant(QString::number( aNodeObjId )), Qt::DisplayRole );
+ const TCoordArray& aCoordArray = anIter->second;
+ aModel->setData( aModel->index(i,1), QVariant(QString::number( aCoordArray[0] )), Qt::DisplayRole );
+ aModel->setData( aModel->index(i,2), QVariant(QString::number( aCoordArray[1] )), Qt::DisplayRole );
+ aModel->setData( aModel->index(i,3), QVariant(QString::number( aCoordArray[2] )), Qt::DisplayRole );
+ aModel->setData( aModel->index(i,4), QVariant( aI ), Qt::DisplayRole );//ENK: 23.11.2006 - PAL13176
+ aModel->setData( aModel->index(i,5), QVariant( aJ ), Qt::DisplayRole );//ENK: 23.11.2006 - PAL13176
+ aModel->setData( aModel->index(i,6), QVariant( aK ), Qt::DisplayRole );//ENK: 23.11.2006 - PAL13176
+
+ vtkIdType aNodeVTKId = anVISUActor->GetNodeVTKID(aNodeObjId);
+ aModel->setData( aModel->index(i,7), QVariant(getValue(aPntData, aNodeVTKId)), Qt::DisplayRole );
+ aModel->setData( aModel->index(i,8), QVariant(getVector(aPntData, aNodeVTKId)), Qt::DisplayRole );
+ }
+ //for(int aColumnId = 0; aColumnId < 9; aColumnId++)
+ myListPoints->resizeColumnsToContents();
+ }
+ } else {
+ clearFields();
+ }
+ myFl = false;
+}
+#undef ABS
+
+
+void VisuGUI_SelectionPanel::clearFields() {
+ int aType = myTabWidget->currentIndex();
+ switch (aType) {
+ case 2:
+ myXValLbl->setText( "" );
+ myYValLbl->setText( "" );
+ myZValLbl->setText( "" );
+ myIValLbl->setText( "-" );//ENK: 23.11.2006 - PAL13176
+ myJValLbl->setText( "-" );//ENK: 23.11.2006 - PAL13176
+ myKValLbl->setText( "-" );//ENK: 23.11.2006 - PAL13176
+ myScalarValLbl->setText("");
+ myVectorValLbl->setText("");
+ break;
+ case 1:
+ myCellScalarValLbl->setText("");
+ myCellVectorValLbl->setText("");
+ myListPoints->setRowCount(0);
+ break;
+ case 0:
+ myXPosLbl->setText("");
+ myYPosLbl->setText("");
+ myZPosLbl->setText("");
+ myDXLbl->setText("");
+ myDYLbl->setText("");
+ myDZLbl->setText("");
+ }
+}
+
+typedef vtkIdType (VISU_PipeLine::* TGetVTKIdMethod)(vtkIdType theID);
+
+bool onIdEdit (const QString& theText,
+ TGetVTKIdMethod theMethod,
+ bool theIsCell,
+ const SalomeApp_Module* theModule,
+ QLabel* theMeshName,
+ QString theValue,
+ QLabel* theFieldName)
+{
+ SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>(theModule);
+ if (!aViewWindow)
+ return false;
+ SVTK_Selector* aSelector = aViewWindow->GetSelector();
+
+ _PTR(SObject) aSObject;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ Handle(SALOME_InteractiveObject) anIO;
+
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule);
+ if(aSelectionInfo.size() == 1){
+ // Get selected SObject
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ VISU::TObjectInfo anObjectInfo = aSelectionItem.myObjectInfo;
+ aPrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
+ if(aPrs3d){
+ anIO = aSelectionItem.myIO;
+ aSObject = anObjectInfo.mySObject;
+ }
+ }
+ if (aPrs3d) {
+ int anObjId = theText.toInt();
+ VISU_PipeLine* aPipeLine = aPrs3d->GetPipeLine();
+ int aVTKId = (aPipeLine->*theMethod)(anObjId);
+ if(aVTKId < 0)
+ return false;
+
+ TColStd_MapOfInteger newIndices;
+ newIndices.Add(anObjId);
+ aSelector->AddOrRemoveIndex(anIO, newIndices, false);
+ aViewWindow->highlight(anIO, true, true);
+
+ return true;
+
+ } else {
+ theMeshName->setText(theValue);
+ theFieldName->setText("");
+ }
+ return false;
+}
+
+void VisuGUI_SelectionPanel::onPointIdEdit ()
+{
+ if (myFl) return;
+ TGetVTKIdMethod aMethod = &VISU_PipeLine::GetNodeVTKID;
+ bool anIsSelected = onIdEdit(myIDValLbl->text(),
+ aMethod,
+ false,
+ myModule,
+ myMeshName,
+ tr("WRN_NO_AVAILABLE_DATA"),
+ myFieldName);
+ if (anIsSelected)
+ // as selection manager doesn't send signal currentSelectionChanged()
+ onSelectionEvent();
+ else
+ clearFields();
+}
+
+void VisuGUI_SelectionPanel::onCellIdEdit ()
+{
+ if (myFl) return;
+ TGetVTKIdMethod aMethod = &VISU_PipeLine::GetElemVTKID;
+ bool anIsSelected = onIdEdit(myCellIDValLbl->text(),
+ aMethod,
+ true,
+ myModule,
+ myMeshName,
+ tr("WRN_NO_AVAILABLE_DATA"),
+ myFieldName);
+ if (anIsSelected)
+ // as selection manager doesn't send signal currentSelectionChanged()
+ onSelectionEvent();
+ else
+ clearFields();
+}
+
+void VisuGUI_SelectionPanel::onApply()
+{
+ //printf( "VisuGUI_SelectionPanel::onApply()\n" );
+ int aType = myTabWidget->currentIndex();
+ switch( aType )
+ {
+ case 1: // Cells
+ onCellIdEdit();
+ break;
+ case 2: // Points
+ onPointIdEdit();
+ break;
+ case 3: // Gauss Points
+ myGaussPointsPane->Apply();
+ break;
+ default:
+ break;
+ }
+
+ VisuGUI_BasePanel::onApply();
+}
+
+void VisuGUI_SelectionPanel::onClose()
+{
+ //printf( "VisuGUI_SelectionPanel::onClose()\n" );
+ close();
+
+ VisuGUI_BasePanel::onClose();
+}
+
+void VisuGUI_SelectionPanel::onHelp()
+{
+ QString aHelpFileName = "selection_info_page.html";
+ LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app)
+ app->onHelpContextModule(myModule ? app->moduleName(myModule->moduleName()) : QString(""), aHelpFileName);
+ else {
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
+ QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) );
+ }
+
+ VisuGUI_BasePanel::onHelp();
+}
+
+void VisuGUI_SelectionPanel::keyPressEvent( QKeyEvent* e )
+{
+ VisuGUI_BasePanel::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 )
+ {
+ e->accept();
+ onHelp();
+ }
+}
--- /dev/null
+// VISU VISUGUI : GUI of VISU 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : VisuGUI_SelectionPanel.h
+// Author : Laurent CORNABE & Hubert ROLLAND
+// Module : VISU
+// $Header$
+
+#ifndef VISUGUI_SELECTIONPANEL_H
+#define VISUGUI_SELECTIONPANEL_H
+
+#include <VisuGUI_BasePanel.h>
+
+class QLabel;
+class QLineEdit;
+class QTableWidget;
+class QTabWidget;
+
+class LightApp_SelectionMgr;
+class SalomeApp_Application;
+class SalomeApp_Module;
+class SVTK_RenderWindowInteractor;
+
+class VisuGUI_GaussPointsSelectionPane;
+
+class VisuGUI_SelectionPanel: public VisuGUI_BasePanel
+{
+ Q_OBJECT
+
+public:
+ VisuGUI_SelectionPanel( const SalomeApp_Module* theModule, QWidget* theParent = 0 );
+ virtual ~VisuGUI_SelectionPanel ();
+
+private:
+ void keyPressEvent( QKeyEvent* theEvent );
+
+protected:
+ void closeEvent( QCloseEvent* theEvent );
+
+private slots:
+ virtual void onApply();
+ virtual void onClose();
+ virtual void onHelp();
+
+ void onSelectionModeChanged( int theId );
+ void onSelectionEvent();
+ void onPointIdEdit();
+ void onCellIdEdit();
+
+private:
+ void clearFields();
+
+private:
+ QLabel* myMeshName;
+ QLabel* myFieldName;
+
+ QTabWidget* myTabWidget;
+ QWidget* myPointsPane;
+ QWidget* myCellsPane;
+ QLabel* myXValLbl;
+ QLabel* myYValLbl;
+ QLabel* myZValLbl;
+ //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing
+ QLabel* myIValLbl; //!< used for structured mesh selection
+ QLabel* myJValLbl; //!< used for structured mesh selection
+ QLabel* myKValLbl; //!< used for structured mesh selection
+ //ENK: 23.11.2006
+
+ QLineEdit* myIDValLbl;
+ QLabel* myScalarValLbl;
+ QLabel* myVectorValLbl;
+
+ QTableWidget* myListPoints;
+ QLineEdit* myCellIDValLbl;
+ QLabel* myCellScalarValLbl;
+ QLabel* myCellVectorValLbl;
+
+ QWidget* myActorsPane;
+ QLabel* myXPosLbl;
+ QLabel* myYPosLbl;
+ QLabel* myZPosLbl;
+ QLabel* myDXLbl;
+ QLabel* myDYLbl;
+ QLabel* myDZLbl;
+
+ VisuGUI_GaussPointsSelectionPane* myGaussPointsPane;
+
+ const SalomeApp_Module* myModule;
+ LightApp_SelectionMgr* mySelectionMgr;
+ bool myFl;
+};
+
+#endif