src/CONVERTOR/Makefile \
src/PIPELINE/Makefile \
src/OBJECT/Makefile \
- src/VVTK/Makefile \
- src/GUITOOLS/Makefile \
src/VISU_I/Makefile \
src/VISUGUI/Makefile \
src/VISU_SWIG/Makefile \
\image html viewtable.png
+When the <b>Enable editing</b> option is checked, the table contents are editable.
+\note At the current moment this mode only allows to sort table data.
+The sorting is performed by clicking on the header of the column, by which the data
+is sorted.
+
+<b>Sort policy</b> option allows to specify how the empty cells will be processed
+during the sort procedure. The following options are available:
+<ul>
+<li><b>Empty cells are considered as lowest values</b></li>
+<li><b>Empty cells are considered as highest values</b></li>
+<li><b>Empty cells are always first</b></li>
+<li><b>Empty cells are always last</b></li>
+<li><b>Empty cells are ignored</b> (this means that the positions of empty cells
+will not change after the sorting)</li>
+</ul>
+
+<b>Adjust Cells</b> button allows to adjust the size of table cells according
+to their contents.
+
It is also possible to create
\subpage table_3d_page "Table 3D presentation" basing on the table
data and display it in the VTK viewer.
NONE /*!< Indicates undefined entity value */
};
+ /*!
+ * Tables' sort order
+ */
+ enum SortOrder {
+ AscendingOrder, /*!< The table items are sorted ascending */
+ DescendingOrder /*!< The table items are sorted descending */
+ };
+
+ /*!
+ * Tables' sort policy (specifies how empty cells are taken into account when sorting)
+ */
+ enum SortPolicy {
+ EmptyLowest, /*!< Empty cells are considered as lowest values */
+ EmptyHighest, /*!< Empty cells are considered as highest values */
+ EmptyFirst, /*!< Empty cells are always first */
+ EmptyLast, /*!< Empty cells are always last */
+ EmptyIgnore /*!< Empty cells are ignored (stay at initial positions) */
+ };
+
/*!
* This enumeration contains a set of elements defining the type of the %VISU object.
* This enumeration is used for navigation between a set of %VISU interfaces.
* \return Long value corresponding to the number of columns of the table
*/
long GetNbColumns();
+
+ /*!
+ * Sorts the specified row of the table.
+ * \param theRow Index of the row to sort
+ * \param theSortOrder Sort order (see <VAR>SortOrder</VAR> enumeration)
+ * \param theSortPolicy Sort policy (see <VAR>SortPolicy</VAR> enumeration)
+ */
+ void SortRow(in long theRow, in SortOrder theSortOrder, in SortPolicy theSortPolicy);
+
+ /*!
+ * Sorts the specified column of the table.
+ * \param theRow Index of the column to sort
+ * \param theSortOrder Sort order (see <VAR>SortOrder</VAR> enumeration)
+ * \param theSortPolicy Sort policy (see <VAR>SortPolicy</VAR> enumeration)
+ */
+ void SortColumn(in long theColumn, in SortOrder theSortOrder, in SortPolicy theSortPolicy);
+
+ /*!
+ * Sorts the table by the specified row.
+ * \param theRow Index of the row, by which the table has to be sort
+ * \param theSortOrder Sort order (see <VAR>SortOrder</VAR> enumeration)
+ * \param theSortPolicy Sort policy (see <VAR>SortPolicy</VAR> enumeration)
+ */
+ void SortByRow(in long theRow, in SortOrder theSortOrder, in SortPolicy theSortPolicy);
+
+ /*!
+ * Sorts the table by the specified column.
+ * \param theColumn Index of the column, by which the table has to be sort
+ * \param theSortOrder Sort order (see <VAR>SortOrder</VAR> enumeration)
+ * \param theSortPolicy Sort policy (see <VAR>SortPolicy</VAR> enumeration)
+ */
+ void SortByColumn(in long theColumn, in SortOrder theSortOrder, in SortPolicy theSortPolicy);
};
//-------------------------------------------------------
<parameter name="show_non_manifold_edges" value="false"/>
<parameter name="feature_edges_coloring" value="false"/>
<parameter name="edge_color" value="255, 255, 255"/>
+ <parameter name="tables_enable_editing" value="false"/>
+ <parameter name="tables_sort_policy" value="3"/>
<parameter name="scalar_bar_horizontal_height" value="0.08"/>
<parameter name="scalar_bar_horizontal_width" value="0.8" />
<parameter name="scalar_bar_horizontal_x" value="0.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 : 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
-
-dist_libVISUGUITOOLS_la_SOURCES= VisuGUI_TableDlg.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
+++ /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_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
-
#
# $Header$
#
-SUBDIRS = CONVERTOR PIPELINE OBJECT VVTK GUITOOLS VISU_I VISUGUI VISU_SWIG ENGINE
+SUBDIRS = CONVERTOR PIPELINE OBJECT VISU_I VISUGUI VISU_SWIG ENGINE
VisuGUI_Slider.h \
VisuGUI_InputPane.h \
VisuGUI_FieldFilter.h \
- VisuGUI_ValuesLabelingDlg.h
+ VisuGUI_ValuesLabelingDlg.h \
+ VisuGUI_PrimitiveBox.h \
+ VisuGUI_SizeBox.h
dist_libVISU_la_SOURCES= \
VisuGUI.cxx \
VisuGUI_ClippingPanel.cxx \
VisuGUI_ClippingPlaneDlg.cxx \
VisuGUI_FilterScalarsDlg.cxx \
- VisuGUI_ValuesLabelingDlg.cxx
+ VisuGUI_ValuesLabelingDlg.cxx \
+ VisuGUI_PrimitiveBox.cxx \
+ VisuGUI_SizeBox.cxx
MOC_FILES= \
VisuGUI_moc.cxx \
VisuGUI_ClippingPanel_moc.cxx \
VisuGUI_ClippingPlaneDlg_moc.cxx \
VisuGUI_FilterScalarsDlg_moc.cxx \
- VisuGUI_ValuesLabelingDlg_moc.cxx
+ VisuGUI_ValuesLabelingDlg_moc.cxx \
+ VisuGUI_PrimitiveBox_moc.cxx \
+ VisuGUI_SizeBox_moc.cxx
nodist_libVISU_la_SOURCES=$(MOC_FILES)
$(BOOST_CPPFLAGS) \
$(GUI_CXXFLAGS) \
$(CORBA_CXXFLAGS) $(CORBA_INCLUDES) \
- -I$(srcdir)/../VVTK -I$(srcdir)/../OBJECT -I$(srcdir)/../VISU_I -I$(srcdir)/../GUITOOLS \
+ -I$(srcdir)/../OBJECT -I$(srcdir)/../VISU_I \
-I$(top_builddir)/idl -I$(srcdir)/../CONVERTOR -I$(srcdir)/../PIPELINE
libVISU_la_LDFLAGS= \
$(CAS_LDFLAGS) -lTKV3d \
$(KERNEL_LDFLAGS) -lSalomeNS -lSalomeDSClient \
$(GUI_LDFLAGS) -lSVTK -lSPlot2d -lSalomePrs -lOCCViewer \
- ../VVTK/libVVTK.la ../OBJECT/libVisuObject.la ../VISU_I/libVISUEngineImpl.la \
- ../GUITOOLS/libVISUGUITOOLS.la \
+ ../OBJECT/libVisuObject.la ../VISU_I/libVISUEngineImpl.la \
../../idl/libSalomeIDLVISU.la
if MED_ENABLE_MULTIPR
<source>ICON_VECTORS</source>
<translation>Visu_vectors.png</translation>
</message>
- <message>
- <source>ICON_VVTK_INTERACTOR_STYLE_SWITCH</source>
- <translation>Visu_vvtk_switch.png</translation>
- </message>
- <message>
- <source>ICON_VVTK_PLANE_SEGMENTATION_SWITCH</source>
- <translation>Visu_PlaneSegmentation.png</translation>
- </message>
- <message>
- <source>ICON_VVTK_RECORDING_PAUSE</source>
- <translation>Visu_recording_pause.png</translation>
- </message>
- <message>
- <source>ICON_VVTK_RECORDING_PLAY</source>
- <translation>Visu_recording_play.png</translation>
- </message>
- <message>
- <source>ICON_VVTK_RECORDING_START</source>
- <translation>Visu_recording_start.png</translation>
- </message>
- <message>
- <source>ICON_VVTK_RECORDING_STOP</source>
- <translation>Visu_recording_stop.png</translation>
- </message>
<message>
<source>ICON_SWEEP_STOP</source>
<translation>Visu_recording_stop.png</translation>
</message>
- <message>
- <source>ICON_VVTK_SELECTION_MODE_SWITCH</source>
- <translation>Visu_points.png</translation>
- </message>
- <message>
- <source>ICON_VVTK_SPHERE_SEGMENTATION_SWITCH</source>
- <translation>Visu_SphereSegmentation.png</translation>
- </message>
<message>
<source>ICON_WIREFRAME</source>
<translation>Visu_wireframe.png</translation>
<source>VISU_SWEEPING_PREF</source>
<translation>Sweeping preferences</translation>
</message>
+ <message>
+ <source>VISU_TABLES</source>
+ <translation>Tables</translation>
+ </message>
+ <message>
+ <source>VISU_TABLES_EDITING_PROPS</source>
+ <translation>Tables editing properties</translation>
+ </message>
+ <message>
+ <source>VISU_TABLES_ENABLE_EDITING</source>
+ <translation>Enable editing</translation>
+ </message>
+ <message>
+ <source>VISU_TABLES_SORT_POLICY</source>
+ <translation>Sort policy</translation>
+ </message>
+ <message>
+ <source>VISU_TABLES_EMPTY_LOWEST</source>
+ <translation>Empty cells are considered as lowest values</translation>
+ </message>
+ <message>
+ <source>VISU_TABLES_EMPTY_HIGHEST</source>
+ <translation>Empty cells are considered as highest values</translation>
+ </message>
+ <message>
+ <source>VISU_TABLES_EMPTY_FIRST</source>
+ <translation>Empty cells are always first</translation>
+ </message>
+ <message>
+ <source>VISU_TABLES_EMPTY_LAST</source>
+ <translation>Empty cells are always last</translation>
+ </message>
+ <message>
+ <source>VISU_TABLES_EMPTY_IGNORE</source>
+ <translation>Empty cells are ignored</translation>
+ </message>
<message>
<source>VISU_TIME_STEP</source>
<translation>Time step(second)</translation>
</message>
</context>
<context>
- <name>VVTK_MainWindow</name>
- <message>
- <source>DSC_VVTK_RECORDING_PAUSE</source>
- <translation>Pause recording</translation>
- </message>
- <message>
- <source>DSC_VVTK_RECORDING_PLAY</source>
- <translation>Play recording</translation>
- </message>
- <message>
- <source>DSC_VVTK_RECORDING_START</source>
- <translation>Start recording</translation>
- </message>
- <message>
- <source>DSC_VVTK_RECORDING_STOP</source>
- <translation>Stop recording</translation>
- </message>
- <message>
- <source>LBL_TOOLBAR_RECORD_LABEL</source>
- <translation>Recording Operations</translation>
- </message>
- <message>
- <source>MNU_VVTK_RECORDING_PAUSE</source>
- <translation>Pause recording</translation>
- </message>
- <message>
- <source>MNU_VVTK_RECORDING_PLAY</source>
- <translation>Play recording</translation>
- </message>
- <message>
- <source>MNU_VVTK_RECORDING_START</source>
- <translation>Start recording</translation>
- </message>
- <message>
- <source>MNU_VVTK_RECORDING_STOP</source>
- <translation>Stop recording</translation>
- </message>
- <message>
- <source>MSG_NO_AVI_MAKER</source>
- <translation>Tool jpeg2yuv, necessary for AVI recording, is not available.
-Please, refer to the documentation.</translation>
- </message>
- </context>
- <context>
- <name>VVTK_MainWindow1</name>
- <message>
- <source>DSC_VVTK_INTERACTOR_STYLE_SWITCH</source>
- <translation>Interaction Style Switch</translation>
- </message>
- <message>
- <source>DSC_VVTK_PLANE_SEGMENTATION_SWITCH</source>
- <translation>Plane Segmentation</translation>
- </message>
- <message>
- <source>DSC_VVTK_SELECTION_MODE_SWITCH</source>
- <translation>Selection Mode Switch</translation>
- </message>
- <message>
- <source>DSC_VVTK_SPHERE_SEGMENTATION_SWITCH</source>
- <translation>Sphere Segmentation</translation>
- </message>
- <message>
- <source>LBL_TOOLBAR_GAUSS_LABEL</source>
- <translation>Gauss Viewer Tools</translation>
- </message>
- <message>
- <source>MNU_VVTK_INTERACTOR_STYLE_SWITCH</source>
- <translation>Interaction Style Switch</translation>
- </message>
- <message>
- <source>MNU_VVTK_PLANE_SEGMENTATION_SWITCH</source>
- <translation>Plane Segmentation</translation>
- </message>
- <message>
- <source>MNU_VVTK_SELECTION_MODE_SWITCH</source>
- <translation>Selection Mode Switch</translation>
- </message>
- <message>
- <source>MNU_VVTK_SPHERE_SEGMENTATION_SWITCH</source>
- <translation>Sphere Segmentation</translation>
- </message>
- </context>
- <context>
- <name>VVTK_PickingDlg</name>
- <message>
- <source>BELOW_POINT</source>
- <translation>Centered below the point</translation>
- </message>
- <message>
- <source>CAMERA_TITLE</source>
- <translation>Movement of the camera</translation>
- </message>
- <message>
- <source>CURSOR_SIZE</source>
- <translation>Size of the cursor :</translation>
- </message>
- <message>
- <source>CURSOR_TITLE</source>
- <translation>Cursor</translation>
- </message>
- <message>
- <source>DISPLAY_PARENT_MESH</source>
- <translation>Display parent mesh element</translation>
- </message>
- <message>
- <source>INFO_WINDOW_TITLE</source>
- <translation>Information window</translation>
- </message>
- <message>
- <source>PARENT_MESH_TITLE</source>
- <translation>Parent mesh element</translation>
- </message>
- <message>
- <source>PICKING_DLG_TITLE</source>
- <translation>Picking</translation>
- </message>
- <message>
- <source>POINT_TOLERANCE</source>
- <translation>Point tolerance :</translation>
- </message>
- <message>
- <source>POSITION</source>
- <translation>Position :</translation>
- </message>
- <message>
- <source>PYRAMID_HEIGHT</source>
- <translation>Height of the pyramids :</translation>
- </message>
- <message>
- <source>SELECTION_COLOR</source>
- <translation>Selection cursor color :</translation>
- </message>
- <message>
- <source>STEP_NUMBER</source>
- <translation>Number of steps between two positions :</translation>
- </message>
- <message>
- <source>TOLERANCE_TITLE</source>
- <translation>Tolerance</translation>
- </message>
- <message>
- <source>TOP_LEFT_CORNER</source>
- <translation>Top-left corner of the 3D view</translation>
- </message>
- <message>
- <source>TRANSPARENCY</source>
- <translation>Transparency :</translation>
- </message>
- <message>
- <source>ZOOM_FACTOR</source>
- <translation>Zoom at first selected point (ratio) :</translation>
- </message>
- <message>
- <source>DATA_POSITION</source>
- <translation>Position</translation>
- </message>
- <message>
- <source>PARENT_ELEMENT</source>
- <translation>Parent mesh element ID:</translation>
- </message>
- <message>
- <source>LOCAL_POINT</source>
- <translation>Local Gauss Point ID:</translation>
- </message>
- </context>
- <context>
- <name>VVTK_PrimitiveBox</name>
+ <name>VisuGUI_PrimitiveBox</name>
<message>
<source>ALPHA_TEXTURE</source>
<translation>Alpha Channel Texture (16x16) : </translation>
</message>
</context>
<context>
- <name>VVTK_RecorderDlg</name>
- <message>
- <source>ALL_DISLPAYED_FRAMES</source>
- <translation>Recording all displayed frames</translation>
- </message>
- <message>
- <source>CLOSE</source>
- <translation>Close</translation>
- </message>
- <message>
- <source>DLG_RECORDER_TITLE</source>
- <translation>Recorder</translation>
- </message>
- <message>
- <source>FILE_NAME</source>
- <translation>Save to file : </translation>
- </message>
- <message>
- <source>FLT_ALL_FILES</source>
- <translation>All Files (*.*)</translation>
- </message>
- <message>
- <source>FLT_AVI_FILES</source>
- <translation>AVI Files (*.avi)</translation>
- </message>
- <message>
- <source>FPS</source>
- <translation>FPS : </translation>
- </message>
- <message>
- <source>PROGRESSIVE</source>
- <translation>Progressive</translation>
- </message>
- <message>
- <source>QUALITY</source>
- <translation>Quality : </translation>
- </message>
- <message>
- <source>RECORDING_MODE</source>
- <translation>Mode : </translation>
- </message>
- <message>
- <source>SETTINGS</source>
- <translation>Settings</translation>
- </message>
- <message>
- <source>SKIPPED_FRAMES</source>
- <translation>Recording at a given FPS</translation>
- </message>
- <message>
- <source>START</source>
- <translation>Start</translation>
- </message>
- </context>
- <context>
- <name>VVTK_SegmentationCursorDlg</name>
- <message>
- <source>DEPTH</source>
- <translation>Depth of the cursor: </translation>
- </message>
- <message>
- <source>DEPTH_TITLE</source>
- <translation>Depth</translation>
- </message>
- <message>
- <source>DIRECTION_DX</source>
- <translation>DX: </translation>
- </message>
- <message>
- <source>DIRECTION_DY</source>
- <translation>DY: </translation>
- </message>
- <message>
- <source>DIRECTION_DZ</source>
- <translation>DZ: </translation>
- </message>
- <message>
- <source>DIRECTION_TITLE</source>
- <translation>Direction</translation>
- </message>
- <message>
- <source>GAUSS_POINTS_TAB</source>
- <translation>Gauss Points</translation>
- </message>
- <message>
- <source>INCREMENT</source>
- <translation>+/- Ratio : </translation>
- </message>
- <message>
- <source>INSIDE_GAUSS_POINTS</source>
- <translation>Inside Cursor Gauss Points Presentation</translation>
- </message>
- <message>
- <source>MAGNIFICATION</source>
- <translation>Magnification (%) : </translation>
- </message>
- <message>
- <source>MAGNIFICATION_TITLE</source>
- <translation>Magnification</translation>
- </message>
- <message>
- <source>ORIGIN_TITLE</source>
- <translation>Origin</translation>
- </message>
- <message>
- <source>ORIGIN_X</source>
- <translation>X: </translation>
- </message>
- <message>
- <source>ORIGIN_Y</source>
- <translation>Y: </translation>
- </message>
- <message>
- <source>ORIGIN_Z</source>
- <translation>Z: </translation>
- </message>
- <message>
- <source>OUTSIDE_GAUSS_POINTS</source>
- <translation>Outside Cursor Gauss Points Presentation</translation>
- </message>
- <message>
- <source>RADIUS</source>
- <translation>Radius of the cursor :</translation>
- </message>
- <message>
- <source>RADIUS_TITLE</source>
- <translation>Radius</translation>
- </message>
- <message>
- <source>RATIO</source>
- <translation>+/- Ratio :</translation>
- </message>
- <message>
- <source>SEGMENTATION_CURSOR_DLG_TITLE</source>
- <translation>Segmentation Cursor</translation>
- </message>
- <message>
- <source>SEGMENTATION_CURSOR_TAB</source>
- <translation>Segmentation Cursor</translation>
- </message>
- </context>
- <context>
- <name>VVTK_SizeBox</name>
+ <name>VisuGUI_SizeBox</name>
<message>
<source>COLOR</source>
<translation>Color : </translation>
<translation>Uniform Color</translation>
</message>
</context>
- <context>
- <name>VVTK_ViewManager</name>
- <message>
- <source>VTK_VIEW_TITLE</source>
- <translation>Gauss scene:%1 - viewer:%2</translation>
- </message>
- </context>
- <context>
- <name>VVTK_ViewWindow</name>
- <message>
- <source>LBL_TOOLBAR_LABEL</source>
- <translation>GAUSS viewer tools</translation>
- </message>
- </context>
<context>
<name>VisuGUI</name>
<message>
<translation>Time step (second):</translation>
</message>
</context>
- <context>
- <name>VisuGUI_TableDlg</name>
- <message>
- <source>EDIT_TABLE_TLT</source>
- <translation>Edit Table</translation>
- </message>
- <message>
- <source>ERR_TABLE_NOT_AVAILABLE</source>
- <translation>Table is not available</translation>
- </message>
- <message>
- <source>TABLE_OF_INTEGER_TLT</source>
- <translation>Table of integer</translation>
- </message>
- <message>
- <source>TABLE_OF_REAL_TLT</source>
- <translation>Table of real</translation>
- </message>
- <message>
- <source>VIEW_TABLE_TLT</source>
- <translation>View Table</translation>
- </message>
- </context>
- <context>
- <name>VisuGUI_TableWidget</name>
- <message>
- <source>ADD_COLUMN_BTN</source>
- <translation>Add Column</translation>
- </message>
- <message>
- <source>ADD_ROW_BTN</source>
- <translation>Add Row</translation>
- </message>
- <message>
- <source>ADJUST_CELLS_BTN</source>
- <translation>Adjust Cells</translation>
- </message>
- <message>
- <source>CLEAR_BTN</source>
- <translation>Clear</translation>
- </message>
- <message>
- <source>REMOVE_COLUMN_BTN</source>
- <translation>Remove Column(s)</translation>
- </message>
- <message>
- <source>REMOVE_ROW_BTN</source>
- <translation>Remove Row(s)</translation>
- </message>
- <message>
- <source>SELECT_ALL_BTN</source>
- <translation>Select All</translation>
- </message>
- <message>
- <source>SET_TITLE_TLT</source>
- <translation>Set title</translation>
- </message>
- <message>
- <source>TITLE_LBL</source>
- <translation>Title:</translation>
- </message>
- <message>
- <source>UNITS_TLT</source>
- <translation>Units</translation>
- </message>
- </context>
<context>
<name>VisuGUI_TextPrefDlg</name>
<message>
<translation>Shrink Factor:</translation>
</message>
</context>
+ <context>
+ <name>VISU_TableDlg</name>
+ <message>
+ <source>ERR_TABLE_NOT_AVAILABLE</source>
+ <translation>Table is not available</translation>
+ </message>
+ <message>
+ <source>TABLE_OF_INTEGER_TLT</source>
+ <translation>Table of integer</translation>
+ </message>
+ <message>
+ <source>TABLE_OF_REAL_TLT</source>
+ <translation>Table of real</translation>
+ </message>
+ <message>
+ <source>TABLE_UNKNOWN_TLT</source>
+ <translation>Table of unknown</translation>
+ </message>
+ <message>
+ <source>VIEW_TABLE_TLT</source>
+ <translation>View Table</translation>
+ </message>
+ <message>
+ <source>ALLOW_EDIT_CHECK</source>
+ <translation>Enable editing</translation>
+ </message>
+ <message>
+ <source>DO_UPDATE_CHECK</source>
+ <translation>Immediate update</translation>
+ </message>
+ <message>
+ <source>ADD_COLUMN_BTN</source>
+ <translation>Add Column</translation>
+ </message>
+ <message>
+ <source>ADD_ROW_BTN</source>
+ <translation>Add Row</translation>
+ </message>
+ <message>
+ <source>ADJUST_CELLS_BTN</source>
+ <translation>Adjust Cells</translation>
+ </message>
+ <message>
+ <source>CLEAR_BTN</source>
+ <translation>Clear</translation>
+ </message>
+ <message>
+ <source>REMOVE_COLUMN_BTN</source>
+ <translation>Remove Column(s)</translation>
+ </message>
+ <message>
+ <source>REMOVE_ROW_BTN</source>
+ <translation>Remove Row(s)</translation>
+ </message>
+ <message>
+ <source>SELECT_ALL_BTN</source>
+ <translation>Select All</translation>
+ </message>
+ <message>
+ <source>SET_TITLE_TLT</source>
+ <translation>Set title</translation>
+ </message>
+ <message>
+ <source>TITLE_LBL</source>
+ <translation>Title:</translation>
+ </message>
+ <message>
+ <source>UNITS_TLT</source>
+ <translation>Units</translation>
+ </message>
+ </context>
</TS>
#include "VISU_Vectors_i.hh"
#include "VisuGUI_VectorsDlg.h"
-#include "VisuGUI_TableDlg.h"
+#include "VISU_TableDlg.h"
#include "VisuGUI_FileInfoDlg.h"
#include "SALOMEconfig.h"
Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
_PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
- if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
+ if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase)) {
aSObject = GetCStudy( GetAppStudy( this ) )->FindObjectID( aTable->GetObjectEntry() );
-
- if( !IsSObjectTable( aSObject ) )
- return;
-
- VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
- aSObject,
- false,
- //SAL2670 Orientation of show tables
- VisuGUI_TableDlg::ttAuto,
- Qt::Vertical );
- dlg->show();
+ if( IsSObjectTable( aSObject ) ) {
+ VISU_TableDlg* dlg = new VISU_TableDlg( GetDesktop( this ),
+ GetCStudy( GetAppStudy( this ) ),
+ aTable,
+ false,
+ //SAL2670 Orientation of show tables
+ VISU_TableDlg::ttAuto,
+ Qt::Vertical );
+ dlg->show();
+ }
+ }
}
//----------------------------------------------------------------------------
addPreference( tr( "VISU_AUTOMATIC_FIT_ALL" ), representGr,
LightApp_Preferences::Bool, "VISU", "automatic_fit_all" );
+ // TAB: Tables ; group: "Tables editing properties"
+ int tablesTab = addPreference( tr( "VISU_TABLES" ) );
+
+ int tablesGr = addPreference( tr( "VISU_TABLES_EDITING_PROPS" ), tablesTab );
+ setPreferenceProperty( tablesGr, "columns", 1 );
+
+ addPreference( tr( "VISU_TABLES_ENABLE_EDITING" ), tablesGr, LightApp_Preferences::Bool, "VISU", "tables_enable_editing" );
+
+ int sortPolicyPref = addPreference( tr( "VISU_TABLES_SORT_POLICY" ), tablesGr, LightApp_Preferences::Selector, "VISU", "tables_sort_policy" );
+ QStringList policies;
+ policies.append( tr( "VISU_TABLES_EMPTY_LOWEST" ) );
+ policies.append( tr( "VISU_TABLES_EMPTY_HIGHEST" ) );
+ policies.append( tr( "VISU_TABLES_EMPTY_FIRST" ) );
+ policies.append( tr( "VISU_TABLES_EMPTY_LAST" ) );
+ policies.append( tr( "VISU_TABLES_EMPTY_IGNORE" ) );
+ indices.clear();
+ indices.append( 0 );
+ indices.append( 1 );
+ indices.append( 2 );
+ indices.append( 3 );
+ indices.append( 4 );
+ setPreferenceProperty( sortPolicyPref, "strings", policies );
+ setPreferenceProperty( sortPolicyPref, "indexes", indices );
+
// TAB: Feature edges ; group: "Feature edges properties"
int featureEdgesTab = addPreference( tr( "VISU_FEATURE_EDGES" ) );
//TO DO
//#include "OB_Browser.h"
-#include "VisuGUI_TableDlg.h"
+#include "VISU_TableDlg.h"
#include <QLayout>
#include <QTabWidget>
//#include "OB_Browser.h"
-#include "VisuGUI_TableDlg.h"
+#include "VISU_TableDlg.h"
#include "SVTK_ViewWindow.h"
#include "VisuGUI_Tools.h"
#include "VisuGUI_InputPane.h"
+#include "VisuGUI_PrimitiveBox.h"
+#include "VisuGUI_SizeBox.h"
#include "VISU_ColoredPrs3dFactory.hh"
#include "VISU_GaussPoints_i.hh"
#include "VISU_OpenGLPointSpriteMapper.hxx"
#include "VISU_Convertor.hxx"
-#include "VVTK_PrimitiveBox.h"
-#include "VVTK_SizeBox.h"
-
#include "LightApp_Application.h"
#include "SalomeApp_Module.h"
#include "LightApp_SelectionMgr.h"
aVBLay->setSpacing(6);
// Primitive
- myPrimitiveBox = new VVTK_PrimitiveBox( aBox );
+ myPrimitiveBox = new VisuGUI_PrimitiveBox( aBox );
aVBLay->addWidget( myPrimitiveBox );
// Size
- mySizeBox = new VVTK_SizeBox( aBox );
+ mySizeBox = new VisuGUI_SizeBox( aBox );
aVBLay->addWidget( mySizeBox );
// Deformed Shape
myPrimitiveBox->setResolution( myPrsCopy->GetResolution() );
myPrimitiveBox->setFaceLimit( myPrsCopy->GetFaceLimit() );
- mySizeBox->setType( isResults || isDeformed ? VVTK_SizeBox::Results : VVTK_SizeBox::Geometry );
+ mySizeBox->setType( isResults || isDeformed ? VisuGUI_SizeBox::Results : VisuGUI_SizeBox::Geometry );
mySizeBox->setGeomSize( myPrsCopy->GetGeomSize() );
mySizeBox->setMinSize( myPrsCopy->GetMinSize() );
mySizeBox->setMaxSize( myPrsCopy->GetMaxSize() );
if( on )//myDefShapeButton->isChecked() )
{
myDefShapeBox->show();
- mySizeBox->setType( VVTK_SizeBox::Results );
+ mySizeBox->setType( VisuGUI_SizeBox::Results );
}
else
myDefShapeBox->hide();
class QtxDoubleSpinBox;
class SalomeApp_Module;
-class VVTK_PrimitiveBox;
-class VVTK_SizeBox;
+class VisuGUI_PrimitiveBox;
+class VisuGUI_SizeBox;
class VisuGUI_TextPrefDlg;
class VisuGUI_InputPane;
QRadioButton* myGeometryButton;
QRadioButton* myDefShapeButton;
- VVTK_PrimitiveBox* myPrimitiveBox;
- VVTK_SizeBox* mySizeBox;
+ VisuGUI_PrimitiveBox* myPrimitiveBox;
+ VisuGUI_SizeBox* mySizeBox;
QGroupBox* myDefShapeBox;
- QtxDoubleSpinBox* myScaleSpinBox;
+ QtxDoubleSpinBox* myScaleSpinBox;
SALOME::GenericObjPtr<VISU::GaussPoints_i> myPrsCopy;
SalomeApp_Module* myModule;
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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 : VisuGUI_PrimitiveBox.cxx
+// Author : Oleg UVAROV
+// Module : VISU
+//
+#include "VisuGUI_PrimitiveBox.h"
+#include "VisuGUI_Tools.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;
+
+VisuGUI_PrimitiveBox::VisuGUI_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 );
+ 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 );
+ 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 );
+ 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 );
+ 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 VisuGUI_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 VisuGUI_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 VisuGUI_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 VisuGUI_PrimitiveBox::onResolutionChanged( int theResolution )
+{
+ setFaceNumber( 2 * theResolution * ( theResolution - 2 ) );
+}
+
+void VisuGUI_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 VisuGUI_PrimitiveBox::getClamp() const
+{
+ return myClampSpinBox->value();
+}
+
+void VisuGUI_PrimitiveBox::setClamp( float theClamp )
+{
+ myClampSpinBox->setValue( theClamp );
+}
+
+void VisuGUI_PrimitiveBox::setClampMaximum( float theClampMaximum )
+{
+ myClampSpinBox->setMaximum( theClampMaximum );
+}
+
+void VisuGUI_PrimitiveBox::setMainTexture( const QString& theMainTexture )
+{
+ myMainTexture = theMainTexture;
+ myMainTextureLineEdit->setText( theMainTexture.section( '/', -1 ) );
+}
+
+void VisuGUI_PrimitiveBox::setAlphaTexture( const QString& theAlphaTexture )
+{
+ myAlphaTexture = theAlphaTexture;
+ myAlphaTextureLineEdit->setText( theAlphaTexture.section( '/', -1 ) );
+}
+
+float VisuGUI_PrimitiveBox::getAlphaThreshold() const
+{
+ return myAlphaThresholdSpinBox->value();
+}
+
+void VisuGUI_PrimitiveBox::setAlphaThreshold( float theAlphaThreshold )
+{
+ myAlphaThresholdSpinBox->setValue( theAlphaThreshold );
+}
+
+int VisuGUI_PrimitiveBox::getResolution() const
+{
+ return myResolutionSpinBox->value();
+}
+
+void VisuGUI_PrimitiveBox::setResolution( int theResolution )
+{
+ myResolutionSpinBox->setValue( theResolution );
+}
+
+int VisuGUI_PrimitiveBox::getFaceNumber() const
+{
+ int aResolution = getResolution();
+ return 2 * aResolution * ( aResolution - 2 );
+ //return myFaceNumberLineEdit->text().toInt();
+}
+
+void VisuGUI_PrimitiveBox::setFaceNumber( int theFaceNumber )
+{
+ myFaceNumberLineEdit->setText( QString::number( theFaceNumber ) );
+}
+
+int VisuGUI_PrimitiveBox::getFaceLimit() const
+{
+ return myFaceLimitSpinBox->value();
+}
+
+void VisuGUI_PrimitiveBox::setFaceLimit( int theFaceLimit )
+{
+ myFaceLimitSpinBox->setValue( theFaceLimit );
+}
+
+void VisuGUI_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 VisuGUI_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-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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 : VisuGUI_PrimitiveBox.h
+// Author : Oleg UVAROV
+// Module : VISU
+//
+#ifndef VISUGUI_PRIMITIVEBOX_H
+#define VISUGUI_PRIMITIVEBOX_H
+
+#include <QGroupBox>
+
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QRadioButton;
+
+class SalomeApp_DoubleSpinBox;
+class SalomeApp_IntSpinBox;
+
+class VisuGUI_PrimitiveBox : public QGroupBox
+{
+ Q_OBJECT
+
+public:
+ VisuGUI_PrimitiveBox( QWidget* );
+ ~VisuGUI_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-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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 : VisuGUI_SizeBox.cxx
+// Author : Oleg UVAROV
+// Module : VISU
+//
+#include "VisuGUI_SizeBox.h"
+
+#include "VisuGUI_Tools.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;
+
+VisuGUI_SizeBox::VisuGUI_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 );
+ 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 );
+ 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 );
+ 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 );
+ 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 );
+ 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 );
+ 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( VisuGUI_SizeBox::Results );
+}
+
+void VisuGUI_SizeBox::onToggleResults()
+{
+ myType = VisuGUI_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 VisuGUI_SizeBox::onToggleGeometry()
+{
+ myType = VisuGUI_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 VisuGUI_SizeBox::onToggleInside()
+{
+ myType = VisuGUI_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 VisuGUI_SizeBox::onToggleOutside()
+{
+ myType = VisuGUI_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 VisuGUI_SizeBox::setType( int theType )
+{
+ myType = theType;
+
+ switch( myType )
+ {
+ case VisuGUI_SizeBox::Results : onToggleResults(); break;
+ case VisuGUI_SizeBox::Geometry : onToggleGeometry(); break;
+ case VisuGUI_SizeBox::Inside : onToggleInside(); break;
+ case VisuGUI_SizeBox::Outside : onToggleOutside(); break;
+ default : break;
+ }
+}
+
+float VisuGUI_SizeBox::getOutsideSize() const
+{
+ return myOutsideSizeSpinBox->value() / 100.0;
+}
+
+void VisuGUI_SizeBox::setOutsideSize( float theOutsideSize )
+{
+ myOutsideSizeSpinBox->setValue( ( int )( theOutsideSize * 100 ) );
+}
+
+float VisuGUI_SizeBox::getGeomSize() const
+{
+ return myGeomSizeSpinBox->value() / 100.0;
+}
+
+void VisuGUI_SizeBox::setGeomSize( float theGeomSize )
+{
+ myGeomSizeSpinBox->setValue( ( int )( theGeomSize * 100 ) );
+}
+
+float VisuGUI_SizeBox::getMinSize() const
+{
+ return myMinSizeSpinBox->value() / 100.0;
+}
+
+void VisuGUI_SizeBox::setMinSize( float theMinSize )
+{
+ myMinSizeSpinBox->setValue( ( int )( theMinSize * 100 ) );
+}
+
+float VisuGUI_SizeBox::getMaxSize() const
+{
+ return myMaxSizeSpinBox->value() / 100.0;
+}
+
+void VisuGUI_SizeBox::setMaxSize( float theMaxSize )
+{
+ myMaxSizeSpinBox->setValue( ( int )( theMaxSize * 100 ) );
+}
+
+float VisuGUI_SizeBox::getMagnification() const
+{
+ return myMagnificationSpinBox->value() / 100.0;
+}
+
+void VisuGUI_SizeBox::setMagnification( float theMagnification )
+{
+ myMagnificationSpinBox->setValue( ( int )( theMagnification * 100 ) );
+}
+
+float VisuGUI_SizeBox::getIncrement() const
+{
+ return myIncrementSpinBox->value();
+}
+
+void VisuGUI_SizeBox::setIncrement( float theIncrement )
+{
+ myIncrementSpinBox->setValue( theIncrement );
+}
+
+bool VisuGUI_SizeBox::getUniform() const
+{
+ return myUniformCheckBox->isChecked();
+}
+
+void VisuGUI_SizeBox::setUniform( bool theUniform )
+{
+ myUniformCheckBox->setChecked( theUniform );
+ myColorButton->setEnabled( theUniform );
+}
+
+QColor VisuGUI_SizeBox::getColor() const
+{
+ return myColorButton->color();//palette().color( myColorButton->backgroundRole() );
+ //return myColorButton->paletteBackgroundColor();
+}
+
+void VisuGUI_SizeBox::setColor( const QColor& theColor )
+{
+ if ( theColor.isValid() )
+ {
+ //QPalette aPalette( myColorButton->palette() );
+ //aPalette.setColor( myColorButton->backgroundRole(), theColor );
+ myColorButton->setColor( theColor );
+ }
+ //myColorButton->setPaletteBackgroundColor( theColor );
+}
+
+void VisuGUI_SizeBox::enableSizeControls( bool enabled )
+{
+ myMagnificationSpinBox->setEnabled( enabled );
+ myMaxSizeSpinBox->setEnabled( enabled );
+ myMinSizeSpinBox->setEnabled( enabled );
+ myIncrementSpinBox->setEnabled( enabled );
+ myGeomSizeSpinBox->setEnabled( enabled );
+}
+
+/*void VisuGUI_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-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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 : VisuGUI_SizeBox.h
+// Author : Oleg UVAROV
+// Module : VISU
+//
+#ifndef VISUGUI_SIZEBOX_H
+#define VISUGUI_SIZEBOX_H
+
+#include <QWidget>
+
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QCheckBox;
+class QGroupBox;
+
+class SalomeApp_DoubleSpinBox;
+class SalomeApp_IntSpinBox;
+class QtxColorButton;
+
+class VisuGUI_SizeBox : public QWidget
+{
+ Q_OBJECT
+
+public:
+ enum { Results = 0, Geometry, Inside, Outside };
+
+public:
+ VisuGUI_SizeBox( QWidget* );
+ ~VisuGUI_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
VISU_Deformation_i.hh \
VISU_OptionalDeformation_i.hh \
SALOME_GenericObjPointer.hh \
- VISU_ClippingPlaneMgr.hxx
+ VISU_ClippingPlaneMgr.hxx \
+ VISU_TableDlg.h
libVISUEngineImpl_la_SOURCES = \
VISU_Deformation_i.cc \
VISU_OptionalDeformation_i.cc \
SALOME_GenericObjPointer.cc \
- VISU_ClippingPlaneMgr.cxx
+ VISU_ClippingPlaneMgr.cxx \
+ VISU_TableDlg.cxx
+
+MOC_FILES = \
+ VISU_TimeAnimation_moc.cxx \
+ VISU_TableDlg_moc.cxx
-MOC_FILES = VISU_TimeAnimation_moc.cxx
nodist_libVISUEngineImpl_la_SOURCES= $(MOC_FILES)
# additionnal information to compil and link file
-I$(srcdir)/../CONVERTOR \
-I$(srcdir)/../PIPELINE \
-I$(srcdir)/../OBJECT \
- -I$(srcdir)/../GUITOOLS \
-I$(top_builddir)/idl
libVISUEngineImpl_la_LDFLAGS= \
../CONVERTOR/libVisuConvertor.la \
../PIPELINE/libVisuPipeLine.la \
../OBJECT/libVisuObject.la \
- ../GUITOOLS/libVISUGUITOOLS.la \
-lSalomeIDLKernel \
-lSalomeHDFPersist \
-lSalomeGenericObj \
--- /dev/null
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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 : VISU_TableDlg.cxx
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+//
+#include "VISU_TableDlg.h"
+
+#include "VISU_Table_i.hh"
+
+#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 <QTableWidget>
+#include <QTabWidget>
+#include <QList>
+#include <QInputDialog>
+#include <QLabel>
+#include <QIntValidator>
+#include <QDoubleValidator>
+#include <QKeyEvent>
+#include <QHeaderView>
+#include <QPushButton>
+#include <QLineEdit>
+#include <QCheckBox>
+#include <QComboBox>
+
+#include "utilities.h"
+
+const int MARGIN_SIZE = 11;
+const int SPACING_SIZE = 6;
+const int MIN_TABLE_WIDTH = 200;
+const int 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:
+ break;
+ }
+ 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( index.model()->data( index, Qt::DisplayRole ).toString() );
+ break;
+ }
+}
+
+class VISU_TableDlg::WidgetCointainer : public QWidget
+{
+public:
+ WidgetCointainer( QWidget* parent, Qt::Orientation o, int lm, int tm, int rm, int bm, int s )
+ : QWidget( parent )
+ {
+ QLayout* l = o == Qt::Horizontal ? (QLayout*)( new QHBoxLayout( this ) ) : ( QLayout* )( new QVBoxLayout( this ) );
+ l->setContentsMargins( lm, tm, rm, bm );
+ l->setSpacing( s );
+ setLayout( l );
+ }
+ void addWidget( QWidget* w )
+ {
+ if ( w ) {
+ QHBoxLayout* hl = qobject_cast<QHBoxLayout*>( layout() );
+ QVBoxLayout* wl = qobject_cast<QVBoxLayout*>( layout() );
+ if ( hl ) hl->addWidget( w );
+ else if ( wl ) wl->addWidget( w );
+ }
+ }
+ void addSpacing( int s )
+ {
+ if ( s > 0 ) {
+ QHBoxLayout* hl = qobject_cast<QHBoxLayout*>( layout() );
+ QVBoxLayout* wl = qobject_cast<QVBoxLayout*>( layout() );
+ if ( hl ) hl->addSpacing( s );
+ else if ( wl ) wl->addSpacing( s );
+ }
+ }
+ void addStretch( int s )
+ {
+ if ( s >= 0 ) {
+ QHBoxLayout* hl = qobject_cast<QHBoxLayout*>( layout() );
+ QVBoxLayout* wl = qobject_cast<QVBoxLayout*>( layout() );
+ if ( hl ) hl->addStretch( s );
+ else if ( wl ) wl->addStretch( s );
+ }
+ }
+};
+
+/*class VISU_Table : public QTableWidget {
+public:
+ VISU_Table( Orientation orient, QWidget* parent = 0 )
+ : QTableWidget( parent ), myValidator( 0 ), myOrientation( orient ) {}
+ VISU_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;
+ };*/
+
+QString VISU_TableDlg::tableTitle( int type )
+{
+ QString tlt;
+ switch ( type ) {
+ case ttInt: tlt = tr( "TABLE_OF_INTEGER_TLT" ); break;
+ case ttReal: tlt = tr( "TABLE_OF_REAL_TLT" ); break;
+ default: tlt = tr( "TABLE_UNKNOWN_TLT" ); break;
+ }
+ return tlt;
+}
+/*!
+ Constructor
+*/
+VISU_TableDlg::VISU_TableDlg( QWidget* parent,
+ _PTR(Study) study,
+ VISU::Table_i* table,
+ bool allowEdition,
+ int which,
+ Qt::Orientation orient,
+ bool showColumnTitles )
+ : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ),
+ myStudy( study ), myTable( table ), myEditCheck( 0 ), myUpdateCheck( 0 )
+{
+ allowEdition = true; //////////////////////////////////
+ setWindowTitle( tr( "VIEW_TABLE_TLT" ) );
+ setSizeGripEnabled( true );
+
+ bool bHasIntTable = false;
+ bool bHasRealTable = false;
+ if ( myStudy && myTable ) {
+ _PTR(SObject) aSObject = myStudy->FindObjectID( myTable->GetObjectEntry() );
+ if ( aSObject ) {
+ _PTR(GenericAttribute) anAttr;
+ bHasIntTable = aSObject->FindAttribute( anAttr, "AttributeTableOfInteger" );
+ bHasRealTable = aSObject->FindAttribute( anAttr, "AttributeTableOfReal" );
+ }
+ }
+
+ if ( allowEdition ) {
+ myEditCheck = new QCheckBox( tr( "ALLOW_EDIT_CHECK" ), this );
+ myUpdateCheck = new QCheckBox( tr( "DO_UPDATE_CHECK" ), this );
+ connect( myEditCheck, SIGNAL( toggled( bool ) ), myUpdateCheck, SLOT( setEnabled( bool ) ) );
+ myUpdateCheck->setEnabled( false );
+ myUpdateCheck->hide(); // the feature has been temporarily disabled
+ }
+
+ QWidget* top = 0;
+
+ if ( which == ttInt || which == ttAll || which == ttAuto && bHasIntTable ) {
+ myTableMap[ ttInt ] = new TableWidget( this, orient );
+ myTableMap[ ttInt ]->initialize( myStudy, myTable, ttInt );
+ myTableMap[ ttInt ]->setEditEnabled( false );
+ myTableMap[ ttInt ]->showColumnTitles( showColumnTitles );
+ if ( myEditCheck )
+ connect( myEditCheck, SIGNAL( toggled( bool ) ), myTableMap[ ttInt ], SLOT( setEditEnabled( bool ) ) );
+ }
+ if ( which == ttReal || which == ttAll || which == ttAuto && bHasRealTable ) {
+ myTableMap[ ttReal ] = new TableWidget( this, orient );
+ myTableMap[ ttReal ]->initialize( myStudy, myTable, ttReal );
+ myTableMap[ ttReal ]->setEditEnabled( false );
+ myTableMap[ ttReal ]->showColumnTitles( showColumnTitles );
+ if ( myEditCheck )
+ connect( myEditCheck, SIGNAL( toggled( bool ) ), myTableMap[ ttReal ], SLOT( setEditEnabled( bool ) ) );
+ }
+
+ if ( myTableMap.count() > 1 ) {
+ QTabWidget* tw = new QTabWidget( this );
+ for ( int i = ttInt; i < ttAll; i++ ) {
+ if ( myTableMap.contains( i ) ) {
+ tw->addTab( myTableMap[ i ], tableTitle( i ) );
+ myTableMap[ i ]->layout()->setMargin( MARGIN_SIZE );
+ }
+ }
+ top = tw;
+ }
+ else if ( myTableMap.count() == 1 ) {
+ top = myTableMap[myTableMap.keys().first()];
+ }
+ else {
+ QLabel* dumbLabel = new QLabel( tr( "ERR_TABLE_NOT_AVAILABLE" ), this );
+ dumbLabel->setAlignment( Qt::AlignCenter );
+ top = dumbLabel;
+ }
+
+ myOKBtn = new QPushButton( tr( "BUT_OK" ), this );
+ myHelpBtn = new QPushButton( tr( "BUT_HELP" ), this );
+
+ QHBoxLayout* btnLayout = new QHBoxLayout;
+ btnLayout->setMargin( 0 );
+ btnLayout->setSpacing( SPACING_SIZE );
+
+ btnLayout->addWidget( myOKBtn );
+ btnLayout->addStretch( 20 );
+ btnLayout->addWidget( myHelpBtn );
+ connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( close() ) );
+ connect( myHelpBtn, SIGNAL( clicked() ), this, SLOT( help() ) );
+
+ QVBoxLayout* mainLayout = new QVBoxLayout( this );
+ mainLayout->setMargin( MARGIN_SIZE );
+ mainLayout->setSpacing( SPACING_SIZE );
+
+ if ( myEditCheck ) {
+ QHBoxLayout* checkLayout = new QHBoxLayout;
+ checkLayout->setMargin( 0 );
+ checkLayout->setSpacing( SPACING_SIZE );
+ checkLayout->addWidget( myEditCheck );
+ checkLayout->addWidget( myUpdateCheck );
+ mainLayout->addLayout( checkLayout );
+
+ if ( LightApp_Application* app = ( LightApp_Application* )SUIT_Session::session()->activeApplication() ) {
+ int anEnableEditing = app->resourceMgr()->booleanValue( "VISU", "tables_enable_editing", false );
+ myEditCheck->setChecked( anEnableEditing );
+ }
+ }
+ mainLayout->addWidget( top );
+ mainLayout->addLayout( btnLayout );
+
+ resize( 500, 400 );
+ SUIT_Tools::centerWidget( this, parent );
+}
+
+/*!
+ Destructor
+*/
+VISU_TableDlg::~VISU_TableDlg()
+{
+}
+
+/*!
+ <OK> button slot, saves table(s)
+ Called only in create/edit mode ( <edit> parameter for constructor is true )
+*/
+/*
+void VISU_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 ( myTableMap.contains( ttInt ) ) {
+ builder->RemoveAttribute( myObject, "AttributeTableOfInteger" );
+ tblIntAttr = builder->FindOrCreateAttribute( myObject, "AttributeTableOfInteger" );
+
+ int i;
+ int nbRows = myTableMap[ ttInt ]->getNumRows();
+ int nbCols = myTableMap[ ttInt ]->getNumCols();
+ QString tlt = myTableMap[ ttInt ]->getTableTitle();
+ QStringList rowTitles, colTitles, units;
+ myTableMap[ ttInt ]->getRowTitles( rowTitles );
+ myTableMap[ ttInt ]->getColTitles( colTitles );
+ myTableMap[ ttInt ]->getUnits( units );
+
+ if ( nbRows > 0) {
+ // data
+ int nRow = 0;
+ tblIntAttr->SetNbColumns( nbCols );
+ for ( i = 0; i < nbRows; i++ ) {
+ QStringList data;
+ myTableMap[ ttInt ]->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*)myTableMap[ ttInt ]->getTableTitle().toLatin1() );
+ }
+ if ( myTableMap.contains( ttReal ) ) {
+ builder->RemoveAttribute( myObject, "AttributeTableOfReal" );
+ tblRealAttr = builder->FindOrCreateAttribute( myObject, "AttributeTableOfReal" );
+
+ int i;
+ int nbRows = myTableMap[ ttReal ]->getNumRows();
+ int nbCols = myTableMap[ ttReal ]->getNumCols();
+ QString tlt = myTableMap[ ttReal ]->getTableTitle();
+ QStringList rowTitles, colTitles, units;
+ myTableMap[ ttReal ]->getRowTitles( rowTitles );
+ myTableMap[ ttReal ]->getColTitles( colTitles );
+ myTableMap[ ttReal ]->getUnits( units );
+
+ if ( nbRows > 0) {
+ // data
+ int nRow = 0;
+ tblRealAttr->SetNbColumns( nbCols );
+ for ( i = 0; i < nbRows; i++ ) {
+ QStringList data;
+ myTableMap[ ttReal ]->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*)myTableMap[ ttReal ]->getTableTitle().toLatin1() );
+ }
+ if ( myTableMap.contains( ttInt ) || myTableMap.contains( ttReal ) )
+ builder->CommitCommand(); // commit transaction !!!!!!!!!!!!!!!!!!!!!!!!!!!
+ else
+ builder->AbortCommand(); // abort transaction !!!!!!!!!!!!!!!!!!!!!!!!!!!
+ }
+ catch( ... ) {
+ MESSAGE("VISU_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 VISU_TableDlg::help()
+{
+ 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( this,
+ QObject::tr("WRN_WARNING"),
+ QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) );
+ }
+}
+
+/*!
+ Provides help on F1 button click
+*/
+void VISU_TableDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 ) {
+ e->accept();
+ help();
+ }
+}
+
+/*!
+ Constructor
+*/
+VISU_TableDlg::TableWidget::TableWidget( QWidget* parent,
+ Qt::Orientation orientation )
+ : QWidget( parent ), myOrientation( orientation )
+{
+ myTitleEdit = new QLineEdit( this );
+
+ myTable = new QTableWidget( 5, 5, this );
+ 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->setDragEnabled( false );
+
+ myAdjustBtn = new QPushButton( VISU_TableDlg::tr( "ADJUST_CELLS_BTN" ), this );
+ myAddRowBtn = new QPushButton( VISU_TableDlg::tr( "ADD_ROW_BTN" ), this );
+ myDelRowBtn = new QPushButton( VISU_TableDlg::tr( "REMOVE_ROW_BTN" ), this );
+ myAddColBtn = new QPushButton( VISU_TableDlg::tr( "ADD_COLUMN_BTN" ), this );
+ myDelColBtn = new QPushButton( VISU_TableDlg::tr( "REMOVE_COLUMN_BTN" ), this );
+ mySelectAllBtn = new QPushButton( VISU_TableDlg::tr( "SELECT_ALL_BTN" ), this );
+ myClearBtn = new QPushButton( VISU_TableDlg::tr( "CLEAR_BTN" ), this );
+
+ mySortPolicyLabel = new QLabel( VISU_TableDlg::tr( "VISU_TABLES_SORT_POLICY" ), this );
+ mySortPolicyCombo = new QComboBox( this );
+ mySortPolicyCombo->insertItems( 0, QStringList() <<
+ VISU_TableDlg::tr( "VISU_TABLES_EMPTY_LOWEST" ) <<
+ VISU_TableDlg::tr( "VISU_TABLES_EMPTY_HIGHEST" ) <<
+ VISU_TableDlg::tr( "VISU_TABLES_EMPTY_FIRST" ) <<
+ VISU_TableDlg::tr( "VISU_TABLES_EMPTY_LAST" ) <<
+ VISU_TableDlg::tr( "VISU_TABLES_EMPTY_IGNORE" ) );
+
+ if ( LightApp_Application* app = ( LightApp_Application* )SUIT_Session::session()->activeApplication() ) {
+ int aSortPolicy = app->resourceMgr()->integerValue( "VISU", "tables_sort_policy", 3 );
+ mySortPolicyCombo->setCurrentIndex( aSortPolicy );
+ }
+
+ // the features has been temporarily disabled
+ myAddRowBtn->hide();
+ myDelRowBtn->hide();
+ myAddColBtn->hide();
+ myDelColBtn->hide();
+ mySelectAllBtn->hide();
+ myClearBtn->hide();
+
+ QVBoxLayout* btnLayout = new QVBoxLayout;
+ btnLayout->setMargin( 0 );
+ btnLayout->setSpacing( SPACING_SIZE );
+ btnLayout->addWidget( myAdjustBtn );
+ btnLayout->addStretch( 20 );
+ btnLayout->addWidget( myAddRowBtn );
+ btnLayout->addWidget( myDelRowBtn );
+ btnLayout->addWidget( myAddColBtn );
+ btnLayout->addWidget( myDelColBtn );
+ btnLayout->addStretch( 20 );
+ btnLayout->addWidget( mySelectAllBtn );
+ btnLayout->addWidget( myClearBtn );
+
+ QHBoxLayout* sortLayout = new QHBoxLayout;
+ sortLayout->setMargin( 0 );
+ sortLayout->setSpacing( SPACING_SIZE );
+ sortLayout->addWidget( mySortPolicyLabel );
+ sortLayout->addWidget( mySortPolicyCombo );
+ sortLayout->addStretch( 1 );
+
+ QGridLayout* mainLayout = new QGridLayout( this );
+ mainLayout->setMargin( 0 );
+ mainLayout->setSpacing( SPACING_SIZE );
+ mainLayout->addWidget( myTitleEdit, 0, 0, 1, 2 );
+ mainLayout->addWidget( myTable, 1, 0 );
+ mainLayout->addLayout( btnLayout, 1, 1 );
+ mainLayout->addLayout( sortLayout, 2, 0, 1, 2 );
+
+ connect( myTable, SIGNAL( itemSelectionChanged() ),
+ this, SLOT( updateButtonsState() ) );
+ connect( myTable, SIGNAL( currentItemChanged( QTableWidgetItem*, QTableWidgetItem* ) ),
+ 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() ) );
+ connect( myTable->horizontalHeader(), SIGNAL( sectionClicked( int ) ),
+ this, SLOT( columnClicked( int ) ) );
+ connect( myTable->verticalHeader(), SIGNAL( sectionClicked( int ) ),
+ this, SLOT( rowClicked( int ) ) );
+ myTable->horizontalHeader()->installEventFilter( this );
+ myTable->verticalHeader()->installEventFilter( this );
+ myTable->installEventFilter( this );
+
+ updateButtonsState();
+}
+
+/*!
+ Destructor
+*/
+VISU_TableDlg::TableWidget::~TableWidget()
+{
+}
+
+/*!
+ Initialize widget
+*/
+void VISU_TableDlg::TableWidget::initialize( _PTR(Study) study, VISU::Table_i* table, int type )
+{
+ myStudy = study;
+ myTableObj = table;
+ myType = type;
+
+ setUnitsTitle( VISU_TableDlg::tr( "UNITS_TLT" ) );
+ setEditEnabled( false );
+ showColumnTitles( false );
+
+ updateTableFromServant();
+ updateButtonsState();
+}
+
+void VISU_TableDlg::TableWidget::updateTableFromServant()
+{
+ _PTR(SObject) aSObject = myStudy->FindObjectID( myTableObj->GetObjectEntry() );
+ if ( aSObject ) {
+ int i, j;
+ switch ( myType ) {
+ case ttInt:
+ myTable->setItemDelegate( new NumDelegateItem( this, NumDelegateItem::NV_Int ) );
+ if ( aSObject->FindAttribute( myAttr, "AttributeTableOfInteger" ) ) {
+ _PTR(AttributeTableOfInteger) intAttr = myAttr;
+ try {
+ // title
+ setTableTitle( intAttr->GetTitle().c_str() );
+ // nb of rows & cols
+ int nbRows = intAttr->GetNbRows() ;
+ int nbCols = intAttr->GetNbColumns();
+ setNumRows( nbRows );
+ setNumCols( nbCols );
+ // rows titles
+ QStringList strlist;
+ std::vector<std::string> titles = intAttr->GetRowTitles();
+ for ( i = 0; i < nbRows; i++ ) {
+ if ( titles.size() > 0 )
+ strlist.append( titles[i].c_str() );
+ else
+ strlist.append( "" );
+ }
+ setRowTitles( strlist );
+ // columns titles
+ strlist.clear();
+ titles = intAttr->GetColumnTitles();
+ for ( i = 0; i < nbCols; i++ ) {
+ if ( titles.size() > 0 )
+ strlist.append( titles[i].c_str() );
+ else
+ strlist.append( "" );
+ }
+ setColTitles( strlist );
+ // units
+ strlist.clear();
+ titles = intAttr->GetRowUnits();
+ if ( titles.size() > 0 ) {
+ for ( i = 0; i < nbRows; i++ )
+ strlist.append( titles[i].c_str() );
+ setUnits( strlist );
+ }
+ // data
+ for ( i = 1; i <= nbRows; i++ ) {
+ strlist.clear();
+ for ( j = 1; j <= nbCols; j++ ) {
+ if ( intAttr->HasValue( i, j ) )
+ strlist.append( QString::number( intAttr->GetValue( i, j ) ) );
+ else
+ strlist.append( QString::null );
+ }
+ setRowData( i-1, strlist );
+ }
+ adjustTable();
+ }
+ catch( ... ) {
+ MESSAGE("VISU_TableDlg::TableWidget::initialize : Exception has been caught !!!");
+ }
+ }
+ break;
+ case ttReal:
+ myTable->setItemDelegate( new NumDelegateItem( this, NumDelegateItem::NV_Real ) );
+ if ( aSObject->FindAttribute( myAttr, "AttributeTableOfReal" ) ) {
+ _PTR(AttributeTableOfReal) realAttr = myAttr;
+ try {
+ // title
+ setTableTitle( realAttr->GetTitle().c_str() );
+ // nb of rows & cols
+ int nbRows = realAttr->GetNbRows() ;
+ int nbCols = realAttr->GetNbColumns();
+ setNumRows( nbRows );
+ setNumCols( nbCols );
+ // rows titles
+ QStringList strlist;
+ std::vector<std::string> titles = realAttr->GetRowTitles();
+ for ( i = 0; i < nbRows; i++ ) {
+ if ( titles.size() > 0 )
+ strlist.append( titles[i].c_str() );
+ else
+ strlist.append( "" );
+ }
+ setRowTitles( strlist );
+ // columns titles
+ strlist.clear();
+ titles = realAttr->GetColumnTitles();
+ for ( i = 0; i < nbCols; i++ ) {
+ if ( titles.size() > 0 )
+ strlist.append( titles[i].c_str() );
+ else
+ strlist.append( "" );
+ }
+ setColTitles( strlist );
+ // units
+ strlist.clear();
+ titles = realAttr->GetRowUnits();
+ if ( titles.size() > 0 ) {
+ for ( i = 0; i < nbRows; i++ )
+ strlist.append( titles[i].c_str() );
+ setUnits( strlist );
+ }
+ // data
+ for ( i = 1; i <= nbRows; i++ ) {
+ strlist.clear();
+ for ( j = 1; j <= nbCols; j++ ) {
+ if ( realAttr->HasValue( i, j ) )
+ strlist.append( QString::number( realAttr->GetValue( i, j ) ) );
+ else
+ strlist.append( QString::null );
+ }
+ setRowData( i-1, strlist );
+ }
+ adjustTable();
+ }
+ catch( ... ) {
+ MESSAGE("VISU_TableDlg::TableWidget::initialize : Exception has been caught !!!");
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+/*!
+ Enable / disable editing
+*/
+void VISU_TableDlg::TableWidget::setEditEnabled( bool enable )
+{
+ if( !enable ) {
+ myTable->horizontalHeader()->setSortIndicatorShown( false );
+ myTable->verticalHeader()->setSortIndicatorShown( false );
+ adjustTable();
+ }
+
+ mySortPolicyLabel->setEnabled( enable );
+ mySortPolicyCombo->setEnabled( enable );
+
+ // the rest features have been temporarily disabled
+ enable = false;
+
+ myTitleEdit->setReadOnly( !enable );
+ myTable->setEditTriggers( enable ?
+ QAbstractItemView::DoubleClicked |
+ QAbstractItemView::SelectedClicked |
+ QAbstractItemView::EditKeyPressed :
+ QAbstractItemView::NoEditTriggers );
+ myAddRowBtn->setVisible( enable );
+ myDelRowBtn->setVisible( enable );
+ myAddColBtn->setVisible( enable );
+ myDelColBtn->setVisible( enable );
+ mySelectAllBtn->setVisible( enable );
+ myClearBtn->setVisible( enable );
+}
+
+/*!
+ Show / hide column titles
+*/
+void VISU_TableDlg::TableWidget::showColumnTitles( bool showTitles )
+{
+ if ( myOrientation == Qt::Horizontal )
+ myTable->horizontalHeader()->setVisible( showTitles );
+ else
+ myTable->verticalHeader()->setVisible( showTitles );
+}
+
+/*!
+ Sets table title
+*/
+void VISU_TableDlg::TableWidget::setTableTitle( const QString& title )
+{
+ myTitleEdit->setText( title );
+}
+
+/*!
+ Gets table title
+*/
+QString VISU_TableDlg::TableWidget::getTableTitle()
+{
+ return myTitleEdit->text();
+}
+
+/*!
+ Sets total number of rows
+*/
+void VISU_TableDlg::TableWidget::setNumRows( const int num )
+{
+ myOrientation == Qt::Horizontal ? myTable->setRowCount( num ) : myTable->setColumnCount( num );
+}
+
+/*!
+ Gets total number of rows
+*/
+int VISU_TableDlg::TableWidget::getNumRows()
+{
+ return myOrientation == Qt::Horizontal ? myTable->rowCount() : myTable->columnCount();
+}
+
+/*!
+ Sets total number of columns
+*/
+void VISU_TableDlg::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 VISU_TableDlg::TableWidget::getNumCols()
+{
+ // !!! first column contains units !!!
+ return myOrientation == Qt::Horizontal ? myTable->columnCount()-1 : myTable->rowCount()-1;
+}
+/*!
+ Sets rows titles
+*/
+void VISU_TableDlg::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 VISU_TableDlg::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 VISU_TableDlg::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( VISU_TableDlg::tr( "UNITS_TLT" ) );
+}
+/*!
+ Sets columns titles
+*/
+void VISU_TableDlg::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 VISU_TableDlg::TableWidget::setUnitsTitle( const QString& tlt ) {
+ // !!! first column contains units !!!
+ myTable->model()->setHeaderData( 0, myOrientation, QVariant(tlt.isNull() ? "" : tlt), Qt::DisplayRole );
+}
+/*!
+ Sets units
+*/
+void VISU_TableDlg::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 VISU_TableDlg::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 VISU_TableDlg::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 VISU_TableDlg::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 VISU_TableDlg::TableWidget::adjustTable()
+{
+ myTable->resizeRowsToContents();
+ myTable->resizeColumnsToContents();
+}
+/*!
+ Called when selection changed in table
+*/
+void VISU_TableDlg::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 VISU_TableDlg::TableWidget::addRow()
+{
+ myTable->insertRow( myTable->rowCount() );
+ updateButtonsState();
+}
+/*!
+ <Add column> button slot
+*/
+void VISU_TableDlg::TableWidget::addCol()
+{
+ myTable->insertColumn( myTable->columnCount() );
+ updateButtonsState();
+}
+/*!
+ <Delete row(s)> button slot
+*/
+void VISU_TableDlg::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 VISU_TableDlg::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 VISU_TableDlg::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 VISU_TableDlg::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();
+}
+/*!
+ Column clicked slot
+*/
+void VISU_TableDlg::TableWidget::columnClicked( int column )
+{
+ if ( myTableObj && mySortPolicyCombo->isEnabled() ) {
+ myTableObj->SortByRow( column + 1,
+ ( VISU::SortOrder )myTable->horizontalHeader()->sortIndicatorOrder(),
+ ( VISU::SortPolicy )mySortPolicyCombo->currentIndex() );
+ myTable->horizontalHeader()->setSortIndicatorShown( true );
+ myTable->verticalHeader()->setSortIndicatorShown( false );
+ updateTableFromServant();
+ }
+}
+/*!
+ Row clicked slot
+*/
+void VISU_TableDlg::TableWidget::rowClicked( int row )
+{
+ /* the feature has been temporarily disabled
+ if ( myTableObj && mySortPolicyCombo->isEnabled() && row > 0 ) { // first row contains units
+ myTableObj->SortByColumn( row,
+ ( VISU::SortOrder )myTable->verticalHeader()->sortIndicatorOrder(),
+ ( VISU::SortPolicy )mySortPolicyCombo->currentIndex() );
+ myTable->horizontalHeader()->setSortIndicatorShown( false );
+ myTable->verticalHeader()->setSortIndicatorShown( true );
+ updateTableFromServant();
+ }
+ */
+}
+/*!
+ Event filter - handles titles editing
+*/
+bool VISU_TableDlg::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-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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 : VISU_TableDlg.h
+// Author : Vadim SANDLER
+// Module : VISU
+//
+#ifndef VISU_TABLEDLG_H
+#define VISU_TABLEDLG_H
+
+#include "VISU_I.hxx"
+
+#include <SALOMEDSClient_Study.hxx>
+
+#include <QDialog>
+#include <QItemDelegate>
+#include <QMap>
+
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QCheckBox;
+class QComboBox;
+class QTableWidget;
+
+namespace VISU
+{
+ class Table_i;
+}
+
+class VISU_I_EXPORT VISU_TableDlg : public QDialog
+{
+ Q_OBJECT
+
+ class TableWidget;
+ class WidgetCointainer;
+
+ enum { tcTitle, tcTable, tcControls, tcButtons };
+
+public:
+
+ enum { ttNone, ttInt, ttReal, ttAll, ttAuto };
+ enum { teNone = 0x00,
+ teAddRemove = 0x01,
+ teEditData = 0x02,
+ teRowColumn = 0x04,
+ teAll = teAddRemove | teEditData | teRowColumn
+ };
+
+ VISU_TableDlg( QWidget* parent,
+ _PTR(Study) study,
+ VISU::Table_i* table,
+ bool allowEdition = false,
+ int which = ttAuto,
+ Qt::Orientation orient = Qt::Horizontal,
+ bool showColumnTitles = true );
+ ~VISU_TableDlg();
+
+protected:
+ void keyPressEvent( QKeyEvent* e );
+
+private slots:
+ void help();
+
+private:
+ QString tableTitle( int type );
+
+private:
+ typedef QMap<int, TableWidget*> TableMap;
+ typedef QMap<int, WidgetCointainer*> ContMap;
+
+ TableMap myTableMap;
+ ContMap myContMap;
+ QCheckBox* myEditCheck;
+ QCheckBox* myUpdateCheck;
+ QPushButton* myOKBtn;
+ QPushButton* myHelpBtn;
+
+ _PTR(Study) myStudy;
+ VISU::Table_i* myTable;
+};
+
+class VISU_I_EXPORT VISU_TableDlg::TableWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ TableWidget( QWidget* parent = 0, Qt::Orientation orientation = Qt::Horizontal );
+ ~TableWidget();
+
+ void initialize( _PTR(Study) study, VISU::Table_i* table, int type );
+
+ 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 );
+
+ bool eventFilter( QObject* o, QEvent* e);
+
+public slots:
+ void setEditEnabled( bool enable );
+ void showColumnTitles( bool showTitles );
+
+ void updateButtonsState();
+ void addRow();
+ void addCol();
+ void delRow();
+ void delCol();
+ void adjustTable();
+ void selectAll();
+ void clearTable();
+
+ void columnClicked( int );
+ void rowClicked( int );
+
+protected:
+ void updateTableFromServant();
+
+private:
+ _PTR(Study) myStudy;
+ VISU::Table_i* myTableObj;
+ _PTR(GenericAttribute) myAttr;
+ int myType;
+
+ QLineEdit* myTitleEdit;
+ QTableWidget* myTable;
+ QPushButton* myAddRowBtn;
+ QPushButton* myAddColBtn;
+ QPushButton* myDelRowBtn;
+ QPushButton* myDelColBtn;
+ QPushButton* myAdjustBtn;
+ QPushButton* mySelectAllBtn;
+ QPushButton* myClearBtn;
+ QLabel* mySortPolicyLabel;
+ QComboBox* mySortPolicyCombo;
+ Qt::Orientation myOrientation;
+};
+
+class VISU_I_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 // VISU_TABLEDLG_H
+
return myOrientation;
}
+
+//----------------------------------------------------------------------------
+void
+VISU::Table_i
+::SortRow(CORBA::Long theRow, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy)
+{
+ SALOMEDS::SObject_var SO = mySObj;
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
+ if ( !SO->_is_nil() ) {
+ SALOMEDS::GenericAttribute_var anAttr;
+ if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
+ SALOMEDS::AttributeTableOfInteger_var anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
+ anInt->SortRow( theRow, (SALOMEDS::AttributeTable::SortOrder)theSortOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy );
+ }
+ else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
+ SALOMEDS::AttributeTableOfReal_var aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
+ aReal->SortRow( theRow, (SALOMEDS::AttributeTable::SortOrder)theSortOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy );
+ }
+ UpdateCurves( std::map<int, int>() );
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Table_i
+::SortColumn(CORBA::Long theColumn, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy)
+{
+ SALOMEDS::SObject_var SO = mySObj;
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
+ if ( !SO->_is_nil() ) {
+ SALOMEDS::GenericAttribute_var anAttr;
+ if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
+ SALOMEDS::AttributeTableOfInteger_var anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
+ anInt->SortColumn( theColumn, (SALOMEDS::AttributeTable::SortOrder)theSortOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy );
+ }
+ else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
+ SALOMEDS::AttributeTableOfReal_var aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
+ aReal->SortColumn( theColumn, (SALOMEDS::AttributeTable::SortOrder)theSortOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy );
+ }
+ UpdateCurves( std::map<int, int>() );
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Table_i
+::SortByRow(CORBA::Long theRow, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy)
+{
+ SALOMEDS::SObject_var SO = mySObj;
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
+ if ( !SO->_is_nil() ) {
+ SALOMEDS::GenericAttribute_var anAttr;
+ if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
+ SALOMEDS::AttributeTableOfInteger_var anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
+ anInt->SortByRow( theRow, (SALOMEDS::AttributeTable::SortOrder)theSortOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy );
+ }
+ else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
+ SALOMEDS::AttributeTableOfReal_var aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
+ aReal->SortByRow( theRow, (SALOMEDS::AttributeTable::SortOrder)theSortOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy );
+ }
+ UpdateCurves( std::map<int, int>() );
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Table_i
+::SortByColumn(CORBA::Long theColumn, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy)
+{
+ SALOMEDS::SObject_var SO = mySObj;
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
+ if ( !SO->_is_nil() ) {
+ SALOMEDS::LongSeq_var aRowIndices;
+ SALOMEDS::GenericAttribute_var anAttr;
+ if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfInteger" ) ) {
+ SALOMEDS::AttributeTableOfInteger_var anInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
+ aRowIndices = anInt->SortByColumn( theColumn, (SALOMEDS::AttributeTable::SortOrder)theSortOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy );
+ }
+ else if ( Builder->FindAttribute( SO, anAttr, "AttributeTableOfReal" ) ) {
+ SALOMEDS::AttributeTableOfReal_var aReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
+ aRowIndices = aReal->SortByColumn( theColumn, (SALOMEDS::AttributeTable::SortOrder)theSortOrder,
+ (SALOMEDS::AttributeTable::SortPolicy)theSortPolicy );
+ }
+ std::map<int, int> aMixData;
+ for ( int i = 0, n = aRowIndices->length(); i < n; i++ )
+ aMixData[ aRowIndices[i] ] = i+1;
+ UpdateCurves( aMixData );
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+VISU::Table_i
+::UpdateCurves(std::map<int,int> theMixData)
+{
+ SALOMEDS::SObject_var SO = mySObj;
+ SALOMEDS::StudyBuilder_var Builder = GetStudyDocument()->NewBuilder();
+ SALOMEDS::ChildIterator_var CI = GetStudyDocument()->NewChildIterator( SO );
+ for ( CI->InitEx( true ); CI->More(); CI->Next() ) {
+ CORBA::Object_var anObj = SObjectToObject( CI->Value() );
+ VISU::Curve_var aCurve = VISU::Curve::_narrow( anObj );
+ if ( !aCurve->_is_nil() ) {
+ if ( VISU::Curve_i* pCurve = dynamic_cast<VISU::Curve_i*>( GetServant( aCurve ).in() ) ) {
+ int aHRow = pCurve->GetHRow(), aVRow = pCurve->GetVRow();
+ if ( theMixData.find( aHRow ) != theMixData.end() )
+ pCurve->SetHRow( theMixData[ aHRow ] );
+ if ( theMixData.find( aVRow ) != theMixData.end() )
+ pCurve->SetVRow( theMixData[ aVRow ] );
+ UpdatePlot2d( pCurve, eUpdateData );
+ }
+ }
+ }
+}
+
//----------------------------------------------------------------------------
SALOMEDS::SObject_var
VISU::Table_i
virtual CORBA::Long GetNbRows();
virtual CORBA::Long GetNbColumns();
+ virtual void SortRow(CORBA::Long theRow, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
+ virtual void SortColumn(CORBA::Long theColumn, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
+ virtual void SortByRow(CORBA::Long theRow, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
+ virtual void SortByColumn(CORBA::Long theColumn, VISU::SortOrder theSortOrder, VISU::SortPolicy theSortPolicy);
+
virtual void RemoveFromStudy();
protected:
Storable* Build(int theRestoring);
+ void UpdateCurves(std::map<int, int> theMixData);
protected:
VISU::Table::Orientation myOrientation;
public:
virtual Storable* Create();
- int GetHRow() const { return myHRow;}
- int GetVRow() const { return myVRow;}
- int GetZRow() const { return myZRow;}
+ int GetHRow() const { return myHRow; }
+ void SetHRow( const int theHRow ) { myHRow = theHRow; }
+
+ int GetVRow() const { return myVRow; }
+ void SetVRow( const int theVRow ) { myVRow = theVRow; }
+
+ int GetZRow() const { return myZRow; }
+ void SetZRow( const int theZRow ) { myZRow = theZRow; }
virtual Storable* Restore( const Storable::TRestoringMap& theMap, SALOMEDS::SObject_ptr theSO);
#include "SVTK_ViewModel.h"
#include "VTKViewer_Algorithm.h"
#include "SPlot2d_Curve.h"
+#include "SPlot2d_ViewModel.h"
#include "Plot2d_ViewFrame.h"
#include "Plot2d_ViewWindow.h"
#include "Plot2d_ViewModel.h"
+#include "Plot2d_ViewManager.h"
#include "SalomeApp_Study.h"
#include "SalomeApp_Application.h"
return anVISUActor;
}
- void UpdatePlot2d (Plot2d_ViewFrame *theView,int theDisplaying, Curve_i* theCurve)
+ struct TUpdatePlot2dEvent: public SALOME_Event
+ {
+ Curve_i* myCurve;
+ int myDisplaying;
+
+ TUpdatePlot2dEvent (Curve_i* theCurve, const int theDisplaying):
+ myCurve(theCurve),
+ myDisplaying(theDisplaying)
+ {}
+
+ virtual void Execute()
+ {
+ SalomeApp_Application* anApp = NULL;
+ CORBA::String_var studyName = myCurve->GetStudyDocument()->Name();
+ std::string aStudyName = studyName.in();
+ SUIT_Session* aSession = SUIT_Session::session();
+ QList<SUIT_Application*> anApplications = aSession->applications();
+ QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
+ while (anIter != anApplications.end()) {
+ SUIT_Application* aSUITApp = *anIter;
+ if (SUIT_Study* aSStudy = aSUITApp->activeStudy()) {
+ if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+ if (_PTR(Study) aCStudy = aStudy->studyDS()) {
+ if (aStudyName == aCStudy->Name()) {
+ anApp = dynamic_cast<SalomeApp_Application*>(aSUITApp);
+ break;
+ }
+ }
+ }
+ }
+ anIter++;
+ }
+ if (!anApp)
+ return;
+
+ ViewManagerList aViewManagerList;
+ anApp->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList);
+ SUIT_ViewManager* aViewManager;
+ foreach( aViewManager, aViewManagerList ) {
+ if (Plot2d_ViewManager* aManager = dynamic_cast<Plot2d_ViewManager*>(aViewManager)) {
+ if (SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel())) {
+ if (Plot2d_ViewFrame* aViewFrame = aViewer->getActiveViewFrame()) {
+ UpdatePlot2d(myCurve, myDisplaying, aViewFrame);
+ }
+ }
+ }
+ }
+ }
+ };
+
+ void UpdatePlot2d (Curve_i* theCurve, int theDisplaying, Plot2d_ViewFrame* theView)
{
if(MYDEBUG) MESSAGE("UpdatePlot2d - theDisplaying = " << theDisplaying);
- if (!theView)
+ if (!theView) {
+ // update all views
+ ProcessVoidEvent(new TUpdatePlot2dEvent(theCurve, theDisplaying));
return;
+ }
QList<Plot2d_Curve*> clist;
theView->getCurves(clist);
if (theDisplaying == eEraseAll) {
}
}
}
- } else if (theDisplaying == eDisplay) {
+ } else if (theDisplaying == eDisplay ||
+ theDisplaying == eDisplayOnly ||
+ theDisplaying == eUpdateData) {
if (theCurve) {
bool bFound = false;
for (int i = 0; i < clist.count(); i++) {
SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
if (aSPlot2dC->hasIO() &&
!strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) {
- if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - " << aSPlot2dC);
- aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() );
- aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() );
- aSPlot2dC->setHorUnits( theCurve->GetHorUnits().c_str() );
- aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() );
+ if (theDisplaying == eUpdateData) {
+ if(MYDEBUG) MESSAGE("UpdatePlot2d - updating data : curve - " << aSPlot2dC);
+ }
+ else {
+ if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve - " << aSPlot2dC);
+ }
double* xList = 0;
double* yList = 0;
QStringList zList;
if (nbPoints > 0 && xList && yList) {
aSPlot2dC->setData( xList, yList, nbPoints, zList );
}
- if (!theCurve->IsAuto()) {
- aSPlot2dC->setLine((Plot2d::LineType)theCurve->GetLine(),
- theCurve->GetLineWidth());
- aSPlot2dC->setMarker((Plot2d::MarkerType)theCurve->GetMarker());
- SALOMEDS::Color color = theCurve->GetColor();
- aSPlot2dC->setColor(QColor((int)(color.R*255.),
- (int)(color.G*255.),
- (int)(color.B*255.)));
+ if (theDisplaying == eUpdateData) {
+ theView->updateCurve(aSPlot2dC, true);
+ } else {
+ aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() );
+ aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() );
+ aSPlot2dC->setHorUnits( theCurve->GetHorUnits().c_str() );
+ aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() );
+ if (!theCurve->IsAuto()) {
+ aSPlot2dC->setLine((Plot2d::LineType)theCurve->GetLine(),
+ theCurve->GetLineWidth());
+ aSPlot2dC->setMarker((Plot2d::MarkerType)theCurve->GetMarker());
+ SALOMEDS::Color color = theCurve->GetColor();
+ aSPlot2dC->setColor(QColor((int)(color.R*255.),
+ (int)(color.G*255.),
+ (int)(color.B*255.)));
+ }
+ aSPlot2dC->setAutoAssign(theCurve->IsAuto());
+ theView->displayCurve(aSPlot2dC);
+ bFound = true;
}
- aSPlot2dC->setAutoAssign(theCurve->IsAuto());
- theView->displayCurve(aSPlot2dC);
- bFound = true;
+ } else if (theDisplaying == eDisplayOnly) {
+ theView->eraseCurve(aSPlot2dC);
}
- }
- if (!bFound) {
+ }
+ if (!bFound && theDisplaying != eUpdateData) {
Plot2d_Curve* crv = theCurve->CreatePresentation();
if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying : curve (new) - "<<crv );
if (crv) {
}
}
}
- } else if (theDisplaying == eDisplayOnly) {
- if (theCurve) {
- bool bFound = false;
- for (int i = 0; i < clist.count(); i++) {
- SPlot2d_Curve* aSPlot2dC = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
- if (aSPlot2dC->hasIO() &&
- !strcmp(theCurve->GetEntry().c_str(), aSPlot2dC->getIO()->getEntry())) {
- if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve - " << aSPlot2dC);
- aSPlot2dC->setHorTitle( theCurve->GetHorTitle().c_str() );
- aSPlot2dC->setVerTitle( theCurve->GetVerTitle().c_str() );
- aSPlot2dC->setHorUnits( theCurve->GetHorUnits().c_str() );
- aSPlot2dC->setVerUnits( theCurve->GetVerUnits().c_str() );
- double* xList = 0;
- double* yList = 0;
- QStringList zList;
- int nbPoints = theCurve->GetData( xList, yList, zList );
- if ( nbPoints > 0 && xList && yList ) {
- aSPlot2dC->setData( xList, yList, nbPoints, zList );
- }
- if ( !theCurve->IsAuto() ) {
- aSPlot2dC->setLine((Plot2d::LineType)theCurve->GetLine(), theCurve->GetLineWidth());
- aSPlot2dC->setMarker((Plot2d::MarkerType)theCurve->GetMarker());
- SALOMEDS::Color color = theCurve->GetColor();
- aSPlot2dC->setColor(QColor((int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.)));
- }
- aSPlot2dC->setAutoAssign(theCurve->IsAuto());
- theView->displayCurve(aSPlot2dC);
- bFound = true;
- } else {
- theView->eraseCurve(aSPlot2dC);
- }
- }
- if (!bFound) {
- Plot2d_Curve* crv = theCurve->CreatePresentation();
- if(MYDEBUG) MESSAGE("UpdatePlot2d - displaying only : curve (new) - " << crv);
- if (crv) {
- theView->displayCurve(crv);
- theCurve->SetLine((VISU::Curve::LineType)crv->getLine(), crv->getLineWidth());
- theCurve->SetMarker((VISU::Curve::MarkerType)crv->getMarker());
- SALOMEDS::Color newColor;
- newColor.R = crv->getColor().red()/255.;
- newColor.G = crv->getColor().green()/255.;
- newColor.B = crv->getColor().blue()/255.;
- theCurve->SetColor(newColor);
- crv->setAutoAssign(theCurve->IsAuto());
- }
- }
- }
}
}
void RepaintView (SUIT_ViewWindow* theViewWindow);
- enum Displaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll};
+ enum Displaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll, eUpdateData};
VISU_I_EXPORT VISU_Actor* UpdateViewer (SUIT_ViewWindow* theViewWindow, int theDisplaing, Prs3d_i* thePrs = NULL);
- void UpdatePlot2d (Plot2d_ViewFrame *theView, int theDisplaying, Curve_i* theCurve);
+ void UpdatePlot2d (Curve_i* theCurve, int theDisplaying, Plot2d_ViewFrame* theView = NULL);
VISU_I_EXPORT VISU_Actor* FindActor(SVTK_ViewWindow* theViewWindow, VISU::Prs3d_i* thePrs3d);
VISU_I_EXPORT VISU_ActorBase* FindActorBase(SVTK_ViewWindow* theViewWindow, VISU::TActorFactory* theActor);
#include "VISU_ScalarMap_i.hh"
#include "VISU_ViewManager_i.hh"
-#include "VisuGUI_TableDlg.h"
+#include "VISU_TableDlg.h"
#include "VISU_Actor.h"
#include "VISU_ScalarMapAct.h"
{
// is it Curve ?
if (Curve_i* aCurve = dynamic_cast<Curve_i*>(VISU::GetServant(myPrsObj).in())) {
- UpdatePlot2d(myView,myDisplaing,aCurve);
+ UpdatePlot2d(aCurve,myDisplaing,myView);
}
// is it Container ?
if (Container_i* aContainer = dynamic_cast<Container_i*>(VISU::GetServant(myPrsObj).in())) {
for ( int i = 1; i <= nbCurves; i++ ) {
VISU::Curve_i* aCurve = aContainer->GetCurve( i );
if ( aCurve && aCurve->IsValid() ) {
- UpdatePlot2d(myView,myDisplaing,aCurve);
+ UpdatePlot2d(aCurve,myDisplaing,myView);
}
}
myView->Repaint();
if (!CORBA::is_nil(childObject)) {
CORBA::Object_ptr aCurve = VISU::Curve::_narrow(childObject);
if (!CORBA::is_nil(aCurve))
- UpdatePlot2d(myView, myDisplaing,
- dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in()));
+ UpdatePlot2d(dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in()),
+ myDisplaing, myView);
}
}
myView->Repaint();
SalomeApp_Application* myApplication;
VISU::Table_i* myTable;
- typedef VisuGUI_TableDlg* TResult;
+ typedef VISU_TableDlg* TResult;
TResult myResult;
TCreateTableViewEvent (SalomeApp_Application* theApplication,
if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
if (_PTR(Study) aCStudy = aStudy->studyDS()) {
- _PTR(SObject) aSObject = aCStudy->FindObjectID(myTable->GetObjectEntry());
- if (aSObject) {
- myResult = new VisuGUI_TableDlg (myApplication->desktop(),
- aSObject,
- false,
- VisuGUI_TableDlg::ttAuto,
- Qt::Vertical);
+ myResult = new VISU_TableDlg (myApplication->desktop(),
+ aCStudy,
+ myTable,
+ false,
+ VISU_TableDlg::ttAuto,
+ Qt::Vertical);
myResult->show();
- }
}
}
}
void TableView_i::SetTitle (const char* theTitle)
{
- ProcessVoidEvent(new TVoidMemFun1ArgEvent<VisuGUI_TableDlg,const QString&,QString>
- (myView, &VisuGUI_TableDlg::setWindowTitle, QString(theTitle)));
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_TableDlg,const QString&,QString>
+ (myView, &VISU_TableDlg::setWindowTitle, QString(theTitle)));
}
char* TableView_i::GetTitle()
class QWidget;
-class VisuGUI_TableDlg;
+class VISU_TableDlg;
class SalomeApp_Application;
virtual void Close();
protected:
- VisuGUI_TableDlg* myView;
+ VISU_TableDlg* myView;
public:
virtual Storable* Create (VISU::Table_ptr theTable);
};
+++ /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
-
-libVVTK_la_LDFLAGS= \
- ../OBJECT/libVisuObject.la \
- ../PIPELINE/libVisuPipeLine.la \
- ../CONVERTOR/libVisuConvertor.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 "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 "QtxDoubleSpinBox.h"
-#include "QtxIntSpinBox.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 QtxDoubleSpinBox( 0, 1, 0.1, CursorGroup );
- myCursorSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
- QLabel* PyramidHeightLabel = new QLabel( tr( "PYRAMID_HEIGHT" ), CursorGroup );
- double aHeightMin=1.e-7;
- double aHeightMax=10.;
- double aHeightStep=0.1;
- myPyramidHeightSpinBox = new QtxDoubleSpinBox(aHeightMin, aHeightMax, aHeightStep, CursorGroup );
- myPyramidHeightSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
- QLabel* SelectionColorLabel = new QLabel( tr( "SELECTION_COLOR" ), CursorGroup );
- mySelectionColorButton = new QtxColorButton( CursorGroup );
- mySelectionColorButton->setColor( Qt::blue );
- //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 QtxDoubleSpinBox( 0.001, 10.0, 0.01, ToleranceGroup );
- myPointToleranceSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
- ToleranceGroupLayout->addWidget( PointToleranceLabel, 0, 0 );
- ToleranceGroupLayout->addWidget( myPointToleranceSpinBox, 0, 1 );
-
- BoxLayout->addWidget( ToleranceGroup );
-
- // Information window
- QGroupBox* InfoWindowGroup = new QGroupBox( tr( "INFO_WINDOW_TITLE" ), aBox );
- //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 QtxIntSpinBox( 0, 100, 10, InfoWindowGroup );
- myTransparencySpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
- InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 );
- InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 );
-
- QLabel* PositionLabel = new QLabel( tr( "POSITION" ), InfoWindowGroup );
- myPositionComboBox = new QComboBox( InfoWindowGroup );
- myPositionComboBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
- myPositionComboBox->addItem( tr( "BELOW_POINT" ) );
- myPositionComboBox->addItem( tr( "TOP_LEFT_CORNER" ) );
-
- InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 );
- InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 );
- InfoWindowGroupLayout->addWidget( PositionLabel, 1, 0 );
- InfoWindowGroupLayout->addWidget( myPositionComboBox, 1, 1 );
-
- BoxLayout->addWidget( InfoWindowGroup );
-
- // Movement of the camera
- QGroupBox* CameraGroup = new QGroupBox( tr( "CAMERA_TITLE" ), aBox );
- //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 QtxDoubleSpinBox( 0.1, 10.0, 0.1, CameraGroup );
- myZoomFactorSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
- QLabel* StepNumberLabel = new QLabel( tr( "STEP_NUMBER" ), CameraGroup );
- myStepNumberSpinBox = new QtxIntSpinBox( 1, 100, 1, CameraGroup );
- myStepNumberSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
- CameraGroupLayout->addWidget( ZoomFactorLabel, 0, 0 );
- CameraGroupLayout->addWidget( myZoomFactorSpinBox, 0, 1 );
- CameraGroupLayout->addWidget( StepNumberLabel, 1, 0 );
- CameraGroupLayout->addWidget( myStepNumberSpinBox, 1, 1 );
-
- BoxLayout->addWidget( CameraGroup );
-
- // Display parent mesh element
- QGroupBox* PositionGroup = new QGroupBox( tr( "DATA_POSITION" ), aBox );
- //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 QtxDoubleSpinBox;
-class QtxIntSpinBox;
-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:
- QtxDoubleSpinBox* myCursorSizeSpinBox;
- QtxDoubleSpinBox* myPyramidHeightSpinBox;
- QtxColorButton* mySelectionColorButton;
- QtxDoubleSpinBox* myPointToleranceSpinBox;
- QtxIntSpinBox* myTransparencySpinBox;
- QComboBox* myPositionComboBox;
- QtxDoubleSpinBox* myZoomFactorSpinBox;
- QtxIntSpinBox* 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 "VISU_OpenGLPointSpriteMapper.hxx"
-
-#include "SUIT_ResourceMgr.h"
-#include "SUIT_Session.h"
-
-#include "QtxDoubleSpinBox.h"
-#include "QtxIntSpinBox.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 QtxDoubleSpinBox( 1.0, 512.0, 1.0, this );
- 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 QtxDoubleSpinBox( 0.0, 1.0, 0.1, this );
- 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 QtxIntSpinBox( 3, 100, 1, this );
- 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 QtxIntSpinBox( 10, 1000000, 10, this );
- 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 QtxDoubleSpinBox;
-class QtxIntSpinBox;
-
-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;
- QtxDoubleSpinBox* myClampSpinBox;
-
- QLabel* myMainTextureLabel;
- QLineEdit* myMainTextureLineEdit;
- QPushButton* myMainTextureButton;
-
- QLabel* myAlphaTextureLabel;
- QLineEdit* myAlphaTextureLineEdit;
- QPushButton* myAlphaTextureButton;
-
- QLabel* myAlphaThresholdLabel;
- QtxDoubleSpinBox* myAlphaThresholdSpinBox;
-
- QLabel* myResolutionLabel;
- QtxIntSpinBox* myResolutionSpinBox;
-
- QLabel* myFaceNumberLabel;
- QLineEdit* myFaceNumberLineEdit;
-
- QLabel* myFaceLimitLabel;
- QtxIntSpinBox* 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 "SUIT_FileDlg.h"
-#include "SUIT_MessageBox.h"
-#include "SUIT_ResourceMgr.h"
-#include "SUIT_Session.h"
-
-#include "QtxDoubleSpinBox.h"
-#include "QtxIntSpinBox.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 QtxDoubleSpinBox( 0.1, 100.0, 1.0, mySettingsBox );
- myFPSSpinBox->setValue( aResourceMgr->doubleValue( "VISU", "recorder_fps", 10.0 ) );
-
- QLabel* aQualityLabel = new QLabel( tr( "QUALITY" ), mySettingsBox );
- myQualitySpinBox = new QtxIntSpinBox( 1, 100, 1, mySettingsBox );
- 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 QtxDoubleSpinBox;
-class QtxIntSpinBox;
-
-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;
- QtxDoubleSpinBox* myFPSSpinBox;
- QtxIntSpinBox* 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 "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 <QtxDoubleSpinBox.h>
-#include <QtxIntSpinBox.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 QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, myOriginGroup );
- myXOriginSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myXOriginSpinBox->setMinimumWidth( 100 );
- myXOriginSpinBox->setValue( 0.0 );
-
- QLabel* YOriginLabel = new QLabel( tr( "ORIGIN_Y" ), myOriginGroup );
- myYOriginSpinBox = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, myOriginGroup );
- myYOriginSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myYOriginSpinBox->setMinimumWidth( 100 );
- myYOriginSpinBox->setValue( 0.0 );
-
- QLabel* ZOriginLabel = new QLabel( tr( "ORIGIN_Z" ), myOriginGroup );
- myZOriginSpinBox = new QtxDoubleSpinBox( -1000.0, 1000.0, 0.1, myOriginGroup );
- //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 QtxDoubleSpinBox( -1.0, 1.0, 0.1, myDirectionGroup );
- myDXDirectionSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myDXDirectionSpinBox->setMinimumWidth( 100 );
- myDXDirectionSpinBox->setValue( 0.0 );
-
- QLabel* DYDirectionLabel = new QLabel( tr( "DIRECTION_DY" ), myDirectionGroup );
- myDYDirectionSpinBox = new QtxDoubleSpinBox( -1.0, 1.0, 0.1, myDirectionGroup );
- myDYDirectionSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myDYDirectionSpinBox->setMinimumWidth( 100 );
- myDYDirectionSpinBox->setValue( 0.0 );
-
- QLabel* DZDirectionLabel = new QLabel( tr( "DIRECTION_DZ" ), myDirectionGroup );
- myDZDirectionSpinBox = new QtxDoubleSpinBox( -1.0, 1.0, 0.1, myDirectionGroup );
- 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 QtxDoubleSpinBox( 0.0, VTK_LARGE_FLOAT, 0.1, myDepthGroup );
- 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 QtxDoubleSpinBox( 0.0, 1000.0, 1.0,myRadiusGroup );
- myRadiusSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
- myRadiusSpinBox->setMinimumWidth( 100 );
- myRadiusSpinBox->setValue( 100.0 );
-
- QLabel* RatioLabel = new QLabel( tr( "RATIO" ), myRadiusGroup );
- myRatioSpinBox = new QtxDoubleSpinBox( 0.1, 10.0, 0.1,myRadiusGroup );
- 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 QtxIntSpinBox( 1, 10000, 10, MagnificationGroup );
- 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 QtxDoubleSpinBox( 0.01, 10, 0.1, MagnificationGroup );
- 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 QtxDoubleSpinBox;
-class QtxIntSpinBox;
-
-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;
- QtxDoubleSpinBox* myXOriginSpinBox;
- QtxDoubleSpinBox* myYOriginSpinBox;
- QtxDoubleSpinBox* myZOriginSpinBox;
-
- QGroupBox* myDirectionGroup;
- QtxDoubleSpinBox* myDXDirectionSpinBox;
- QtxDoubleSpinBox* myDYDirectionSpinBox;
- QtxDoubleSpinBox* myDZDirectionSpinBox;
-
- QGroupBox* myDepthGroup;
- QtxDoubleSpinBox* myDepthSpinBox;
-
- QGroupBox* myRadiusGroup;
- QtxDoubleSpinBox* myRadiusSpinBox;
- QtxDoubleSpinBox* 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;
- QtxIntSpinBox* myMagnificationSpinBox;
- QLabel* myIncrementLabel;
- QtxDoubleSpinBox* 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 "SUIT_ResourceMgr.h"
-#include "SUIT_Session.h"
-
-#include <QtxDoubleSpinBox.h>
-#include <QtxIntSpinBox.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 QtxIntSpinBox( 0, 100, 1, SizeGroup );
- 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 QtxIntSpinBox( 0, 100, 1, SizeGroup );
- 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 QtxIntSpinBox( 0, 100, 1, SizeGroup );
- 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 QtxIntSpinBox( 0, 100, 1, SizeGroup );
- 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 QtxIntSpinBox( 1, 10000, 10, SizeGroup );
- 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 QtxDoubleSpinBox( 0.01, 10, 0.1, SizeGroup );
- 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 QtxDoubleSpinBox;
-class QtxIntSpinBox;
-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;
- QtxIntSpinBox* myOutsideSizeSpinBox;
-
- QLabel* myGeomSizeLabel;
- QtxIntSpinBox* myGeomSizeSpinBox;
-
- QLabel* myMinSizeLabel;
- QtxIntSpinBox* myMinSizeSpinBox;
-
- QLabel* myMaxSizeLabel;
- QtxIntSpinBox* myMaxSizeSpinBox;
-
- QLabel* myMagnificationLabel;
- QtxIntSpinBox* myMagnificationSpinBox;
-
- QLabel* myIncrementLabel;
- QtxDoubleSpinBox* 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