Refactoring (removing obsolete GUITOOLS and VVTK packages) + improvement of VISU_TableDlg class, introducing edition and sorting features (intermediate state)
--- /dev/null
+# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# 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
+#
+# VISU VISUGUI : GUI of VISU component
+# File : Makefile.in
+# Author : Marc Tajchman (CEA)
+# Module : VISU
+# $Header$
+#
+include $(top_srcdir)/adm_local/unix/make_common_starter.am
+
+lib_LTLIBRARIES= libVISUGUITOOLS.la
+
+salomeinclude_HEADERS= \
+ VisuGUI_TableDlg.h \
+ VisuGUITools.h \
+ VisuGUI_GUITools.h
+
+dist_libVISUGUITOOLS_la_SOURCES= \
+ VisuGUI_TableDlg.cxx \
+ VisuGUI_GUITools.cxx
+
+MOC_FILES= VisuGUI_TableDlg_moc.cxx
+nodist_libVISUGUITOOLS_la_SOURCES=$(MOC_FILES)
+
+# additionnal information to compil and link file
+libVISUGUITOOLS_la_CPPFLAGS= -ftemplate-depth-32 \
+ $(QT_INCLUDES) $(VTK_INCLUDES) @CAS_CPPFLAGS@ @CAS_CXXFLAGS@ \
+ $(PYTHON_INCLUDES) $(HDF5_INCLUDES) $(QWT_INCLUDES) \
+ $(KERNEL_CXXFLAGS) $(GUI_CXXFLAGS) $(BOOST_CPPFLAGS)
+
+libVISUGUITOOLS_la_LDFLAGS= \
+ $(KERNEL_LDFLAGS) -lSALOMELocalTrace \
+ $(GUI_LDFLAGS) -lCAM -lsuit -lqtx -lSalomeApp
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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 : VisuGUITools.h
+// Author : Oleg UVAROV
+// Module : VISU
+//
+#ifndef _VisuGUITools_H_
+#define _VisuGUITools_H_
+
+#ifdef WNT
+ #if defined VISU_GUITOOLS_EXPORTS || defined VISUGUITOOLS_EXPORTS
+ #if defined WIN32
+ #define VISU_GUITOOLS_EXPORT __declspec( dllexport )
+ #else
+ #define VISU_GUITOOLS_EXPORT
+ #endif
+ #else
+ #if defined WIN32
+ #define VISU_GUITOOLS_EXPORT __declspec( dllimport )
+ #else
+ #define VISU_GUITOOLS_EXPORT
+ #endif
+ #endif
+#else
+ #define VISU_GUITOOLS_EXPORT
+#endif
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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_GUITools.cxx
+// Author : Sergey ANIKIN, Open CASCADE S.A.S.
+// Module : VISU
+//
+
+#include "VisuGUI_GUITools.h"
+
+#include <SalomeApp_IntSpinBox.h>
+#include <SalomeApp_DoubleSpinBox.h>
+
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
+#include <QVariant>
+
+namespace VISU{
+ void initSpinBox( SalomeApp_IntSpinBox* sb,
+ const int bottom,
+ const int top,
+ const int step )
+ {
+ sb->setAcceptNames( false );
+ sb->setRange( bottom, top );
+ sb->setSingleStep( step );
+ }
+
+ void initSpinBox( SalomeApp_DoubleSpinBox* sb,
+ const double& bottom,
+ const double& top,
+ const double& step,
+ const char* quantity )
+ {
+ // Obtain precision from preferences
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ int precision = resMgr->integerValue( "VISU", quantity, 3 );
+
+ sb->setPrecision ( precision );
+ sb->setDecimals ( qAbs(precision) );
+ sb->setRange ( bottom, top );
+ sb->setSingleStep ( step );
+ sb->setDefaultValue( bottom );
+ sb->setAcceptNames ( false );
+
+ // Add a hint for the user saying how to tune precision
+ QString userPropName = QObject::tr( QString( "VISU_PREF_%1" ).arg( quantity ).toLatin1().constData() );
+ sb->setProperty( "validity_tune_hint",
+ QVariant( QObject::tr( "VISU_PRECISION_HINT" ).arg( userPropName ) ) );
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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_GUITools.h
+// Author : Sergey ANIKIN, Open CASCADE S.A.S.
+// Module : VISU
+//
+#ifndef VISUGUI_GUITOOLS_H
+#define VISUGUI_GUITOOLS_H
+
+#include "VisuGUITools.h"
+
+class SalomeApp_IntSpinBox;
+class SalomeApp_DoubleSpinBox;
+
+namespace VISU{
+ VISU_GUITOOLS_EXPORT
+ void initSpinBox( SalomeApp_IntSpinBox*, const int, const int, const int );
+ VISU_GUITOOLS_EXPORT
+ void initSpinBox( SalomeApp_DoubleSpinBox*, const double&, const double&, const double&, const char* );
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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_TableDlg.cxx
+// Author : Vadim SANDLER
+// Module : SALOME
+//
+#include "VisuGUI_TableDlg.h"
+
+#include "SUIT_Tools.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+
+#include "LightApp_Application.h"
+
+#include "CAM_Module.h"
+
+#include "SALOMEDSClient_Study.hxx"
+#include "SALOMEDSClient_GenericAttribute.hxx"
+#include "SALOMEDSClient_AttributeTableOfInteger.hxx"
+#include "SALOMEDSClient_AttributeTableOfReal.hxx"
+#include "SALOMEDSClient_StudyBuilder.hxx"
+
+#include <QLayout>
+#include <QValidator>
+#include <QTableWidget>
+#include <QTabWidget>
+#include <QList>
+#include <QVector>
+#include <QInputDialog>
+#include <QLabel>
+#include <QIntValidator>
+#include <QDoubleValidator>
+#include <QKeyEvent>
+#include <QHeaderView>
+
+#include "utilities.h"
+
+using namespace std;
+
+#define MARGIN_SIZE 11
+#define SPACING_SIZE 6
+#define SPACER_SIZE 5
+#define MIN_TABLE_WIDTH 200
+#define MIN_TABLE_HEIGHT 200
+
+NumDelegateItem::NumDelegateItem( QObject* parent, NumValidator mode )
+ : QItemDelegate( parent ),
+ myMode( mode )
+{
+}
+
+NumDelegateItem::~NumDelegateItem()
+{
+}
+
+QWidget * NumDelegateItem::createEditor( QWidget * parent,
+ const QStyleOptionViewItem & option,
+ const QModelIndex & index ) const
+{
+ QLineEdit *editor = new QLineEdit(parent);
+ switch ( myMode )
+ {
+ case NV_Int:
+ editor->setValidator( new QIntValidator( editor ) );
+ break;
+ case NV_Real:
+ editor->setValidator( new QDoubleValidator( editor ) );
+ break;
+ default:
+ editor->setText( "No validator!" );
+ }
+
+ return editor;
+}
+
+void NumDelegateItem::setEditorData( QWidget * editor,
+ const QModelIndex & index ) const
+{
+ QLineEdit *aLE = qobject_cast<QLineEdit*>(editor);
+ if ( !aLE )
+ return;
+
+ switch ( myMode )
+ {
+ case NV_Int:
+ {
+ int value = index.model()->data(index, Qt::DisplayRole).toInt();
+ aLE->setText( QString("%1").arg( value ) );
+ break;
+ }
+ case NV_Real:
+ {
+ double value = index.model()->data(index, Qt::DisplayRole).toDouble();
+ aLE->setText( QString("%1").arg( value ) );
+ break;
+ }
+ default:
+ aLE->setText( "No validator!!!" );
+ }
+}
+
+
+
+
+
+/*class VisuGUI_Table : public QTableWidget {
+public:
+ VisuGUI_Table( Orientation orient, QWidget* parent = 0 )
+ : QTableWidget( parent ), myValidator( 0 ), myOrientation( orient ) {}
+ VisuGUI_Table( Orientation orient, int numRows, int numCols, QWidget* parent = 0 )
+ : QTableWidget( numRows, numCols, parent ), myValidator( 0 ), myOrientation( orient ) {}
+
+ void setValidator( QValidator* v = 0 ) { myValidator = v; }
+ bool isEditing() const { return QTable::isEditing(); }
+
+protected:
+ QWidget* createEditor ( int row, int col, bool initFromCell ) const
+ {
+ bool testUnits = ( myOrientation == Qt::Horizontal && col == 0 ) || ( myOrientation == Qt::Vertical && row == 0 );
+ QWidget* wg = QTable::createEditor( row, col, initFromCell );
+ if ( wg && wg->inherits("QLineEdit") && myValidator && !testUnits )
+ (( QLineEdit*)wg)->setValidator( myValidator );
+ return wg;
+ }
+
+protected:
+ QValidator* myValidator;
+ Orientation myOrientation;
+ };*/
+
+/*!
+ Constructor
+*/
+VisuGUI_TableDlg::VisuGUI_TableDlg( QWidget* parent,
+ _PTR(SObject) obj,
+ bool edit,
+ int which,
+ Qt::Orientation orient,
+ bool showColumnTitles )
+ : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
+ myIntTable( 0 ), myRealTable( 0 )
+{
+ setWindowTitle( edit ? tr( "EDIT_TABLE_TLT" ) : tr( "VIEW_TABLE_TLT" ) );
+ setSizeGripEnabled( true );
+
+ myObject = obj;
+ bool bHasIntTable = false;
+ bool bHasRealTable = false;
+ if ( myObject ) {
+ _PTR(GenericAttribute) anAttr;
+ bHasIntTable = myObject->FindAttribute( anAttr, "AttributeTableOfInteger");
+ bHasRealTable = myObject->FindAttribute( anAttr, "AttributeTableOfReal");
+ }
+
+ QVBoxLayout* mainLayout = new QVBoxLayout( this );
+ mainLayout->setMargin( MARGIN_SIZE );
+ mainLayout->setSpacing( SPACING_SIZE );
+
+ bool bDoInt = which == ttInt || which == ttBoth || which == ttAuto && bHasIntTable;
+ bool bDoReal = which == ttReal || which == ttBoth || which == ttAuto && bHasRealTable;
+
+ QWidget* top;
+ QVBoxLayout* tl;
+ if ( bDoInt && bDoReal ) {
+ top = new QTabWidget( this );
+ //( ( QTabWidget* ) top) ->setMargin( MARGIN_SIZE );
+ }
+ else {
+ top = new QWidget( this );
+ tl = new QVBoxLayout( top ); tl->setMargin( 0 ); tl->setSpacing( SPACING_SIZE );
+ }
+
+ if ( bDoInt ) {
+ myIntTable = new VisuGUI_TableWidget( top, "myIntTable", edit, orient, showColumnTitles );
+ //myIntTable->getTable()->setValidator( new QIntValidator( this ) );
+ //QAbstractItemDelegate* item = myIntTable->getTable()->itemDelegate();
+ myIntTable->getTable()->setItemDelegate( new NumDelegateItem( myIntTable, NumDelegateItem::NV_Int ) );
+ //item->deleteLater();
+
+ if ( bDoInt && bDoReal )
+ ( ( QTabWidget* )top )->addTab( myIntTable, tr( "TABLE_OF_INTEGER_TLT" ) );
+ else
+ tl->addWidget( myIntTable );
+ }
+ if ( bDoReal ) {
+ myRealTable = new VisuGUI_TableWidget( top, "myRealTable", edit, orient, showColumnTitles );
+ //myRealTable->getTable()->setValidator( new QDoubleValidator( this ) );
+ //QAbstractItemDelegate* item = myIntTable->getTable()->itemDelegate();
+ myRealTable->getTable()->setItemDelegate( new NumDelegateItem( myRealTable, NumDelegateItem::NV_Real ) );
+ //item->deleteLater();
+ if ( bDoInt && bDoReal )
+ ( ( QTabWidget* )top )->addTab( myRealTable, tr( "TABLE_OF_REAL_TLT" ) );
+ else
+ tl->addWidget( myRealTable );
+ }
+ if ( !bDoInt && !bDoReal ) {
+ QLabel *dumbLabel = new QLabel( tr( "ERR_TABLE_NOT_AVAILABLE" ), top );
+ dumbLabel->setAlignment( Qt::AlignCenter );
+ tl->addWidget( dumbLabel );
+ }
+
+ QHBoxLayout* btnLayout = new QHBoxLayout;
+ btnLayout->setMargin( 0 ); btnLayout->setSpacing( SPACING_SIZE );
+
+ myOKBtn = new QPushButton( tr( "BUT_OK" ), this );
+ myHelpBtn = new QPushButton( tr( "BUT_HELP" ), this );
+ if ( edit ) {
+ myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this );
+ btnLayout->addWidget( myOKBtn );
+ btnLayout->addItem( new QSpacerItem( SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
+ btnLayout->addWidget( myCancelBtn );
+ btnLayout->addWidget( myHelpBtn );
+ connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( onOK() ) );
+ connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ }
+ else {
+ btnLayout->addWidget( myOKBtn );
+ btnLayout->addItem( new QSpacerItem( SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
+ btnLayout->addWidget( myHelpBtn );
+ connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ }
+ connect( myHelpBtn, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
+
+ mainLayout->addWidget( top );
+ mainLayout->addLayout( btnLayout );
+
+ initDlg();
+ resize( 500, 400 );
+ SUIT_Tools::centerWidget( this, parent );
+}
+
+/*!
+ Destructor
+*/
+VisuGUI_TableDlg::~VisuGUI_TableDlg()
+{
+}
+
+/*!
+ <OK> button slot, saves table(s)
+ Called only in create/edit mode ( <edit> parameter for constructor is true )
+*/
+void VisuGUI_TableDlg::onOK()
+{
+ myOKBtn->setFocus(); // accept possible changes
+ bool done = true;
+
+ if ( myObject ) {
+ _PTR(Study) study = myObject->GetStudy();
+ _PTR(AttributeTableOfInteger) tblIntAttr;
+ _PTR(AttributeTableOfReal) tblRealAttr;
+
+ if ( study ) {
+ _PTR(StudyBuilder) builder = study->NewBuilder();
+ builder->NewCommand(); // start transaction !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ try {
+ if ( myIntTable ) {
+ builder->RemoveAttribute( myObject, "AttributeTableOfInteger" );
+ tblIntAttr = builder->FindOrCreateAttribute( myObject, "AttributeTableOfInteger" );
+
+ int i;
+ int nbRows = myIntTable->getNumRows();
+ int nbCols = myIntTable->getNumCols();
+ QString tlt = myIntTable->getTableTitle();
+ QStringList rowTitles, colTitles, units;
+ myIntTable->getRowTitles( rowTitles );
+ myIntTable->getColTitles( colTitles );
+ myIntTable->getUnits( units );
+
+ if ( nbRows > 0) {
+ // data
+ int nRow = 0;
+ tblIntAttr->SetNbColumns( nbCols );
+ for ( i = 0; i < nbRows; i++ ) {
+ QStringList data;
+ myIntTable->getRowData( i, data );
+ bool bEmptyRow = true;
+ for ( int j = 0; j < data.count(); j++ ) {
+ if ( !data[ j ].isNull() ) {
+ tblIntAttr->PutValue( data[ j ].toInt(), nRow+1, j+1 );
+ bEmptyRow = false;
+ }
+ }
+ if ( !bEmptyRow ) { // Skip rows with no data !!!
+ // set row title
+ tblIntAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? "" : (const char*)rowTitles[ i ].toLatin1() );
+ // set row unit
+ tblIntAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? "" : (const char*)units[ i ].toLatin1() );
+ nRow++;
+ }
+ }
+ if ( nRow > 0 ) { // Set columns only if table is not empty, otherwise exception is raised !!!
+ // column titles
+ for ( i = 0; i < colTitles.count(); i++ )
+ tblIntAttr->SetColumnTitle( i+1, colTitles[ i ].isNull() ? "" : (const char*)colTitles[ i ].toLatin1() );
+ }
+ }
+ // title
+ tblIntAttr->SetTitle( (const char*)myIntTable->getTableTitle().toLatin1() );
+ }
+ if ( myRealTable ) {
+ builder->RemoveAttribute( myObject, "AttributeTableOfReal" );
+ tblRealAttr = builder->FindOrCreateAttribute( myObject, "AttributeTableOfReal" );
+
+ int i;
+ int nbRows = myRealTable->getNumRows();
+ int nbCols = myRealTable->getNumCols();
+ QString tlt = myRealTable->getTableTitle();
+ QStringList rowTitles, colTitles, units;
+ myRealTable->getRowTitles( rowTitles );
+ myRealTable->getColTitles( colTitles );
+ myRealTable->getUnits( units );
+
+ if ( nbRows > 0) {
+ // data
+ int nRow = 0;
+ tblRealAttr->SetNbColumns( nbCols );
+ for ( i = 0; i < nbRows; i++ ) {
+ QStringList data;
+ myRealTable->getRowData( i, data );
+ bool bEmptyRow = true;
+ for ( int j = 0; j < data.count(); j++ ) {
+ if ( !data[ j ].isNull() ) {
+ tblRealAttr->PutValue( data[ j ].toDouble(), nRow+1, j+1 );
+ bEmptyRow = false;
+ }
+ }
+ if ( !bEmptyRow ) { // Skip rows with no data !!!
+ // set row title
+ tblRealAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? "" : (const char*)rowTitles[ i ].toLatin1() );
+ // set row unit
+ tblRealAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? "" : (const char*)units[ i ].toLatin1() );
+ nRow++;
+ }
+ }
+ if ( nRow > 0 ) { // Set columns only if table is not empty, otherwise exception is raised !!!
+ // column titles
+ for ( i = 0; i < colTitles.count(); i++ )
+ tblRealAttr->SetColumnTitle( i+1, colTitles[ i ].isNull() ? "" : (const char*)colTitles[ i ].toLatin1() );
+ }
+ }
+ // title
+ tblRealAttr->SetTitle( (const char*)myRealTable->getTableTitle().toLatin1() );
+ }
+ if ( myIntTable || myRealTable)
+ builder->CommitCommand(); // commit transaction !!!!!!!!!!!!!!!!!!!!!!!!!!!
+ else
+ builder->AbortCommand(); // abort transaction !!!!!!!!!!!!!!!!!!!!!!!!!!!
+ }
+ catch( ... ) {
+ MESSAGE("VisuGUI_TableDlg::onOK : Exception has been caught !!!");
+ builder->AbortCommand(); // abort transaction !!!!!!!!!!!!!!!!!!!!!!!!!!!
+ done = false;
+ SUIT_MessageBox::critical ( this, tr("ERR_ERROR"), tr("ERR_APP_EXCEPTION") );
+ }
+ }
+ }
+ if ( done )
+ accept();
+}
+
+/*!
+ <Help> button slot, shows corresponding help page
+*/
+void VisuGUI_TableDlg::onHelp()
+{
+ QString aHelpFileName = "table_presentations_page.html";
+ 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) );
+ }
+}
+
+/*!
+ Populates table with data
+*/
+void VisuGUI_TableDlg::initDlg()
+{
+ int i, j;
+ if ( myObject ) {
+ _PTR(GenericAttribute) anAttr;
+ _PTR(AttributeTableOfInteger) tblIntAttr;
+ _PTR(AttributeTableOfReal) tblRealAttr;
+ if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger") ) {
+ tblIntAttr = anAttr;
+ }
+ if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal") ) {
+ tblRealAttr = anAttr;
+ }
+ // Table of integer
+ if ( tblIntAttr && myIntTable ) {
+ try {
+ // title
+ myIntTable->setTableTitle( tblIntAttr->GetTitle().c_str() );
+ // nb of rows & cols
+ int nbRows = tblIntAttr->GetNbRows() ;
+ int nbCols = tblIntAttr->GetNbColumns();
+ myIntTable->setNumRows( nbRows );
+ myIntTable->setNumCols( nbCols );
+ // rows titles
+ QStringList strlist;
+ vector<string> rowTitles = tblIntAttr->GetRowTitles();
+ for ( i = 0; i < nbRows; i++ ) {
+ if ( rowTitles.size() > 0 )
+ strlist.append( rowTitles[i].c_str() );
+ else
+ strlist.append( "" );
+ }
+ myIntTable->setRowTitles( strlist );
+ // columns titles
+ strlist.clear();
+ vector<string> colTitles = tblIntAttr->GetColumnTitles();
+ for ( i = 0; i < nbCols; i++ ) {
+ if ( colTitles.size() > 0 )
+ strlist.append( colTitles[i].c_str() );
+ else
+ strlist.append( "" );
+ }
+ myIntTable->setColTitles( strlist );
+ // units
+ strlist.clear();
+ vector<string> rowUnits = tblIntAttr->GetRowUnits();
+ if ( rowUnits.size() > 0 ) {
+ for ( i = 0; i < nbRows; i++ )
+ strlist.append( rowUnits[i].c_str() );
+ myIntTable->setUnits( strlist );
+ }
+ // data
+ for ( i = 1; i <= nbRows; i++ ) {
+ strlist.clear();
+ for ( j = 1; j <= nbCols; j++ ) {
+ if ( tblIntAttr->HasValue( i, j ) )
+ strlist.append( QString::number( tblIntAttr->GetValue( i, j ) ) );
+ else
+ strlist.append( QString::null );
+ }
+ myIntTable->setRowData( i-1, strlist );
+ }
+ myIntTable->adjustTable();
+ }
+ catch( ... ) {
+ MESSAGE("VisuGUI_TableDlg::initDlg : Exception has been caught !!!");
+ }
+ }
+ // Table of real
+ if ( tblRealAttr && myRealTable ) {
+ try {
+ // title
+ myRealTable->setTableTitle( tblRealAttr->GetTitle().c_str() );
+ // nb of rows & cols
+ int nbRows = tblRealAttr->GetNbRows() ;
+ int nbCols = tblRealAttr->GetNbColumns();
+ myRealTable->setNumRows( nbRows );
+ myRealTable->setNumCols( nbCols );
+ // rows titles
+ QStringList strlist;
+ vector<string> rowTitles = tblRealAttr->GetRowTitles();
+ for ( i = 0; i < nbRows; i++ ) {
+ if ( rowTitles.size() > 0 )
+ strlist.append( rowTitles[i].c_str() );
+ else
+ strlist.append( "" );
+ }
+ myRealTable->setRowTitles( strlist );
+ // columns titles
+ strlist.clear();
+ vector<string> colTitles = tblRealAttr->GetColumnTitles();
+ for ( i = 0; i < nbCols; i++ ) {
+ if ( colTitles.size() > 0 )
+ strlist.append( colTitles[i].c_str() );
+ else
+ strlist.append( "" );
+ }
+ myRealTable->setColTitles( strlist );
+ // units
+ strlist.clear();
+ vector<string> rowUnits = tblRealAttr->GetRowUnits();
+ if ( rowUnits.size() > 0 ) {
+ for ( i = 0; i < nbRows; i++ )
+ strlist.append( rowUnits[i].c_str() );
+ myRealTable->setUnits( strlist );
+ }
+ // data
+ for ( i = 1; i <= nbRows; i++ ) {
+ strlist.clear();
+ for ( j = 1; j <= nbCols; j++ ) {
+ if ( tblRealAttr->HasValue( i, j ) )
+ strlist.append( QString::number( tblRealAttr->GetValue( i, j ) ) );
+ else
+ strlist.append( QString::null );
+ }
+ myRealTable->setRowData( i-1, strlist );
+ }
+ myRealTable->adjustTable();
+ }
+ catch( ... ) {
+ MESSAGE("VisuGUI_TableDlg::initDlg : Exception has been caught !!!");
+ }
+ }
+ }
+}
+
+/*!
+ Provides help on F1 button click
+*/
+void VisuGUI_TableDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 )
+ {
+ e->accept();
+ onHelp();
+ }
+}
+
+/*!
+ Constructor
+*/
+VisuGUI_TableWidget::VisuGUI_TableWidget( QWidget* parent,
+ const char* name,
+ bool edit,
+ Qt::Orientation orient,
+ bool showColumnTitles )
+ : QWidget( parent ), myOrientation( orient )
+{
+ QGridLayout* mainLayout = new QGridLayout( this );
+ mainLayout->setMargin( 0 );
+ mainLayout->setSpacing( SPACING_SIZE );
+
+ myTitleEdit = new QLineEdit( this );
+ myTitleEdit->setAlignment( Qt::AlignCenter );
+ myTitleEdit->setReadOnly( !edit );
+ QFont fnt = myTitleEdit->font();
+ fnt.setBold( true );
+ myTitleEdit->setFont( fnt );
+
+ //myTable = new VisuGUI_Table( orient, this );
+ myTable = new QTableWidget( 5, 5, this );
+ //myTable->setNumRows( 5 );
+ //myTable->setNumCols( 5 );
+ myTable->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+ myTable->setMinimumSize( MIN_TABLE_WIDTH, MIN_TABLE_HEIGHT );
+ myTable->setSelectionMode( QAbstractItemView::SingleSelection );
+ myTable->setShowGrid( true );
+ myTable->horizontalHeader()->setMovable( false );
+ myTable->verticalHeader()->setMovable( false );
+ //myTable->setColumnMovingEnabled( false );
+ //myTable->setRowMovingEnabled( false );
+ myTable->setDragEnabled( false );
+ //myTable->setReadOnly( !edit );
+ myTable->setEditTriggers( edit ? QAbstractItemView::AllEditTriggers : QAbstractItemView::NoEditTriggers );
+
+ setUnitsTitle( tr( "UNITS_TLT" ) );
+
+ if ( !showColumnTitles ) {
+ if ( myOrientation == Qt::Horizontal ) {
+ myTable->horizontalHeader()->hide();
+ //myTable->setTopMargin( 0 );
+ }
+ else {
+ myTable->verticalHeader()->hide();
+ //myTable->setLeftMargin( 0 );
+ }
+ }
+
+ mainLayout->addWidget( myTitleEdit, 0, 0 );
+ mainLayout->addWidget( myTable, 1, 0 );
+
+ if ( edit ) {
+ myAddRowBtn = new QPushButton( tr( "ADD_ROW_BTN" ), this );
+ myDelRowBtn = new QPushButton( tr( "REMOVE_ROW_BTN" ), this );
+ myAddColBtn = new QPushButton( tr( "ADD_COLUMN_BTN" ), this );
+ myDelColBtn = new QPushButton( tr( "REMOVE_COLUMN_BTN" ), this );
+ myAdjustBtn = new QPushButton( tr( "ADJUST_CELLS_BTN" ), this );
+ mySelectAllBtn = new QPushButton( tr( "SELECT_ALL_BTN" ), this );
+ myClearBtn = new QPushButton( tr( "CLEAR_BTN"), this );
+ QVBoxLayout* btnLayout = new QVBoxLayout; btnLayout->setMargin( 0 ); btnLayout->setSpacing( SPACING_SIZE );
+ btnLayout->addWidget( myAddRowBtn );
+ btnLayout->addWidget( myDelRowBtn );
+ btnLayout->addWidget( myAddColBtn );
+ btnLayout->addWidget( myDelColBtn );
+ btnLayout->addStretch();
+ btnLayout->addWidget( myAdjustBtn );
+ btnLayout->addStretch();
+ btnLayout->addWidget( mySelectAllBtn );
+ btnLayout->addWidget( myClearBtn );
+ mainLayout->addLayout( btnLayout, 1, 1 );
+ connect( myTable, SIGNAL( selectionChanged() ), this, SLOT( updateButtonsState() ) );
+ connect( myTable, SIGNAL( currentChanged( int, int) ), this, SLOT( updateButtonsState() ) );
+ connect( myAddRowBtn, SIGNAL( clicked() ), this, SLOT( addRow() ) );
+ connect( myAddColBtn, SIGNAL( clicked() ), this, SLOT( addCol() ) );
+ connect( myDelRowBtn, SIGNAL( clicked() ), this, SLOT( delRow() ) );
+ connect( myDelColBtn, SIGNAL( clicked() ), this, SLOT( delCol() ) );
+ connect( myAdjustBtn, SIGNAL( clicked() ), this, SLOT( adjustTable() ) );
+ connect( mySelectAllBtn, SIGNAL( clicked() ), this, SLOT( selectAll() ) );
+ connect( myClearBtn, SIGNAL( clicked() ), this, SLOT( clearTable() ) );
+ myTable->horizontalHeader()->installEventFilter( this );
+ myTable->verticalHeader()->installEventFilter( this );
+ myTable->installEventFilter( this );
+ }
+ updateButtonsState();
+}
+/*!
+ Destructor
+*/
+VisuGUI_TableWidget::~VisuGUI_TableWidget()
+{
+}
+/*!
+ Sets table title
+*/
+void VisuGUI_TableWidget::setTableTitle( const QString& title )
+{
+ myTitleEdit->setText( title );
+}
+/*!
+ Gets table title
+*/
+QString VisuGUI_TableWidget::getTableTitle()
+{
+ return myTitleEdit->text();
+}
+/*!
+ Sets total number of rows
+*/
+void VisuGUI_TableWidget::setNumRows( const int num )
+{
+ myOrientation == Qt::Horizontal ? myTable->setRowCount( num ) : myTable->setColumnCount( num );
+}
+/*!
+ Gets total number of rows
+*/
+int VisuGUI_TableWidget::getNumRows()
+{
+ return myOrientation == Qt::Horizontal ? myTable->rowCount() : myTable->columnCount();
+}
+/*!
+ Sets total number of columns
+*/
+void VisuGUI_TableWidget::setNumCols( const int num )
+{
+ // !!! first column contains units !!!
+ myOrientation == Qt::Horizontal ? myTable->setColumnCount( num+1 ) : myTable->setRowCount( num+1 );
+// myOrientation == Qt::Horizontal ? myTable->setColumnReadOnly( 0, true ) : myTable->setRowReadOnly( 0, true );
+}
+/*!
+ Gets total number of columns
+*/
+int VisuGUI_TableWidget::getNumCols()
+{
+ // !!! first column contains units !!!
+ return myOrientation == Qt::Horizontal ? myTable->columnCount()-1 : myTable->rowCount()-1;
+}
+/*!
+ Sets rows titles
+*/
+void VisuGUI_TableWidget::setRowTitles( QStringList& tlts )
+{
+ QStringList aLabels;
+ for ( int i = 0; i < tlts.count(); i++ )
+ tlts[i].isNull() ? aLabels.append("") : aLabels.append( tlts[i] );
+
+ myOrientation == Qt::Horizontal ?
+ myTable->setVerticalHeaderLabels( aLabels ) :
+ myTable->setHorizontalHeaderLabels( aLabels );
+
+ // myTable->verticalHeader()->setLabel( i, tlts[i] ) :
+ //myTable->horizontalHeader()->setLabel( i, tlts[i] );
+ //}
+}
+/*!
+ Gets rows titles
+*/
+void VisuGUI_TableWidget::getRowTitles( QStringList& tlts )
+{
+ tlts.clear();
+ if ( myOrientation == Qt::Horizontal ) {
+ for ( int i = 0; i < myTable->rowCount(); i++ ) {
+ tlts.append( myTable->verticalHeaderItem(i) ? myTable->verticalHeaderItem(i)->text() : "" );
+ }
+ }
+ else {
+ for ( int i = 0; i < myTable->columnCount(); i++ ) {
+ tlts.append( myTable->horizontalHeaderItem(i) ? myTable->horizontalHeaderItem(i)->text() : "" );
+ }
+ }
+}
+/*!
+ Sets columns titles
+*/
+void VisuGUI_TableWidget::setColTitles( QStringList& tlts )
+{
+ QStringList aLabels;
+
+ // !!! first column contains units !!!
+ aLabels.append(""); // it'll be initialized below - in setUnitsTitle() method
+
+ for ( int i = 0; i < tlts.count(); i++ )
+ tlts[i].isNull() ? aLabels.append("") : aLabels.append( tlts[i] );
+
+ myOrientation == Qt::Horizontal ?
+ myTable->setHorizontalHeaderLabels( aLabels ) :
+ myTable->setVerticalHeaderLabels( aLabels );
+
+ setUnitsTitle( tr( "UNITS_TLT" ) );
+}
+/*!
+ Sets columns titles
+*/
+void VisuGUI_TableWidget::getColTitles( QStringList& tlts )
+{
+ // !!! first column contains units !!!
+ tlts.clear();
+ if ( myOrientation == Qt::Horizontal ) {
+ for ( int i = 1; i < myTable->columnCount(); i++ ) {
+ tlts.append( myTable->horizontalHeaderItem(i) ? myTable->horizontalHeaderItem(i)->text() : "" );
+ }
+ }
+ else {
+ for ( int i = 1; i < myTable->rowCount(); i++ ) {
+ tlts.append( myTable->verticalHeaderItem(i) ? myTable->verticalHeaderItem(i)->text() : "" );
+ }
+ }
+}
+/*!
+ Sets units title
+*/
+void VisuGUI_TableWidget::setUnitsTitle( const QString& tlt ) {
+ // !!! first column contains units !!!
+ myTable->model()->setHeaderData( 0, myOrientation, QVariant(tlt.isNull() ? "" : tlt), Qt::DisplayRole );
+}
+/*!
+ Sets units
+*/
+void VisuGUI_TableWidget::setUnits( QStringList& units )
+{
+ QAbstractTableModel* aModel = qobject_cast<QAbstractTableModel*>( myTable->model() );
+ if ( aModel )
+ {
+ QModelIndex anIndex;
+ for ( int i = 0; i < units.count(); i++ )
+ {
+ myOrientation == Qt::Horizontal ?
+ anIndex = aModel->index( i, 0 ) :
+ anIndex = aModel->index( 0, i );
+
+ aModel->setData( anIndex, QVariant( units[i].isNull() ? "" : units[i] ) );
+ }
+ }
+}
+/*!
+ Gets units
+*/
+void VisuGUI_TableWidget::getUnits( QStringList& units )
+{
+ units.clear();
+ QAbstractTableModel* aModel = qobject_cast<QAbstractTableModel*>( myTable->model() );
+ if ( aModel )
+ {
+ if ( myOrientation == Qt::Horizontal )
+ {
+ for ( int i = 0; i < myTable->rowCount(); i++ )
+ units.append( aModel->index( i, 0 ).data().toString() );
+ }
+ else {
+ for ( int i = 0; i < myTable->columnCount(); i++ )
+ units.append( aModel->index( 0, i ).data().toString() );
+ }
+ }
+}
+/*!
+ Sets row data
+*/
+void VisuGUI_TableWidget::setRowData( int row, QStringList& data )
+{
+ QAbstractTableModel* aModel = qobject_cast<QAbstractTableModel*>( myTable->model() );
+ if ( aModel )
+ {
+ QModelIndex anIndex;
+ if ( row >= 0 && row < getNumRows() ) {
+ for ( int i = 0; i < data.count(); i++ )
+ {
+ myOrientation == Qt::Horizontal ? anIndex = aModel->index( row, i+1 ) :
+ anIndex = aModel->index( i+1, row );
+ aModel->setData( anIndex, QVariant( data[i] ) );
+
+ }
+ }
+ }
+}
+/*!
+ Gets row data
+*/
+void VisuGUI_TableWidget::getRowData( int row, QStringList& data )
+{
+ data.clear();
+ QAbstractTableModel* aModel = qobject_cast<QAbstractTableModel*>( myTable->model() );
+ if ( aModel )
+ {
+ if ( row >= 0 && row < getNumRows() )
+ {
+ if ( myOrientation == Qt::Horizontal )
+ {
+ for ( int i = 1; i < myTable->columnCount(); i++ )
+ data.append( aModel->index( row, i ).data().toString() );
+ }
+ else {
+ for ( int i = 1; i < myTable->rowCount(); i++ )
+ data.append( aModel->index( i, row ).data().toString() );
+ }
+ }
+ }
+}
+/*!
+ Adjusts table cell to see contents, <Adjust Cells> button slot
+*/
+void VisuGUI_TableWidget::adjustTable()
+{
+ myTable->resizeRowsToContents();
+ myTable->resizeColumnsToContents();
+}
+/*!
+ Called when selection changed in table
+*/
+void VisuGUI_TableWidget::updateButtonsState()
+{
+ if ( myTable->editTriggers() == QAbstractItemView::NoEditTriggers )
+ return;
+ bool bDR = false; // <Delete Row(s)>
+ bool bDC = false; // <Delete Column(s)>
+ bool bSA = false; // <Select All>
+ bool bCT = false; // <Clear>
+ int i;
+ //TO DO column/row selection check
+ /*int c = myOrientation == Qt::Horizontal ? 0 : 1;
+ for ( i = c; i < myTable->rowCount(); i++ ) {
+
+ if ( myTable->isRowSelected( i, true ) )
+ bDR = true;
+ else
+ bSA = true;
+ }
+ c = myOrientation == Qt::Horizontal ? 1 : 0;
+ for ( i = c; i < myTable->columnCount(); i++ ) {
+ if ( myTable->isColumnSelected( i, true ) )
+ bDC = true;
+ else
+ bSA = true;
+ }*/
+ /*int nbSel = myTable->numSelections();
+ for ( i = 0; i < nbSel; i++ ) {
+ QTableSelection ts = myTable->selection( i );
+ for ( int j = ts.topRow(); j < ts.bottomRow()+1; j++) {
+ for ( int k = ts.leftCol(); k < ts.rightCol()+1; k++) {
+ if ( myTable->item( j, k ) )
+ bCT = true;
+ }
+ }
+ }*/
+ QList<QTableWidgetItem*> aSelection = myTable->selectedItems();
+ QList<QTableWidgetItem*>::ConstIterator anIt = aSelection.constBegin(),
+ anEndIt = aSelection.constEnd();
+ for ( ; anIt != anEndIt; anIt++ )
+ {
+ if( *anIt )
+ {
+ bCT = true;
+ break;
+ }
+ }
+
+ if ( myTable->item( myTable->currentRow(), myTable->currentColumn() ) )
+ bCT = true;
+ myDelRowBtn->setEnabled( bDR );
+ myDelColBtn->setEnabled( bDC );
+ mySelectAllBtn->setEnabled( bSA );
+ myClearBtn->setEnabled( bCT );
+}
+/*!
+ <Add row> button slot
+*/
+void VisuGUI_TableWidget::addRow()
+{
+ myTable->insertRow( myTable->rowCount() );
+ updateButtonsState();
+}
+/*!
+ <Add column> button slot
+*/
+void VisuGUI_TableWidget::addCol()
+{
+ myTable->insertColumn( myTable->columnCount() );
+ updateButtonsState();
+}
+/*!
+ <Delete row(s)> button slot
+*/
+void VisuGUI_TableWidget::delRow()
+{
+ //TODO
+ /*int c = myOrientation == Qt::Horizontal ? 0 : 1;
+ QList<int> il;
+ int i;
+ for ( i = c; i < myTable->rowCount(); i++ )
+ if ( myTable->isRowSelected( i, true ) )
+ il.append( i );
+ if ( il.count() > 0 ) {
+ QMemArray<int> ildel( il.count() );
+ for ( i = 0; i < il.count(); i++ )
+ ildel[ i ] = il[ i ];
+ myTable->removeRows( ildel );
+ }*/
+
+ updateButtonsState();
+}
+/*!
+ <Delete column(s)> button slot
+*/
+void VisuGUI_TableWidget::delCol()
+{
+ //TODO
+ /*int c = myOrientation == Qt::Horizontal ? 1 : 0;
+ QValueList<int> il;
+ int i;
+ for ( i = c; i < myTable->numCols(); i++ )
+ if ( myTable->isColumnSelected( i, true ) )
+ il.append( i );
+ if ( il.count() > 0 ) {
+ QMemArray<int> ildel( il.count() );
+ for ( i = 0; i < il.count(); i++ )
+ ildel[ i ] = il[ i ];
+ myTable->removeColumns( ildel );
+ }*/
+ updateButtonsState();
+}
+/*!
+ <Select All> button slot
+*/
+void VisuGUI_TableWidget::selectAll()
+{
+ /*myTable->clearSelection();
+ QTableSelection ts;
+ ts.init( 0, 0 ); ts.expandTo( myTable->numRows()-1, myTable->numCols()-1 );
+ myTable->addSelection( ts );*/
+ myTable->selectAll();
+ updateButtonsState();
+}
+/*!
+ <Clear> button slot
+*/
+void VisuGUI_TableWidget::clearTable()
+{
+ /*int nbSel = myTable->numSelections();
+ for ( int i = 0; i < nbSel; i++ ) {
+ QTableSelection ts = myTable->selection( i );
+ for ( int j = ts.topRow(); j < ts.bottomRow()+1; j++) {
+ if ( myOrientation == Qt::Vertical && j == 0 ) {
+// continue; // UNITS
+ }
+ for ( int k = ts.leftCol(); k < ts.rightCol()+1; k++) {
+ if ( myOrientation == Qt::Horizontal && k == 0 ) {
+// continue; // UNITS
+ }
+ myTable->clearCell( j, k );
+ }
+ }
+ }
+ if ( nbSel == 0 )
+ myTable->clearCell( myTable->currentRow(), myTable->currentColumn() );
+ myTable->clearSelection();*/
+ myTable->clearContents();
+ updateButtonsState();
+}
+/*!
+ Event filter - handles titles editing
+*/
+bool VisuGUI_TableWidget::eventFilter( QObject* o, QEvent* e )
+{
+ if ( e->type() == QEvent::MouseButtonDblClick) {
+ //TODO
+ /*QMouseEvent* me = ( QMouseEvent* )e;
+ if ( me->button() == Qt::LeftButton && (myTable->editTriggers() != QAbstractItemView::NoEditTriggers ) ) {
+ if ( o == myTable->horizontalHeader() ) {
+ for ( int i = 0; i < myTable->horizontalHeader()->count(); i++ ) {
+ QRect rect = myTable->horizontalHeader()->sectionRect( i );
+ rect.addCoords( 1, 1, -1, -1 );
+ if ( rect.contains( myTable->horizontalHeader()->mapFromGlobal( me->globalPos() ) ) ) {
+ if ( myOrientation == Qt::Vertical || i != 0 ) {
+ bool bOk;
+ QString tlt = QInputDialog::getText( tr( "SET_TITLE_TLT" ),
+ tr( "TITLE_LBL" ),
+ QLineEdit::Normal,
+ myTable->horizontalHeader()->label( i ),
+ &bOk,
+ this );
+ if ( bOk && !tlt.isNull() )
+ myTable->horizontalHeader()->setLabel( i, tlt );
+ break;
+ }
+ }
+ }
+ }
+ if ( o == myTable->verticalHeader() ) {
+ for ( int i = 0; i < myTable->verticalHeader()->count(); i++ ) {
+ QRect rect = myTable->verticalHeader()->sectionRect( i );
+ rect.addCoords( 1, 1, -1, -1 );
+ if ( rect.contains( myTable->verticalHeader()->mapFromGlobal( me->globalPos() ) ) ) {
+ if ( myOrientation == Qt::Horizontal || i != 0 ) {
+ bool bOk;
+ QString tlt = QInputDialog::getText( tr( "SET_TITLE_TLT" ),
+ tr( "TITLE_LBL" ),
+ QLineEdit::Normal,
+ myTable->verticalHeader()->label( i ),
+ &bOk,
+ this );
+ if ( bOk && !tlt.isNull() )
+ myTable->verticalHeader()->setLabel( i, tlt );
+ break;
+ }
+ }
+ }
+ }
+ }*/
+ }
+ else if ( e->type() == QEvent::KeyRelease && o == myTable ) {
+ QKeyEvent* ke = (QKeyEvent*)e;
+ if ( ke->key() == Qt::Key_Delete && (myTable->editTriggers() != QAbstractItemView::NoEditTriggers) ) {
+ clearTable();
+ }
+ else if ( ke->key() == Qt::Key_Backspace && (myTable->editTriggers() != QAbstractItemView::NoEditTriggers) ) {
+ clearTable();
+ int i = myTable->currentRow();
+ int j = myTable->currentColumn() - 1;
+ if ( j < 0 ) { j = myTable->columnCount()-1; i--; }
+ if ( i >= 0 && j >= 0 )
+ myTable->setCurrentCell( i, j );
+ }
+ }
+ return QWidget::eventFilter( o, e );
+}
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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_TableDlg.h
+// Author : Vadim SANDLER
+// Module : VISU
+//
+#ifndef VisuGUI_TABLE_DLG_H
+#define VisuGUI_TABLE_DLG_H
+
+#include <QDialog>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QItemDelegate>
+
+class QTableWidget;
+class VisuGUI_TableWidget;
+
+#include <SALOMEDSClient_SObject.hxx>
+
+#include "VisuGUITools.h"
+
+class VISU_GUITOOLS_EXPORT VisuGUI_TableDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+
+ enum { ttNone, ttInt, ttReal, ttBoth, ttAuto };
+
+ VisuGUI_TableDlg( QWidget* parent,
+ _PTR(SObject) obj,
+ bool edit = false,
+ int which = ttAuto,
+ Qt::Orientation orient = Qt::Horizontal,
+ bool showColumnTitles = true );
+ ~VisuGUI_TableDlg();
+
+private:
+ void keyPressEvent( QKeyEvent* e );
+
+public slots:
+ void onOK();
+ void onHelp();
+
+private:
+ void initDlg();
+
+private:
+ VisuGUI_TableWidget* myIntTable;
+ VisuGUI_TableWidget* myRealTable;
+ QPushButton* myOKBtn;
+ QPushButton* myCancelBtn;
+ QPushButton* myHelpBtn;
+
+ _PTR(SObject) myObject;
+};
+
+class VISU_GUITOOLS_EXPORT VisuGUI_TableWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ VisuGUI_TableWidget( QWidget* parent = 0,
+ const char* name = 0,
+ bool edit = false,
+ Qt::Orientation orient = Qt::Horizontal,
+ bool showColumnTitles = true );
+ ~VisuGUI_TableWidget();
+
+ void setTableTitle( const QString& title );
+ QString getTableTitle();
+ void setNumRows( const int num );
+ int getNumRows();
+ void setNumCols( const int num );
+ int getNumCols();
+ void setRowTitles( QStringList& tlts );
+ void getRowTitles( QStringList& tlts );
+ void setColTitles( QStringList& tlts );
+ void getColTitles( QStringList& tlts );
+ void setUnitsTitle( const QString& tlt );
+ void setUnits( QStringList& units );
+ void getUnits( QStringList& units );
+ void setRowData( int row, QStringList& data );
+ void getRowData( int row, QStringList& data );
+
+ QTableWidget* getTable() { return myTable; }
+ QLineEdit* getTitleEdit() { return myTitleEdit; }
+
+ bool eventFilter( QObject* o, QEvent* e);
+
+public slots:
+ void updateButtonsState();
+ void addRow();
+ void addCol();
+ void delRow();
+ void delCol();
+ void adjustTable();
+ void selectAll();
+ void clearTable();
+
+private:
+ QLineEdit* myTitleEdit;
+ QTableWidget* myTable;
+ QPushButton* myAddRowBtn;
+ QPushButton* myAddColBtn;
+ QPushButton* myDelRowBtn;
+ QPushButton* myDelColBtn;
+ QPushButton* myAdjustBtn;
+ QPushButton* mySelectAllBtn;
+ QPushButton* myClearBtn;
+ Qt::Orientation myOrientation;
+};
+
+class VISU_GUITOOLS_EXPORT NumDelegateItem: public QItemDelegate
+{
+public:
+ enum NumValidator{ NV_Int, NV_Real };
+
+ NumDelegateItem( QObject* parent, NumValidator mode = NV_Int );
+ virtual ~NumDelegateItem();
+
+ virtual QWidget * createEditor( QWidget * parent,
+ const QStyleOptionViewItem & option,
+ const QModelIndex & index ) const;
+ virtual void setEditorData( QWidget * editor,
+ const QModelIndex & index ) const;
+private:
+ int myMode;
+};
+
+#endif // VisuGUI_TABLE_DLG_H
+
--- /dev/null
+# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# 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 : Makefile.in
+# Author : Alexander Solovyov(OCN)
+# Module : VVTK
+# $Header:
+#
+include $(top_srcdir)/adm_local/unix/make_common_starter.am
+
+lib_LTLIBRARIES= libVVTK.la
+
+# header files
+salomeinclude_HEADERS= \
+ VVTK.h \
+ VVTK_PrimitiveBox.h \
+ VVTK_SizeBox.h
+
+dist_libVVTK_la_SOURCES= \
+ VVTK_PrimitiveBox.cxx \
+ VVTK_SizeBox.cxx
+
+MOC_FILES= \
+ VVTK_PrimitiveBox_moc.cxx \
+ VVTK_SizeBox_moc.cxx
+
+nodist_libVVTK_la_SOURCES=$(MOC_FILES)
+
+libVVTK_la_CPPFLAGS= \
+ $(QT_INCLUDES) \
+ @CAS_CXXFLAGS@ @CAS_CPPFLAGS@ \
+ $(VTK_INCLUDES) \
+ $(BOOST_CPPFLAGS) \
+ $(KERNEL_CXXFLAGS) \
+ $(GUI_CXXFLAGS) \
+ $(MED_CXXFLAGS) \
+ -I$(srcdir)/../OBJECT -I$(srcdir)/../PIPELINE -I$(srcdir)/../CONVERTOR \
+ -I$(srcdir)/../GUITOOLS
+
+libVVTK_la_LDFLAGS= \
+ ../OBJECT/libVisuObject.la \
+ ../PIPELINE/libVisuPipeLine.la \
+ ../CONVERTOR/libVisuConvertor.la \
+ ../GUITOOLS/libVISUGUITOOLS.la \
+ $(KERNEL_LDFLAGS) -lOpUtil \
+ $(GUI_LDFLAGS) -lsuit -lCAM -lSalomeObject -lSVTK \
+ $(QT_MT_LIBS) \
+ $(OCC_LIBS) \
+ $(VTK_LIBS)
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+#ifdef WNT
+#if defined VISU_VVTK_EXPORTS || defined VVTK_EXPORTS
+#define VVTK_EXPORT __declspec(dllexport)
+#else
+#define VVTK_EXPORT __declspec(dllimport)
+#endif
+#else
+#define VVTK_EXPORT
+#endif
+
+#if defined WNT
+#pragma warning ( disable: 4251 )
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+// File :
+// Author :
+// Module :
+// $Header$
+//
+#include "VVTK_ImageWriter.h"
+
+#include <QSemaphore>
+
+#include "utilities.h"
+
+#include <vtkImageData.h>
+#include <vtkImageClip.h>
+#include <vtkJPEGWriter.h>
+#include <vtkSmartPointer.h>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
+VVTK_ImageWriter
+::VVTK_ImageWriter(QSemaphore* theSemaphore,
+ vtkImageData* theImageData,
+ const std::string& theName,
+ int theProgressive,
+ int theQuality):
+ mySemaphore(theSemaphore),
+ myImageData(theImageData),
+ myName(theName),
+ myProgressive(theProgressive),
+ myQuality(theQuality),
+ myConstraint16Flag(true)
+{}
+
+//----------------------------------------------------------------------------
+VVTK_ImageWriter
+::~VVTK_ImageWriter()
+{
+ if(MYDEBUG) MESSAGE("VVTK_ImageWriter::~VVTK_ImageWriter - this = "<<this);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_ImageWriter
+::run()
+{
+ vtkJPEGWriter *aWriter = vtkJPEGWriter::New();
+ vtkImageData *anImageData = myImageData;
+ vtkSmartPointer<vtkImageClip> anImageClip;
+ //
+ if(myConstraint16Flag){
+ int uExtent[6];
+ myImageData->UpdateInformation();
+ myImageData->GetUpdateExtent(uExtent);
+ unsigned int width = uExtent[1] - uExtent[0] + 1;
+ unsigned int height = uExtent[3] - uExtent[2] + 1;
+ width = (width / 16) * 16;
+ height= (height / 16) * 16;
+ uExtent[1] = uExtent[0] + width - 1;
+ uExtent[3] = uExtent[2] + height - 1;
+ //
+ anImageClip = vtkImageClip::New();
+ anImageClip->Delete();
+
+ anImageClip->SetInput(myImageData);
+ anImageClip->SetOutputWholeExtent(uExtent);
+ anImageClip->ClipDataOn();
+ anImageData = anImageClip->GetOutput();
+ }
+ //
+ aWriter->WriteToMemoryOff();
+ aWriter->SetFileName(myName.c_str());
+ aWriter->SetQuality(myQuality);
+ aWriter->SetProgressive(myProgressive);
+ aWriter->SetInput(anImageData);
+ aWriter->Write();
+
+ aWriter->Delete();
+ myImageData->Delete();
+
+ if(MYDEBUG) MESSAGE("VVTK_ImageWriter::run "<<
+ "- this = "<<this<<
+ //"; total = "<<mySemaphore->total()<<
+ "; available = "<<mySemaphore->available() );
+ mySemaphore->release();
+}
+
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+// File :
+// Author :
+// Module :
+// $Header$
+//
+#ifndef _VVTK_ImageWriter_Header_File_
+#define _VVTK_ImageWriter_Header_File_
+
+#include <QThread>
+#include <string>
+
+class vtkImageData;
+class QSemaphore;
+
+
+class VVTK_ImageWriter : public QThread
+{
+public:
+ VVTK_ImageWriter(QSemaphore* theSemaphore,
+ vtkImageData* theImageData,
+ const std::string& theName,
+ int theProgressive,
+ int theQuality);
+
+ ~VVTK_ImageWriter();
+
+ protected:
+ virtual
+ void
+ run();
+
+ protected:
+ QSemaphore* mySemaphore;
+ vtkImageData *myImageData;
+ std::string myName;
+ int myProgressive;
+ int myQuality;
+ bool myConstraint16Flag;
+};
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+// File :
+// Author :
+// Module :
+// $Header$
+//
+#include "VVTK_ImageWriterMgr.h"
+#include "VVTK_ImageWriter.h"
+
+#include <vtkImageData.h>
+
+#include <QSemaphore>
+
+#include "utilities.h"
+
+#include <limits>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//----------------------------------------------------------------------------
+VVTK_ImageWriterMgr
+::VVTK_ImageWriterMgr()
+{
+ int aMax = std::numeric_limits<int>::max() / 2;
+ mySemaphore = new QSemaphore(aMax);
+ mySemaphore->acquire( aMax );
+ if(MYDEBUG) MESSAGE("VVTK_ImageWriterMgr::VVTK_ImageWriterMgr "<<
+ //"- total = "<<mySemaphore->total()<<
+ "; available = "<<mySemaphore->available() );
+}
+
+
+//----------------------------------------------------------------------------
+VVTK_ImageWriterMgr
+::~VVTK_ImageWriterMgr()
+{
+ Stop();
+ delete mySemaphore;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_ImageWriterMgr
+::StartImageWriter(vtkImageData *theImageData,
+ const std::string& theName,
+ const int theProgressive,
+ const int theQuality)
+{
+ VVTK_ImageWriter *anImageWriter =
+ new VVTK_ImageWriter(mySemaphore,
+ theImageData,
+ theName,
+ theProgressive,
+ theQuality);
+ myThreads.push_back(anImageWriter);
+
+ anImageWriter->start();
+
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_ImageWriterMgr
+::Stop()
+{
+ if(MYDEBUG) MESSAGE("VVTK_ImageWriterMgr::Stop "<<
+ //"- total = "<<mySemaphore->total()<<
+ "; available = "<<mySemaphore->available() );
+ if(MYDEBUG) MESSAGE("VVTK_ImageWriterMgr::Stop - *mySemaphore += "<<myThreads.size() );
+ mySemaphore->acquire( myThreads.size() );
+
+ for(size_t anId = 0, anEnd = myThreads.size(); anId < anEnd; anId++){
+ VVTK_ImageWriter* anImageWriter = myThreads[anId];
+ anImageWriter->wait();
+ delete anImageWriter;
+ }
+ myThreads.clear();
+}
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+// File :
+// Author :
+// Module :
+// $Header$
+//
+#ifndef _VVTK_ImageWriterMgr_Header_File_
+#define _VVTK_ImageWriterMgr_Header_File_
+
+#include <string>
+#include <vector>
+
+class QString;
+class vtkImageData;
+class VVTK_ImageWriter;
+class QSemaphore;
+
+class VVTK_ImageWriterMgr
+{
+ public:
+ VVTK_ImageWriterMgr();
+ ~VVTK_ImageWriterMgr();
+
+ void
+ StartImageWriter(vtkImageData *theImageData,
+ const std::string& theName,
+ const int theProgressive,
+ const int theQuality);
+
+ void
+ Stop();
+
+ typedef std::vector<VVTK_ImageWriter*> TWriterThreads;
+
+ protected:
+ TWriterThreads myThreads;
+
+ QSemaphore* mySemaphore;
+};
+
+
+#endif
+
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+// File : VVTK_InteractorStyle.cxx
+// Author : Christophe ATTANASIO
+// Module : SALOME
+// $Header$
+//
+#include "VVTK_InteractorStyle.h"
+#include "VISU_GaussPtsSettings.h"
+#include "SVTK_Selector.h"
+#include "VISU_Event.h"
+
+#include <vtkObjectFactory.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkCallbackCommand.h>
+#include <vtkCommand.h>
+#include <vtkRenderer.h>
+#include <vtkCamera.h>
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(VVTK_InteractorStyle);
+//----------------------------------------------------------------------------
+
+VVTK_InteractorStyle
+::VVTK_InteractorStyle():
+ myIsMidButtonDown( false ),
+ myIsLeftButtonDown( false ),
+ mySMDecreaseMagnificationBtn(10),
+ mySMIncreaseMagnificationBtn(11)
+{
+}
+
+//----------------------------------------------------------------------------
+VVTK_InteractorStyle
+::~VVTK_InteractorStyle()
+{
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_InteractorStyle
+::OnLeftButtonDown(int ctrl, int shift,
+ int x, int y)
+{
+ myIsLeftButtonDown = true;
+
+ if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) {
+ this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
+ return;
+ }
+ this->FindPokedRenderer(x, y);
+ if (this->CurrentRenderer == NULL) {
+ return;
+ }
+ myShiftState = shift;
+ // finishing current viewer operation
+ if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ onFinishOperation();
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
+ }
+ myOtherPoint = myPoint = QPoint(x, y);
+ if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ startOperation(ForcedState);
+ }
+ else {
+ if (!(ctrl||shift)){
+ if (myIsMidButtonDown){
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
+ }
+ else{
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
+ }
+ }
+ }
+ return;
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_InteractorStyle
+::OnMiddleButtonDown(int ctrl,
+ int shift,
+ int x, int y)
+{
+ myIsMidButtonDown = true;
+
+ if (this->HasObserver(vtkCommand::MiddleButtonPressEvent)) {
+ this->InvokeEvent(vtkCommand::MiddleButtonPressEvent,NULL);
+ return;
+ }
+ this->FindPokedRenderer(x, y);
+ if (this->CurrentRenderer == NULL) {
+ return;
+ }
+ myShiftState = shift;
+ // finishing current viewer operation
+ if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ onFinishOperation();
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
+ }
+ myOtherPoint = myPoint = QPoint(x, y);
+ if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ startOperation(ForcedState);
+ }
+ else {
+ if (!(ctrl||shift)){
+ if ( myIsLeftButtonDown ){
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
+ }
+ else{
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN);
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_InteractorStyle
+::OnLeftButtonUp(int ctrl, int shift, int x, int y)
+{
+ myIsLeftButtonDown = false;
+ SVTK_InteractorStyle::OnLeftButtonUp( ctrl, shift, x, y );
+
+ if ( myIsMidButtonDown )
+ OnMiddleButtonDown( ctrl, shift, x, y );
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_InteractorStyle
+::OnMiddleButtonUp(int ctrl, int shift, int x, int y)
+{
+ myIsMidButtonDown = false;
+ SVTK_InteractorStyle::OnMiddleButtonUp( ctrl, shift, x, y );
+
+ if ( myIsLeftButtonDown )
+ OnLeftButtonDown( ctrl, shift, x, y );
+}
+//----------------------------------------------------------------------------
+void VVTK_InteractorStyle::onFinishOperation()
+{
+ Superclass::onFinishOperation();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_InteractorStyle
+::SetInteractor( vtkRenderWindowInteractor* theInteractor )
+{
+ // register EventCallbackCommand as observer of standard events (keypress, mousemove, etc)
+ Superclass::SetInteractor( theInteractor );
+
+ if(theInteractor){
+ theInteractor->AddObserver( VISU::SetSMDecreaseMagnificationEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( VISU::SetSMIncreaseMagnificationEvent, EventCallbackCommand, Priority );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_InteractorStyle
+::ProcessEvents( vtkObject* object,
+ unsigned long event,
+ void* clientData,
+ void* callData )
+{
+ if ( clientData ) {
+ vtkObject* anObject = reinterpret_cast<vtkObject*>( clientData );
+ VVTK_InteractorStyle* self = dynamic_cast<VVTK_InteractorStyle*>( anObject );
+ if( self ){
+ switch ( event ) {
+ case VISU::SetSMDecreaseMagnificationEvent:
+ self->mySMDecreaseMagnificationBtn = *((int*)callData);
+ return;
+ case VISU::SetSMIncreaseMagnificationEvent:
+ self->mySMIncreaseMagnificationBtn = *((int*)callData);
+ return;
+ }
+ }
+ }
+
+ Superclass::ProcessEvents( object, event, clientData, callData );
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_InteractorStyle
+::onSpaceMouseButton( int button )
+{
+ if( mySMDecreaseMagnificationBtn == button )
+ DecreaseGaussPointMagnification();
+ if( mySMIncreaseMagnificationBtn == button )
+ IncreaseGaussPointMagnification();
+
+ Superclass::onSpaceMouseButton( button );
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_InteractorStyle
+::DecreaseGaussPointMagnification()
+{
+ Interactor->InvokeEvent(VISU::SetSMDecreaseMagnificationEvent,NULL);
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_InteractorStyle
+::IncreaseGaussPointMagnification()
+{
+ Interactor->InvokeEvent(VISU::SetSMIncreaseMagnificationEvent,NULL);
+}
+//============================================================================
+//
+// Controllers
+//
+vtkStandardNewMacro(VVTK_ControllerIncrement);
+//----------------------------------------------------------------------------
+VVTK_ControllerIncrement::VVTK_ControllerIncrement()
+{
+ myIncrement=10;
+}
+//----------------------------------------------------------------------------
+VVTK_ControllerIncrement::~VVTK_ControllerIncrement()
+{
+}
+//----------------------------------------------------------------------------
+int VVTK_ControllerIncrement::Increase()
+{
+ myIncrement*=2;
+ return myIncrement;
+}
+//----------------------------------------------------------------------------
+int VVTK_ControllerIncrement::Decrease()
+{
+ myIncrement/=2;
+ if (!myIncrement){
+ myIncrement=1;
+ }
+ return myIncrement;
+}
+//
+vtkStandardNewMacro(VVTK_ControllerOnKeyDown);
+//----------------------------------------------------------------------------
+VVTK_ControllerOnKeyDown::VVTK_ControllerOnKeyDown()
+{
+}
+//----------------------------------------------------------------------------
+VVTK_ControllerOnKeyDown::~VVTK_ControllerOnKeyDown()
+{
+}
+//----------------------------------------------------------------------------
+bool VVTK_ControllerOnKeyDown::OnKeyDown(vtkInteractorStyle* theIS)
+{
+ SVTK_InteractorStyle *pIS=dynamic_cast<SVTK_InteractorStyle *>(theIS);
+ if (pIS){
+ if(pIS->GetSelector()->SelectionMode()==GaussPointSelection){
+ char key = pIS->GetInteractor()->GetKeyCode();
+ //
+ if (key == 'S') {
+ pIS->ActionPicking();
+ return false;
+ }
+ }
+ }
+ return Superclass::OnKeyDown(theIS);
+}
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+// File : VVTK_InteractorStyle.h
+// Author : Christophe ATTANASIO
+// Module : SALOME
+// $Header$
+//
+#ifndef __VVTK_InteractorStyle_h
+#define __VVTK_InteractorStyle_h
+
+
+#include "VVTK.h"
+
+#include "SVTK_InteractorStyle.h"
+//
+//-------------------------------------------
+//! Control the value of increment in new style of interaction.
+/*!
+ This class controls of value of increment,
+ for pan/rotate/zoom operations in new style
+ of interaction
+*/
+class VVTK_ControllerIncrement : public SVTK_ControllerIncrement {
+ public:
+ vtkTypeMacro(VVTK_ControllerIncrement,SVTK_ControllerIncrement);
+ static VVTK_ControllerIncrement* New();
+
+ //! Increace the increment value by multiplying on 2
+ virtual int Increase();
+
+ //! Decreace the increment value by division on 2
+ virtual int Decrease();
+
+ protected:
+ VVTK_ControllerIncrement();
+ virtual ~VVTK_ControllerIncrement();
+ //
+ private:
+ VVTK_ControllerIncrement(const VVTK_ControllerIncrement&); //Not implemented
+ void operator=(const VVTK_ControllerIncrement&); //Not implemented
+};
+//
+//-------------------------------------------
+//! Control the behaviour of KeyDown event in new style of interaction.
+/*!
+ This class controls of behaviour of of KeyDown event
+ in new style of interaction.
+*/
+class VVTK_ControllerOnKeyDown : public SVTK_ControllerOnKeyDown{
+ public:
+ vtkTypeMacro(VVTK_ControllerOnKeyDown, SVTK_ControllerOnKeyDown);
+ static VVTK_ControllerOnKeyDown* New();
+
+ //! Provides the action on event
+ virtual bool OnKeyDown(vtkInteractorStyle* );
+
+ protected:
+ VVTK_ControllerOnKeyDown();
+ virtual ~VVTK_ControllerOnKeyDown();
+
+ private:
+ VVTK_ControllerOnKeyDown(const VVTK_ControllerOnKeyDown&);//Not implemented
+ void operator=(const VVTK_ControllerOnKeyDown&); //Not implemented
+};
+
+
+//! Introduce new style of interaction (keyboard free)
+class VVTK_EXPORT VVTK_InteractorStyle : public SVTK_InteractorStyle
+{
+ public:
+ static VVTK_InteractorStyle *New();
+ vtkTypeMacro(VVTK_InteractorStyle,SVTK_InteractorStyle);
+
+ //! Redefined from SVTK_InteractorStyle::SetInteractor in order to add an observer (callback) for custorm event (space mouse event)
+ virtual
+ void
+ SetInteractor( vtkRenderWindowInteractor* );
+
+ protected:
+ VVTK_InteractorStyle();
+ ~VVTK_InteractorStyle();
+
+ VVTK_InteractorStyle(const VVTK_InteractorStyle&); // Not implemented
+ void operator=(const VVTK_InteractorStyle&); // Not implemented
+
+ // Generic event bindings must be overridden in subclasses
+
+ //! Redefine SVTK_InteractorStyle::OnLeftButtonDown
+ virtual void OnLeftButtonDown(int ctrl, int shift, int x, int y);
+
+ //! Redefine SVTK_InteractorStyle::OnMiddleButtonDown
+ virtual void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
+
+ //! Redefine SVTK_InteractorStyle::OnLeftButtonUp
+ virtual void OnLeftButtonUp(int ctrl, int shift, int x, int y);
+
+ //! Redefine SVTK_InteractorStyle::OnMiddleButtonUp
+ virtual void OnMiddleButtonUp(int ctrl, int shift, int x, int y);
+
+ //! Redefine SVTK_InteractorStyle::onFinishOperation
+ virtual void onFinishOperation();
+
+ //! Main process VTK event method
+ static
+ void
+ ProcessEvents(vtkObject* object,
+ unsigned long event,
+ void* clientData,
+ void* callData );
+
+ //! Redefine SVTK_InteractorStyle::onSpaceMouseButton
+ virtual void onSpaceMouseButton( int button );
+
+ //! To decrease magnification of the Gauss Points
+ void DecreaseGaussPointMagnification();
+
+ //! To increase magnification of the Gauss Points
+ void IncreaseGaussPointMagnification();
+
+ //! SpaceMouse short cuts
+ int mySMDecreaseMagnificationBtn;
+ int mySMIncreaseMagnificationBtn;
+
+ bool myIsMidButtonDown;
+ bool myIsLeftButtonDown;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
+// File :
+// Author :
+// Module :
+// $Header$
+//
+#include "VVTK_MainWindow.h"
+#include "VVTK_InteractorStyle.h"
+#include "VVTK_Recorder.h"
+#include "VVTK_RecorderDlg.h"
+#include "VISU_WidgetCtrl.hxx"
+#include "VISU_GaussPtsAct.h"
+#include "VISU_Event.h"
+
+#include "SVTK_ViewWindow.h"
+#include "SVTK_RenderWindowInteractor.h"
+#include "VVTK_Renderer.h"
+#include "VVTK_PickingDlg.h"
+#include "VVTK_SegmentationCursorDlg.h"
+
+#include "SUIT_Application.h"
+#include "SUIT_Session.h"
+#include "SUIT_Tools.h"
+#include "SUIT_ViewWindow.h"
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Accel.h"
+#include "SUIT_MessageBox.h"
+#include "QtxAction.h"
+#include "QtxMultiAction.h"
+#include "QtxActionToolMgr.h"
+
+#include <QImage>
+#include <QToolBar>
+#include <QSplitter>
+#include <QFileDialog>
+#include <QApplication>
+
+//----------------------------------------------------------------------------
+VVTK_MainWindow::VVTK_MainWindow(QWidget* theParent,
+ const char* theName,
+ SUIT_ResourceMgr* theResourceMgr,
+ SUIT_ViewWindow* theViewWindow):
+ SVTK_MainWindow(theParent,theName,theResourceMgr,theViewWindow),
+ myControllerIncrement(VVTK_ControllerIncrement::New()),
+ myControllerOnKeyDown(VVTK_ControllerOnKeyDown::New())
+{
+ myToolMgr = new QtxActionToolMgr( this );
+
+ myControllerIncrement->Delete();
+ myControllerOnKeyDown->Delete();
+
+ // Recording
+ myRecordingToolBar = new QToolBar(tr("LBL_TOOLBAR_RECORD_LABEL"), this);
+ addToolBar(Qt::LeftToolBarArea, myRecordingToolBar );
+ myViewWindow->toolMgr()->remove( NonIsometric, myToolBar );
+
+
+ myStartAction = new QtxAction(tr("MNU_VVTK_RECORDING_START"),
+ theResourceMgr->loadPixmap( "VISU", tr( "ICON_VVTK_RECORDING_START" ) ),
+ tr( "MNU_VVTK_RECORDING_START" ), 0, this);
+ myStartAction->setStatusTip(tr("DSC_VVTK_RECORDING_START"));
+ //myStartAction->addTo( myRecordingToolBar );
+ myRecordingToolBar->addAction( myStartAction );
+ connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( OnStartRecording() ) );
+
+ myPlayAction = new QtxAction(tr("MNU_VVTK_RECORDING_PLAY"),
+ theResourceMgr->loadPixmap( "VISU", tr( "ICON_VVTK_RECORDING_PLAY" ) ),
+ tr( "MNU_VVTK_RECORDING_PLAY" ), 0, this);
+ myPlayAction->setStatusTip(tr("DSC_VVTK_RECORDING_PLAY"));
+ myPlayAction->setEnabled( false );
+ //myPlayAction->addTo( myRecordingToolBar );
+ myRecordingToolBar->addAction( myPlayAction );
+ connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( OnPlayRecording() ) );
+
+ myPauseAction = new QtxAction(tr("MNU_VVTK_RECORDING_PAUSE"),
+ theResourceMgr->loadPixmap( "VISU", tr( "ICON_VVTK_RECORDING_PAUSE" ) ),
+ tr( "MNU_VVTK_RECORDING_PAUSE" ), 0, this);
+ myPauseAction->setStatusTip(tr("DSC_VVTK_RECORDING_PAUSE"));
+ myPauseAction->setEnabled( false );
+ //myPauseAction->addTo( myRecordingToolBar );
+ myRecordingToolBar->addAction( myPauseAction );
+ connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( OnPauseRecording() ) );
+
+ myStopAction = new QtxAction(tr("MNU_VVTK_RECORDING_STOP"),
+ theResourceMgr->loadPixmap( "VISU", tr( "ICON_VVTK_RECORDING_STOP" ) ),
+ tr( "MNU_VVTK_RECORDING_STOP" ), 0, this);
+ myStopAction->setStatusTip(tr("DSC_VVTK_RECORDING_STOP"));
+ myStopAction->setEnabled( false );
+ //myStopAction->addTo( myRecordingToolBar );
+ myRecordingToolBar->addAction( myStopAction );
+ connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( OnStopRecording() ) );
+
+ myRecorder = VVTK_Recorder::New();
+ //myRecorder->CheckExistAVIMaker();
+ //if(myRecorder->ErrorStatus())
+ // myRecordingToolBar->setEnabled(false);
+}
+
+//----------------------------------------------------------------------------
+
+QtxActionToolMgr* VVTK_MainWindow::toolMgr() const
+{
+ return myToolMgr;
+}
+
+//----------------------------------------------------------------------------
+void VVTK_MainWindow::Initialize(SVTK_RenderWindowInteractor* theInteractor)
+{
+ vtkInteractorStyle* aStyle = theInteractor->GetInteractorStyle();
+ if(SVTK_InteractorStyle *anInteractorStyle = dynamic_cast<SVTK_InteractorStyle*>(aStyle)){
+ anInteractorStyle->SetControllerIncrement(myControllerIncrement.GetPointer());
+ anInteractorStyle->SetControllerOnKeyDown(myControllerOnKeyDown.GetPointer());
+ }
+
+ myRecorder->SetNbFPS(17.3);
+ myRecorder->SetQuality(100);
+ myRecorder->SetProgressiveMode(true);
+ myRecorder->SetUseSkippedFrames(true);
+ myRecorder->SetRenderWindow(theInteractor->getRenderWindow());
+
+ disconnect( SVTK_MainWindow::action( DumpId ), SIGNAL( activated() ),
+ myViewWindow, SLOT( onDumpView() ) );
+
+ connect( SVTK_MainWindow::action( DumpId ), SIGNAL( activated() ),
+ this, SLOT( onDumpView() ) );
+
+ SVTK_MainWindow::Initialize(theInteractor);
+ addToolBar( Qt::LeftToolBarArea, getToolBar() );
+}
+
+VVTK_MainWindow::~VVTK_MainWindow()
+{
+ if(myRecorder)
+ myRecorder->Delete();
+}
+
+//----------------------------------------------------------------------------
+void VVTK_MainWindow::onDumpView()
+{
+ QImage img = dumpView();
+ if( img.isNull() )
+ return;
+
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ QString fileName = app->getFileName( false, QString::null,
+ tr( "TLT_IMAGE_FILES" ),
+ tr( "TLT_DUMP_VIEW" ), 0 );
+ if( fileName.isEmpty() )
+ return;
+
+ QString fmt = SUIT_Tools::extension( fileName ).toUpper();
+ if( fmt.isEmpty() )
+ fmt = QString( "BMP" ); // default format
+ else if( fmt == "JPG" )
+ fmt = "JPEG";
+
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ img.save( fileName, fmt.toLatin1() );
+ QApplication::restoreOverrideCursor();
+}
+
+//----------------------------------------------------------------------------
+void VVTK_MainWindow::OnStartRecording()
+{
+ myRecorder->CheckExistAVIMaker();
+ if (myRecorder->ErrorStatus()) {
+ SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER") );
+ }
+ else {
+ VVTK_RecorderDlg* aRecorderDlg = new VVTK_RecorderDlg( this, myRecorder );
+
+ if( !aRecorderDlg->exec() )
+ return;
+
+ myStartAction->setEnabled( false );
+ myPlayAction->setEnabled( false );
+ myPauseAction->setEnabled( true );
+ myStopAction->setEnabled( true );
+
+ myRecorder->Record();
+ }
+}
+
+//----------------------------------------------------------------------------
+void VVTK_MainWindow::OnPlayRecording()
+{
+ myStartAction->setEnabled( false );
+ myPlayAction->setEnabled( false );
+ myPauseAction->setEnabled( true );
+ myStopAction->setEnabled( true );
+ //
+ myRecorder->Pause();
+}
+
+//----------------------------------------------------------------------------
+void VVTK_MainWindow::OnPauseRecording()
+{
+ myStartAction->setEnabled( false );
+ myPlayAction->setEnabled( true );
+ myPauseAction->setEnabled( false );
+ myStopAction->setEnabled( true );
+ //
+ myRecorder->Pause();
+}
+
+//----------------------------------------------------------------------------
+void VVTK_MainWindow::OnStopRecording()
+{
+ myStartAction->setEnabled( true );
+ myPlayAction->setEnabled( false );
+ myPauseAction->setEnabled( false );
+ myStopAction->setEnabled( false );
+ //
+ myRecorder->Stop();
+}
+
+//----------------------------------------------------------------------------
+void VVTK_MainWindow::action( const int accelAction )
+{
+ if ( accelAction == SUIT_Accel::ZoomFit )
+ onFitAll();
+ else {
+ int anEvent = SVTK::convertAction( accelAction );
+ InvokeEvent( anEvent, 0 );
+ }
+}
+
+//----------------------------------------------------------------------------
+VVTK_MainWindow1::VVTK_MainWindow1(QSplitter* theParent,
+ const char* theName,
+ SUIT_ResourceMgr* theResourceMgr,
+ SUIT_ViewWindow* theViewWindow):
+ VVTK_MainWindow(theParent,theName,theResourceMgr,theViewWindow),
+ mySplitter(theParent),
+ myPickingDlg(NULL)
+{
+ myPtsToolBar = new QToolBar( tr("LBL_TOOLBAR_GAUSS_LABEL"), this );
+ addToolBar( Qt::LeftToolBarArea, myPtsToolBar );
+
+ QPixmap aPixmap;
+ QtxAction* anAction;
+
+ aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_SELECTION_MODE_SWITCH"));
+ myPickingAction = new QtxAction(tr("MNU_VVTK_SELECTION_MODE_SWITCH"),
+ aPixmap,
+ tr( "MNU_VVTK_SELECTION_MODE_SWITCH" ),
+ 0,
+ this,
+ //"VVTK/SVTK SelectionSwitch",
+ true);
+ myPickingAction->setCheckable(true);
+ myPickingAction->setStatusTip(tr("DSC_VVTK_SELECTION_MODE_SWITCH"));
+ myPtsToolBar->addAction( myPickingAction );
+ connect(myPickingAction, SIGNAL(toggled(bool)), this, SLOT(OnSelectionModeSwitch(bool)));
+
+ myPickingDlg = new VVTK_PickingDlg( myPickingAction, this, "PickingDlg" );
+
+ // Plane/Sphere Segmentation
+ aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_PLANE_SEGMENTATION_SWITCH"));
+ myPlaneSegmentationAction = new QtxAction(tr("MNU_VVTK_PLANE_SEGMENTATION_SWITCH"),
+ aPixmap,
+ tr( "MNU_VVTK_PLANE_SEGMENTATION_SWITCH" ),
+ 0,
+ this,
+ //"VVTK/SVTK PlaneSegmentationSwitch",
+ true);
+ myPlaneSegmentationAction->setCheckable(true);
+ myPlaneSegmentationAction->setStatusTip(tr("DSC_VVTK_PLANE_SEGMENTATION_SWITCH"));
+ //myPlaneSegmentationAction->addTo( myPtsToolBar );
+ connect( myPlaneSegmentationAction, SIGNAL( triggered() ), this, SLOT( OnSegmentationSwitch() ) );
+
+ aPixmap = theResourceMgr->loadPixmap("VISU",tr("ICON_VVTK_SPHERE_SEGMENTATION_SWITCH"));
+ mySphereSegmentationAction = new QtxAction(tr("MNU_VVTK_SPHERE_SEGMENTATION_SWITCH"),
+ aPixmap,
+ tr( "MNU_VVTK_SPHERE_SEGMENTATION_SWITCH" ),
+ 0,
+ this,
+ //"VVTK/SVTK SphereSegmentationSwitch",
+ true);
+ mySphereSegmentationAction->setCheckable(true);
+ mySphereSegmentationAction->setStatusTip(tr("DSC_VVTK_SPHERE_SEGMENTATION_SWITCH"));
+ //mySphereSegmentationAction->addTo( myPtsToolBar );
+ connect( mySphereSegmentationAction, SIGNAL( activated() ), this, SLOT( OnSegmentationSwitch() ) );
+
+ mySegmentationCursorDlg = new VVTK_SegmentationCursorDlg( this, "SegmentationCursorDlg" );
+ mySegmentationCursorDlg->SetPlaneAction( myPlaneSegmentationAction );
+ mySegmentationCursorDlg->SetSphereAction( mySphereSegmentationAction );
+ connect( mySegmentationCursorDlg, SIGNAL( scgClose() ), this, SLOT( OnSegmentationSwitch() ) );
+
+ //SUIT_ToolButton* aSegmentationButton = new SUIT_ToolButton( myPtsToolBar );
+ QtxMultiAction* aSegmentationAction = new QtxMultiAction( this );
+ aSegmentationAction->insertAction( myPlaneSegmentationAction );
+ aSegmentationAction->insertAction( mySphereSegmentationAction );
+ myPtsToolBar->addAction( aSegmentationAction );
+}
+
+void VVTK_MainWindow1::Initialize(SVTK_RenderWindowInteractor* theInteractor,
+ VVTK_Renderer1* theRenderer)
+{
+ myRenderer = theRenderer;
+ VVTK_MainWindow::Initialize(theInteractor);
+
+ mySegmentationCursorDlg->SetWidgetCtrl( theRenderer->GetWidgetCtrl() );
+ mySegmentationCursorDlg->SetInteractor( theInteractor );
+
+ connect( theInteractor, SIGNAL( selectionChanged() ), SLOT( OnSelectionChanged() ) );
+ myPickingDlg->SetInteractor( theInteractor );
+}
+
+VVTK_MainWindow1::~VVTK_MainWindow1()
+{}
+
+//----------------------------------------------------------------------------
+VVTK_MainWindow2* VVTK_MainWindow1::CreateMainWindow2(QWidget* theParent,
+ const char* theName,
+ SUIT_ResourceMgr* theResourceMgr,
+ SUIT_ViewWindow* theViewWindow)
+{
+ myMainWindow2 = new VVTK_MainWindow2(theParent,
+ theName,
+ theResourceMgr,
+ theViewWindow);
+ return myMainWindow2;
+}
+
+
+//----------------------------------------------------------------------------
+void VVTK_MainWindow1::OnSelectionModeSwitch(bool theIsSelectionOn)
+{
+ if ( theIsSelectionOn && !isVisible() )
+ return;
+
+ Selection_Mode aSelectionMode = SelectionMode();
+ if(theIsSelectionOn && aSelectionMode != GaussPointSelection)
+ SetSelectionMode(GaussPointSelection);
+ else if(!theIsSelectionOn && aSelectionMode == GaussPointSelection)
+ SetSelectionMode(ActorSelection);
+
+ if( theIsSelectionOn )
+ {
+ myPickingDlg->Update();
+ myPickingDlg->show();
+ }
+ else
+ myPickingDlg->hide();
+}
+
+void VVTK_MainWindow1::OnSelectionChanged()
+{
+ Selection_Mode aSelectionMode = SelectionMode();
+ if(myPickingAction->isChecked() && aSelectionMode != GaussPointSelection)
+ myPickingAction->setChecked(false);
+ else if(!myPickingAction->isChecked() && aSelectionMode == GaussPointSelection)
+ myPickingAction->setChecked(true);
+}
+
+
+//----------------------------------------------------------------------------
+VISU_WidgetCtrl* VVTK_MainWindow1::GetWidgetCtrl()
+{
+ return myRenderer->GetWidgetCtrl();
+}
+
+VISU_InsideCursorSettings* VVTK_MainWindow1::GetInsideCursorSettings()
+{
+ return mySegmentationCursorDlg->GetInsideCursorSettings();
+}
+
+VISU_OutsideCursorSettings* VVTK_MainWindow1::GetOutsideCursorSettings()
+{
+ return mySegmentationCursorDlg->GetOutsideCursorSettings();
+}
+
+VISU_PickingSettings* VVTK_MainWindow1::GetPickingSettings()
+{
+ return myPickingDlg->GetPickingSettings();
+}
+
+//----------------------------------------------------------------------------
+void VVTK_MainWindow1::SetPlanesSegementation(bool theIsOn)
+{
+ myPlaneSegmentationAction->setChecked( theIsOn );
+ OnSegmentationSwitch(myPlaneSegmentationAction);
+}
+
+void VVTK_MainWindow1::SetSphereSegementation(bool theIsOn)
+{
+ mySphereSegmentationAction->setChecked( theIsOn );
+ OnSegmentationSwitch(mySphereSegmentationAction);
+}
+
+void VVTK_MainWindow1::OnSegmentationSwitch(QtxAction* theAction)
+{
+ bool anIsSegmentationOn = myPlaneSegmentationAction->isChecked() ||
+ mySphereSegmentationAction->isChecked();
+
+ if( !theAction )
+ return;
+
+ VISU_WidgetCtrl *aWidgetCtrl = myRenderer->GetWidgetCtrl();
+
+ if (anIsSegmentationOn) {
+ int anIndex = (theAction == myPlaneSegmentationAction) ? 0 : 1;
+ aWidgetCtrl->SetActiveIndex(anIndex);
+ }
+ aWidgetCtrl->SetEnabled(anIsSegmentationOn);
+
+ if( theAction == myPlaneSegmentationAction && anIsSegmentationOn )
+ mySphereSegmentationAction->setChecked( false );
+ else if( theAction == mySphereSegmentationAction && anIsSegmentationOn )
+ myPlaneSegmentationAction->setChecked( false );
+
+ if( anIsSegmentationOn )
+ {
+ myMainWindow2->show();
+ mySegmentationCursorDlg->SetIsPlaneSegmentation( theAction == myPlaneSegmentationAction );
+ mySegmentationCursorDlg->UpdateSegmentation();
+ mySegmentationCursorDlg->UpdateInsideGaussPoints();
+ mySegmentationCursorDlg->UpdateOutsideGaussPoints();
+ mySegmentationCursorDlg->show();
+ }
+ else
+ {
+ myMainWindow2->hide();
+ mySegmentationCursorDlg->hide();
+ }
+}
+
+void VVTK_MainWindow1::OnSegmentationSwitch()
+{
+ QtxAction* anAction = ( QtxAction* )sender();
+ OnSegmentationSwitch(anAction);
+}
+
+
+//----------------------------------------------------------------------------
+VVTK_MainWindow2::VVTK_MainWindow2(QWidget* theParent,
+ const char* theName,
+ SUIT_ResourceMgr* theResourceMgr,
+ SUIT_ViewWindow* theViewWindow):
+ VVTK_MainWindow(theParent,theName,theResourceMgr,theViewWindow)
+{}
+
+VVTK_MainWindow2::~VVTK_MainWindow2()
+{}
+
+
+//----------------------------------------------------------------------------
+void VVTK_MainWindow2::Initialize(SVTK_RenderWindowInteractor* theInteractor)
+{
+ VVTK_MainWindow::Initialize(theInteractor);
+}
+
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+#ifndef VVTK_MAINWINDOW_H
+#define VVTK_MAINWINDOW_H
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+#include "VVTK.h"
+#include "SVTK_MainWindow.h"
+
+class QSplitter;
+
+class VISU_WidgetCtrl;
+class VVTK_SegmentationCursorDlg;
+class VISU_InsideCursorSettings;
+class VISU_OutsideCursorSettings;
+class VISU_PickingSettings;
+class VVTK_InteractorStyle;
+class VVTK_ControllerIncrement;
+class VVTK_ControllerOnKeyDown;
+class VVTK_PickingDlg;
+class VVTK_MainWindow2;
+class VVTK_Renderer1;
+class VVTK_Renderer2;
+class VVTK_Recorder;
+
+//----------------------------------------------------------------------------
+//! Customize SVTK_MainWindow to provide VVTK functionality
+class VVTK_EXPORT VVTK_MainWindow: public SVTK_MainWindow
+{
+ Q_OBJECT;
+
+public:
+ //! Construct instance of the class
+ VVTK_MainWindow(QWidget* theParent,
+ const char* theName,
+ SUIT_ResourceMgr* theResourceMgr,
+ SUIT_ViewWindow* theViewWindow);
+
+ //! Reimplement SVTK_MainWindow::Initialize
+ virtual void Initialize(SVTK_RenderWindowInteractor* theInteractor);
+
+ //! Destroy instance of the class
+ virtual ~VVTK_MainWindow();
+
+ public slots:
+
+ virtual void onDumpView();
+
+ virtual void action( const int );
+
+ virtual void OnStartRecording();
+
+ virtual void OnPlayRecording();
+
+ virtual void OnPauseRecording();
+
+ virtual void OnStopRecording();
+
+ protected:
+ virtual QtxActionToolMgr* toolMgr() const;
+
+ vtkSmartPointer<VVTK_ControllerIncrement> myControllerIncrement;
+ vtkSmartPointer<VVTK_ControllerOnKeyDown> myControllerOnKeyDown;
+
+ QToolBar* myRecordingToolBar;
+ QtxAction* myStartAction;
+ QtxAction* myPlayAction;
+ QtxAction* myPauseAction;
+ QtxAction* myStopAction;
+
+ VVTK_Recorder *myRecorder;
+ QtxActionToolMgr* myToolMgr;
+};
+
+
+//----------------------------------------------------------------------------
+//! Extend VVTK_MainWindow to implement functionality for base view
+class VVTK_EXPORT VVTK_MainWindow1: public VVTK_MainWindow
+{
+ Q_OBJECT;
+
+public:
+ //! Construct instance of the class
+ VVTK_MainWindow1(QSplitter* theParent,
+ const char* theName,
+ SUIT_ResourceMgr* theResourceMgr,
+ SUIT_ViewWindow* theViewWindow);
+
+ //! Reimplement VVTK_MainWindow::Initialize
+ virtual void Initialize(SVTK_RenderWindowInteractor* theInteractor,
+ VVTK_Renderer1* theRenderer);
+
+ //! Destroy instance of the class
+ virtual ~VVTK_MainWindow1();
+
+ //! Create instance of the segmented VVTK_MainWindow
+ /*!
+ The two views (VVTK_MainWindow1 and VVTK_MainWindow2) should change its behaviour in the same time.
+ So, it is necessary to synhronize them through sharing some common pointers.
+ */
+ VVTK_MainWindow2* CreateMainWindow2(QWidget* theParent,
+ const char* theName,
+ SUIT_ResourceMgr* theResourceMgr,
+ SUIT_ViewWindow* theViewWindow);
+
+ VISU_WidgetCtrl* GetWidgetCtrl();
+
+ void SetPlanesSegementation(bool theIsOn);
+
+ void SetSphereSegementation(bool theIsOn);
+
+ VISU_InsideCursorSettings* GetInsideCursorSettings();
+
+ //! Get contained VISU_OutsideCursorSettings
+ VISU_OutsideCursorSettings* GetOutsideCursorSettings();
+
+ //! Get contained VISU_PickingSettings
+ VISU_PickingSettings* GetPickingSettings();
+
+ public slots:
+ //! To activate/ deactivate the segementation cursor at run-time
+ void OnSegmentationSwitch();//bool theIsSegmentationOn);
+
+ void OnSegmentationSwitch(QtxAction* theAction);//bool theIsSegmentationOn);
+
+ //! To change active selection mode at run-time
+ virtual void OnSelectionModeSwitch(bool theIsSelectionOn);
+
+ //! To adjust to the current selection mode
+ virtual void OnSelectionChanged();
+
+ protected:
+ VVTK_Renderer1* myRenderer; //!< Keeps extended version of SVTK_Renderer
+
+ VVTK_MainWindow2* myMainWindow2; //!< Refer to segmented view
+
+ QToolBar* myPtsToolBar; //!< Additional tool bar
+
+ //! To implement show/hide segmented view on acttivate/ deactivate segementation cursor
+ QSplitter* mySplitter;
+
+ QtxAction* myPickingAction; //!< Action for switch selection mode
+ QtxAction* myPlaneSegmentationAction; //!< Action for switch segmentation mode to plane
+ QtxAction* mySphereSegmentationAction; //!< Action for switch segmentation mode to sphere
+
+ //! Keep reference to VVTK_SegmentationCursorDlg
+ VVTK_SegmentationCursorDlg* mySegmentationCursorDlg;
+ VVTK_PickingDlg* myPickingDlg; //!< Keep reference to VVTK_PickingDlg
+};
+
+
+//----------------------------------------------------------------------------
+//! Extend VVTK_MainWindow to implement functionality for segmented view
+class VVTK_EXPORT VVTK_MainWindow2: public VVTK_MainWindow
+{
+ Q_OBJECT;
+
+ friend class VVTK_MainWindow1;
+
+ //! Construct instance of the class
+ VVTK_MainWindow2(QWidget* theParent,
+ const char* theName,
+ SUIT_ResourceMgr* theResourceMgr,
+ SUIT_ViewWindow* theViewWindow);
+public:
+ //! Destroy instance of the class
+ virtual ~VVTK_MainWindow2();
+
+ //! Reimplement SVTK_MainWindow::Initialize
+ virtual void Initialize(SVTK_RenderWindowInteractor* theInteractor);
+
+};
+
+
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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 : VVTK_PickingDlg.cxx
+// Author : Oleg Uvarov
+// Module : VISU
+//
+#include "VVTK_PickingDlg.h"
+#include <VisuGUI_GUITools.h>
+
+#include "VISU_GaussPtsAct.h"
+#include "VISU_PickingSettings.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_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 <QColorDialog>
+#include <QComboBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QKeyEvent>
+#include <QIntValidator>
+
+#include "QtxAction.h"
+#include <SalomeApp_DoubleSpinBox.h>
+#include <SalomeApp_IntSpinBox.h>
+#include "QtxColorButton.h"
+
+#include "LightApp_Application.h"
+
+namespace
+{
+ struct SelectorHelper
+ {
+ public:
+ SelectorHelper( SVTK_RenderWindowInteractor* theInteractor ):
+ myInteractor( theInteractor )
+ {}
+
+ bool
+ get()
+ {
+ bool aResult = false;
+ myMapIndex.Clear();
+ mySelector = NULL;
+ myPipeLine = NULL;
+ myActor = NULL;
+
+ if ( !myInteractor )
+ return aResult;
+
+ mySelector = myInteractor->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);
+
+ VTK::ActorCollectionCopy aCopy(myInteractor->getRenderer()->GetActors());
+ myActor = SVTK::Find<VISU_GaussPtsAct>(aCopy.GetActors(),
+ SVTK::TIsSameIObject<VISU_GaussPtsAct>( myIO ));
+ if ( !myActor )
+ return aResult;
+
+ myPipeLine = myActor->GetGaussPointsPL();
+
+ return true;
+ }
+
+ SVTK_RenderWindowInteractor* myInteractor;
+ TColStd_IndexedMapOfInteger myMapIndex;
+ Handle(SALOME_InteractiveObject) myIO;
+ SVTK_Selector* mySelector;
+
+ VISU_GaussPointsPL* myPipeLine;
+ VISU_GaussPtsAct* myActor;
+ };
+
+
+
+ class GaussPtsIDValidator: public QIntValidator
+ {
+ public:
+ GaussPtsIDValidator( SVTK_RenderWindowInteractor* theInteractor,
+ QObject * theParent ):
+ QIntValidator( 0, VTK_LARGE_ID, theParent ),
+ myHelper(theInteractor)
+ {}
+
+ 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,
+ SVTK_RenderWindowInteractor* theInteractor,
+ QObject * theParent ):
+ GaussPtsIDValidator( theInteractor, 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,
+ SVTK_RenderWindowInteractor* theInteractor,
+ QObject * theParent ):
+ GaussPtsIDValidator( theInteractor, 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;
+ };
+}
+
+
+VVTK_ValidatedLineEdit::VVTK_ValidatedLineEdit( QWidget* parent ):
+ QLineEdit( parent )
+{
+ connect( this, SIGNAL( textChanged( const QString& ) ), this, SLOT( MarkValidated( const QString& ) ) );
+}
+
+void VVTK_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;
+ }
+}
+
+//---------------------------------------------------------------------------------
+
+VVTK_PickingDlg::VVTK_PickingDlg(QtxAction* theAction,
+ SVTK_MainWindow* theParent,
+ const char* theName):
+ SVTK_DialogBase(theAction,
+ theParent,
+ theName),
+ myEventCallbackCommand( vtkCallbackCommand::New() ),
+ myPickingSettings( VISU_PickingSettings::New() )
+{
+ myPriority = 0.0;
+ myEventCallbackCommand->Delete();
+ myEventCallbackCommand->SetClientData(this);
+ myEventCallbackCommand->SetCallback(VVTK_PickingDlg::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 );
+ //CursorGroup->setColumnLayout(0, Qt::Vertical );
+ //CursorGroup->layout()->setSpacing( 0 );
+ //CursorGroup->layout()->setMargin( 0 );
+
+ 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 SalomeApp_DoubleSpinBox( CursorGroup );
+ VISU::initSpinBox( myCursorSizeSpinBox, 0, 1, 0.1, "parametric_precision" );
+ 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 SalomeApp_DoubleSpinBox( CursorGroup );
+ VISU::initSpinBox( myPyramidHeightSpinBox, aHeightMin, aHeightMax, aHeightStep, "length_precision" );
+ myPyramidHeightSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ QLabel* SelectionColorLabel = new QLabel( tr( "SELECTION_COLOR" ), CursorGroup );
+ mySelectionColorButton = new QtxColorButton( CursorGroup );
+ mySelectionColorButton->setColor( Qt::blue );
+ //QPalette aPalette( mySelectionColorButton->palette() );
+ //aPalette.setColor( mySelectionColorButton->backgroundRole(), Qt::blue );
+ //mySelectionColorButton->setPalette( aPalette );
+ //connect( mySelectionColorButton, SIGNAL( clicked() ), this, SLOT( onColorButtonPressed() ) );
+
+ 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 );
+ //ToleranceGroup->setColumnLayout(0, Qt::Vertical );
+ //ToleranceGroup->layout()->setSpacing( 0 );
+ //ToleranceGroup->layout()->setMargin( 0 );
+
+ 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 SalomeApp_DoubleSpinBox( ToleranceGroup );
+ VISU::initSpinBox( myPointToleranceSpinBox, 0.001, 10.0, 0.01, "len_tol_precision" );
+ 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 );
+ //InfoWindowGroup->setColumnLayout(0, Qt::Vertical );
+ //InfoWindowGroup->layout()->setSpacing( 0 );
+ //InfoWindowGroup->layout()->setMargin( 0 );
+
+ 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 SalomeApp_IntSpinBox( InfoWindowGroup );
+ VISU::initSpinBox( myTransparencySpinBox, 0, 100, 10 );
+ 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 );
+ //CameraGroup->setColumnLayout(0, Qt::Vertical );
+ //CameraGroup->layout()->setSpacing( 0 );
+ //CameraGroup->layout()->setMargin( 0 );
+
+ 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 SalomeApp_DoubleSpinBox( CameraGroup );
+ VISU::initSpinBox( myZoomFactorSpinBox, 0.1, 10.0, 0.1, "parametric_precision" );
+ myZoomFactorSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ QLabel* StepNumberLabel = new QLabel( tr( "STEP_NUMBER" ), CameraGroup );
+ myStepNumberSpinBox = new SalomeApp_IntSpinBox( CameraGroup );
+ VISU::initSpinBox( myStepNumberSpinBox, 1, 100, 1 );
+ 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 );
+ //PositionGroup->setColumnLayout(0, Qt::Vertical );
+ //PositionGroup->layout()->setSpacing( 0 );
+ //PositionGroup->layout()->setMargin( 0 );
+
+ 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 VVTK_ValidatedLineEdit( PositionGroup );
+
+ QLabel* LocalPointLabel = new QLabel( tr( "LOCAL_POINT" ), PositionGroup );
+
+ myLocalPointLineEdit = new VVTK_ValidatedLineEdit( PositionGroup );
+
+ 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 );
+
+ // Common buttons ===========================================================
+ QGroupBox* GroupButtons = new QGroupBox( this );
+ //GroupButtons->setColumnLayout(0, Qt::Vertical );
+ //GroupButtons->layout()->setSpacing( 0 );
+ //GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );
+ GroupButtonsLayout->setSpacing( 6 );
+ GroupButtonsLayout->setMargin( 11 );
+
+ QPushButton* buttonApply = new QPushButton( tr( "&Apply" ), GroupButtons );
+ 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->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonClose, 0, 2 );
+
+ QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons );
+ buttonHelp->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
+
+ TopLayout->addWidget( aBox );
+ TopLayout->addWidget( GroupButtons );
+
+ connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onClickApply() ) );
+ connect( buttonClose, SIGNAL( clicked() ), this, SLOT( onClickClose() ) );
+ connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onClickHelp() ) );
+
+ connect( myParentElementLineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onSelectionValidate() ) );
+ connect( myLocalPointLineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( onSelectionValidate() ) );
+
+}
+
+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 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();
+
+ //QPalette aPalette( mySelectionColorButton->palette() );
+ /*aPalette.setColor( mySelectionColorButton->backgroundRole(),
+ QColor( ( int )( aColor[0] * 255.0 ),
+ ( int )( aColor[1] * 255.0 ),
+ ( int )( aColor[2] * 255.0 ) ) );
+ mySelectionColorButton->setPalette( aPalette );*/
+ 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 );
+ //QPalette aPalette( mySelectionColorButton->palette() );
+ //aPalette.setColor( mySelectionColorButton->backgroundRole(), 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 );
+
+ onClickApply();
+}
+
+void VVTK_PickingDlg::onSelectionValidate()
+{
+ myParentElementLineEdit->MarkValidated( myParentElementLineEdit->text() );
+ myLocalPointLineEdit->MarkValidated( myLocalPointLineEdit->text() );
+}
+
+void VVTK_PickingDlg::onSelectionEvent()
+{
+ SelectorHelper aHelper( myInteractor );
+ 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 ) );
+}
+
+VISU_PickingSettings*
+VVTK_PickingDlg
+::GetPickingSettings()
+{
+ return myPickingSettings.GetPointer();
+}
+
+void VVTK_PickingDlg::SetInteractor( SVTK_RenderWindowInteractor* theInteractor )
+{
+ myInteractor = theInteractor;
+
+ theInteractor->GetDevice()->AddObserver(vtkCommand::KeyPressEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+ theInteractor->GetDevice()->AddObserver(vtkCommand::EndPickEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+ {
+ QValidator* aValidator = new GaussCellIDValidator( myLocalPointLineEdit, theInteractor, myParentElementLineEdit );
+ myParentElementLineEdit->setValidator( aValidator );
+ }
+ {
+ QValidator* aValidator = new GaussLocalPointIDValidator( myParentElementLineEdit, theInteractor, myLocalPointLineEdit );
+ myLocalPointLineEdit->setValidator( aValidator );
+ }
+}
+
+void VVTK_PickingDlg::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* vtkNotUsed(theCallData))
+{
+ VVTK_PickingDlg* self = reinterpret_cast<VVTK_PickingDlg*>(theClientData);
+
+ switch(theEvent){
+ case vtkCommand::KeyPressEvent:
+ self->KeyPressed();
+ break;
+ case vtkCommand::EndPickEvent:
+ self->onSelectionEvent();
+ break;
+ }
+}
+
+void VVTK_PickingDlg::KeyPressed()
+{
+ if( myInteractor->GetDevice()->GetKeyCode() == 'P' )
+ {
+ bool aDisplayParentMesh = !myPickingSettings->GetDisplayParentMesh();
+ myPickingSettings->SetDisplayParentMesh( aDisplayParentMesh );
+
+ myDisplayParentMeshCheckBox->setChecked( aDisplayParentMesh );
+
+ myPickingSettings->InvokeEvent(VISU::UpdatePickingSettingsEvent,NULL);
+ }
+}
+
+void VVTK_PickingDlg::onClickApply()
+{
+ //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() );
+
+ //QPalette aPalette( mySelectionColorButton->palette() );
+ QColor aButtonColor = mySelectionColorButton->color();//aPalette.color(mySelectionColorButton->backgroundRole() );
+ 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 );
+
+ SelectorHelper aHelper( myInteractor );
+ if ( !aHelper.get() )
+ return;
+
+ VISU::TCellID aCellID = myParentElementLineEdit->text().toInt();
+ VISU::TLocalPntID aLocalPntID = myLocalPointLineEdit->text().toInt();
+ VISU::PGaussPtsIDMapper anIDMapper = aHelper.myPipeLine->GetGaussPtsIDMapper();
+ vtkIdType anObjId = anIDMapper->GetVTKID( VISU::TGaussPointID( aCellID, aLocalPntID ) );
+ if ( anObjId < 0 )
+ return;
+
+ aHelper.myMapIndex.Clear();
+ aHelper.myMapIndex.Add( anObjId );
+ aHelper.mySelector->AddOrRemoveIndex( aHelper.myIO, aHelper.myMapIndex, false );
+ aHelper.myActor->Highlight( aHelper.myIO );
+ myInteractor->GetDevice()->CreateTimer( VTKI_TIMER_FIRST );
+}
+
+void VVTK_PickingDlg::onClickClose()
+{
+ reject();
+}
+
+void VVTK_PickingDlg::onClickHelp()
+{
+ 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 VVTK_PickingDlg::onColorButtonPressed()
+{
+ QPalette aPalette( mySelectionColorButton->palette() );
+ QColor aColor = QColorDialog::
+ getColor( aPalette.color(mySelectionColorButton->backgroundRole() ), this );
+
+ if( aColor.isValid() )
+ {
+ aPalette.setColor( mySelectionColorButton->backgroundRole(),
+ aColor );
+ mySelectionColorButton->setPalette( aPalette );
+ }
+}*/
+
+void VVTK_PickingDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 )
+ {
+ e->accept();
+ onClickHelp();
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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 : VVTK_PickingDlg.h
+// Author : Oleg Uvarov
+// Module : VISU
+//
+#ifndef VVTK_PICKINGDLG_H
+#define VVTK_PICKINGDLG_H
+
+#include "SVTK_DialogBase.h"
+
+#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 SalomeApp_DoubleSpinBox;
+class SalomeApp_IntSpinBox;
+class QtxColorButton;
+
+class VISU_GaussPtsAct;
+class VISU_PickingSettings;
+
+class SVTK_MainWindow;
+class SVTK_RenderWindowInteractor;
+class VVTK_ValidatedLineEdit;
+
+//! Picking Dialog.
+/*!
+ * Uses for set up picking preferenses and apply
+ * them to all actors in the current renderer.
+ */
+class VVTK_PickingDlg : public SVTK_DialogBase
+{
+ Q_OBJECT
+
+public:
+ VVTK_PickingDlg(QtxAction* theAction,
+ SVTK_MainWindow* theParent,
+ const char* theName);
+
+ ~VVTK_PickingDlg();
+
+ //! 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* );
+
+protected slots:
+ void onSelectionEvent();
+ void onClickApply();
+ void onClickClose();
+ void onClickHelp();
+
+ //void onColorButtonPressed();
+ void onSelectionValidate();
+
+private:
+ static void ProcessEvents(vtkObject* theObject,
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData);
+
+ void KeyPressed();
+ void keyPressEvent( QKeyEvent* e );
+
+private:
+ SalomeApp_DoubleSpinBox* myCursorSizeSpinBox;
+ SalomeApp_DoubleSpinBox* myPyramidHeightSpinBox;
+ QtxColorButton* mySelectionColorButton;
+ SalomeApp_DoubleSpinBox* myPointToleranceSpinBox;
+ SalomeApp_IntSpinBox* myTransparencySpinBox;
+ QComboBox* myPositionComboBox;
+ SalomeApp_DoubleSpinBox* myZoomFactorSpinBox;
+ SalomeApp_IntSpinBox* myStepNumberSpinBox;
+ QCheckBox* myDisplayParentMeshCheckBox;
+
+ QtxAction* myAction;
+ vtkSmartPointer<VISU_PickingSettings>
+ myPickingSettings;
+
+ VVTK_ValidatedLineEdit*
+ myParentElementLineEdit;
+ VVTK_ValidatedLineEdit*
+ myLocalPointLineEdit;
+
+ SVTK_RenderWindowInteractor*
+ myInteractor;
+
+ float myPriority;
+ vtkSmartPointer<vtkCallbackCommand>
+ myEventCallbackCommand;
+};
+
+class VVTK_ValidatedLineEdit : public QLineEdit
+{
+ Q_OBJECT;
+public:
+ VVTK_ValidatedLineEdit( QWidget* parent );
+
+public slots:
+ void MarkValidated( const QString& theText );
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// VISU VISUGUI : GUI of VISU component
+// File : VVTK_PrimitiveBox.cxx
+// Author : Oleg UVAROV
+// Module : VISU
+//
+#include "VVTK_PrimitiveBox.h"
+#include <VisuGUI_GUITools.h>
+
+#include "VISU_OpenGLPointSpriteMapper.hxx"
+
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+
+#include <SalomeApp_DoubleSpinBox.h>
+#include <SalomeApp_IntSpinBox.h>
+
+#include <QLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QButtonGroup>
+#include <QRadioButton>
+#include <QPushButton>
+#include <QFileDialog>
+
+#include <iostream>
+
+using namespace std;
+
+VVTK_PrimitiveBox::VVTK_PrimitiveBox( QWidget* parent ) :
+ QGroupBox( parent )
+{
+ SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+
+ setTitle( tr( "PRIMITIVE_TITLE" ) );
+ //setColumnLayout(0, Qt::Vertical );
+ //layout()->setSpacing( 0 );
+ //layout()->setMargin( 0 );
+
+ QGridLayout* aLayout = new QGridLayout( this );
+ aLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ aLayout->setSpacing(6);
+ aLayout->setMargin(11);
+
+ myPrimitiveType = VISU_OpenGLPointSpriteMapper::PointSprite;
+
+ QString aRootDir = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/";
+ myMainTexture = aRootDir + "sprite_texture.bmp";
+ myAlphaTexture = aRootDir + "sprite_alpha.bmp";
+
+ // Primitive Type
+ QGroupBox* aPrimitiveTypeGroup = new QGroupBox( this );
+ aPrimitiveTypeGroup->setMinimumWidth( 450 );
+ QHBoxLayout* aPrimLayout = new QHBoxLayout( aPrimitiveTypeGroup );
+ aPrimLayout->setMargin( 0 );
+
+ //QButtonGroup* aPrimitiveTypeGroup = new QButtonGroup( 3, Qt::Horizontal, this, "PrimitiveTypeGroup" );
+ //aPrimitiveTypeGroup->setMinimumWidth( 450 );
+ //aPrimitiveTypeGroup->setRadioButtonExclusive( true );
+ //aPrimitiveTypeGroup->setFrameStyle( QFrame::NoFrame );
+ //aPrimitiveTypeGroup->layout()->setMargin( 0 );
+
+ myPointSpriteButton = new QRadioButton( tr( "POINT_SPRITE" ), aPrimitiveTypeGroup );
+ myOpenGLPointButton = new QRadioButton( tr( "OPENGL_POINT" ), aPrimitiveTypeGroup );
+ myGeomSphereButton = new QRadioButton( tr( "GEOMETRICAL_SPHERE" ), aPrimitiveTypeGroup );
+
+ aPrimLayout->addWidget( myPointSpriteButton );
+ aPrimLayout->addWidget( myOpenGLPointButton );
+ aPrimLayout->addWidget( myGeomSphereButton );
+
+ aLayout->addWidget( aPrimitiveTypeGroup, 0, 0, 1, 2 );
+
+ // Clamp ( Point Sprite & OpenGL Point )
+ myClampLabel = new QLabel( tr( "CLAMP" ), this );
+ myClampSpinBox = new SalomeApp_DoubleSpinBox( this );
+ VISU::initSpinBox( myClampSpinBox, 1.0, 512.0, 1.0, "parametric_precision" );
+ myClampSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ aLayout->addWidget( myClampLabel, 1, 0 );
+ aLayout->addWidget( myClampSpinBox, 1, 1, 1, 2 );
+
+ // Main Texture ( Point Sprite )
+ myMainTextureLabel = new QLabel( tr( "MAIN_TEXTURE" ), this );
+ myMainTextureLineEdit = new QLineEdit( this );
+ myMainTextureButton = new QPushButton( this );
+ myMainTextureButton->setAutoDefault( false );
+ myMainTextureButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_LOAD_TEXTURE" ) ) );
+ connect( myMainTextureButton, SIGNAL( clicked() ), this, SLOT( onBrowseMainTexture() ) );
+
+ aLayout->addWidget( myMainTextureLabel, 2, 0 );
+ aLayout->addWidget( myMainTextureLineEdit, 2, 1 );
+ aLayout->addWidget( myMainTextureButton, 2, 2 );
+
+ // Alpha Texture ( Point Sprite )
+ myAlphaTextureLabel = new QLabel( tr( "ALPHA_TEXTURE" ), this );
+ myAlphaTextureLineEdit = new QLineEdit( this );
+ myAlphaTextureButton = new QPushButton( this );
+ myAlphaTextureButton->setAutoDefault( false );
+ myAlphaTextureButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_LOAD_TEXTURE" ) ) );
+ connect( myAlphaTextureButton, SIGNAL( clicked() ), this, SLOT( onBrowseAlphaTexture() ) );
+
+ aLayout->addWidget( myAlphaTextureLabel, 3, 0 );
+ aLayout->addWidget( myAlphaTextureLineEdit, 3, 1 );
+ aLayout->addWidget( myAlphaTextureButton, 3, 2 );
+
+ // Alpha Threshold ( Point Sprite )
+ myAlphaThresholdLabel = new QLabel( tr( "ALPHA_THRESHOLD" ), this );
+ myAlphaThresholdSpinBox = new SalomeApp_DoubleSpinBox( this );
+ VISU::initSpinBox( myAlphaThresholdSpinBox, 0.0, 1.0, 0.1, "parametric_precision" );
+ myAlphaThresholdSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ aLayout->addWidget( myAlphaThresholdLabel, 4, 0 );
+ aLayout->addWidget( myAlphaThresholdSpinBox, 4, 1, 1, 2 );
+
+ // Resolution ( Geometrical Sphere )
+ myResolutionLabel = new QLabel( tr( "RESOLUTION" ), this );
+ myResolutionSpinBox = new SalomeApp_IntSpinBox( this );
+ VISU::initSpinBox( myResolutionSpinBox, 3, 100, 1 );
+ myResolutionSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ connect( myResolutionSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( onResolutionChanged( int ) ) );
+
+ aLayout->addWidget( myResolutionLabel, 5, 0 );
+ aLayout->addWidget( myResolutionSpinBox, 5, 1, 1, 2 );
+
+ // Number of faces ( Geometrical Sphere )
+ myFaceNumberLabel = new QLabel( tr( "FACE_NUMBER" ), this );
+ myFaceNumberLineEdit = new QLineEdit( this );
+ myFaceNumberLineEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myFaceNumberLineEdit->setEnabled( false );
+ //myFaceNumberLineEdit->setReadOnly( true );
+
+ aLayout->addWidget( myFaceNumberLabel, 6, 0 );
+ aLayout->addWidget( myFaceNumberLineEdit, 6, 1, 1, 2 );
+
+ // Notification ( Geometrical Sphere )
+ myFaceLimitLabel = new QLabel( tr( "FACE_LIMIT" ), this );
+ myFaceLimitSpinBox = new SalomeApp_IntSpinBox( this );
+ VISU::initSpinBox( myFaceLimitSpinBox, 10, 1000000, 10 );
+ myFaceLimitSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ aLayout->addWidget( myFaceLimitLabel, 7, 0 );
+ aLayout->addWidget( myFaceLimitSpinBox, 7, 1, 1, 2 );
+
+ connect( myPointSpriteButton, SIGNAL( clicked() ), this, SLOT( onTogglePointSprite() ) );
+ connect( myOpenGLPointButton, SIGNAL( clicked() ), this, SLOT( onToggleOpenGLPoint() ) );
+ connect( myGeomSphereButton, SIGNAL( clicked() ), this, SLOT( onToggleGeomSphere() ) );
+}
+
+void VVTK_PrimitiveBox::onTogglePointSprite()
+{
+ myPrimitiveType = VISU_OpenGLPointSpriteMapper::PointSprite;
+
+ myClampLabel->show();
+ myClampSpinBox->show();
+
+ myMainTextureLabel->show();
+ myMainTextureLineEdit->show();
+ myMainTextureButton->show();
+
+ myAlphaTextureLabel->show();
+ myAlphaTextureLineEdit->show();
+ myAlphaTextureButton->show();
+
+ myAlphaThresholdLabel->show();
+ myAlphaThresholdSpinBox->show();
+
+ myResolutionLabel->hide();
+ myResolutionSpinBox->hide();
+
+ myFaceNumberLabel->hide();
+ myFaceNumberLineEdit->hide();
+
+ myFaceLimitLabel->hide();
+ myFaceLimitSpinBox->hide();
+}
+
+void VVTK_PrimitiveBox::onToggleOpenGLPoint()
+{
+ myPrimitiveType = VISU_OpenGLPointSpriteMapper::OpenGLPoint;
+
+ myClampLabel->show();
+ myClampSpinBox->show();
+
+ myMainTextureLabel->hide();
+ myMainTextureLineEdit->hide();
+ myMainTextureButton->hide();
+
+ myAlphaTextureLabel->hide();
+ myAlphaTextureLineEdit->hide();
+ myAlphaTextureButton->hide();
+
+ myAlphaThresholdLabel->hide();
+ myAlphaThresholdSpinBox->hide();
+
+ myResolutionLabel->hide();
+ myResolutionSpinBox->hide();
+
+ myFaceNumberLabel->hide();
+ myFaceNumberLineEdit->hide();
+
+ myFaceLimitLabel->hide();
+ myFaceLimitSpinBox->hide();
+}
+
+void VVTK_PrimitiveBox::onToggleGeomSphere()
+{
+ myPrimitiveType = VISU_OpenGLPointSpriteMapper::GeomSphere;
+
+ myClampLabel->hide();
+ myClampSpinBox->hide();
+
+ myMainTextureLabel->hide();
+ myMainTextureLineEdit->hide();
+ myMainTextureButton->hide();
+
+ myAlphaTextureLabel->hide();
+ myAlphaTextureLineEdit->hide();
+ myAlphaTextureButton->hide();
+
+ myAlphaThresholdLabel->hide();
+ myAlphaThresholdSpinBox->hide();
+
+ myResolutionLabel->show();
+ myResolutionSpinBox->show();
+
+ myFaceNumberLabel->show();
+ myFaceNumberLineEdit->show();
+
+ myFaceLimitLabel->show();
+ myFaceLimitSpinBox->show();
+}
+
+void VVTK_PrimitiveBox::onResolutionChanged( int theResolution )
+{
+ setFaceNumber( 2 * theResolution * ( theResolution - 2 ) );
+}
+
+void VVTK_PrimitiveBox::setPrimitiveType( int theType )
+{
+ myPrimitiveType = theType;
+
+ switch( myPrimitiveType )
+ {
+ case VISU_OpenGLPointSpriteMapper::PointSprite :
+ myPointSpriteButton->setChecked( true );
+ onTogglePointSprite();
+ break;
+ case VISU_OpenGLPointSpriteMapper::OpenGLPoint :
+ myOpenGLPointButton->setChecked( true );
+ onToggleOpenGLPoint();
+ break;
+ case VISU_OpenGLPointSpriteMapper::GeomSphere :
+ myGeomSphereButton->setChecked( true );
+ onToggleGeomSphere();
+ break;
+ default : break;
+ }
+}
+
+float VVTK_PrimitiveBox::getClamp() const
+{
+ return myClampSpinBox->value();
+}
+
+void VVTK_PrimitiveBox::setClamp( float theClamp )
+{
+ myClampSpinBox->setValue( theClamp );
+}
+
+void VVTK_PrimitiveBox::setClampMaximum( float theClampMaximum )
+{
+ myClampSpinBox->setMaximum( theClampMaximum );
+}
+
+void VVTK_PrimitiveBox::setMainTexture( const QString& theMainTexture )
+{
+ myMainTexture = theMainTexture;
+ myMainTextureLineEdit->setText( theMainTexture.section( '/', -1 ) );
+}
+
+void VVTK_PrimitiveBox::setAlphaTexture( const QString& theAlphaTexture )
+{
+ myAlphaTexture = theAlphaTexture;
+ myAlphaTextureLineEdit->setText( theAlphaTexture.section( '/', -1 ) );
+}
+
+float VVTK_PrimitiveBox::getAlphaThreshold() const
+{
+ return myAlphaThresholdSpinBox->value();
+}
+
+void VVTK_PrimitiveBox::setAlphaThreshold( float theAlphaThreshold )
+{
+ myAlphaThresholdSpinBox->setValue( theAlphaThreshold );
+}
+
+int VVTK_PrimitiveBox::getResolution() const
+{
+ return myResolutionSpinBox->value();
+}
+
+void VVTK_PrimitiveBox::setResolution( int theResolution )
+{
+ myResolutionSpinBox->setValue( theResolution );
+}
+
+int VVTK_PrimitiveBox::getFaceNumber() const
+{
+ int aResolution = getResolution();
+ return 2 * aResolution * ( aResolution - 2 );
+ //return myFaceNumberLineEdit->text().toInt();
+}
+
+void VVTK_PrimitiveBox::setFaceNumber( int theFaceNumber )
+{
+ myFaceNumberLineEdit->setText( QString::number( theFaceNumber ) );
+}
+
+int VVTK_PrimitiveBox::getFaceLimit() const
+{
+ return myFaceLimitSpinBox->value();
+}
+
+void VVTK_PrimitiveBox::setFaceLimit( int theFaceLimit )
+{
+ myFaceLimitSpinBox->setValue( theFaceLimit );
+}
+
+void VVTK_PrimitiveBox::onBrowseMainTexture()
+{
+ QString aRootDir = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/";
+ QString aFileName = QFileDialog::getOpenFileName( this,
+ 0,
+ aRootDir,
+ "Bitmap (*.bmp *.jpg *.png)" );
+
+ if( aFileName.isNull() )
+ return;
+
+ myMainTexture = aFileName;
+ myMainTextureLineEdit->setText( aFileName.section( '/', -1 ) );
+}
+
+void VVTK_PrimitiveBox::onBrowseAlphaTexture()
+{
+ QString aRootDir = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/";
+ QString aFileName = QFileDialog::getOpenFileName( this,
+ 0,
+ aRootDir,
+ "Bitmap (*.bmp *.jpg *.png)" );
+
+ if( aFileName.isNull() )
+ return;
+
+ myAlphaTexture = aFileName;
+ myAlphaTextureLineEdit->setText( aFileName.section( '/', -1 ) );
+}
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// VISU VISUGUI : GUI of VISU component
+// File : VVTK_PrimitiveBox.h
+// Author : Oleg UVAROV
+// Module : VISU
+//
+#ifndef VVTK_PRIMITIVEBOX_H
+#define VVTK_PRIMITIVEBOX_H
+
+#include "VVTK.h"
+
+#include <QGroupBox>
+
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QRadioButton;
+
+class SalomeApp_DoubleSpinBox;
+class SalomeApp_IntSpinBox;
+
+class VVTK_EXPORT VVTK_PrimitiveBox : public QGroupBox
+{
+ Q_OBJECT
+
+public:
+ VVTK_PrimitiveBox( QWidget* );
+ ~VVTK_PrimitiveBox() {}
+
+public:
+ int getPrimitiveType() const { return myPrimitiveType; }
+ void setPrimitiveType( int );
+
+ float getClamp() const;
+ void setClamp( float );
+ void setClampMaximum( float );
+
+ QString getMainTexture() const { return myMainTexture; }
+ void setMainTexture( const QString& );
+
+ QString getAlphaTexture() const { return myAlphaTexture; }
+ void setAlphaTexture( const QString& );
+
+ float getAlphaThreshold() const;
+ void setAlphaThreshold( float );
+
+ int getResolution() const;
+ void setResolution( int );
+
+ int getFaceNumber() const;
+ void setFaceNumber( int );
+
+ int getFaceLimit() const;
+ void setFaceLimit( int );
+
+protected slots:
+ void onTogglePointSprite();
+ void onToggleOpenGLPoint();
+ void onToggleGeomSphere();
+
+ void onBrowseMainTexture();
+ void onBrowseAlphaTexture();
+
+ void onResolutionChanged( int );
+
+private:
+ int myPrimitiveType;
+
+ QRadioButton* myPointSpriteButton;
+ QRadioButton* myOpenGLPointButton;
+ QRadioButton* myGeomSphereButton;
+
+ QString myMainTexture;
+ QString myAlphaTexture;
+
+ QLabel* myClampLabel;
+ SalomeApp_DoubleSpinBox* myClampSpinBox;
+
+ QLabel* myMainTextureLabel;
+ QLineEdit* myMainTextureLineEdit;
+ QPushButton* myMainTextureButton;
+
+ QLabel* myAlphaTextureLabel;
+ QLineEdit* myAlphaTextureLineEdit;
+ QPushButton* myAlphaTextureButton;
+
+ QLabel* myAlphaThresholdLabel;
+ SalomeApp_DoubleSpinBox* myAlphaThresholdSpinBox;
+
+ QLabel* myResolutionLabel;
+ SalomeApp_IntSpinBox* myResolutionSpinBox;
+
+ QLabel* myFaceNumberLabel;
+ QLineEdit* myFaceNumberLineEdit;
+
+ QLabel* myFaceLimitLabel;
+ SalomeApp_IntSpinBox* myFaceLimitSpinBox;
+};
+
+
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+// File :
+// Author :
+// Module :
+// $Header$
+//
+#include "VVTK_Recorder.h"
+
+#include "VVTK_ImageWriter.h"
+#include "VVTK_ImageWriterMgr.h"
+
+#include <vtkObjectFactory.h>
+#include <vtkObject.h>
+#include <vtkCallbackCommand.h>
+#include <vtkRenderWindow.h>
+#include <vtkTimerLog.h>
+#include <vtkWindowToImageFilter.h>
+#include <vtkJPEGWriter.h>
+#include <vtkImageData.h>
+
+#include <sstream>
+#include <iomanip>
+#include <iostream>
+
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
+#include <QApplication>
+#include <QFileInfo>
+#include <QDir>
+
+#include "utilities.h"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+namespace
+{
+ //----------------------------------------------------------------------------
+ inline
+ void
+ GetNameJPEG(const std::string& thePreffix,
+ const int theIndex,
+ std::string& theName)
+ {
+ using namespace std;
+ ostringstream aStream;
+ aStream<<thePreffix<<"_"<<setw(6)<<setfill('0')<<theIndex<<".jpeg";
+ theName = aStream.str();
+ }
+}
+
+//----------------------------------------------------------------------------
+vtkCxxRevisionMacro(VVTK_Recorder,"$Revision$");
+vtkStandardNewMacro(VVTK_Recorder);
+
+
+//----------------------------------------------------------------------------
+VVTK_Recorder
+::VVTK_Recorder():
+ myRenderWindow(NULL),
+ myState(VVTK_Recorder_Stop),
+ myNbFPS(5.5),
+ myQuality(100),
+ myProgressiveMode(true),
+ myUseSkippedFrames(true),
+ myErrorStatus(0),
+ myCommand(vtkCallbackCommand::New()),
+ myPriority(0.0),
+ myTimeStart(0.0),
+ myFrameIndex(0),
+ myPaused(0),
+ myFilter(vtkWindowToImageFilter::New()),
+ myWriterMgr(new VVTK_ImageWriterMgr),
+ myNbWrittenFrames(0),
+ myNameAVIMaker("jpeg2yuv")
+{
+ myCommand->SetClientData(this);
+ myCommand->SetCallback(VVTK_Recorder::ProcessEvents);
+}
+
+
+//----------------------------------------------------------------------------
+VVTK_Recorder
+::~VVTK_Recorder()
+{
+ myCommand->Delete();
+ myFilter->Delete();
+ delete myWriterMgr;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::CheckExistAVIMaker()
+{
+ myErrorStatus = 0;
+ using namespace std;
+ ostringstream aStream;
+ aStream<<"which "<<myNameAVIMaker<<" >& /dev/null";
+ std::string anAVIMakeCheck = aStream.str();
+ int iErr = system(anAVIMakeCheck.c_str());
+ if(iErr != 0)
+ myErrorStatus = 127;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::SetName(const char* theName)
+{
+ myName = theName;
+}
+
+const char*
+VVTK_Recorder::Name() const
+{
+ return myName.c_str();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::SetNbFPS(const double theNbFPS)
+{
+ myNbFPS = theNbFPS;
+}
+
+double
+VVTK_Recorder
+::NbFPS() const
+{
+ return myNbFPS;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::SetQuality(int theQuality)
+{
+ myQuality = theQuality;
+}
+
+int
+VVTK_Recorder
+::GetQuality() const
+{
+ return myQuality;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::SetRenderWindow(vtkRenderWindow* theRenderWindow)
+{
+ myRenderWindow = theRenderWindow;
+}
+
+vtkRenderWindow*
+VVTK_Recorder
+::RenderWindow()
+{
+ return myRenderWindow;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::SetProgressiveMode(bool theProgressiveMode)
+{
+ myProgressiveMode = theProgressiveMode;
+}
+
+bool
+VVTK_Recorder
+::GetProgressiveMode() const
+{
+ return myProgressiveMode;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::SetUseSkippedFrames(bool theUseSkippedFrames)
+{
+ myUseSkippedFrames = theUseSkippedFrames;
+}
+
+bool
+VVTK_Recorder
+::UseSkippedFrames() const
+{
+ return myUseSkippedFrames;
+}
+
+
+//----------------------------------------------------------------------------
+int
+VVTK_Recorder
+::ErrorStatus() const
+{
+ return myErrorStatus;
+}
+
+int
+VVTK_Recorder
+::State() const
+{
+ return myState;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* vtkNotUsed(theCallData))
+{
+ if(vtkObject* anObj = reinterpret_cast<vtkObject*>(theClientData)){
+ if(VVTK_Recorder* aSelf = dynamic_cast<VVTK_Recorder*>(anObj)){
+ if(theEvent==vtkCommand::EndEvent){
+ if(aSelf->State() == VVTK_Recorder::VVTK_Recorder_Record){
+ aSelf->DoRecord();
+ }
+ }
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::Record()
+{
+ if(myState == VVTK_Recorder_Stop){
+ if(myRenderWindow){
+ myState = VVTK_Recorder_Record;
+ myFilter->SetInput(myRenderWindow);
+ myFrameIndex = -1;
+ myNbWrittenFrames = 0;
+ myRenderWindow->RemoveObserver(myCommand);
+ myRenderWindow->AddObserver(vtkCommand::EndEvent,
+ myCommand,
+ myPriority);
+ myRenderWindow->Render();
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::Stop()
+{
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+
+ if(myState == VVTK_Recorder_Record){
+ if(!myPaused)
+ DoRecord();
+
+ myWriterMgr->Stop();
+
+ if(myUseSkippedFrames)
+ AddSkippedFrames();
+
+ myFrameIndexes.clear();
+
+ MakeFileAVI();
+ }
+ myState = VVTK_Recorder_Stop;
+ myPaused = 0;
+
+ QApplication::restoreOverrideCursor();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::Pause()
+{
+ myPaused = myPaused ? 0 : 1;
+ if(myPaused && !myFrameIndexes.empty()){
+ myFrameIndexes.back() *= -1;
+ if(MYDEBUG) MESSAGE("VVTK_Recorder::Pause - myFrameIndexes.back() = "<<myFrameIndexes.back());
+ }
+}
+
+
+//----------------------------------------------------------------------------
+inline
+int
+GetFrameIndex(double theStartTime,
+ double theFPS)
+{
+ double aTimeNow = vtkTimerLog::GetCurrentTime();
+ double aDelta = aTimeNow - theStartTime;
+ return int(aDelta*theFPS);
+}
+
+void
+VVTK_Recorder
+::DoRecord()
+{
+ if(myPaused)
+ return;
+
+ if(myFrameIndex < 0){
+ myFrameIndex = 0;
+ myTimeStart = vtkTimerLog::GetCurrentTime();
+ }else{
+ int aFrameIndex = GetFrameIndex(myTimeStart,myNbFPS);
+ if(aFrameIndex <= myFrameIndex)
+ return;
+
+ // If there was a "pause" we correct the myTimeStart
+ int aLastFrameIndex = myFrameIndexes.back();
+ if(aLastFrameIndex < 0){
+ myFrameIndexes.back() = abs(myFrameIndexes.back());
+ double aPauseTime = fabs((double)(aFrameIndex - myFrameIndex - 1)) / myNbFPS;
+ if(MYDEBUG)
+ MESSAGE("VVTK_Recorder::DoRecord - aFrameIndex = "<<aFrameIndex<<
+ "; aPauseTime = "<<aPauseTime);
+ myTimeStart += aPauseTime;
+ }
+
+ aFrameIndex = GetFrameIndex(myTimeStart,myNbFPS);
+ if(aFrameIndex <= myFrameIndex)
+ return;
+
+ myFrameIndex = aFrameIndex;
+ }
+
+ myFrameIndexes.push_back(myFrameIndex);
+ if(MYDEBUG) MESSAGE("VVTK_Recorder::DoRecord - myFrameIndex = "<<myFrameIndex);
+
+ myRenderWindow->RemoveObserver(myCommand);
+ myFilter->Modified();
+
+ std::string aName;
+ GetNameJPEG(myName,myFrameIndex,aName);
+
+ PreWrite();
+
+ vtkImageData *anImageData = vtkImageData::New();
+ anImageData->DeepCopy(myFilter->GetOutput());
+
+ myWriterMgr->StartImageWriter(anImageData,aName,myProgressiveMode,myQuality);
+ myNbWrittenFrames++;
+
+ myRenderWindow->AddObserver(vtkCommand::EndEvent,
+ myCommand,
+ myPriority);
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::PreWrite()
+{
+ vtkImageData *anImageData = myFilter->GetOutput();
+ //
+ if(!anImageData){
+ myErrorStatus = 20;
+ return;
+ }
+ anImageData->UpdateInformation();
+ int *anExtent = anImageData->GetWholeExtent();
+ anImageData->SetUpdateExtent(anExtent[0], anExtent[1],
+ anExtent[2], anExtent[3],
+ 0,0);
+ anImageData->UpdateData();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::AddSkippedFrames()
+{
+ myErrorStatus = 0;
+
+ if(myFrameIndexes.size() < 2)
+ return;
+
+ size_t anId = 0, anEnd = myFrameIndexes.size() - 1;
+ for(; anId < anEnd; anId++){
+ int aStartIndex = myFrameIndexes[anId];
+ if(aStartIndex < 0)
+ continue;
+
+ int aFinishIndex = abs(myFrameIndexes[anId + 1]);
+ if(aStartIndex + 1 == aFinishIndex)
+ continue;
+
+ std::string anInitialName;
+ std::ostringstream aStream;
+ GetNameJPEG(myName,aStartIndex,anInitialName);
+ for(int anIndex = aStartIndex + 1; anIndex < aFinishIndex; anIndex++){
+ myNbWrittenFrames++;
+ std::string anCurrentName;
+ GetNameJPEG(myName,anIndex,anCurrentName);
+ aStream<<"ln -s "<< anInitialName<<" "<<anCurrentName<<";";
+ if(anIndex + 1 < aFinishIndex)
+ aStream<<" \\";
+ aStream<<endl;
+ }
+ std::string aString(aStream.str());
+ system(aString.c_str());
+ if(MYDEBUG) MESSAGE("VVTK_Recorder::AddSkippedFrames - "<<aString);
+ }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Recorder
+::MakeFileAVI()
+{
+ myErrorStatus = 0;
+ std::ostringstream aStream;
+ aStream<<myNameAVIMaker<<
+ " -I p"<<
+ " -v 0"<<
+ //" -f "<<int(myNbFPS)<<" "<<
+ " -f "<<myNbFPS<<" "<<
+ " -n "<<myNbWrittenFrames<<" "<<
+ " -j "<<myName<<"_\%06d.jpeg "<<
+ "| yuv2lav"<<
+ " -o "<<myName;
+
+ std::string aString(aStream.str());
+ myErrorStatus = system(aString.c_str());
+
+ if(MYDEBUG) MESSAGE("VVTK_Recorder::MakeFileAVI - "<<aString);
+
+ QFileInfo aFileInfo(myName.c_str());
+ QString aDirPath = aFileInfo.absoluteDir().path();
+ QString aBaseName = aFileInfo.fileName();
+ QString aCommand =
+ QString("(cd ") + aDirPath +
+ "; ls " +
+ " | egrep '" + aBaseName + "_[0-9]*.jpeg'" +
+ " | xargs rm " +
+ ")";
+
+ aCommand =
+ QString("rm ") + aDirPath + "/" + aBaseName + "*.jpeg";
+
+ if(MYDEBUG) MESSAGE("VVTK_Recorder::MakeFileAVI - "<<aCommand.toLatin1().data() );
+ system((const char*)aCommand.toLatin1());
+}
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+//
+#ifndef _VVTK_Recorder_Header_File_
+#define _VVTK_Recorder_Header_File_
+
+#include <list>
+#include <string>
+#include <vector>
+
+#include <vtkObject.h>
+
+class vtkRenderWindow;
+class vtkCallbackCommand;
+class vtkWindowToImageFilter;
+class VVTK_ImageWriterMgr;
+//
+class VVTK_Recorder : public vtkObject
+{
+ protected:
+ enum State {
+ VVTK_Recorder_Unknown=0,
+ VVTK_Recorder_Record,
+ VVTK_Recorder_Stop
+ };
+
+ public:
+ static VVTK_Recorder *New();
+ vtkTypeRevisionMacro(VVTK_Recorder,vtkObject);
+
+ void
+ SetRenderWindow(vtkRenderWindow* theRenderWindow);
+
+ vtkRenderWindow*
+ RenderWindow();
+
+ void
+ SetName(const char *theName);
+
+ const char*
+ Name() const;
+
+ void
+ SetNbFPS(const double theNbFPS);
+
+ double
+ NbFPS() const;
+
+ void
+ SetQuality(int theQuality);
+
+ int
+ GetQuality() const;
+
+ void
+ SetProgressiveMode(bool theProgressiveMode);
+
+ bool
+ GetProgressiveMode() const;
+
+ void
+ SetUseSkippedFrames(bool theUseSkippedFrames);
+
+ bool
+ UseSkippedFrames() const;
+
+ void
+ Record();
+
+ void
+ Pause();
+
+ void
+ Stop();
+
+ int
+ State() const;
+
+ int
+ ErrorStatus() const;
+
+ void
+ CheckExistAVIMaker();
+
+protected :
+ VVTK_Recorder();
+
+ ~VVTK_Recorder();
+
+ void
+ DoRecord();
+
+ void
+ MakeFileAVI();
+
+ void
+ AddSkippedFrames();
+
+ void
+ PreWrite();
+
+ static
+ void
+ ProcessEvents(vtkObject* theObject,
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData);
+
+protected :
+ int myState;
+ int myPaused;
+ int myErrorStatus;
+
+ float myPriority;
+ double myTimeStart;
+
+ int myFrameIndex;
+ int myNbWrittenFrames;
+
+ double myNbFPS;
+ int myQuality;
+ bool myProgressiveMode;
+
+ typedef std::vector<int> TFrameIndexes;
+ TFrameIndexes myFrameIndexes;
+ bool myUseSkippedFrames;
+
+ std::string myName;
+ std::string myNameAVIMaker;
+
+ vtkCallbackCommand *myCommand;
+ vtkRenderWindow *myRenderWindow;
+ vtkWindowToImageFilter *myFilter;
+ VVTK_ImageWriterMgr *myWriterMgr;
+
+
+private:
+ VVTK_Recorder(const VVTK_Recorder&); //Not implemented
+ void operator=(const VVTK_Recorder&); //Not implemented
+};
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// VISU VISUGUI : GUI of VISU component
+// File : VVTK_RecorderDlg.cxx
+// Author : Oleg UVAROV
+// Module : VISU
+//
+#include "VVTK_RecorderDlg.h"
+#include "VVTK_Recorder.h"
+#include <VisuGUI_GUITools.h>
+
+#include "SUIT_FileDlg.h"
+#include "SUIT_MessageBox.h"
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+
+#include <SalomeApp_DoubleSpinBox.h>
+#include <SalomeApp_IntSpinBox.h>
+
+#include "LightApp_Application.h"
+
+#include "CAM_Module.h"
+
+#include <QCheckBox>
+#include <QComboBox>
+#include <QGroupBox>
+#include <QKeyEvent>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+#include <QPushButton>
+
+/*!
+ * Constructor
+ */
+VVTK_RecorderDlg::VVTK_RecorderDlg( QWidget* theParent, VVTK_Recorder* theRecorder ):
+ QDialog( theParent ),
+ myRecorder( theRecorder )
+{
+ setWindowTitle( tr( "DLG_RECORDER_TITLE" ) );
+
+ SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+
+ QVBoxLayout* aTopLayout = new QVBoxLayout( this );
+ aTopLayout->setSpacing( 6 );
+ aTopLayout->setMargin( 6 );
+ //aTopLayout->setAutoAdd( true );
+
+ // Settings
+ QGroupBox* mySettingsBox = new QGroupBox( tr( "SETTINGS" ), this );
+ //mySettingsBox->setColumnLayout( 0, Qt::Vertical );
+ //mySettingsBox->layout()->setSpacing( 0 );
+ //mySettingsBox->layout()->setMargin( 0 );
+
+ QGridLayout* aSettingsLayout = new QGridLayout( mySettingsBox );
+ aSettingsLayout->setSpacing( 6 );
+ aSettingsLayout->setMargin( 11 );
+
+ QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), mySettingsBox );
+ myFileNameLineEdit = new QLineEdit( mySettingsBox );
+ myFileNameLineEdit->setMinimumWidth( 250 );
+ myFileNameLineEdit->setReadOnly( true );
+
+ QLabel* aRecordingModeLabel = new QLabel( tr( "RECORDING_MODE" ), mySettingsBox );
+ myRecordingModeComboBox = new QComboBox( mySettingsBox );
+ myRecordingModeComboBox->addItem( tr( "SKIPPED_FRAMES" ) );
+ myRecordingModeComboBox->addItem( tr( "ALL_DISLPAYED_FRAMES" ) );
+ myRecordingModeComboBox->setCurrentIndex( aResourceMgr->integerValue( "VISU", "recorder_mode", 1 ) );
+
+ QLabel* aFPSLabel = new QLabel( tr( "FPS" ), mySettingsBox );
+ myFPSSpinBox = new SalomeApp_DoubleSpinBox( mySettingsBox );
+ VISU::initSpinBox( myFPSSpinBox, 0.1, 100.0, 1.0, "parametric_precision" );
+ myFPSSpinBox->setValue( aResourceMgr->doubleValue( "VISU", "recorder_fps", 10.0 ) );
+
+ QLabel* aQualityLabel = new QLabel( tr( "QUALITY" ), mySettingsBox );
+ myQualitySpinBox = new SalomeApp_IntSpinBox( mySettingsBox );
+ VISU::initSpinBox( myQualitySpinBox, 1, 100, 1 );
+ myQualitySpinBox->setValue( aResourceMgr->integerValue( "VISU", "recorder_quality", 80 ) );
+
+ myProgressiveCheckBox = new QCheckBox( tr( "PROGRESSIVE" ), mySettingsBox );
+ myProgressiveCheckBox->setChecked( aResourceMgr->booleanValue( "VISU", "recorder_progressive", false ) );
+
+ aSettingsLayout->addWidget( aFileNameLabel, 0, 0 );
+ aSettingsLayout->addWidget( myFileNameLineEdit, 1, 0, 1, 2 );
+ //aSettingsLayout->addWidget( aFileNameButton, 1, 2 );
+ aSettingsLayout->addWidget( aRecordingModeLabel, 2, 0 );
+ aSettingsLayout->addWidget( myRecordingModeComboBox, 2, 1 );
+ aSettingsLayout->addWidget( aFPSLabel, 3, 0 );
+ aSettingsLayout->addWidget( myFPSSpinBox, 3, 1 );
+ aSettingsLayout->addWidget( aQualityLabel, 4, 0 );
+ aSettingsLayout->addWidget( myQualitySpinBox, 4, 1 );
+ aSettingsLayout->addWidget( myProgressiveCheckBox, 5, 0 );
+
+ aTopLayout->addWidget( mySettingsBox );
+
+ // Start / Close
+ QGroupBox* CommonGroup = new QGroupBox( this );
+ //CommonGroup->setColumnLayout(0, Qt::Vertical );
+ //CommonGroup->layout()->setSpacing( 0 );
+ //CommonGroup->layout()->setMargin( 0 );
+ QGridLayout* CommonGroupLayout = new QGridLayout( CommonGroup );
+ CommonGroupLayout->setAlignment( Qt::AlignTop );
+ CommonGroupLayout->setSpacing( 6 );
+ CommonGroupLayout->setMargin( 11 );
+
+ QPushButton* aStartButton = new QPushButton( tr( "START" ), CommonGroup );
+ aStartButton->setAutoDefault( true );
+ aStartButton->setDefault( true );
+ CommonGroupLayout->addWidget( aStartButton, 0, 0 );
+ CommonGroupLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
+
+ QPushButton* aCloseButton = new QPushButton( tr( "CLOSE" ), CommonGroup );
+ aCloseButton->setAutoDefault( true );
+ CommonGroupLayout->addWidget( aCloseButton, 0, 2 );
+
+ QPushButton* aHelpButton = new QPushButton( tr( "HELP" ), CommonGroup );
+ aHelpButton->setAutoDefault( true );
+ CommonGroupLayout->addWidget( aHelpButton, 0, 3 );
+
+ aTopLayout->addWidget( CommonGroup );
+
+ connect( aStartButton, SIGNAL( clicked() ), this, SLOT( onStart() ) );
+ connect( aCloseButton, SIGNAL( clicked() ), this, SLOT( onClose() ) );
+ connect( aHelpButton, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
+}
+
+VVTK_RecorderDlg::~VVTK_RecorderDlg()
+{
+}
+
+void VVTK_RecorderDlg::onStart()
+{
+ if( myFileName.isNull() )
+ return;
+
+ myRecorder->SetName( (const char*)myFileName.toLatin1() );
+
+ myRecorder->SetUseSkippedFrames( myRecordingModeComboBox->currentIndex() == 0 );
+ myRecorder->SetNbFPS( myFPSSpinBox->value() );
+ myRecorder->SetQuality( myQualitySpinBox->value() );
+ myRecorder->SetProgressiveMode( myProgressiveCheckBox->isChecked() );
+
+ accept();
+
+}
+
+void VVTK_RecorderDlg::onClose()
+{
+ reject();
+}
+
+void VVTK_RecorderDlg::onHelp()
+{
+ QString aHelpFileName = "animation_in_gauss_viewer.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) );
+ }
+}
+
+bool VVTK_RecorderDlg::onBrowseFile()
+{
+ QString aRootDir = QString( getenv( "VISU_ROOT_DIR") );
+
+ QStringList aFilter;
+ aFilter.append( tr( "FLT_AVI_FILES" ) );
+ aFilter.append( tr( "FLT_ALL_FILES" ) );
+
+ QString aFileName = SUIT_FileDlg::getFileName( this, getenv( "HOME" ), aFilter,
+ tr( "FILE_NAME" ), false );
+
+ if( aFileName.isNull() )
+ return false;
+
+ myFileName = aFileName;
+ myFileNameLineEdit->setText( aFileName.section( '/', -1 ) );
+
+ return true;
+}
+
+int VVTK_RecorderDlg::exec()
+{
+ if( !onBrowseFile() )
+ {
+ reject();
+ return 0;
+ }
+ return QDialog::exec();
+}
+
+void VVTK_RecorderDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 )
+ {
+ e->accept();
+ onHelp();
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// VISU VISUGUI : GUI of VISU component
+// File : VVTK_RecorderDlg.h
+// Author : Oleg UVAROV
+// Module : VISU
+// $Header$
+//
+#ifndef VVTK_RECORDERDLG_H
+#define VVTK_RECORDERDLG_H
+
+#include <QDateTime>
+#include <QDialog>
+
+class QCheckBox;
+class QComboBox;
+class QGroupBox;
+class QLCDNumber;
+class QLineEdit;
+class QPushButton;
+class QTimer;
+
+class SalomeApp_DoubleSpinBox;
+class SalomeApp_IntSpinBox;
+
+class VVTK_Recorder;
+
+//! Recorder Dialog.
+class VVTK_RecorderDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ VVTK_RecorderDlg( QWidget*, VVTK_Recorder* );
+ ~VVTK_RecorderDlg();
+
+ int exec();
+
+ QString fileName() const { return myFileName; }
+
+private:
+ virtual void keyPressEvent( QKeyEvent* );
+
+protected slots:
+ void onStart();
+ void onClose();
+ void onHelp();
+
+ bool onBrowseFile();
+
+private:
+ VVTK_Recorder* myRecorder;
+ QString myFileName;
+
+ QLineEdit* myFileNameLineEdit;
+
+ QComboBox* myRecordingModeComboBox;
+ SalomeApp_DoubleSpinBox* myFPSSpinBox;
+ SalomeApp_IntSpinBox* myQualitySpinBox;
+ QCheckBox* myProgressiveCheckBox;
+
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+// File :
+// Author :
+// Module :
+// $Header$
+//
+#include "VVTK_Renderer.h"
+
+#include "VISU_GaussPtsAct.h"
+#include "VISU_GaussPointsPL.hxx"
+#include "VISU_WidgetCtrl.hxx"
+#include "VISU_PlanesWidget.hxx"
+#include "VISU_SphereWidget.hxx"
+
+#include <VTKViewer_Algorithm.h>
+
+#include <vtkObjectFactory.h>
+#include <vtkProperty.h>
+#include <vtkPointPicker.h>
+
+#include <vtkRenderWindowInteractor.h>
+#include <vtkCallbackCommand.h>
+#include <vtkCommand.h>
+#include <vtkPlane.h>
+
+#include <vtkPropCollection.h>
+#include <vtkProp.h>
+#include <vtkActor.h>
+#include <vtkMapper.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkPolyData.h>
+#include <vtkTextMapper.h>
+#include <vtkTextActor.h>
+#include <vtkTextProperty.h>
+#include <vtkRenderer.h>
+
+#include <vtkPropCollection.h>
+#include <vtkProp.h>
+#include <vtkActor.h>
+#include <vtkMapper.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkPolyData.h>
+#include <vtkTextMapper.h>
+#include <vtkTextActor.h>
+#include <vtkTextProperty.h>
+#include <vtkRenderer.h>
+
+#include "utilities.h"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//======================================================================
+class VISU_FPSActor : public vtkTextActor
+{
+public:
+ vtkTypeMacro( VISU_FPSActor, vtkTextActor);
+ static
+ VISU_FPSActor*
+ New();
+
+ virtual
+ int
+ RenderOpaqueGeometry(vtkViewport *theViewport);
+};
+
+//======================================================================
+vtkStandardNewMacro(VISU_FPSActor);
+
+//======================================================================
+// function: RenderOpaqueGeometry
+// purpose :
+//======================================================================
+int
+VISU_FPSActor
+::RenderOpaqueGeometry(vtkViewport *theViewport)
+{
+ // It's impossible to render opaque geometry of text actor
+ // if the size of the viewport is less than 1.0
+ int *size = theViewport->GetSize();
+ if( size[0] <= 1.0 || size[1] <= 1.0 )
+ return 1;
+
+ if(vtkRenderer *aRenderer = dynamic_cast<vtkRenderer*>(theViewport)){
+ static float aTol = 1.e-6;
+ float aLastRenderTimeInSeconds = aRenderer->GetLastRenderTimeInSeconds();
+ if(aLastRenderTimeInSeconds > aTol){
+ size_t aNumberOfCells = 0;
+ VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+ if(vtkActorCollection *anActorCollection = aCopy.GetActors()){
+ anActorCollection->InitTraversal();
+ while(vtkActor *anActor = anActorCollection->GetNextActor()){
+ if(anActor->GetVisibility()){
+ if(SALOME_Actor *aSActor = dynamic_cast<SALOME_Actor*>(anActor)){
+ if(vtkMapper *aMapper = aSActor->GetMapper()){
+ if(vtkDataSet *aDataSet = aMapper->GetInput()){
+ aNumberOfCells += aDataSet->GetNumberOfCells();
+ }
+ }
+ }
+ }
+ }
+ }
+ std::ostringstream aStr;
+ float aFPS = 1.0 / aLastRenderTimeInSeconds;
+ aStr<<"FPS: "<<aFPS<<"\n NumberOfCells: "<<aNumberOfCells;
+ std::string anInput = aStr.str();
+ SetInput(anInput.c_str());
+ return Superclass::RenderOpaqueGeometry(theViewport);
+ }
+ }
+ return 1;
+}
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(VVTK_Renderer);
+
+//----------------------------------------------------------------------------
+VVTK_Renderer
+::VVTK_Renderer():
+ myFPSActor(VISU_FPSActor::New()),
+ myInsideCursorSettings(NULL),
+ myPickingSettings(NULL),
+ myGaussPointPicker(vtkPointPicker::New()),
+ myGaussPreHighlightProperty(vtkProperty::New()),
+ myGaussHighlightProperty(vtkProperty::New())
+{
+ if(MYDEBUG) INFOS("VVTK_Renderer() - "<<this);
+
+ myFPSActor->Delete();
+
+ vtkTextMapper* aTextMapper = vtkTextMapper::New();
+ vtkTextProperty *aTextProperty = aTextMapper->GetTextProperty();
+ aTextProperty->SetJustificationToRight();
+ aTextProperty->SetVerticalJustificationToTop();
+ aTextProperty->SetFontSize(10);
+
+ myFPSActor->SetPickable(false);
+ myFPSActor->ScaledTextOff();
+ myFPSActor->SetAlignmentPoint(8);
+ myFPSActor->SetPosition2 (1., 1.);
+ myFPSActor->SetMapper(aTextMapper);
+ aTextMapper->Delete();
+
+ //GetDevice()->AddActor2D(myFPSActor.GetPointer());
+
+ myGaussPointPicker->Delete();
+
+ myGaussPreHighlightProperty->Delete();
+ myGaussPreHighlightProperty->SetColor(0,1,1);
+
+ myGaussHighlightProperty->Delete();
+ myGaussHighlightProperty->SetColor(1,1,0);
+
+}
+
+VVTK_Renderer
+::~VVTK_Renderer()
+{
+ if(MYDEBUG) INFOS("~VVTK_Renderer() - "<<this);
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_Renderer
+::AddActor(VTKViewer_Actor* theActor)
+{
+ Superclass::AddActor(theActor);
+ if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor)){
+ anActor->SetPointPicker(myGaussPointPicker.GetPointer());
+ anActor->SetPreHighlightProperty(myGaussPreHighlightProperty.GetPointer());
+ anActor->SetHighlightProperty(myGaussHighlightProperty.GetPointer());
+
+ anActor->SetInsideCursorSettings(myInsideCursorSettings);
+ //anActor->SetPickingSettings(myPickingSettings);
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_Renderer
+::RemoveActor(VTKViewer_Actor* theActor)
+{
+ Superclass::RemoveActor(theActor);
+ if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor)){
+ anActor->SetPointPicker(NULL);
+ anActor->SetPreHighlightProperty(NULL);
+ anActor->SetHighlightProperty(NULL);
+
+ anActor->SetInsideCursorSettings(NULL);
+ //anActor->SetPickingSettings(NULL);
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_Renderer
+::SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings)
+{
+ myInsideCursorSettings = theInsideCursorSettings;
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_Renderer
+::SetPickingSettings(VISU_PickingSettings* thePickingSettings)
+{
+ myPickingSettings = thePickingSettings;
+}
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(VVTK_Renderer1);
+
+//----------------------------------------------------------------------------
+VVTK_Renderer1::VVTK_Renderer1():
+ myWidgetCtrl(VISU_WidgetCtrl::New()),
+ myOutsideCursorSettings(NULL)
+{
+ if(MYDEBUG) INFOS("VVTK_Renderer1() - "<<this);
+
+ myWidgetCtrl->SetPlaceFactor(1.1);
+ //
+ VISU_PlanesWidget *aPlanesWidget = myWidgetCtrl->GetPlanesWidget();
+ aPlanesWidget->SetOutlineTranslation(false);
+ vtkProperty* aSelectedPlaneProperty = aPlanesWidget->GetSelectedPlaneProperty();
+ vtkProperty* aPlaneProperty = aPlanesWidget->GetPlaneProperty();
+ aPlaneProperty->SetOpacity(aSelectedPlaneProperty->GetOpacity()*1.5);
+ //
+ //myWidgetCtrl->Delete();
+}
+
+VVTK_Renderer1
+::~VVTK_Renderer1()
+{
+ if(MYDEBUG) INFOS("~VVTK_Renderer1() - "<<this);
+ myWidgetCtrl->SetInteractor(NULL);
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_Renderer1
+::AddActor(VTKViewer_Actor* theActor)
+{
+ Superclass::AddActor(theActor);
+ if(VISU_GaussPtsAct1* anActor = dynamic_cast<VISU_GaussPtsAct1*>(theActor)){
+ anActor->SetWidgetCtrl(GetWidgetCtrl());
+ anActor->SetOutsideCursorSettings(myOutsideCursorSettings);
+ AdjustWidgetCtrl();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Renderer1
+::RemoveActor(VTKViewer_Actor* theActor)
+{
+ Superclass::RemoveActor(theActor);
+ if(VISU_GaussPtsAct1* anActor = dynamic_cast<VISU_GaussPtsAct1*>(theActor)){
+ anActor->SetWidgetCtrl(NULL);
+ anActor->SetOutsideCursorSettings(NULL);
+ AdjustWidgetCtrl();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_Renderer1
+::AdjustWidgetCtrl()
+{
+ VISU_PlanesWidget *aPlanesWidget = myWidgetCtrl->GetPlanesWidget();
+ aPlanesWidget->InitialPlaceWidget(myBndBox);
+ aPlanesWidget->SetOrigin(0.5*(myBndBox[1] + myBndBox[0]),
+ 0.5*(myBndBox[3] + myBndBox[2]),
+ 0.5*(myBndBox[5] + myBndBox[4]));
+ //
+ VISU_SphereWidget *aSphereWidget = myWidgetCtrl->GetSphereWidget();
+ aSphereWidget->SetCenter(0.5*(myBndBox[1] + myBndBox[0]),
+ 0.5*(myBndBox[3] + myBndBox[2]),
+ 0.5*(myBndBox[5] + myBndBox[4]));
+
+ float aMinLength = VTK_LARGE_FLOAT;
+ for (int i=0; i<3; ++i) {
+ float aLength = myBndBox[2*i+1]-myBndBox[2*i];
+ aMinLength = std::min(aMinLength,aLength);
+ }
+ aSphereWidget->SetRadius(aMinLength);
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_Renderer1
+::Initialize(vtkRenderWindowInteractor* theInteractor,
+ SVTK_Selector* theSelector)
+{
+ SVTK_Renderer::Initialize(theInteractor,theSelector);
+ myWidgetCtrl->SetInteractor(theInteractor);
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_Renderer1
+::SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings)
+{
+ myOutsideCursorSettings = theOutsideCursorSettings;
+}
+
+//----------------------------------------------------------------------------
+VISU_WidgetCtrl*
+VVTK_Renderer1
+::GetWidgetCtrl()
+{
+ return myWidgetCtrl;//.GetPointer();
+}
+
+//----------------------------------------------------------------------------
+bool
+VVTK_Renderer1
+::OnAdjustActors()
+{
+ return SVTK_Renderer::OnAdjustActors();
+}
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(VVTK_Renderer2);
+
+//----------------------------------------------------------------------------
+VVTK_Renderer2
+::VVTK_Renderer2():
+ myEventCallbackCommand(vtkCallbackCommand::New())
+{
+ if(MYDEBUG) INFOS("VVTK_Renderer2() - "<<this);
+ myEventCallbackCommand->Delete();
+
+ myPriority = 0.0;
+ myEventCallbackCommand->SetClientData(this);
+ myEventCallbackCommand->SetCallback(VVTK_Renderer2::ProcessEvents);
+}
+
+VVTK_Renderer2
+::~VVTK_Renderer2()
+{
+ if(MYDEBUG) INFOS("~VVTK_Renderer2() - "<<this);
+}
+
+//----------------------------------------------------------------------------
+void VVTK_Renderer2::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
+{
+ theWidgetCtrl->AddObserver(vtkCommand::EndInteractionEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+ theWidgetCtrl->AddObserver(vtkCommand::EnableEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+ theWidgetCtrl->AddObserver(vtkCommand::DisableEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+ myWidgetCtrl = theWidgetCtrl;
+}
+
+void
+VVTK_Renderer2
+::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* vtkNotUsed(theCallData))
+{
+ VVTK_Renderer2* self = reinterpret_cast<VVTK_Renderer2*>(theClientData);
+
+ switch(theEvent){
+ case vtkCommand::EnableEvent:
+ case vtkCommand::EndInteractionEvent:
+ self->OnEndInteractionEvent();
+ break;
+ }
+}
+
+void
+VVTK_Renderer2
+::OnEndInteractionEvent()
+{
+ AdjustActors();
+ myInteractor->Render();
+}
+
+
+//----------------------------------------------------------------------------
+void VVTK_Renderer2::AddActor(VTKViewer_Actor* theActor)
+{
+ if(VISU_GaussPtsAct1* anActor = dynamic_cast<VISU_GaussPtsAct1*>(theActor)){
+ if(VISU::TGaussPtsActorFactory* aFactory = anActor->GetGaussPtsFactory()){
+ if(VISU_GaussPtsAct2* anActor2 = aFactory->CloneActor(anActor)){
+ anActor2->SetWidgetCtrl(myWidgetCtrl);
+ Superclass::AddActor(anActor2);
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_Renderer2
+::RemoveActor(VTKViewer_Actor* theActor)
+{
+ using namespace VISU;
+ if(VISU_GaussPtsAct2* anActor = dynamic_cast<VISU_GaussPtsAct2*>(theActor)){
+ anActor->SetWidgetCtrl(NULL);
+ Superclass::RemoveActor(theActor);
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+//
+#ifndef VVTK_Renderer_h
+#define VVTK_Renderer_h
+
+#include "VVTK.h"
+
+#include "SVTK_Renderer.h"
+
+class VISU_WidgetCtrl;
+class VISU_InsideCursorSettings;
+class VISU_OutsideCursorSettings;
+class VISU_PickingSettings;
+class VISU_FPSActor;
+
+class vtkPointPicker;
+class vtkImplicitFunction;
+
+//----------------------------------------------------------------------------
+//! To customize SVTK_Renderer according to VVTK functionality
+class VVTK_EXPORT VVTK_Renderer : public SVTK_Renderer
+{
+ public:
+ vtkTypeMacro(VVTK_Renderer,SVTK_Renderer);
+ static VVTK_Renderer* New();
+
+ //! Reimplement SVTK_Renderer::AddActor
+ /*!
+ Perform an additional action - apply picking settings on the published VISU_GaussPtsAct actors
+ */
+ virtual
+ void
+ AddActor(VTKViewer_Actor* theActor);
+
+ //! Reimplement SVTK_Renderer::RemoveActor (remove additional settings)
+ virtual
+ void
+ RemoveActor(VTKViewer_Actor* theActor);
+
+ //! To set VISU_PickingSettings to share them among all VISU_GaussPtsAct actors published into the view
+ void
+ SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings);
+
+ void
+ SetPickingSettings(VISU_PickingSettings* thePickingSettings);
+
+ protected:
+ VVTK_Renderer();
+ ~VVTK_Renderer();
+
+ VISU_PickingSettings* myPickingSettings; //! Keeps reference of the VISU_PickingSettings
+ VISU_InsideCursorSettings* myInsideCursorSettings; //! Keeps reference of the VISU_InsideCursorSettings
+ vtkSmartPointer<VISU_FPSActor> myFPSActor; //!< To show FPS of the rendering at run-time
+
+ vtkSmartPointer<vtkPointPicker> myGaussPointPicker;
+ vtkSmartPointer<vtkProperty> myGaussPreHighlightProperty;
+ vtkSmartPointer<vtkProperty> myGaussHighlightProperty;
+};
+
+
+//----------------------------------------------------------------------------
+//! To extend VVTK_Renderer to implement base view functionality
+class VVTK_EXPORT VVTK_Renderer1 : public VVTK_Renderer
+{
+ public:
+ vtkTypeMacro(VVTK_Renderer1,VVTK_Renderer);
+ static VVTK_Renderer1* New();
+
+ //! Reimplement SVTK_Renderer::Initialize
+ virtual
+ void
+ Initialize(vtkRenderWindowInteractor* theInteractor,
+ SVTK_Selector* theSelector);
+
+ //! Reimplement VVTK_Renderer::AddActor to apply to the actor additional settings
+ virtual
+ void
+ AddActor(VTKViewer_Actor* theActor);
+
+ //! Reimplement VVTK_Renderer::RemoveActor
+ virtual
+ void
+ RemoveActor(VTKViewer_Actor* theActor);
+
+ //! To set VISU_PickingSettings to share them among all VISU_GaussPtsAct1 actors published into the view
+ void
+ SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings);
+
+ VISU_WidgetCtrl* GetWidgetCtrl();
+
+ protected:
+ VVTK_Renderer1();
+ ~VVTK_Renderer1();
+
+ //! Reimplement VVTK_Renderer::OnAdjustActors
+ virtual
+ bool
+ OnAdjustActors();
+
+ void AdjustWidgetCtrl();
+
+ VISU_WidgetCtrl* myWidgetCtrl;
+ //vtkSmartPointer<VISU_WidgetCtrl> myWidgetCtrl;
+ VISU_OutsideCursorSettings* myOutsideCursorSettings;
+ vtkSmartPointer<VISU_FPSActor> myTextActor;
+};
+
+
+//----------------------------------------------------------------------------
+class VVTK_EXPORT VVTK_Renderer2 : public VVTK_Renderer
+{
+ public:
+ vtkTypeMacro(VVTK_Renderer2,VVTK_Renderer);
+ static VVTK_Renderer2* New();
+
+ //! Reimplement VVTK_Renderer::AddActor to apply to the actor additional settings
+ virtual
+ void
+ AddActor(VTKViewer_Actor* theActor);
+
+ //! Reimplement VVTK_Renderer::RemoveActor
+ virtual
+ void
+ RemoveActor(VTKViewer_Actor* theActor);
+
+ void SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl);
+
+ //! To handle vtkCommand::EndInteractionEvent to redraw the view
+ void
+ OnEndInteractionEvent();
+
+ protected:
+ VVTK_Renderer2();
+ ~VVTK_Renderer2();
+
+ //! Main process VTK event method
+ static
+ void
+ ProcessEvents(vtkObject* theObject,
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData);
+
+ //! Used to process VTK events
+ vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
+
+ //! Priority at which events are processed
+ float myPriority;
+
+ VISU_WidgetCtrl* myWidgetCtrl;
+};
+
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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 : VVTK_SegmentationCursorDlg.cxx
+// Author : Oleg Uvarov
+// Module : VISU
+//
+#include "VVTK_SegmentationCursorDlg.h"
+#include "VVTK_PrimitiveBox.h"
+#include "VVTK_SizeBox.h"
+#include <VisuGUI_GUITools.h>
+
+#include "VISU_GaussPtsAct.h"
+#include "VISU_GaussPtsSettings.h"
+
+#include "VISU_WidgetCtrl.hxx"
+#include "VISU_PlanesWidget.hxx"
+#include "VISU_SphereWidget.hxx"
+
+#include "VISU_GaussPointsPL.hxx"
+#include "VISU_OpenGLPointSpriteMapper.hxx"
+
+#include <LightApp_Application.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
+#include <SVTK_RenderWindowInteractor.h>
+#include <VTKViewer_Algorithm.h>
+
+#include <vtkActorCollection.h>
+#include <vtkCallbackCommand.h>
+#include <vtkObjectFactory.h>
+#include <vtkRenderer.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkSmartPointer.h>
+#include <vtkImageData.h>
+
+#include "utilities.h"
+
+#include <QButtonGroup>
+#include <QColorDialog>
+#include <QFileDialog>
+#include <QGroupBox>
+#include <QKeyEvent>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QTabWidget>
+
+#include <QtxAction.h>
+#include <SalomeApp_DoubleSpinBox.h>
+#include <SalomeApp_IntSpinBox.h>
+#include <CAM_Module.h>
+
+//----------------------------------------------------------------
+VVTK_SegmentationCursorDlg::VVTK_SegmentationCursorDlg( QWidget* parent, const char* name )
+ :QDialog( parent,
+ Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
+ myEventCallbackCommand( vtkCallbackCommand::New() ),
+ myInsideCursorSettings( VISU_InsideCursorSettings::New() ),
+ myOutsideCursorSettings( VISU_OutsideCursorSettings::New() ),
+ myIsPlaneSegmentation( true ),
+ myWidgetCtrl(NULL),
+ myInteractor(NULL)
+{
+ setAccessibleName( name );
+
+ myPriority = 0.0;
+ myEventCallbackCommand->Delete();
+ myEventCallbackCommand->SetClientData(this);
+ myEventCallbackCommand->SetCallback(VVTK_SegmentationCursorDlg::ProcessEvents);
+
+ myInsideCursorSettings->AddObserver(VISU::UpdateFromSettingsEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+
+ setWindowTitle( tr( "SEGMENTATION_CURSOR_DLG_TITLE" ) );
+ setSizeGripEnabled(TRUE);
+
+ QVBoxLayout* TopLayout = new QVBoxLayout( this );
+ TopLayout->setSpacing(6);
+ TopLayout->setMargin(11);
+
+ myTabBox = new QTabWidget( this );
+
+ // Segmentation cursor pane
+ mySegmentationCursorBox = new QWidget( this );
+ QVBoxLayout* SCBoxLayout = new QVBoxLayout( mySegmentationCursorBox );
+ SCBoxLayout->setMargin(11);
+ SCBoxLayout->setSpacing(6);
+ SCBoxLayout->setAlignment(Qt::AlignTop);
+
+ // Origin
+ myOriginGroup = new QGroupBox( tr( "ORIGIN_TITLE" ), mySegmentationCursorBox );
+ //myOriginGroup->setColumnLayout( 0, Qt::Vertical );
+ //myOriginGroup->layout()->setSpacing( 0 );
+ //myOriginGroup->layout()->setMargin( 0 );
+
+ QGridLayout* OriginGroupLayout = new QGridLayout( myOriginGroup );
+ OriginGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ OriginGroupLayout->setSpacing(6);
+ OriginGroupLayout->setMargin(11);
+
+ QLabel* XOriginLabel = new QLabel( tr( "ORIGIN_X" ), myOriginGroup );
+ myXOriginSpinBox = new SalomeApp_DoubleSpinBox( myOriginGroup );
+ VISU::initSpinBox( myXOriginSpinBox, -1000.0, 1000.0, 0.1, "length_precision" );
+ myXOriginSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myXOriginSpinBox->setMinimumWidth( 100 );
+ myXOriginSpinBox->setValue( 0.0 );
+
+ QLabel* YOriginLabel = new QLabel( tr( "ORIGIN_Y" ), myOriginGroup );
+ myYOriginSpinBox = new SalomeApp_DoubleSpinBox( myOriginGroup );
+ VISU::initSpinBox( myYOriginSpinBox, -1000.0, 1000.0, 0.1, "length_precision" );
+ myYOriginSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myYOriginSpinBox->setMinimumWidth( 100 );
+ myYOriginSpinBox->setValue( 0.0 );
+
+ QLabel* ZOriginLabel = new QLabel( tr( "ORIGIN_Z" ), myOriginGroup );
+ myZOriginSpinBox = new SalomeApp_DoubleSpinBox( myOriginGroup );
+ VISU::initSpinBox( myZOriginSpinBox, -1000.0, 1000.0, 0.1, "length_precision" );
+ //myZOriginSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myZOriginSpinBox->setMinimumWidth( 100 );
+ myZOriginSpinBox->setValue( 1.0 );
+
+ OriginGroupLayout->addWidget( XOriginLabel, 0, 0 );
+ OriginGroupLayout->addWidget( myXOriginSpinBox, 0, 1 );
+ OriginGroupLayout->addWidget( YOriginLabel, 0, 2 );
+ OriginGroupLayout->addWidget( myYOriginSpinBox, 0, 3 );
+ OriginGroupLayout->addWidget( ZOriginLabel, 0, 4 );
+ OriginGroupLayout->addWidget( myZOriginSpinBox, 0, 5 );
+
+ SCBoxLayout->addWidget( myOriginGroup );
+
+ // Direction ( Plane Segmentation )
+ myDirectionGroup = new QGroupBox( tr( "DIRECTION_TITLE" ), mySegmentationCursorBox );
+ //myDirectionGroup->setColumnLayout( 0, Qt::Vertical );
+ //myDirectionGroup->layout()->setSpacing( 0 );
+ //myDirectionGroup->layout()->setMargin( 0 );
+
+ QGridLayout* DirectionGroupLayout = new QGridLayout( myDirectionGroup );
+ DirectionGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ DirectionGroupLayout->setSpacing(6);
+ DirectionGroupLayout->setMargin(11);
+
+ QLabel* DXDirectionLabel = new QLabel( tr( "DIRECTION_DX" ), myDirectionGroup );
+ myDXDirectionSpinBox = new SalomeApp_DoubleSpinBox( myDirectionGroup );
+ VISU::initSpinBox( myDXDirectionSpinBox, -1.0, 1.0, 0.1, "length_precision" );
+ myDXDirectionSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myDXDirectionSpinBox->setMinimumWidth( 100 );
+ myDXDirectionSpinBox->setValue( 0.0 );
+
+ QLabel* DYDirectionLabel = new QLabel( tr( "DIRECTION_DY" ), myDirectionGroup );
+ myDYDirectionSpinBox = new SalomeApp_DoubleSpinBox( myDirectionGroup );
+ VISU::initSpinBox( myDYDirectionSpinBox, -1.0, 1.0, 0.1, "length_precision" );
+ myDYDirectionSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myDYDirectionSpinBox->setMinimumWidth( 100 );
+ myDYDirectionSpinBox->setValue( 0.0 );
+
+ QLabel* DZDirectionLabel = new QLabel( tr( "DIRECTION_DZ" ), myDirectionGroup );
+ myDZDirectionSpinBox = new SalomeApp_DoubleSpinBox( myDirectionGroup );
+ VISU::initSpinBox( myDZDirectionSpinBox, -1.0, 1.0, 0.1, "length_precision" );
+ myDZDirectionSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myDZDirectionSpinBox->setMinimumWidth( 100 );
+ myDZDirectionSpinBox->setValue( 1.0 );
+
+ DirectionGroupLayout->addWidget( DXDirectionLabel, 0, 0 );
+ DirectionGroupLayout->addWidget( myDXDirectionSpinBox, 0, 1 );
+ DirectionGroupLayout->addWidget( DYDirectionLabel, 0, 2 );
+ DirectionGroupLayout->addWidget( myDYDirectionSpinBox, 0, 3 );
+ DirectionGroupLayout->addWidget( DZDirectionLabel, 0, 4 );
+ DirectionGroupLayout->addWidget( myDZDirectionSpinBox, 0, 5 );
+
+ SCBoxLayout->addWidget( myDirectionGroup );
+
+ // Depth ( Plane Segmentation )
+ myDepthGroup = new QGroupBox( tr( "DEPTH_TITLE" ), mySegmentationCursorBox );
+ //myDepthGroup->setColumnLayout( 0, Qt::Vertical );
+ //myDepthGroup->layout()->setSpacing( 0 );
+ //myDepthGroup->layout()->setMargin( 0 );
+
+ QGridLayout* DepthGroupLayout = new QGridLayout( myDepthGroup );
+ DepthGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ DepthGroupLayout->setSpacing(6);
+ DepthGroupLayout->setMargin(11);
+
+ QLabel* DepthLabel = new QLabel( tr( "DEPTH" ), myDepthGroup );
+ myDepthSpinBox = new SalomeApp_DoubleSpinBox( myDepthGroup );
+ VISU::initSpinBox( myDepthSpinBox, 0.0, VTK_LARGE_FLOAT, 0.1, "length_precision" );
+ myDepthSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myDepthSpinBox->setMinimumWidth( 100 );
+ myDepthSpinBox->setValue( 1.0 );
+
+ DepthGroupLayout->addWidget( DepthLabel, 0, 0 );
+ DepthGroupLayout->addWidget( myDepthSpinBox, 0, 1 );
+
+ SCBoxLayout->addWidget( myDepthGroup );
+
+ // Radius ( Sphere Segmentation )
+ myRadiusGroup = new QGroupBox( tr( "RADIUS_TITLE" ), mySegmentationCursorBox );
+ //myRadiusGroup->setColumnLayout( 0, Qt::Vertical );
+ //myRadiusGroup->layout()->setSpacing( 0 );
+ //myRadiusGroup->layout()->setMargin( 0 );
+
+ QGridLayout* RadiusGroupLayout = new QGridLayout( myRadiusGroup );
+ RadiusGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ RadiusGroupLayout->setSpacing(6);
+ RadiusGroupLayout->setMargin(11);
+
+ QLabel* RadiusLabel = new QLabel( tr( "RADIUS" ),myRadiusGroup );
+ myRadiusSpinBox = new SalomeApp_DoubleSpinBox( myRadiusGroup );
+ VISU::initSpinBox( myRadiusSpinBox, 0.0, 1000.0, 1.0, "length_precision" );
+ myRadiusSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myRadiusSpinBox->setMinimumWidth( 100 );
+ myRadiusSpinBox->setValue( 100.0 );
+
+ QLabel* RatioLabel = new QLabel( tr( "RATIO" ), myRadiusGroup );
+ myRatioSpinBox = new SalomeApp_DoubleSpinBox( myRadiusGroup );
+ VISU::initSpinBox( myRatioSpinBox, 0.1, 10.0, 0.1, "parametric_precision" );
+ myRatioSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ myRatioSpinBox->setMinimumWidth( 100 );
+ myRatioSpinBox->setValue( 2.0 );
+
+ RadiusGroupLayout->addWidget( RadiusLabel, 0, 0 );
+ RadiusGroupLayout->addWidget( myRadiusSpinBox, 0, 1 );
+ RadiusGroupLayout->addWidget( RatioLabel, 0, 2 );
+ RadiusGroupLayout->addWidget( myRatioSpinBox, 0, 3 );
+
+ SCBoxLayout->addWidget( myRadiusGroup );
+
+ myTabBox->addTab( mySegmentationCursorBox, tr( "SEGMENTATION_CURSOR_TAB" ) );
+
+ // Gauss points pane
+ myGaussPointsBox = new QWidget( this );
+ QVBoxLayout* GPBoxLayout = new QVBoxLayout( myGaussPointsBox );
+ GPBoxLayout->setMargin(11);
+ GPBoxLayout->setSpacing(6);
+
+ // Inside Gauss points
+ QGroupBox* anInsideGroup = new QGroupBox( tr( "INSIDE_GAUSS_POINTS" ), myGaussPointsBox );
+ //anInsideGroup->setColumnLayout( 0, Qt::Vertical );
+ //anInsideGroup->layout()->setSpacing( 0 );
+ //anInsideGroup->layout()->setMargin( 0 );
+
+ QGridLayout* anInsideGroupLayout = new QGridLayout( anInsideGroup );
+ anInsideGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ anInsideGroupLayout->setSpacing(6);
+ anInsideGroupLayout->setMargin(11);
+
+ // Primitive
+ myInsidePrimitiveBox = new VVTK_PrimitiveBox( anInsideGroup );
+
+ // Size
+ myInsideSizeBox = new VVTK_SizeBox( anInsideGroup );
+ myInsideSizeBox->setType( VVTK_SizeBox::Inside );
+
+ anInsideGroupLayout->addWidget( myInsidePrimitiveBox, 0, 0 );
+ anInsideGroupLayout->addWidget( myInsideSizeBox, 1, 0 );
+
+ GPBoxLayout->addWidget( anInsideGroup );
+
+ // Outside Gauss points
+ QGroupBox* anOutsideGroup = new QGroupBox( tr( "OUTSIDE_GAUSS_POINTS" ), myGaussPointsBox );
+ //anOutsideGroup->setColumnLayout( 0, Qt::Vertical );
+ //anOutsideGroup->layout()->setSpacing( 0 );
+ //anOutsideGroup->layout()->setMargin( 0 );
+
+ QGridLayout* anOutsideGroupLayout = new QGridLayout( anOutsideGroup );
+ anOutsideGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ anOutsideGroupLayout->setSpacing(6);
+ anOutsideGroupLayout->setMargin(11);
+
+ // Primitive
+ myOutsidePrimitiveBox = new VVTK_PrimitiveBox( anOutsideGroup );
+
+ // Size
+ myOutsideSizeBox = new VVTK_SizeBox( anOutsideGroup );
+ myOutsideSizeBox->setType( VVTK_SizeBox::Outside );
+
+ anOutsideGroupLayout->addWidget( myOutsidePrimitiveBox, 0, 0 );
+ anOutsideGroupLayout->addWidget( myOutsideSizeBox, 1, 0 );
+
+ GPBoxLayout->addWidget( anOutsideGroup );
+
+ // Magnification
+ QGroupBox* MagnificationGroup = new QGroupBox ( tr( "MAGNIFICATION_TITLE" ), myGaussPointsBox );
+ //MagnificationGroup->setColumnLayout(0, Qt::Vertical );
+ //MagnificationGroup->layout()->setSpacing( 0 );
+ //MagnificationGroup->layout()->setMargin( 0 );
+
+ QGridLayout* MagnificationGroupLayout = new QGridLayout ( MagnificationGroup );
+ MagnificationGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ MagnificationGroupLayout->setSpacing(6);
+ MagnificationGroupLayout->setMargin(11);
+
+ myMagnificationLabel = new QLabel( tr( "MAGNIFICATION" ), MagnificationGroup );
+ myMagnificationSpinBox = new SalomeApp_IntSpinBox( MagnificationGroup );
+ VISU::initSpinBox( myMagnificationSpinBox, 1, 10000, 10 );
+ myMagnificationSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ MagnificationGroupLayout->addWidget( myMagnificationLabel, 0, 0 );
+ MagnificationGroupLayout->addWidget( myMagnificationSpinBox, 0, 1 );
+
+ // Increment
+ myIncrementLabel = new QLabel( tr( "INCREMENT" ), MagnificationGroup );
+ myIncrementSpinBox = new SalomeApp_DoubleSpinBox( MagnificationGroup );
+ VISU::initSpinBox( myIncrementSpinBox, 0.01, 10, 0.1, "parametric_precision" );
+ myIncrementSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ MagnificationGroupLayout->addWidget( myIncrementLabel, 0, 2 );
+ MagnificationGroupLayout->addWidget( myIncrementSpinBox, 0, 3 );
+
+
+ myTabBox->addTab( myGaussPointsBox, tr( "GAUSS_POINTS_TAB" ) );
+ //myTabBox->showPage( myGaussPointsBox );
+ myTabBox->setCurrentWidget( myGaussPointsBox );
+
+ GPBoxLayout->addWidget( MagnificationGroup );
+
+
+ // Common buttons ===========================================================
+ QGroupBox* GroupButtons = new QGroupBox( this );
+ //GroupButtons->setColumnLayout(0, Qt::Vertical );
+ //GroupButtons->layout()->setSpacing( 0 );
+ //GroupButtons->layout()->setMargin( 0 );
+ QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons );
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );
+ GroupButtonsLayout->setSpacing( 6 );
+ GroupButtonsLayout->setMargin( 11 );
+
+ QPushButton* buttonApply = new QPushButton( tr( "&Apply" ), GroupButtons );
+ 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->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonClose, 0, 2 );
+
+ QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons );
+ buttonHelp->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( buttonHelp, 0, 3 );
+
+ TopLayout->addWidget( myTabBox );
+ TopLayout->addWidget( GroupButtons );
+
+ connect( buttonApply, SIGNAL( clicked() ), this, SLOT( onClickApply() ) );
+ connect( buttonClose, SIGNAL( clicked() ), this, SLOT( onClickClose() ) );
+ connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onClickHelp() ) );
+
+ connect(parent, SIGNAL(Show( QShowEvent * )), this, SLOT(onParentShow()));
+ connect(parent, SIGNAL(Hide( QHideEvent * )), this, SLOT(onParentHide()));
+}
+
+VVTK_SegmentationCursorDlg::~VVTK_SegmentationCursorDlg()
+{
+ SetWidgetCtrl(NULL);
+}
+
+float VVTK_SegmentationCursorDlg::getMagnification() const
+{
+ return myMagnificationSpinBox->value() / 100.0;
+}
+
+void VVTK_SegmentationCursorDlg::setMagnification( float theMagnification )
+{
+ myMagnificationSpinBox->setValue( ( int )( theMagnification * 100 ) );
+}
+
+float VVTK_SegmentationCursorDlg::getIncrement() const
+{
+ return myIncrementSpinBox->value();
+}
+
+void VVTK_SegmentationCursorDlg::setIncrement( float theIncrement )
+{
+ myIncrementSpinBox->setValue( theIncrement );
+}
+
+
+void VVTK_SegmentationCursorDlg::SetWidgetCtrl( VISU_WidgetCtrl* theWidgetCtrl )
+{
+ if(myWidgetCtrl == theWidgetCtrl)
+ return;
+
+ if(myWidgetCtrl)
+ myWidgetCtrl->RemoveObserver(myEventCallbackCommand.GetPointer());
+
+ myWidgetCtrl = theWidgetCtrl;
+
+ if(theWidgetCtrl)
+ theWidgetCtrl->AddObserver(vtkCommand::EndInteractionEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+}
+
+void VVTK_SegmentationCursorDlg::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* vtkNotUsed(theCallData))
+{
+ VVTK_SegmentationCursorDlg* self = reinterpret_cast<VVTK_SegmentationCursorDlg*>(theClientData);
+
+ switch(theEvent){
+ case vtkCommand::EndInteractionEvent:
+ self->UpdateSegmentation();
+ break;
+ case VISU::UpdateFromSettingsEvent:
+ self->GetOutsideCursorSettings()->SetMagnification( self->GetInsideCursorSettings()->GetMagnification() );
+ self->GetOutsideCursorSettings()->SetIncrement( self->GetInsideCursorSettings()->GetIncrement() );
+
+ self->UpdateInsideGaussPoints();
+ self->UpdateOutsideGaussPoints();
+
+ self->GetInsideCursorSettings()->InvokeEvent(VISU::UpdateInsideSettingsEvent,NULL);
+ self->GetOutsideCursorSettings()->InvokeEvent(VISU::UpdateOutsideSettingsEvent,NULL);
+ break;
+ }
+}
+
+void VVTK_SegmentationCursorDlg::UpdateSegmentation()
+{
+ if( myIsPlaneSegmentation )
+ {
+ myDirectionGroup->show();
+ myDepthGroup->show();
+ myRadiusGroup->hide();
+
+ VISU_PlanesWidget *pPlanesWidget=myWidgetCtrl->GetPlanesWidget();
+ vtkFloatingPointType origin[3];
+ pPlanesWidget->GetOrigin( origin );
+ myXOriginSpinBox->setValue( origin[0] );
+ myYOriginSpinBox->setValue( origin[1] );
+ myZOriginSpinBox->setValue( origin[2] );
+
+ vtkFloatingPointType normal[3];
+ pPlanesWidget->GetNormal( normal );
+ myDXDirectionSpinBox->setValue( normal[0] );
+ myDYDirectionSpinBox->setValue( normal[1] );
+ myDZDirectionSpinBox->setValue( normal[2] );
+
+ myDepthSpinBox->setValue( pPlanesWidget->Distance() );
+ }
+ else
+ {
+ myDirectionGroup->hide();
+ myDepthGroup->hide();
+ myRadiusGroup->show();
+
+ VISU_SphereWidget *pSphereWidget=myWidgetCtrl->GetSphereWidget();
+ vtkFloatingPointType origin[3], aRadius;
+ pSphereWidget->GetCenter(origin);
+ myXOriginSpinBox->setValue( origin[0] );
+ myYOriginSpinBox->setValue( origin[1] );
+ myZOriginSpinBox->setValue( origin[2] );
+ aRadius=pSphereWidget->GetRadius();
+ myRadiusSpinBox->setValue(aRadius);
+ myRatioSpinBox->setValue(pSphereWidget->GetRatio());
+ }
+}
+
+void VVTK_SegmentationCursorDlg::UpdateInsideGaussPoints()
+{
+ int aPrimitiveType = VISU_OpenGLPointSpriteMapper::PointSprite;
+ vtkFloatingPointType aClamp = 200.0;
+ QString aMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/sprite_texture.bmp";
+ QString anAlphaTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/sprite_alpha.bmp";
+ vtkFloatingPointType anAlphaThreshold = 0.1;
+ int aResolution = 8;
+ int aMinSize = 3;
+ int aMaxSize = 33;
+ int aMagnification = 100;
+ vtkFloatingPointType anIncrement = 2.0;
+
+ if( !myInsideCursorSettings->GetInitial() )
+ {
+ myInsidePrimitiveBox->setPrimitiveType( myInsideCursorSettings->GetPrimitiveType() );
+ myInsidePrimitiveBox->setClamp( myInsideCursorSettings->GetClamp() );
+ myInsidePrimitiveBox->setMainTexture( myInsideMainTexture );
+ myInsidePrimitiveBox->setAlphaTexture( myInsideAlphaTexture );
+ myInsidePrimitiveBox->setAlphaThreshold( myInsideCursorSettings->GetAlphaThreshold() );
+ myInsidePrimitiveBox->setResolution( myInsideCursorSettings->GetResolution() );
+
+ myInsideSizeBox->setMinSize( myInsideCursorSettings->GetMinSize() );
+ myInsideSizeBox->setMaxSize( myInsideCursorSettings->GetMaxSize() );
+
+ this->setMagnification( myInsideCursorSettings->GetMagnification() );
+ this->setIncrement( myInsideCursorSettings->GetIncrement() );
+
+ return;
+ }
+
+ SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+
+ aPrimitiveType = aResourceMgr->integerValue( "VISU", "inside_point_sprite_primitive_type", aPrimitiveType );
+ myInsidePrimitiveBox->setPrimitiveType( aPrimitiveType );
+
+ aClamp = aResourceMgr->doubleValue( "VISU", "inside_point_sprite_clamp", aClamp );
+ myInsidePrimitiveBox->setClamp( aClamp );
+
+ aMainTexture = aResourceMgr->stringValue( "VISU", "inside_point_sprite_main_texture", aMainTexture );
+ myInsidePrimitiveBox->setMainTexture( aMainTexture );
+
+ anAlphaTexture = aResourceMgr->stringValue( "VISU", "inside_point_sprite_alpha_texture", anAlphaTexture );
+ myInsidePrimitiveBox->setAlphaTexture( anAlphaTexture );
+
+ anAlphaThreshold = aResourceMgr->doubleValue( "VISU", "inside_point_sprite_alpha_threshold", anAlphaThreshold );
+ myInsidePrimitiveBox->setAlphaThreshold( anAlphaThreshold );
+
+ aResolution = aResourceMgr->integerValue( "VISU", "inside_geom_sphere_resolution", aResolution );
+ myInsidePrimitiveBox->setResolution( aResolution );
+
+ aMinSize = aResourceMgr->integerValue( "VISU", "inside_point_sprite_min_size", aMinSize );
+ myInsideSizeBox->setMinSize( aMinSize / 100.0 );
+
+ aMaxSize = aResourceMgr->integerValue( "VISU", "inside_point_sprite_max_size", aMaxSize );
+ myInsideSizeBox->setMaxSize( aMaxSize / 100.0 );
+
+ aMagnification = aResourceMgr->integerValue( "VISU", "inside_point_sprite_magnification", aMagnification );
+ this->setMagnification( aMagnification / 100.0 );
+
+ anIncrement = aResourceMgr->doubleValue( "VISU", "inside_point_sprite_increment", anIncrement );
+ this->setIncrement( anIncrement );
+
+ myInsidePrimitiveBox->setFaceLimit( 50000 );
+
+ ApplyInsideGaussPoints();
+}
+
+void VVTK_SegmentationCursorDlg::UpdateOutsideGaussPoints()
+{
+ vtkFloatingPointType aClamp = 256.0;
+ int aPrimitiveType = VISU_OpenGLPointSpriteMapper::PointSprite;
+ QString aMainTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/sprite_texture.bmp";
+ QString anAlphaTexture = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/sprite_alpha.bmp";
+ vtkFloatingPointType anAlphaThreshold = 0.1;
+ int aResolution = 8;
+ int aSize = 25;
+ bool aUniform = false;
+ QColor aColor = Qt::blue;
+
+ if( !myOutsideCursorSettings->GetInitial() )
+ {
+ myOutsidePrimitiveBox->setPrimitiveType( myOutsideCursorSettings->GetPrimitiveType() );
+ myOutsidePrimitiveBox->setClamp( myOutsideCursorSettings->GetClamp() );
+ myOutsidePrimitiveBox->setMainTexture( myOutsideMainTexture );
+ myOutsidePrimitiveBox->setAlphaTexture( myOutsideAlphaTexture );
+ myOutsidePrimitiveBox->setAlphaThreshold( myOutsideCursorSettings->GetAlphaThreshold() );
+ myOutsidePrimitiveBox->setResolution( myOutsideCursorSettings->GetResolution() );
+
+ myOutsideSizeBox->setOutsideSize( myOutsideCursorSettings->GetSize() );
+ myOutsideSizeBox->setUniform( myOutsideCursorSettings->GetUniform() );
+
+ vtkFloatingPointType* aColor = myOutsideCursorSettings->GetColor();
+ myOutsideSizeBox->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();
+
+ aPrimitiveType = aResourceMgr->integerValue( "VISU", "outside_point_sprite_primitive_type", aPrimitiveType );
+ myOutsidePrimitiveBox->setPrimitiveType( aPrimitiveType );
+
+ aClamp = aResourceMgr->doubleValue( "VISU", "outside_point_sprite_clamp", aClamp );
+ myOutsidePrimitiveBox->setClamp( aClamp );
+
+ aMainTexture = aResourceMgr->stringValue( "VISU", "outside_point_sprite_main_texture", aMainTexture );
+ myOutsidePrimitiveBox->setMainTexture( aMainTexture );
+
+ anAlphaTexture = aResourceMgr->stringValue( "VISU", "outside_point_sprite_alpha_texture", anAlphaTexture );
+ myOutsidePrimitiveBox->setAlphaTexture( anAlphaTexture );
+
+ anAlphaThreshold = aResourceMgr->doubleValue( "VISU", "outside_point_sprite_alpha_threshold", anAlphaThreshold );
+ myOutsidePrimitiveBox->setAlphaThreshold( anAlphaThreshold );
+
+ aResolution = aResourceMgr->integerValue( "VISU", "outside_geom_sphere_resolution", aResolution );
+ myOutsidePrimitiveBox->setResolution( aResolution );
+
+ aSize = aResourceMgr->integerValue( "VISU", "outside_point_sprite_size", aSize );
+ myOutsideSizeBox->setOutsideSize( aSize / 100.0 );
+
+ aUniform = aResourceMgr->booleanValue( "VISU", "outside_point_sprite_uniform", aUniform );
+ myOutsideSizeBox->setUniform( aUniform );
+
+ aColor = aResourceMgr->colorValue( "VISU", "outside_point_sprite_color", aColor );
+ myOutsideSizeBox->setColor( aColor );
+
+ myOutsidePrimitiveBox->setFaceLimit( 50000 );
+
+ ApplyOutsideGaussPoints();
+}
+
+VISU_InsideCursorSettings* VVTK_SegmentationCursorDlg::GetInsideCursorSettings()
+{
+ return myInsideCursorSettings.GetPointer();
+}
+
+VISU_OutsideCursorSettings* VVTK_SegmentationCursorDlg::GetOutsideCursorSettings()
+{
+ return myOutsideCursorSettings.GetPointer();
+}
+
+VISU::TTextureValue
+VVTK_SegmentationCursorDlg
+::MakeImageData( bool theInside,
+ const QString& theMainTexture,
+ const QString& theAlphaTexture )
+{
+ if( theInside )
+ {
+ bool updateMainTexture = myInsideMainTexture != theMainTexture;
+ bool updateAlphaTexture = myInsideAlphaTexture != theAlphaTexture;
+ if( !updateMainTexture && !updateAlphaTexture )
+ return 0;
+
+ myInsideMainTexture = theMainTexture;
+ myInsideAlphaTexture = theAlphaTexture;
+ }
+ else
+ {
+ bool updateMainTexture = myOutsideMainTexture != theMainTexture;
+ bool updateAlphaTexture = myOutsideAlphaTexture != theAlphaTexture;
+ if( !updateMainTexture && !updateAlphaTexture )
+ return 0;
+
+ myOutsideMainTexture = theMainTexture;
+ myOutsideAlphaTexture = theAlphaTexture;
+ }
+
+ return VISU::GetTexture( (const char*)theMainTexture.toLatin1(),
+ (const char*)theAlphaTexture.toLatin1());
+}
+
+void VVTK_SegmentationCursorDlg::onClickApply()
+{
+ if( myTabBox->currentWidget() == mySegmentationCursorBox )
+ ApplySegmentationCursor();
+ else
+ {
+ QString aWarning = "The number of faces needed to perform the 'Geometrical Sphere' primitive\n";
+ aWarning.append( "presentation might be too important to ensure an acceptable frame rate.\n\n" );
+ aWarning.append( "Can you please confirm that you want to continue anyway?" );
+ bool toApply = CheckNumberOfFaces() ||
+ SUIT_MessageBox::warning( this, tr( "Warning" ), aWarning,
+ tr( "&OK" ), tr( "&Cancel" ), 0, 1, 1 ) == 0;
+
+ if( toApply )
+ {
+ ApplyInsideGaussPoints();
+ ApplyOutsideGaussPoints();
+ }
+ }
+}
+
+void VVTK_SegmentationCursorDlg::ApplySegmentationCursor()
+{
+ if( myIsPlaneSegmentation )
+ {
+ VISU_PlanesWidget *pPlanesWidget=myWidgetCtrl->GetPlanesWidget();
+ vtkFloatingPointType origin[3];
+ origin[0] = myXOriginSpinBox->value();
+ origin[1] = myYOriginSpinBox->value();
+ origin[2] = myZOriginSpinBox->value();
+ pPlanesWidget->SetOrigin( origin );
+
+ vtkFloatingPointType normal[3];
+ normal[0] = myDXDirectionSpinBox->value();
+ normal[1] = myDYDirectionSpinBox->value();
+ normal[2] = myDZDirectionSpinBox->value();
+
+ if( normal[0] == 0.0 && normal[1] == 0.0 && normal[2] == 0.0 )
+ {
+ normal[2] = 1.0;
+ myDZDirectionSpinBox->setValue( 1.0 );
+ }
+ pPlanesWidget->SetNormal( normal );
+
+ pPlanesWidget->SetDistance( myDepthSpinBox->value() );
+
+ myWidgetCtrl->InvokeEvent(vtkCommand::EndInteractionEvent,NULL);
+ myWidgetCtrl->GetInteractor()->Render();
+ }
+ else
+ {
+ VISU_SphereWidget *pSphereWidget=myWidgetCtrl->GetSphereWidget();
+ vtkFloatingPointType origin[3], aRadius;
+ origin[0] = myXOriginSpinBox->value();
+ origin[1] = myYOriginSpinBox->value();
+ origin[2] = myZOriginSpinBox->value();
+ pSphereWidget->SetCenter(origin);
+
+ aRadius=myRadiusSpinBox->value();
+ pSphereWidget->SetRadius(aRadius);
+
+ pSphereWidget->SetRatio(myRatioSpinBox->value());
+
+ myWidgetCtrl->InvokeEvent(vtkCommand::EndInteractionEvent,NULL);
+ myWidgetCtrl->GetInteractor()->Render();
+ }
+}
+
+void VVTK_SegmentationCursorDlg::ApplyInsideGaussPoints()
+{
+ QString anInsideMainTexture = myInsidePrimitiveBox->getMainTexture();
+ QString anInsideAlphaTexture = myInsidePrimitiveBox->getAlphaTexture();
+ VISU::TTextureValue aTexture = MakeImageData( true, anInsideMainTexture, anInsideAlphaTexture );
+
+ if( aTexture.GetPointer() )
+ myInsideCursorSettings->SetTexture( aTexture.GetPointer() );
+
+ myInsideCursorSettings->SetInitial( false );
+ myInsideCursorSettings->SetPrimitiveType( myInsidePrimitiveBox->getPrimitiveType() );
+ myInsideCursorSettings->SetClamp( myInsidePrimitiveBox->getClamp() );
+ myInsideCursorSettings->SetAlphaThreshold( myInsidePrimitiveBox->getAlphaThreshold() );
+ myInsideCursorSettings->SetResolution( myInsidePrimitiveBox->getResolution() );
+
+ myInsideCursorSettings->SetMinSize( myInsideSizeBox->getMinSize() );
+ myInsideCursorSettings->SetMaxSize( myInsideSizeBox->getMaxSize() );
+
+ myInsideCursorSettings->SetMagnification( this->getMagnification() );
+ myInsideCursorSettings->SetIncrement( this->getIncrement() );
+
+ myInsideCursorSettings->InvokeEvent(VISU::UpdateInsideSettingsEvent,NULL);
+}
+
+void VVTK_SegmentationCursorDlg::ApplyOutsideGaussPoints()
+{
+ QString anOutsideMainTexture = myOutsidePrimitiveBox->getMainTexture();
+ QString anOutsideAlphaTexture = myOutsidePrimitiveBox->getAlphaTexture();
+ VISU::TTextureValue aTexture = MakeImageData( false, anOutsideMainTexture, anOutsideAlphaTexture );
+
+ if( aTexture.GetPointer() )
+ myOutsideCursorSettings->SetTexture( aTexture.GetPointer() );
+
+ myOutsideCursorSettings->SetInitial( false );
+ myOutsideCursorSettings->SetPrimitiveType( myOutsidePrimitiveBox->getPrimitiveType() );
+ myOutsideCursorSettings->SetClamp( myOutsidePrimitiveBox->getClamp() );
+ myOutsideCursorSettings->SetAlphaThreshold( myOutsidePrimitiveBox->getAlphaThreshold() );
+ myOutsideCursorSettings->SetResolution( myOutsidePrimitiveBox->getResolution() );
+
+ myOutsideCursorSettings->SetSize( myOutsideSizeBox->getOutsideSize() );
+ myOutsideCursorSettings->SetUniform( myOutsideSizeBox->getUniform() );
+
+ QColor aButtonColor = myOutsideSizeBox->getColor();
+ vtkFloatingPointType aColor[3];
+ aColor[0] = aButtonColor.red() / 255.0;
+ aColor[1] = aButtonColor.green() / 255.0;
+ aColor[2] = aButtonColor.blue() / 255.0;
+ myOutsideCursorSettings->SetColor( aColor );
+
+ myOutsideCursorSettings->SetMagnification( this->getMagnification() );
+ myOutsideCursorSettings->SetIncrement( this->getIncrement() );
+
+ myOutsideCursorSettings->InvokeEvent(VISU::UpdateOutsideSettingsEvent,NULL);
+}
+
+void VVTK_SegmentationCursorDlg::onClickClose()
+{
+ myPlaneAction->setChecked( false );
+ mySphereAction->setChecked( false );
+
+ emit scgClose();
+
+ reject();
+}
+
+void VVTK_SegmentationCursorDlg::onClickHelp()
+{
+ QString aHelpFileName = "segmentation.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 VVTK_SegmentationCursorDlg::done( int r )
+{
+ myPlaneAction->setChecked( false );
+ mySphereAction->setChecked( false );
+
+ emit scgClose();
+
+ QDialog::done( r );
+}
+
+void VVTK_SegmentationCursorDlg::onParentShow()
+{
+ if(myPlaneAction->isChecked() || mySphereAction->isChecked())
+ show();
+ else
+ hide();
+}
+
+void VVTK_SegmentationCursorDlg::onParentHide()
+{
+ hide();
+}
+
+bool VVTK_SegmentationCursorDlg::CheckNumberOfFaces()
+{
+ if( !myInteractor )
+ return false;
+
+ vtkRenderer* aRenderer = myInteractor->getRenderer();
+
+ if( !aRenderer )
+ return false;
+
+ int aNumberOfPoints = 0;
+
+ vtkActor* anActor;
+ VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+ vtkActorCollection* anActColl = aCopy.GetActors();
+ for( anActColl->InitTraversal(); ( anActor = anActColl->GetNextActor() ) != NULL; )
+ {
+ if( VISU_GaussPtsAct1* aGaussActor = VISU_GaussPtsAct1::SafeDownCast( anActor ) )
+ aNumberOfPoints += aGaussActor->GetInput()->GetNumberOfCells();
+ }
+ return !( myInsidePrimitiveBox->getPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere &&
+ aNumberOfPoints * myInsidePrimitiveBox->getFaceNumber() * 2 > myInsidePrimitiveBox->getFaceLimit() ||
+ myOutsidePrimitiveBox->getPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere &&
+ aNumberOfPoints * myOutsidePrimitiveBox->getFaceNumber() > myOutsidePrimitiveBox->getFaceLimit() );
+}
+
+void VVTK_SegmentationCursorDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 )
+ {
+ e->accept();
+ onClickHelp();
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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 : VVTK_SegmentationCursorDlg.h
+// Author : Oleg Uvarov
+// Module : VISU
+//
+#ifndef VVTK_SEGMENTATIONCURSORDLG_H
+#define VVTK_SEGMENTATIONCURSORDLG_H
+
+#include "VVTK.h"
+
+#include "VISU_GaussPtsDeviceActor.h"
+
+#include <QDialog>
+
+#include <vtkObject.h>
+#include <vtkSmartPointer.h>
+
+class vtkActorCollection;
+class vtkCallbackCommand;
+class vtkImageData;
+
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QRadioButton;
+class QTabWidget;
+class QGroupBox;
+class QWidget;
+//class QVBox;
+
+class QtxAction;
+class SalomeApp_DoubleSpinBox;
+class SalomeApp_IntSpinBox;
+
+class VISU_GaussPtsAct1;
+class VISU_InsideCursorSettings;
+class VISU_OutsideCursorSettings;
+class VISU_WidgetCtrl;
+
+class VVTK_PrimitiveBox;
+class VVTK_SizeBox;
+
+class SVTK_RenderWindowInteractor;
+
+
+//! Segmentation Cursor Dialog.
+/*!
+ * Uses for set up Segmentation and Outside Cursor Gauss Points preferenses
+ * and apply them to all actors in the current renderer.
+ */
+class VVTK_SegmentationCursorDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ VVTK_SegmentationCursorDlg( QWidget* parent = 0, const char* name = 0 );
+ ~VVTK_SegmentationCursorDlg();
+
+ void SetWidgetCtrl( VISU_WidgetCtrl* );
+ void SetPlaneAction( QtxAction* theAction ) { myPlaneAction = theAction; }
+ void SetSphereAction( QtxAction* theAction ) { mySphereAction = theAction; }
+
+ bool GetIsPlaneSegmentation() const { return myIsPlaneSegmentation; }
+ void SetIsPlaneSegmentation( bool on ) { myIsPlaneSegmentation = on; }
+
+ //! Update contents of the Segmentation tab.
+ void UpdateSegmentation();
+ void UpdateInsideGaussPoints();
+ void UpdateOutsideGaussPoints();
+
+ //! Update contents of the Outside Cursor tab.
+ void UpdateOutsideCursor();
+
+ VISU_InsideCursorSettings* GetInsideCursorSettings();
+ VISU_OutsideCursorSettings* GetOutsideCursorSettings();
+
+ vtkSmartPointer<vtkCallbackCommand> GetEventCallbackCommand() { return myEventCallbackCommand; }
+
+ void SetInteractor( SVTK_RenderWindowInteractor* theInteractor ) { myInteractor = theInteractor; }
+
+public:
+ float getMagnification() const;
+ void setMagnification( float );
+
+ float getIncrement() const;
+ void setIncrement( float );
+
+protected:
+ void ApplySegmentationCursor();
+ void ApplyInsideGaussPoints();
+ void ApplyOutsideGaussPoints();
+
+ bool CheckNumberOfFaces();
+
+ VISU::TTextureValue
+ MakeImageData( bool theInside,
+ const QString& theMainTexture,
+ const QString& theAlphaTexture );
+
+private:
+ static void ProcessEvents(vtkObject* theObject,
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData);
+
+ void keyPressEvent( QKeyEvent* e );
+
+protected slots:
+ virtual void done( int );
+ void onParentShow();
+ void onParentHide();
+
+ void onClickApply();
+ void onClickClose();
+ void onClickHelp();
+
+signals:
+ void scgClose();
+
+private:
+ SVTK_RenderWindowInteractor* myInteractor;
+
+ QTabWidget* myTabBox;
+
+ // Segmentation cursor
+ QWidget* mySegmentationCursorBox;
+
+ QGroupBox* myOriginGroup;
+ SalomeApp_DoubleSpinBox* myXOriginSpinBox;
+ SalomeApp_DoubleSpinBox* myYOriginSpinBox;
+ SalomeApp_DoubleSpinBox* myZOriginSpinBox;
+
+ QGroupBox* myDirectionGroup;
+ SalomeApp_DoubleSpinBox* myDXDirectionSpinBox;
+ SalomeApp_DoubleSpinBox* myDYDirectionSpinBox;
+ SalomeApp_DoubleSpinBox* myDZDirectionSpinBox;
+
+ QGroupBox* myDepthGroup;
+ SalomeApp_DoubleSpinBox* myDepthSpinBox;
+
+ QGroupBox* myRadiusGroup;
+ SalomeApp_DoubleSpinBox* myRadiusSpinBox;
+ SalomeApp_DoubleSpinBox* myRatioSpinBox;
+
+ bool myIsPlaneSegmentation;
+
+ float myPriority;
+ vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
+
+ VISU_WidgetCtrl* myWidgetCtrl;
+ QtxAction* myPlaneAction;
+ QtxAction* mySphereAction;
+
+ // Gauss Points
+ QWidget* myGaussPointsBox;
+
+ VVTK_PrimitiveBox* myInsidePrimitiveBox;
+ VVTK_SizeBox* myInsideSizeBox;
+
+ QString myInsideMainTexture;
+ QString myInsideAlphaTexture;
+
+ vtkSmartPointer<VISU_InsideCursorSettings> myInsideCursorSettings;
+
+ VVTK_PrimitiveBox* myOutsidePrimitiveBox;
+ VVTK_SizeBox* myOutsideSizeBox;
+
+ QString myOutsideMainTexture;
+ QString myOutsideAlphaTexture;
+
+ vtkSmartPointer<VISU_OutsideCursorSettings> myOutsideCursorSettings;
+
+ QLabel* myMagnificationLabel;
+ SalomeApp_IntSpinBox* myMagnificationSpinBox;
+ QLabel* myIncrementLabel;
+ SalomeApp_DoubleSpinBox* myIncrementSpinBox;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// VISU VISUGUI : GUI of VISU component
+// File : VVTK_SizeBox.cxx
+// Author : Oleg UVAROV
+// Module : VISU
+//
+#include "VVTK_SizeBox.h"
+
+#include <VisuGUI_GUITools.h>
+
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+
+#include <SalomeApp_DoubleSpinBox.h>
+#include <SalomeApp_IntSpinBox.h>
+#include <QtxColorButton.h>
+
+#include <QLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QButtonGroup>
+#include <QRadioButton>
+#include <QPushButton>
+#include <QColorDialog>
+
+using namespace std;
+
+VVTK_SizeBox::VVTK_SizeBox( QWidget* parent ) :
+ QWidget( parent )
+{
+ QVBoxLayout* aMainLayout = new QVBoxLayout( this );
+ aMainLayout->setSpacing( 0 );
+ aMainLayout->setMargin( 0 );
+
+ // Size
+ QGroupBox* SizeGroup = new QGroupBox ( tr( "SIZE_TITLE" ), this );
+ //SizeGroup->setColumnLayout(0, Qt::Vertical );
+ //SizeGroup->layout()->setSpacing( 0 );
+ //SizeGroup->layout()->setMargin( 0 );
+
+ QGridLayout* SizeGroupLayout = new QGridLayout (SizeGroup);
+ SizeGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
+ SizeGroupLayout->setSpacing(6);
+ SizeGroupLayout->setMargin(11);
+
+ // Outside Size
+ myOutsideSizeLabel = new QLabel( tr( "OUTSIDE_SIZE" ), SizeGroup );
+ myOutsideSizeSpinBox = new SalomeApp_IntSpinBox( SizeGroup );
+ VISU::initSpinBox( myOutsideSizeSpinBox, 0, 100, 1 );
+ myOutsideSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ SizeGroupLayout->addWidget( myOutsideSizeLabel, 0, 0 );
+ SizeGroupLayout->addWidget( myOutsideSizeSpinBox, 0, 1 );
+
+ // Geometry Size
+ myGeomSizeLabel = new QLabel( tr( "GEOM_SIZE" ), SizeGroup );
+ myGeomSizeSpinBox = new SalomeApp_IntSpinBox( SizeGroup );
+ VISU::initSpinBox( myGeomSizeSpinBox, 0, 100, 1 );
+ myGeomSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ SizeGroupLayout->addWidget( myGeomSizeLabel, 0, 0 );
+ SizeGroupLayout->addWidget( myGeomSizeSpinBox, 0, 1 );
+
+ // Min Size
+ myMinSizeLabel = new QLabel( tr( "MIN_SIZE" ), SizeGroup );
+ myMinSizeSpinBox = new SalomeApp_IntSpinBox( SizeGroup );
+ VISU::initSpinBox( myMinSizeSpinBox, 0, 100, 1 );
+ myMinSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ SizeGroupLayout->addWidget( myMinSizeLabel, 1, 0 );
+ SizeGroupLayout->addWidget( myMinSizeSpinBox, 1, 1 );
+
+ // Max Size
+ myMaxSizeLabel = new QLabel( tr( "MAX_SIZE" ), SizeGroup );
+ myMaxSizeSpinBox = new SalomeApp_IntSpinBox( SizeGroup );
+ VISU::initSpinBox( myMaxSizeSpinBox, 0, 100, 1 );
+ myMaxSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ SizeGroupLayout->addWidget( myMaxSizeLabel, 1, 2 );
+ SizeGroupLayout->addWidget( myMaxSizeSpinBox, 1, 3 );
+
+ // Magnification
+ myMagnificationLabel = new QLabel( tr( "MAGNIFICATION" ), SizeGroup );
+ myMagnificationSpinBox = new SalomeApp_IntSpinBox( SizeGroup );
+ VISU::initSpinBox( myMagnificationSpinBox, 1, 10000, 10 );
+ myMagnificationSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ SizeGroupLayout->addWidget( myMagnificationLabel, 2, 0 );
+ SizeGroupLayout->addWidget( myMagnificationSpinBox, 2, 1 );
+
+ // Increment
+ myIncrementLabel = new QLabel( tr( "INCREMENT" ), SizeGroup );
+ myIncrementSpinBox = new SalomeApp_DoubleSpinBox( SizeGroup );
+ VISU::initSpinBox( myIncrementSpinBox, 0.01, 10, 0.1, "parametric_precision" );
+ myIncrementSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+ SizeGroupLayout->addWidget( myIncrementLabel, 2, 2 );
+ SizeGroupLayout->addWidget( myIncrementSpinBox, 2, 3 );
+
+ aMainLayout->addWidget( SizeGroup );
+
+ // Color
+ myColorGroup = new QGroupBox ( tr( "COLOR_TITLE" ), this );
+ //myColorGroup->setColumnLayout(0, Qt::Vertical );
+ //myColorGroup->layout()->setSpacing( 0 );
+ //myColorGroup->layout()->setMargin( 0 );
+
+ QGridLayout* ColorGroupLayout = new QGridLayout ( myColorGroup );
+ ColorGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
+ ColorGroupLayout->setSpacing(6);
+ ColorGroupLayout->setMargin(11);
+
+ myUniformCheckBox = new QCheckBox( tr( "UNIFORM_COLOR" ), myColorGroup );
+
+ myColorLabel = new QLabel( tr( "COLOR" ), myColorGroup );
+ myColorButton = new QtxColorButton( myColorGroup );
+
+ ColorGroupLayout->addWidget( myUniformCheckBox, 0, 0 );
+ ColorGroupLayout->addWidget( myColorLabel, 0, 1 );
+ ColorGroupLayout->addWidget( myColorButton, 0, 2 );
+
+ aMainLayout->addWidget( myColorGroup );
+
+ connect( myUniformCheckBox, SIGNAL( toggled( bool ) ), myColorButton, SLOT( setEnabled( bool ) ) );
+ //connect( myColorButton, SIGNAL( clicked() ), this, SLOT( onColorButtonPressed() ) );
+
+ setType( VVTK_SizeBox::Results );
+}
+
+void VVTK_SizeBox::onToggleResults()
+{
+ myType = VVTK_SizeBox::Results;
+
+ myOutsideSizeLabel->hide();
+ myOutsideSizeSpinBox->hide();
+
+ myGeomSizeLabel->hide();
+ myGeomSizeSpinBox->hide();
+
+ myMinSizeLabel->show();
+ myMinSizeSpinBox->show();
+
+ myMaxSizeLabel->show();
+ myMaxSizeSpinBox->show();
+
+ myMagnificationLabel->show();
+ myMagnificationSpinBox->show();
+
+ myIncrementLabel->show();
+ myIncrementSpinBox->show();
+
+ myColorGroup->hide();
+
+ myUniformCheckBox->hide();
+}
+
+void VVTK_SizeBox::onToggleGeometry()
+{
+ myType = VVTK_SizeBox::Geometry;
+
+ myOutsideSizeLabel->hide();
+ myOutsideSizeSpinBox->hide();
+
+ myGeomSizeLabel->show();
+ myGeomSizeSpinBox->show();
+
+ myMinSizeLabel->hide();
+ myMinSizeSpinBox->hide();
+
+ myMaxSizeLabel->hide();
+ myMaxSizeSpinBox->hide();
+
+ myMagnificationLabel->show();
+ myMagnificationSpinBox->show();
+
+ myIncrementLabel->show();
+ myIncrementSpinBox->show();
+
+ myColorGroup->show();
+
+ myUniformCheckBox->hide();
+}
+
+void VVTK_SizeBox::onToggleInside()
+{
+ myType = VVTK_SizeBox::Inside;
+
+ myOutsideSizeLabel->hide();
+ myOutsideSizeSpinBox->hide();
+
+ myGeomSizeLabel->hide();
+ myGeomSizeSpinBox->hide();
+
+ myMinSizeLabel->show();
+ myMinSizeSpinBox->show();
+
+ myMaxSizeLabel->show();
+ myMaxSizeSpinBox->show();
+
+ myMagnificationLabel->hide();
+ myMagnificationSpinBox->hide();
+
+ myIncrementLabel->hide();
+ myIncrementSpinBox->hide();
+
+ myColorGroup->hide();
+
+ myUniformCheckBox->hide();
+}
+
+void VVTK_SizeBox::onToggleOutside()
+{
+ myType = VVTK_SizeBox::Outside;
+
+ myOutsideSizeLabel->show();
+ myOutsideSizeSpinBox->show();
+
+ myGeomSizeLabel->hide();
+ myGeomSizeSpinBox->hide();
+
+ myMinSizeLabel->hide();
+ myMinSizeSpinBox->hide();
+
+ myMaxSizeLabel->hide();
+ myMaxSizeSpinBox->hide();
+
+ myMagnificationLabel->hide();
+ myMagnificationSpinBox->hide();
+
+ myIncrementLabel->hide();
+ myIncrementSpinBox->hide();
+
+ myColorGroup->show();
+
+ myUniformCheckBox->show();
+}
+
+void VVTK_SizeBox::setType( int theType )
+{
+ myType = theType;
+
+ switch( myType )
+ {
+ case VVTK_SizeBox::Results : onToggleResults(); break;
+ case VVTK_SizeBox::Geometry : onToggleGeometry(); break;
+ case VVTK_SizeBox::Inside : onToggleInside(); break;
+ case VVTK_SizeBox::Outside : onToggleOutside(); break;
+ default : break;
+ }
+}
+
+float VVTK_SizeBox::getOutsideSize() const
+{
+ return myOutsideSizeSpinBox->value() / 100.0;
+}
+
+void VVTK_SizeBox::setOutsideSize( float theOutsideSize )
+{
+ myOutsideSizeSpinBox->setValue( ( int )( theOutsideSize * 100 ) );
+}
+
+float VVTK_SizeBox::getGeomSize() const
+{
+ return myGeomSizeSpinBox->value() / 100.0;
+}
+
+void VVTK_SizeBox::setGeomSize( float theGeomSize )
+{
+ myGeomSizeSpinBox->setValue( ( int )( theGeomSize * 100 ) );
+}
+
+float VVTK_SizeBox::getMinSize() const
+{
+ return myMinSizeSpinBox->value() / 100.0;
+}
+
+void VVTK_SizeBox::setMinSize( float theMinSize )
+{
+ myMinSizeSpinBox->setValue( ( int )( theMinSize * 100 ) );
+}
+
+float VVTK_SizeBox::getMaxSize() const
+{
+ return myMaxSizeSpinBox->value() / 100.0;
+}
+
+void VVTK_SizeBox::setMaxSize( float theMaxSize )
+{
+ myMaxSizeSpinBox->setValue( ( int )( theMaxSize * 100 ) );
+}
+
+float VVTK_SizeBox::getMagnification() const
+{
+ return myMagnificationSpinBox->value() / 100.0;
+}
+
+void VVTK_SizeBox::setMagnification( float theMagnification )
+{
+ myMagnificationSpinBox->setValue( ( int )( theMagnification * 100 ) );
+}
+
+float VVTK_SizeBox::getIncrement() const
+{
+ return myIncrementSpinBox->value();
+}
+
+void VVTK_SizeBox::setIncrement( float theIncrement )
+{
+ myIncrementSpinBox->setValue( theIncrement );
+}
+
+bool VVTK_SizeBox::getUniform() const
+{
+ return myUniformCheckBox->isChecked();
+}
+
+void VVTK_SizeBox::setUniform( bool theUniform )
+{
+ myUniformCheckBox->setChecked( theUniform );
+ myColorButton->setEnabled( theUniform );
+}
+
+QColor VVTK_SizeBox::getColor() const
+{
+ return myColorButton->color();//palette().color( myColorButton->backgroundRole() );
+ //return myColorButton->paletteBackgroundColor();
+}
+
+void VVTK_SizeBox::setColor( const QColor& theColor )
+{
+ if ( theColor.isValid() )
+ {
+ //QPalette aPalette( myColorButton->palette() );
+ //aPalette.setColor( myColorButton->backgroundRole(), theColor );
+ myColorButton->setColor( theColor );
+ }
+ //myColorButton->setPaletteBackgroundColor( theColor );
+}
+
+void VVTK_SizeBox::enableSizeControls( bool enabled )
+{
+ myMagnificationSpinBox->setEnabled( enabled );
+ myMaxSizeSpinBox->setEnabled( enabled );
+ myMinSizeSpinBox->setEnabled( enabled );
+ myIncrementSpinBox->setEnabled( enabled );
+ myGeomSizeSpinBox->setEnabled( enabled );
+}
+
+/*void VVTK_SizeBox::onColorButtonPressed()
+{
+ QPalette aPalette( myColorButton->palette() );
+ QColor aColor = QColorDialog::
+ getColor( aPalette.color(myColorButton->backgroundRole() ), this );
+
+ if( aColor.isValid() )
+ {
+ aPalette.setColor( myColorButton->backgroundRole(), aColor );
+ myColorButton->setPalette( aPalette );
+ }
+}*/
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// VISU VISUGUI : GUI of VISU component
+// File : VVTK_SizeBox.h
+// Author : Oleg UVAROV
+// Module : VISU
+//
+#ifndef VVTK_SIZEBOX_H
+#define VVTK_SIZEBOX_H
+
+#include "VVTK.h"
+
+#include <QWidget>
+
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QCheckBox;
+class QGroupBox;
+
+class SalomeApp_DoubleSpinBox;
+class SalomeApp_IntSpinBox;
+class QtxColorButton;
+
+class VVTK_EXPORT VVTK_SizeBox : public QWidget
+{
+ Q_OBJECT
+
+public:
+ enum { Results = 0, Geometry, Inside, Outside };
+
+public:
+ VVTK_SizeBox( QWidget* );
+ ~VVTK_SizeBox() {}
+
+public:
+ int getType() const { return myType; }
+ void setType( int );
+
+ float getOutsideSize() const;
+ void setOutsideSize( float );
+
+ float getGeomSize() const;
+ void setGeomSize( float );
+
+ float getMinSize() const;
+ void setMinSize( float );
+
+ float getMaxSize() const;
+ void setMaxSize( float );
+
+ float getMagnification() const;
+ void setMagnification( float );
+
+ float getIncrement() const;
+ void setIncrement( float );
+
+ bool getUniform() const;
+ void setUniform( bool );
+
+ QColor getColor() const;
+ void setColor( const QColor& );
+
+ void enableSizeControls( bool enabled );
+
+protected slots:
+ void onToggleResults();
+ void onToggleGeometry();
+ void onToggleInside();
+ void onToggleOutside();
+
+ //void onColorButtonPressed();
+
+private:
+ int myType;
+
+ QLabel* myOutsideSizeLabel;
+ SalomeApp_IntSpinBox* myOutsideSizeSpinBox;
+
+ QLabel* myGeomSizeLabel;
+ SalomeApp_IntSpinBox* myGeomSizeSpinBox;
+
+ QLabel* myMinSizeLabel;
+ SalomeApp_IntSpinBox* myMinSizeSpinBox;
+
+ QLabel* myMaxSizeLabel;
+ SalomeApp_IntSpinBox* myMaxSizeSpinBox;
+
+ QLabel* myMagnificationLabel;
+ SalomeApp_IntSpinBox* myMagnificationSpinBox;
+
+ QLabel* myIncrementLabel;
+ SalomeApp_DoubleSpinBox* myIncrementSpinBox;
+
+ QCheckBox* myUniformCheckBox;
+
+ QGroupBox* myColorGroup;
+ QLabel* myColorLabel;
+ QtxColorButton* myColorButton;
+};
+
+
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+#include "VVTK_ViewManager.h"
+#include "VVTK_ViewModel.h"
+
+#include <SUIT_ViewWindow.h>
+
+int VVTK_ViewManager::_VVTKViewMgr_Id = 0;
+
+//***************************************************************
+VVTK_ViewManager
+::VVTK_ViewManager( SUIT_Study* study,
+ SUIT_Desktop* theDesktop )
+: SVTK_ViewManager( study, theDesktop )
+{
+ myId = ++_VVTKViewMgr_Id;
+ setViewModel( new VVTK_Viewer() );
+}
+
+//***************************************************************
+VVTK_ViewManager::~VVTK_ViewManager()
+{
+}
+
+//***************************************************************
+void VVTK_ViewManager::setViewName(SUIT_ViewWindow* theView)
+{
+ int aPos = myViews.indexOf(theView);
+ theView->setWindowTitle( tr( "VTK_VIEW_TITLE" ).arg( myId ).arg( aPos + 1 ) );
+}
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+#ifndef VVTK_VIEWMANAGER_H
+#define VVTK_VIEWMANAGER_H
+
+#include "SVTK_ViewManager.h"
+#include "VVTK.h"
+
+class SUIT_Desktop;
+
+//! Extend SUIT_ViewManager to deal with VVTK_Viewer
+class VVTK_EXPORT VVTK_ViewManager : public SVTK_ViewManager
+{
+ Q_OBJECT;
+public:
+ //! Construct the view manager
+ VVTK_ViewManager( SUIT_Study* study, SUIT_Desktop* );
+
+ //! Destroy the view manager
+ virtual ~VVTK_ViewManager();
+
+protected:
+ void setViewName( SUIT_ViewWindow* theView );
+
+private:
+ int myId;
+ static int _VVTKViewMgr_Id;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+#include "VVTK_ViewModel.h"
+#include "VISU_ActorFactory.h"
+#include "VVTK_ViewWindow.h"
+
+#include "VTKViewer_Algorithm.h"
+#include "SVTK_Functor.h"
+#include "VISU_ActorBase.h"
+#include "SVTK_View.h"
+#include "SVTK_Prs.h"
+
+#include <SUIT_ViewManager.h>
+
+#include <vtkActorCollection.h>
+#include <vtkRenderer.h>
+
+//---------------------------------------------------------------
+VVTK_Viewer::VVTK_Viewer()
+{
+}
+
+//---------------------------------------------------------------
+VVTK_Viewer::~VVTK_Viewer()
+{
+}
+
+//---------------------------------------------------------------
+SUIT_ViewWindow* VVTK_Viewer::createView( SUIT_Desktop* theDesktop )
+{
+ TViewWindow* aViewWindow = new TViewWindow (theDesktop);
+ aViewWindow->Initialize(this);
+
+ aViewWindow->setBackgroundColor( backgroundColor() );
+ aViewWindow->SetTrihedronSize( trihedronSize() );
+ aViewWindow->SetProjectionMode( projectionMode() );
+ aViewWindow->SetInteractionStyle( interactionStyle() );
+ aViewWindow->SetIncrementalSpeed( incrementalSpeed(), incrementalSpeedMode() );
+ aViewWindow->SetSpacemouseButtons( spacemouseBtn(1), spacemouseBtn(2), spacemouseBtn(3) );
+
+ return aViewWindow;
+}
+
+//---------------------------------------------------------------
+void VVTK_Viewer::Display(const SALOME_VTKPrs* thePrs)
+{
+ // try do downcast object
+ if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>(thePrs)){
+ if(aPrs->IsNull())
+ return;
+ if(vtkActorCollection* aCollection = aPrs->GetObjects()){
+ aCollection->InitTraversal();
+ while(VISU_ActorBase* anActor = dynamic_cast<VISU_ActorBase*>(aCollection->GetNextActor())){
+ if(!anActor->GetFactory()->GetActiveState())
+ continue;
+ QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
+ if(SVTK_View* aView = aViewWindow->getView()){
+ aView->Display(anActor, false);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------------
+namespace VVTK
+{
+ struct TIsOneActorVisibleAction
+ {
+ bool& myResult;
+ TIsOneActorVisibleAction(bool& theResult):
+ myResult(theResult)
+ {
+ myResult = false;
+ }
+ void
+ operator()(SALOME_Actor* theActor)
+ {
+ if(!myResult)
+ myResult = theActor->GetVisibility();
+ }
+ };
+}
+
+//---------------------------------------------------------------
+bool VVTK_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
+{
+ QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
+ for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
+ if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
+ bool aResult;
+ VVTK::TIsOneActorVisibleAction anAction(aResult);
+ VTK::ActorCollectionCopy aCopy(aViewWindow->getRenderer()->GetActors());
+ SVTK::ForEachIf<SALOME_Actor>(aCopy.GetActors(),
+ SVTK::TIsSameIObject<SALOME_Actor>(theIO),
+ anAction);
+ return anAction.myResult;
+ }
+
+ return false;
+}
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+#ifndef VVTK_VIEWMODEL_H
+#define VVTK_VIEWMODEL_H
+
+#include <QColor>
+
+#include "VVTK.h"
+#include "SVTK_ViewModel.h"
+
+class VVTK_ViewWindow;
+
+//! VVTK View Model
+class VVTK_EXPORT VVTK_Viewer : public SVTK_Viewer
+{
+ Q_OBJECT;
+
+public:
+ typedef VVTK_ViewWindow TViewWindow;
+
+ static
+ QString
+ Type()
+ {
+ return "VVTK";
+ }
+
+ VVTK_Viewer();
+
+ virtual
+ ~VVTK_Viewer();
+
+ //! See #SUIT_ViewModel::createView
+ virtual
+ SUIT_ViewWindow*
+ createView(SUIT_Desktop*);
+
+ //! See SUIT_ViewModel::getType
+ virtual
+ QString
+ getType() const
+ {
+ return Type();
+ }
+
+ //! See #SALOME_View::Display( const SALOME_Prs* )
+ virtual
+ void
+ Display(const SALOME_VTKPrs* thePrs);
+
+ //! See #SALOME_View::isVisible( const Handle(SALOME_InteractiveObject)& )
+ virtual
+ bool
+ isVisible(const Handle(SALOME_InteractiveObject)& theIO);
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+//
+#include "VVTK_ViewWindow.h"
+#include "VVTK_ViewModel.h"
+#include "VVTK_MainWindow.h"
+#include "SVTK_View.h"
+
+#include "SUIT_Session.h"
+
+#include "VVTK_Renderer.h"
+#include "SVTK_Selector.h"
+#include "SVTK_InteractorStyle.h"
+#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_GenericRenderWindowInteractor.h"
+
+#include <vtkRenderWindow.h>
+
+#include <QLayout>
+#include <QList>
+#include <QSplitter>
+#include <QToolBar>
+
+//----------------------------------------------------------------------------
+VVTK_ViewWindow
+::VVTK_ViewWindow(SUIT_Desktop* theDesktop):
+ SVTK_ViewWindow(theDesktop),
+ myMainWindow1(NULL),
+ myMainWindow2(NULL),
+ myView2(NULL),
+ myDumpImage(QImage())
+{}
+
+//----------------------------------------------------------------------------
+void VVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
+{
+ if(SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr()){
+
+ QSplitter* s = new QSplitter( Qt::Vertical, this );
+ setCentralWidget( s );
+
+ VISU_WidgetCtrl* aWidgetCtrl = NULL;
+ VISU_InsideCursorSettings* anInsideCursorSettings = NULL;
+ VISU_OutsideCursorSettings* anOutsideCursorSettings = NULL;
+ VISU_PickingSettings* aPickingSettings = NULL;
+ SVTK_Selector* aSelector = SVTK_Selector::New();
+ {
+ myMainWindow1 = new VVTK_MainWindow1(s,
+ "VVTK_MainWindow",
+ aResourceMgr,
+ this);
+
+ anInsideCursorSettings = myMainWindow1->GetInsideCursorSettings();
+ anOutsideCursorSettings = myMainWindow1->GetOutsideCursorSettings();
+ aPickingSettings = myMainWindow1->GetPickingSettings();
+
+ SVTK_RenderWindowInteractor* anIteractor =
+ new SVTK_RenderWindowInteractor(myMainWindow1,"SVTK_RenderWindowInteractor1");
+
+ SVTK_GenericRenderWindowInteractor* aDevice =
+ SVTK_GenericRenderWindowInteractor::New();
+ aDevice->SetRenderWidget(anIteractor);
+ aDevice->SetSelector(aSelector);
+
+ VVTK_Renderer1* aRenderer = VVTK_Renderer1::New();
+ aRenderer->Initialize(aDevice,aSelector);
+
+ aWidgetCtrl = aRenderer->GetWidgetCtrl();
+
+ aRenderer->SetInsideCursorSettings(anInsideCursorSettings);
+ aRenderer->SetOutsideCursorSettings(anOutsideCursorSettings);
+ aRenderer->SetPickingSettings(aPickingSettings);
+
+ anIteractor->Initialize(aDevice,aRenderer,aSelector);
+
+ SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New();
+ anIteractor->PushInteractorStyle(aStyle);
+ aStyle->Delete();
+
+ aDevice->Delete();
+ aRenderer->Delete();
+
+ myMainWindow1->Initialize(anIteractor,aRenderer);
+
+ myView1 = new SVTK_View(myMainWindow1);
+ SVTK_ViewWindow::Initialize(myView1,theModel);
+
+ anIteractor->getRenderWindow()->Render();
+ myMainWindow1->onResetView();
+ }
+ {
+ myMainWindow2 = myMainWindow1->CreateMainWindow2(s,
+ "VVTK_SegmantationWindow",
+ aResourceMgr,
+ this);
+ SVTK_RenderWindowInteractor* anIteractor =
+ new SVTK_RenderWindowInteractor(myMainWindow2,"SVTK_RenderWindowInteractor1");
+
+ SVTK_GenericRenderWindowInteractor* aDevice =
+ SVTK_GenericRenderWindowInteractor::New();
+ aDevice->SetRenderWidget(anIteractor);
+ aDevice->SetSelector(aSelector);
+
+ VVTK_Renderer2* aRenderer = VVTK_Renderer2::New();
+ aRenderer->Initialize(aDevice,aSelector);
+
+ aRenderer->SetWidgetCtrl(aWidgetCtrl);
+
+ aRenderer->SetInsideCursorSettings(anInsideCursorSettings);
+ aRenderer->SetPickingSettings(aPickingSettings);
+
+ anIteractor->Initialize(aDevice,aRenderer,aSelector);
+
+ SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New();
+ anIteractor->PushInteractorStyle(aStyle);
+ aStyle->Delete();
+
+ aDevice->Delete();
+ aRenderer->Delete();
+
+ myMainWindow2->Initialize(anIteractor);
+
+ myView2 = new SVTK_View(myMainWindow2);
+ SVTK_ViewWindow::Initialize(myView2,theModel);
+
+ anIteractor->getRenderWindow()->Render();
+ myMainWindow2->onResetView();
+ }
+ aSelector->Delete();
+
+ int h = height() / 2;
+ QList<int> aSizes;
+ aSizes.append( h );
+ aSizes.append( h );
+ s->setSizes( aSizes );
+ myMainWindow2->hide();
+
+ myMainWindow = myMainWindow1;
+ myView = myView1;
+ }
+}
+
+//----------------------------------------------------------------------------
+VVTK_ViewWindow
+::~VVTK_ViewWindow()
+{}
+
+
+//----------------------------------------------------------------------------
+VVTK_MainWindow1*
+VVTK_ViewWindow
+::getMainWindow1()
+{
+ return myMainWindow1;
+}
+
+VVTK_MainWindow2*
+VVTK_ViewWindow
+::getMainWindow2()
+{
+ return myMainWindow2;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_ViewWindow
+::AddActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate)
+{
+ myMainWindow1->AddActor(theActor,theIsUpdate);
+ myMainWindow2->AddActor(theActor,theIsUpdate);
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_ViewWindow
+::RemoveActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate)
+{
+ myMainWindow1->RemoveActor(theActor,theIsUpdate);
+ myMainWindow2->RemoveActor(theActor,theIsUpdate);
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_ViewWindow
+::Repaint(bool theUpdateTrihedron)
+{
+ myMainWindow1->Repaint(theUpdateTrihedron);
+ myMainWindow2->Repaint(theUpdateTrihedron);
+}
+
+//----------------------------------------------------------------
+void
+VVTK_ViewWindow
+::unHighlightAll()
+{
+ myView1->unHighlightAll();
+ myView2->unHighlightAll();
+}
+
+//----------------------------------------------------------------
+void
+VVTK_ViewWindow
+::highlight(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theIsHighlight,
+ bool theIsUpdate )
+{
+ if(GetSelector()->AddIObject(theIO))
+ GetSelector()->EndPickCallback();
+ myView1->highlight( theIO, theIsHighlight, theIsUpdate );
+ myView2->highlight( theIO, theIsHighlight, theIsUpdate );
+}
+
+//----------------------------------------------------------------
+void
+VVTK_ViewWindow
+::onSelectionChanged()
+{
+ myView1->onSelectionChanged();
+ myView2->onSelectionChanged();
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_ViewWindow
+::onResetView()
+{
+ myMainWindow1->onResetView();
+ myMainWindow2->onResetView();
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_ViewWindow
+::onFitAll()
+{
+ myMainWindow1->onFitAll();
+ myMainWindow2->onFitAll();
+}
+
+//----------------------------------------------------------------------------
+bool
+VVTK_ViewWindow
+::action( const int accelAction )
+{
+ if ( myMainWindow1->hasFocus() )
+ myMainWindow1->action( accelAction );
+ else if ( myMainWindow2->hasFocus() )
+ myMainWindow2->action( accelAction );
+ else
+ return false;
+ return true;
+}
+
+//----------------------------------------------------------------------------
+QImage
+VVTK_ViewWindow
+::dumpView()
+{
+ if( myMainWindow1->GetInteractor()->hasFocus() )
+ {
+ if ( myMainWindow1->getToolBar()->testAttribute(Qt::WA_UnderMouse) || myDumpImage.isNull() )
+ return myMainWindow1->dumpView();
+ else
+ return myDumpImage;
+ }
+
+ if( myMainWindow2->GetInteractor()->hasFocus() )
+ {
+ if ( myMainWindow1->getToolBar()->testAttribute(Qt::WA_UnderMouse) || myDumpImage.isNull() )
+ return myMainWindow2->dumpView();
+ else
+ return myDumpImage;
+ }
+
+ return QImage();
+}
+
+//----------------------------------------------------------------------------
+void
+VVTK_ViewWindow
+::setBackgroundColor( const QColor& theColor )
+{
+ myMainWindow1->SetBackgroundColor( theColor );
+ myMainWindow2->SetBackgroundColor( theColor );
+}
+
+
+//----------------------------------------------------------------------------
+void
+VVTK_ViewWindow
+::RefreshDumpImage()
+{
+ if( myMainWindow1->GetInteractor()->hasFocus() )
+ myDumpImage = myMainWindow1->dumpView();
+ else if ( myMainWindow2->GetInteractor()->hasFocus() )
+ myDumpImage = myMainWindow2->dumpView();
+}
--- /dev/null
+// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// 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
+//
+#ifndef VVTK_VIEWWINDOW_H
+#define VVTK_VIEWWINDOW_H
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+#include "VVTK.h"
+#include "SVTK_ViewWindow.h"
+
+#include <QImage>
+
+#include <string>
+
+class VVTK_MainWindow1;
+class VVTK_MainWindow2;
+class SVTK_View;
+
+//----------------------------------------------------------------------------
+//! Customize the SVTK_ViewWindow in order to manage two SVTK_View (base and segmented one)
+class VVTK_EXPORT VVTK_ViewWindow : public SVTK_ViewWindow
+{
+ Q_OBJECT;
+
+public:
+ //! To construct the class
+ VVTK_ViewWindow(SUIT_Desktop* theDesktop);
+
+ //! Destroy
+ virtual
+ ~VVTK_ViewWindow();
+
+ //! To initialize
+ virtual
+ void
+ Initialize(SVTK_ViewModelBase* theModel);
+
+ //----------------------------------------------------------------------------
+ //! Get access to base SVTK_MainWindow
+ VVTK_MainWindow1*
+ getMainWindow1();
+
+ //! Get access to segmented SVTK_MainWindow
+ VVTK_MainWindow2*
+ getMainWindow2();
+
+ //----------------------------------------------------------------------------
+ //! Redefine SVTK_ViewWindow::AddActor method
+ /*!
+ This is an entry point for publication the presentation into the viewer.
+ Pointed actor published into the basic MainWindow. If the actor is
+ a Gauss Points one second actor is created from initial actor and
+ is put into segemented MainWindow.
+ */
+ virtual
+ void
+ AddActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
+
+ //! Redefine SVTK_ViewWindow::RemoveActor method
+ virtual
+ void
+ RemoveActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
+
+ //! Redefine SVTK_ViewWindow::Repaint method
+ virtual
+ void
+ Repaint(bool theUpdateTrihedron = true);
+
+ //----------------------------------------------------------------------------
+ /* interactive object management */
+ //! Redefine SVTK_ViewWindow::highlight method
+ virtual
+ void
+ highlight(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theIsHighlight = true,
+ bool theIsUpdate = true);
+
+ //! Redefine SVTK_ViewWindow::unHighlightAll method
+ virtual
+ void
+ unHighlightAll();
+
+ //! Redefine SVTK_ViewWindow::setBackgroundColor method
+ virtual
+ void
+ setBackgroundColor( const QColor& );
+
+ //----------------------------------------------------------------------------
+
+ //! Refresh dump images of the viewers
+ virtual
+ void RefreshDumpImage();
+
+public slots:
+ //! Redefine SVTK_ViewWindow::onSelectionChanged method
+ virtual
+ void
+ onSelectionChanged();
+
+ //! Redefine SVTK_ViewWindow::onResetView method
+ virtual
+ void
+ onResetView();
+
+ //! Redefine SVTK_ViewWindow::onFitAll method
+ virtual
+ void
+ onFitAll();
+
+ //----------------------------------------------------------------------------
+protected:
+ virtual
+ bool
+ action( const int );
+
+ virtual QImage dumpView();
+
+ VVTK_MainWindow1* myMainWindow1; //!< The manage base view
+ SVTK_View* myView1; //!< The manage base view
+
+ VVTK_MainWindow2* myMainWindow2; //!< The manage segmented view
+ SVTK_View* myView2; //!< The manage segmented view
+
+private:
+ QImage myDumpImage;
+};
+
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif