--- /dev/null
+# VISU VISUGUI : GUI of VISU component
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+#
+#
+#
+# File : Makefile.in
+# Author : Marc Tajchman (CEA)
+# Module : VISU
+# $Header$
+
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@
+
+@COMMENCE@
+
+# header files
+EXPORT_HEADERS= \
+ VisuGUI_TableDlg.h
+
+# .po files to transform in .qm
+#PO_FILES = \
+# VISU_msg_en.po VISU_images.po
+
+# Libraries targets
+LIB = libVISUGUITOOLS.la
+
+LIB_SRC = VisuGUI_TableDlg.cxx
+
+LIB_MOC = VisuGUI_TableDlg.h
+
+LIB_CLIENT_IDL = SALOME_Exception.idl
+
+LIB_SERVER_IDL =
+
+# additionnal information to compil and link file
+
+CPPFLAGS += -ftemplate-depth-32 $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) \
+ $(PYTHON_INCLUDES) $(HDF5_INCLUDES) $(QWT_INCLUDES) \
+ -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS)
+
+CXXFLAGS += -ftemplate-depth-32 $(OCC_CXXFLAGS) \
+ -I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome
+
+LDFLAGS += $(QWT_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome
+
+@CONCLUDE@
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : VisuGUI_TableDlg.cxx
+// Author : Vadim SANDLER
+// Module : SALOME
+
+#include "VisuGUI_TableDlg.h"
+
+#include "SUIT_Tools.h"
+#include "SUIT_MessageBox.h"
+
+#include "SALOMEDSClient_Study.hxx"
+#include "SALOMEDSClient_GenericAttribute.hxx"
+#include "SALOMEDSClient_AttributeTableOfInteger.hxx"
+#include "SALOMEDSClient_AttributeTableOfReal.hxx"
+#include "SALOMEDSClient_StudyBuilder.hxx"
+
+#include <qlayout.h>
+#include <qvalidator.h>
+#include <qtable.h>
+#include <qtabwidget.h>
+#include <qvaluelist.h>
+#include <qmemarray.h>
+#include <qinputdialog.h>
+#include <qlabel.h>
+#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
+
+
+class VisuGUI_Table : public QTable {
+public:
+ VisuGUI_Table( Orientation orient, QWidget* parent = 0, const char* name = 0 )
+ : QTable( parent, name ), myValidator( 0 ), myOrientation( orient ) {}
+ VisuGUI_Table( Orientation orient, int numRows, int numCols, QWidget* parent = 0, const char* name = 0 )
+ : QTable( numRows, numCols, parent, name ), 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 == Horizontal && col == 0 ) || ( myOrientation == 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,
+ Orientation orient,
+ bool showColumnTitles )
+ : QDialog( parent, "", false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
+ myIntTable( 0 ), myRealTable( 0 )
+{
+ setCaption( 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, "TabWidget" );
+ ( ( QTabWidget* ) top) ->setMargin( MARGIN_SIZE );
+ }
+ else {
+ top = new QWidget( this, "DumbWidget" );
+ 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 ) );
+ 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 ) );
+ 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" );
+ dumbLabel->setAlignment( AlignCenter );
+ tl->addWidget( dumbLabel );
+ }
+
+ QHBoxLayout* btnLayout = new QHBoxLayout;
+ btnLayout->setMargin( 0 ); btnLayout->setSpacing( SPACING_SIZE );
+
+ myOKBtn = new QPushButton( tr( "BUT_OK" ), 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 );
+ connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( onOK() ) );
+ connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ }
+ else {
+ btnLayout->addItem( new QSpacerItem( SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
+ btnLayout->addWidget( myOKBtn );
+ btnLayout->addItem( new QSpacerItem( SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
+ connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ }
+
+ 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() ? "" : rowTitles[ i ].latin1() );
+ // set row unit
+ tblIntAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? "" : units[ i ].latin1() );
+ 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() ? "" : colTitles[ i ].latin1() );
+ }
+ }
+ // title
+ tblIntAttr->SetTitle( myIntTable->getTableTitle().latin1() );
+ }
+ 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() ? "" : rowTitles[ i ].latin1() );
+ // set row unit
+ tblRealAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? "" : units[ i ].latin1() );
+ 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() ? "" : colTitles[ i ].latin1() );
+ }
+ }
+ // title
+ tblRealAttr->SetTitle( myRealTable->getTableTitle().latin1() );
+ }
+ 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::error1 ( this, tr("ERR_ERROR"), tr("ERR_APP_EXCEPTION"), tr ("BUT_OK") );
+ }
+ }
+ }
+ if ( done )
+ accept();
+}
+
+/*!
+ 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 !!!");
+ }
+ }
+ }
+}
+
+/*!
+ Constructor
+*/
+VisuGUI_TableWidget::VisuGUI_TableWidget( QWidget* parent,
+ const char* name,
+ bool edit,
+ Orientation orient,
+ bool showColumnTitles )
+ : QWidget( parent, name ), myOrientation( orient )
+{
+ QGridLayout* mainLayout = new QGridLayout( this );
+ mainLayout->setMargin( 0 );
+ mainLayout->setSpacing( SPACING_SIZE );
+
+ myTitleEdit = new QLineEdit( this, "TitleEdit" );
+ myTitleEdit->setAlignment( AlignCenter );
+ myTitleEdit->setReadOnly( !edit );
+ QFont fnt = myTitleEdit->font();
+ fnt.setBold( true );
+ myTitleEdit->setFont( fnt );
+
+ myTable = new VisuGUI_Table( orient, this, "Table" );
+ myTable->setNumRows( 5 );
+ myTable->setNumCols( 5 );
+ myTable->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+ myTable->setMinimumSize( MIN_TABLE_WIDTH, MIN_TABLE_HEIGHT );
+ myTable->setSelectionMode( QTable::Single );
+ myTable->setShowGrid( true );
+ myTable->setColumnMovingEnabled( false );
+ myTable->setRowMovingEnabled( false );
+ myTable->setReadOnly( !edit );
+ myTable->setDragEnabled( false );
+ setUnitsTitle( tr( "UNITS_TLT" ) );
+
+ if ( !showColumnTitles ) {
+ if ( myOrientation == 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, "AddRowBtn" );
+ myDelRowBtn = new QPushButton( tr( "REMOVE_ROW_BTN" ), this, "DelRowBtn" );
+ myAddColBtn = new QPushButton( tr( "ADD_COLUMN_BTN" ), this, "AddColBtn" );
+ myDelColBtn = new QPushButton( tr( "REMOVE_COLUMN_BTN" ), this, "DelColBtn" );
+ myAdjustBtn = new QPushButton( tr( "ADJUST_CELLS_BTN" ), this, "AdjustBtn" );
+ mySelectAllBtn = new QPushButton( tr( "SELECT_ALL_BTN" ), this, "SelectAllBtn" );
+ myClearBtn = new QPushButton( tr( "CLEAR_BTN"), this, "ClearBtn" );
+ 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 == Horizontal ? myTable->setNumRows( num ) : myTable->setNumCols( num );
+}
+/*!
+ Gets total number of rows
+*/
+int VisuGUI_TableWidget::getNumRows()
+{
+ return myOrientation == Horizontal ? myTable->numRows() : myTable->numCols();
+}
+/*!
+ Sets total number of columns
+*/
+void VisuGUI_TableWidget::setNumCols( const int num )
+{
+ // !!! first column contains units !!!
+ myOrientation == Horizontal ? myTable->setNumCols( num+1 ) : myTable->setNumRows( num+1 );
+// myOrientation == Horizontal ? myTable->setColumnReadOnly( 0, true ) : myTable->setRowReadOnly( 0, true );
+}
+/*!
+ Gets total number of columns
+*/
+int VisuGUI_TableWidget::getNumCols()
+{
+ // !!! first column contains units !!!
+ return myOrientation == Horizontal ? myTable->numCols()-1 : myTable->numRows()-1;
+}
+/*!
+ Sets rows titles
+*/
+void VisuGUI_TableWidget::setRowTitles( QStringList& tlts )
+{
+ for ( int i = 0; i < tlts.count(); i++ ) {
+ myOrientation == Horizontal ?
+ 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 == Horizontal ) {
+ for ( int i = 0; i < myTable->numRows(); i++ ) {
+ tlts.append( myTable->verticalHeader()->label( i ) );
+ }
+ }
+ else {
+ for ( int i = 0; i < myTable->numCols(); i++ ) {
+ tlts.append( myTable->horizontalHeader()->label( i ) );
+ }
+ }
+}
+/*!
+ Sets columns titles
+*/
+void VisuGUI_TableWidget::setColTitles( QStringList& tlts )
+{
+ // !!! first column contains units !!!
+ for ( int i = 0; i < tlts.count(); i++ ) {
+ myOrientation == Horizontal ?
+ myTable->horizontalHeader()->setLabel( i+1, tlts[i].isNull() ? "" : tlts[i] ) :
+ myTable->verticalHeader()->setLabel( i+1, tlts[i].isNull() ? "" : tlts[i] );
+ }
+ setUnitsTitle( tr( "UNITS_TLT" ) );
+}
+/*!
+ Sets columns titles
+*/
+void VisuGUI_TableWidget::getColTitles( QStringList& tlts )
+{
+ // !!! first column contains units !!!
+ tlts.clear();
+ if ( myOrientation == Horizontal ) {
+ for ( int i = 1; i < myTable->numCols(); i++ ) {
+ tlts.append( myTable->horizontalHeader()->label( i ) );
+ }
+ }
+ else {
+ for ( int i = 1; i < myTable->numRows(); i++ ) {
+ tlts.append( myTable->verticalHeader()->label( i ) );
+ }
+ }
+}
+/*!
+ Sets units title
+*/
+void VisuGUI_TableWidget::setUnitsTitle( const QString& tlt ) {
+ // !!! first column contains units !!!
+ myOrientation == Horizontal ? myTable->horizontalHeader()->setLabel( 0, tlt.isNull() ? "" : tlt ) : myTable->verticalHeader()->setLabel( 0, tlt.isNull() ? "" : tlt );
+}
+/*!
+ Sets units
+*/
+void VisuGUI_TableWidget::setUnits( QStringList& units )
+{
+ for ( int i = 0; i < units.count(); i++ ) {
+ myOrientation == Horizontal ? myTable->setText( i, 0, units[i].isNull() ? "" : units[i] ) : myTable->setText( 0, i, units[i].isNull() ? "" : units[i] );
+ }
+}
+/*!
+ Gets units
+*/
+void VisuGUI_TableWidget::getUnits( QStringList& units )
+{
+ units.clear();
+ if ( myOrientation == Horizontal ) {
+ for ( int i = 0; i < myTable->numRows(); i++ )
+ units.append( myTable->text( i, 0 ).isNull() ? QString("") : myTable->text( i, 0 ) );
+ }
+ else {
+ for ( int i = 0; i < myTable->numCols(); i++ )
+ units.append( myTable->text( 0, i ).isNull() ? QString("") : myTable->text( 0, i ) );
+ }
+}
+/*!
+ Sets row data
+*/
+void VisuGUI_TableWidget::setRowData( int row, QStringList& data )
+{
+ if ( row >= 0 && row < getNumRows() ) {
+ for ( int i = 0; i < data.count(); i++ ) {
+ if ( data[i].isNull() ) {
+ myOrientation == Horizontal ? myTable->clearCell( row, i+1 ) :
+ myTable->clearCell( i+1, row );
+ }
+ else {
+ myOrientation == Horizontal ? myTable->setText( row, i+1, data[i] ) :
+ myTable->setText( i+1, row, data[i] );
+ }
+ }
+ }
+}
+/*!
+ Gets row data
+*/
+void VisuGUI_TableWidget::getRowData( int row, QStringList& data )
+{
+ data.clear();
+ if ( row >= 0 && row < getNumRows() ) {
+ if ( myOrientation == Horizontal ) {
+ for ( int i = 1; i < myTable->numCols(); i++ )
+ data.append( myTable->text( row, i ) );
+ }
+ else {
+ for ( int i = 1; i < myTable->numRows(); i++ )
+ data.append( myTable->text( i, row ) );
+ }
+ }
+}
+/*!
+ Adjusts table cell to see contents, <Adjust Cells> button slot
+*/
+void VisuGUI_TableWidget::adjustTable()
+{
+ int i;
+ for ( i = 0; i < myTable->numRows(); i++ )
+ myTable->adjustRow( i );
+ for ( i = 0; i < myTable->numCols(); i++ )
+ myTable->adjustColumn( i );
+}
+/*!
+ Called when selection changed in table
+*/
+void VisuGUI_TableWidget::updateButtonsState()
+{
+ if ( myTable->isReadOnly() )
+ return;
+ bool bDR = false; // <Delete Row(s)>
+ bool bDC = false; // <Delete Column(s)>
+ bool bSA = false; // <Select All>
+ bool bCT = false; // <Clear>
+ int i;
+ int c = myOrientation == Horizontal ? 0 : 1;
+ for ( i = c; i < myTable->numRows(); i++ ) {
+ if ( myTable->isRowSelected( i, true ) )
+ bDR = true;
+ else
+ bSA = true;
+ }
+ c = myOrientation == Horizontal ? 1 : 0;
+ for ( i = c; i < myTable->numCols(); 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;
+ }
+ }
+ }
+ 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->insertRows( myTable->numRows(), 1 );
+ updateButtonsState();
+}
+/*!
+ <Add column> button slot
+*/
+void VisuGUI_TableWidget::addCol()
+{
+ myTable->insertColumns( myTable->numCols(), 1 );
+ updateButtonsState();
+}
+/*!
+ <Delete row(s)> button slot
+*/
+void VisuGUI_TableWidget::delRow()
+{
+ int c = myOrientation == Horizontal ? 0 : 1;
+ QValueList<int> il;
+ int i;
+ for ( i = c; i < myTable->numRows(); 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()
+{
+ int c = myOrientation == 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 );
+ 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 == Vertical && j == 0 ) {
+// continue; // UNITS
+ }
+ for ( int k = ts.leftCol(); k < ts.rightCol()+1; k++) {
+ if ( myOrientation == Horizontal && k == 0 ) {
+// continue; // UNITS
+ }
+ myTable->clearCell( j, k );
+ }
+ }
+ }
+ if ( nbSel == 0 )
+ myTable->clearCell( myTable->currentRow(), myTable->currentColumn() );
+ myTable->clearSelection();
+ updateButtonsState();
+}
+/*!
+ Event filter - handles titles editing
+*/
+bool VisuGUI_TableWidget::eventFilter( QObject* o, QEvent* e )
+{
+ if ( e->type() == QEvent::MouseButtonDblClick) {
+ QMouseEvent* me = ( QMouseEvent* )e;
+ if ( me->button() == LeftButton && !myTable->isReadOnly() ) {
+ 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 == 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 == 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() == Key_Delete && !myTable->isEditing() ) {
+ clearTable();
+ }
+ else if ( ke->key() == Key_Backspace && !myTable->isEditing() ) {
+ clearTable();
+ int i = myTable->currentRow();
+ int j = myTable->currentColumn() - 1;
+ if ( j < 0 ) { j = myTable->numCols()-1; i--; }
+ if ( i >= 0 && j >= 0 )
+ myTable->setCurrentCell( i, j );
+ }
+ }
+ return QWidget::eventFilter( o, e );
+}
+
+
+
--- /dev/null
+// VISU VISUGUI : GUI of VISU component
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : VisuGUI_TableDlg.h
+// Author : Vadim SANDLER
+// Module : VISU
+
+#ifndef VisuGUI_TABLE_DLG_H
+#define VisuGUI_TABLE_DLG_H
+
+#include <qdialog.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+
+class VisuGUI_Table;
+class VisuGUI_TableWidget;
+
+#include <SALOMEDSClient_SObject.hxx>
+
+class 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,
+ Orientation orient = Horizontal,
+ bool showColumnTitles = true );
+ ~VisuGUI_TableDlg();
+
+public slots:
+ void onOK();
+
+private:
+ void initDlg();
+
+private:
+ VisuGUI_TableWidget* myIntTable;
+ VisuGUI_TableWidget* myRealTable;
+ QPushButton* myOKBtn;
+ QPushButton* myCancelBtn;
+
+ _PTR(SObject) myObject;
+};
+
+class VisuGUI_TableWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ VisuGUI_TableWidget( QWidget* parent = 0,
+ const char* name = 0,
+ bool edit = false,
+ Orientation orient = 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 );
+
+ VisuGUI_Table* 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;
+ VisuGUI_Table* myTable;
+ QPushButton* myAddRowBtn;
+ QPushButton* myAddColBtn;
+ QPushButton* myDelRowBtn;
+ QPushButton* myDelColBtn;
+ QPushButton* myAdjustBtn;
+ QPushButton* mySelectAllBtn;
+ QPushButton* myClearBtn;
+ Orientation myOrientation;
+};
+
+#endif // VisuGUI_TABLE_DLG_H
+
@COMMENCE@
-SUBDIRS = CONVERTOR PIPELINE OBJECT ENGINE VISU_I VISUGUI VISU_SWIG
+SUBDIRS = CONVERTOR PIPELINE OBJECT ENGINE GUITOOLS VISU_I VISUGUI VISU_SWIG
@MODULE@
VisuGUI_CutLinesDlg.cxx \
VisuGUI_CutPlanesDlg.cxx \
VisuGUI_StreamLinesDlg.cxx \
- VisuGUI_VectorsDlg.cxx \
- VisuGUI_TableDlg.cxx
+ VisuGUI_VectorsDlg.cxx
LIB_MOC = VisuGUI.h \
VisuGUI_Selection.h \
VisuGUI_CutLinesDlg.h \
VisuGUI_CutPlanesDlg.h \
VisuGUI_StreamLinesDlg.h \
- VisuGUI_VectorsDlg.h \
- VisuGUI_TableDlg.h
+ VisuGUI_VectorsDlg.h
LIB_CLIENT_IDL = SALOME_Exception.idl \
VISU_Gen.idl \
-I${KERNEL_ROOT_DIR}/include/salome -I${GUI_ROOT_DIR}/include/salome
LDFLAGS += $(QWT_LIBS) -lSalomeNS \
- -lVisuObject -lVISUEngineImpl -lSVTK -lSPlot2d \
- -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome
+ -lSVTK -lSPlot2d -lVisuObject -lVISUEngineImpl -lVISUGUITOOLS \
+ -L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome
@CONCLUDE@
-
+++ /dev/null
-// VISU VISUGUI : GUI of VISU component
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
-// File : VisuGUI_TableDlg.cxx
-// Author : Vadim SANDLER
-// Module : SALOME
-
-#include "VisuGUI_TableDlg.h"
-
-#include "SUIT_Tools.h"
-#include "SUIT_MessageBox.h"
-
-#include "SALOMEDSClient_Study.hxx"
-#include "SALOMEDSClient_GenericAttribute.hxx"
-#include "SALOMEDSClient_AttributeTableOfInteger.hxx"
-#include "SALOMEDSClient_AttributeTableOfReal.hxx"
-#include "SALOMEDSClient_StudyBuilder.hxx"
-
-#include <qlayout.h>
-#include <qvalidator.h>
-#include <qtable.h>
-#include <qtabwidget.h>
-#include <qvaluelist.h>
-#include <qmemarray.h>
-#include <qinputdialog.h>
-#include <qlabel.h>
-#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
-
-
-class VisuGUI_Table : public QTable {
-public:
- VisuGUI_Table( Orientation orient, QWidget* parent = 0, const char* name = 0 )
- : QTable( parent, name ), myValidator( 0 ), myOrientation( orient ) {}
- VisuGUI_Table( Orientation orient, int numRows, int numCols, QWidget* parent = 0, const char* name = 0 )
- : QTable( numRows, numCols, parent, name ), 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 == Horizontal && col == 0 ) || ( myOrientation == 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,
- Orientation orient,
- bool showColumnTitles )
- : QDialog( parent, "", false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose),
- myIntTable( 0 ), myRealTable( 0 )
-{
- setCaption( 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, "TabWidget" );
- ( ( QTabWidget* ) top) ->setMargin( MARGIN_SIZE );
- }
- else {
- top = new QWidget( this, "DumbWidget" );
- 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 ) );
- 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 ) );
- 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" );
- dumbLabel->setAlignment( AlignCenter );
- tl->addWidget( dumbLabel );
- }
-
- QHBoxLayout* btnLayout = new QHBoxLayout;
- btnLayout->setMargin( 0 ); btnLayout->setSpacing( SPACING_SIZE );
-
- myOKBtn = new QPushButton( tr( "BUT_OK" ), 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 );
- connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( onOK() ) );
- connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
- }
- else {
- btnLayout->addItem( new QSpacerItem( SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
- btnLayout->addWidget( myOKBtn );
- btnLayout->addItem( new QSpacerItem( SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
- connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) );
- }
-
- 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() ? "" : rowTitles[ i ].latin1() );
- // set row unit
- tblIntAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? "" : units[ i ].latin1() );
- 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() ? "" : colTitles[ i ].latin1() );
- }
- }
- // title
- tblIntAttr->SetTitle( myIntTable->getTableTitle().latin1() );
- }
- 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() ? "" : rowTitles[ i ].latin1() );
- // set row unit
- tblRealAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? "" : units[ i ].latin1() );
- 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() ? "" : colTitles[ i ].latin1() );
- }
- }
- // title
- tblRealAttr->SetTitle( myRealTable->getTableTitle().latin1() );
- }
- 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::error1 ( this, tr("ERR_ERROR"), tr("ERR_APP_EXCEPTION"), tr ("BUT_OK") );
- }
- }
- }
- if ( done )
- accept();
-}
-
-/*!
- 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 !!!");
- }
- }
- }
-}
-
-/*!
- Constructor
-*/
-VisuGUI_TableWidget::VisuGUI_TableWidget( QWidget* parent,
- const char* name,
- bool edit,
- Orientation orient,
- bool showColumnTitles )
- : QWidget( parent, name ), myOrientation( orient )
-{
- QGridLayout* mainLayout = new QGridLayout( this );
- mainLayout->setMargin( 0 );
- mainLayout->setSpacing( SPACING_SIZE );
-
- myTitleEdit = new QLineEdit( this, "TitleEdit" );
- myTitleEdit->setAlignment( AlignCenter );
- myTitleEdit->setReadOnly( !edit );
- QFont fnt = myTitleEdit->font();
- fnt.setBold( true );
- myTitleEdit->setFont( fnt );
-
- myTable = new VisuGUI_Table( orient, this, "Table" );
- myTable->setNumRows( 5 );
- myTable->setNumCols( 5 );
- myTable->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
- myTable->setMinimumSize( MIN_TABLE_WIDTH, MIN_TABLE_HEIGHT );
- myTable->setSelectionMode( QTable::Single );
- myTable->setShowGrid( true );
- myTable->setColumnMovingEnabled( false );
- myTable->setRowMovingEnabled( false );
- myTable->setReadOnly( !edit );
- myTable->setDragEnabled( false );
- setUnitsTitle( tr( "UNITS_TLT" ) );
-
- if ( !showColumnTitles ) {
- if ( myOrientation == 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, "AddRowBtn" );
- myDelRowBtn = new QPushButton( tr( "REMOVE_ROW_BTN" ), this, "DelRowBtn" );
- myAddColBtn = new QPushButton( tr( "ADD_COLUMN_BTN" ), this, "AddColBtn" );
- myDelColBtn = new QPushButton( tr( "REMOVE_COLUMN_BTN" ), this, "DelColBtn" );
- myAdjustBtn = new QPushButton( tr( "ADJUST_CELLS_BTN" ), this, "AdjustBtn" );
- mySelectAllBtn = new QPushButton( tr( "SELECT_ALL_BTN" ), this, "SelectAllBtn" );
- myClearBtn = new QPushButton( tr( "CLEAR_BTN"), this, "ClearBtn" );
- 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 == Horizontal ? myTable->setNumRows( num ) : myTable->setNumCols( num );
-}
-/*!
- Gets total number of rows
-*/
-int VisuGUI_TableWidget::getNumRows()
-{
- return myOrientation == Horizontal ? myTable->numRows() : myTable->numCols();
-}
-/*!
- Sets total number of columns
-*/
-void VisuGUI_TableWidget::setNumCols( const int num )
-{
- // !!! first column contains units !!!
- myOrientation == Horizontal ? myTable->setNumCols( num+1 ) : myTable->setNumRows( num+1 );
-// myOrientation == Horizontal ? myTable->setColumnReadOnly( 0, true ) : myTable->setRowReadOnly( 0, true );
-}
-/*!
- Gets total number of columns
-*/
-int VisuGUI_TableWidget::getNumCols()
-{
- // !!! first column contains units !!!
- return myOrientation == Horizontal ? myTable->numCols()-1 : myTable->numRows()-1;
-}
-/*!
- Sets rows titles
-*/
-void VisuGUI_TableWidget::setRowTitles( QStringList& tlts )
-{
- for ( int i = 0; i < tlts.count(); i++ ) {
- myOrientation == Horizontal ?
- 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 == Horizontal ) {
- for ( int i = 0; i < myTable->numRows(); i++ ) {
- tlts.append( myTable->verticalHeader()->label( i ) );
- }
- }
- else {
- for ( int i = 0; i < myTable->numCols(); i++ ) {
- tlts.append( myTable->horizontalHeader()->label( i ) );
- }
- }
-}
-/*!
- Sets columns titles
-*/
-void VisuGUI_TableWidget::setColTitles( QStringList& tlts )
-{
- // !!! first column contains units !!!
- for ( int i = 0; i < tlts.count(); i++ ) {
- myOrientation == Horizontal ?
- myTable->horizontalHeader()->setLabel( i+1, tlts[i].isNull() ? "" : tlts[i] ) :
- myTable->verticalHeader()->setLabel( i+1, tlts[i].isNull() ? "" : tlts[i] );
- }
- setUnitsTitle( tr( "UNITS_TLT" ) );
-}
-/*!
- Sets columns titles
-*/
-void VisuGUI_TableWidget::getColTitles( QStringList& tlts )
-{
- // !!! first column contains units !!!
- tlts.clear();
- if ( myOrientation == Horizontal ) {
- for ( int i = 1; i < myTable->numCols(); i++ ) {
- tlts.append( myTable->horizontalHeader()->label( i ) );
- }
- }
- else {
- for ( int i = 1; i < myTable->numRows(); i++ ) {
- tlts.append( myTable->verticalHeader()->label( i ) );
- }
- }
-}
-/*!
- Sets units title
-*/
-void VisuGUI_TableWidget::setUnitsTitle( const QString& tlt ) {
- // !!! first column contains units !!!
- myOrientation == Horizontal ? myTable->horizontalHeader()->setLabel( 0, tlt.isNull() ? "" : tlt ) : myTable->verticalHeader()->setLabel( 0, tlt.isNull() ? "" : tlt );
-}
-/*!
- Sets units
-*/
-void VisuGUI_TableWidget::setUnits( QStringList& units )
-{
- for ( int i = 0; i < units.count(); i++ ) {
- myOrientation == Horizontal ? myTable->setText( i, 0, units[i].isNull() ? "" : units[i] ) : myTable->setText( 0, i, units[i].isNull() ? "" : units[i] );
- }
-}
-/*!
- Gets units
-*/
-void VisuGUI_TableWidget::getUnits( QStringList& units )
-{
- units.clear();
- if ( myOrientation == Horizontal ) {
- for ( int i = 0; i < myTable->numRows(); i++ )
- units.append( myTable->text( i, 0 ).isNull() ? QString("") : myTable->text( i, 0 ) );
- }
- else {
- for ( int i = 0; i < myTable->numCols(); i++ )
- units.append( myTable->text( 0, i ).isNull() ? QString("") : myTable->text( 0, i ) );
- }
-}
-/*!
- Sets row data
-*/
-void VisuGUI_TableWidget::setRowData( int row, QStringList& data )
-{
- if ( row >= 0 && row < getNumRows() ) {
- for ( int i = 0; i < data.count(); i++ ) {
- if ( data[i].isNull() ) {
- myOrientation == Horizontal ? myTable->clearCell( row, i+1 ) :
- myTable->clearCell( i+1, row );
- }
- else {
- myOrientation == Horizontal ? myTable->setText( row, i+1, data[i] ) :
- myTable->setText( i+1, row, data[i] );
- }
- }
- }
-}
-/*!
- Gets row data
-*/
-void VisuGUI_TableWidget::getRowData( int row, QStringList& data )
-{
- data.clear();
- if ( row >= 0 && row < getNumRows() ) {
- if ( myOrientation == Horizontal ) {
- for ( int i = 1; i < myTable->numCols(); i++ )
- data.append( myTable->text( row, i ) );
- }
- else {
- for ( int i = 1; i < myTable->numRows(); i++ )
- data.append( myTable->text( i, row ) );
- }
- }
-}
-/*!
- Adjusts table cell to see contents, <Adjust Cells> button slot
-*/
-void VisuGUI_TableWidget::adjustTable()
-{
- int i;
- for ( i = 0; i < myTable->numRows(); i++ )
- myTable->adjustRow( i );
- for ( i = 0; i < myTable->numCols(); i++ )
- myTable->adjustColumn( i );
-}
-/*!
- Called when selection changed in table
-*/
-void VisuGUI_TableWidget::updateButtonsState()
-{
- if ( myTable->isReadOnly() )
- return;
- bool bDR = false; // <Delete Row(s)>
- bool bDC = false; // <Delete Column(s)>
- bool bSA = false; // <Select All>
- bool bCT = false; // <Clear>
- int i;
- int c = myOrientation == Horizontal ? 0 : 1;
- for ( i = c; i < myTable->numRows(); i++ ) {
- if ( myTable->isRowSelected( i, true ) )
- bDR = true;
- else
- bSA = true;
- }
- c = myOrientation == Horizontal ? 1 : 0;
- for ( i = c; i < myTable->numCols(); 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;
- }
- }
- }
- 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->insertRows( myTable->numRows(), 1 );
- updateButtonsState();
-}
-/*!
- <Add column> button slot
-*/
-void VisuGUI_TableWidget::addCol()
-{
- myTable->insertColumns( myTable->numCols(), 1 );
- updateButtonsState();
-}
-/*!
- <Delete row(s)> button slot
-*/
-void VisuGUI_TableWidget::delRow()
-{
- int c = myOrientation == Horizontal ? 0 : 1;
- QValueList<int> il;
- int i;
- for ( i = c; i < myTable->numRows(); 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()
-{
- int c = myOrientation == 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 );
- 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 == Vertical && j == 0 ) {
-// continue; // UNITS
- }
- for ( int k = ts.leftCol(); k < ts.rightCol()+1; k++) {
- if ( myOrientation == Horizontal && k == 0 ) {
-// continue; // UNITS
- }
- myTable->clearCell( j, k );
- }
- }
- }
- if ( nbSel == 0 )
- myTable->clearCell( myTable->currentRow(), myTable->currentColumn() );
- myTable->clearSelection();
- updateButtonsState();
-}
-/*!
- Event filter - handles titles editing
-*/
-bool VisuGUI_TableWidget::eventFilter( QObject* o, QEvent* e )
-{
- if ( e->type() == QEvent::MouseButtonDblClick) {
- QMouseEvent* me = ( QMouseEvent* )e;
- if ( me->button() == LeftButton && !myTable->isReadOnly() ) {
- 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 == 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 == 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() == Key_Delete && !myTable->isEditing() ) {
- clearTable();
- }
- else if ( ke->key() == Key_Backspace && !myTable->isEditing() ) {
- clearTable();
- int i = myTable->currentRow();
- int j = myTable->currentColumn() - 1;
- if ( j < 0 ) { j = myTable->numCols()-1; i--; }
- if ( i >= 0 && j >= 0 )
- myTable->setCurrentCell( i, j );
- }
- }
- return QWidget::eventFilter( o, e );
-}
-
-
-
+++ /dev/null
-// VISU VISUGUI : GUI of VISU component
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
-// File : VisuGUI_TableDlg.h
-// Author : Vadim SANDLER
-// Module : VISU
-
-#ifndef VisuGUI_TABLE_DLG_H
-#define VisuGUI_TABLE_DLG_H
-
-#include <qdialog.h>
-#include <qlineedit.h>
-#include <qpushbutton.h>
-
-class VisuGUI_Table;
-class VisuGUI_TableWidget;
-
-#include <SALOMEDSClient_SObject.hxx>
-
-class 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,
- Orientation orient = Horizontal,
- bool showColumnTitles = true );
- ~VisuGUI_TableDlg();
-
-public slots:
- void onOK();
-
-private:
- void initDlg();
-
-private:
- VisuGUI_TableWidget* myIntTable;
- VisuGUI_TableWidget* myRealTable;
- QPushButton* myOKBtn;
- QPushButton* myCancelBtn;
-
- _PTR(SObject) myObject;
-};
-
-class VisuGUI_TableWidget : public QWidget
-{
- Q_OBJECT
-public:
- VisuGUI_TableWidget( QWidget* parent = 0,
- const char* name = 0,
- bool edit = false,
- Orientation orient = 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 );
-
- VisuGUI_Table* 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;
- VisuGUI_Table* myTable;
- QPushButton* myAddRowBtn;
- QPushButton* myAddColBtn;
- QPushButton* myDelRowBtn;
- QPushButton* myDelColBtn;
- QPushButton* myAdjustBtn;
- QPushButton* mySelectAllBtn;
- QPushButton* myClearBtn;
- Orientation myOrientation;
-};
-
-#endif // VisuGUI_TABLE_DLG_H
-
LDFLAGS += $(PYTHON_LIBS) $(QT_MT_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeNS -lTOOLSDS \
-lSalomeContainer -lOpUtil -lSalomeApp -lVTKViewer -lSVTK -lSPlot2d -lSalomeHDFPersist \
- -lVisuConvertor -lVisuPipeLine -lVisuObject -lSalomeGenericObj \
+ -lSalomeGenericObj -lVisuConvertor -lVisuPipeLine -lVisuObject -lVISUGUITOOLS \
-L${KERNEL_ROOT_DIR}/lib/salome -L${GUI_ROOT_DIR}/lib/salome -lEvent
LIBS+= -lPlot2d -L${KERNEL_ROOT_DIR}/lib/salome
// VISU OBJECT : interactive object for VISU entities implementation
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
// File : VISU_Gen_i.cc
#include "VISU_Table_i.hh"
#include "VISU_TimeAnimation.h"
+#include "VISU_Actor.h"
+
#include "HDFascii.hxx"
#include "SALOMEDS_Tool.hxx"
#include "SALOMEDSClient_AttributeName.hxx"
#include "SALOMEDSClient_AttributePixMap.hxx"
-#include "utilities.h"
+#include "SUIT_Session.h"
+#include "SalomeApp_Study.h"
+#include "SalomeApp_Application.h"
+#include "SalomeApp_SelectionMgr.h"
+#include "SVTK_ViewModel.h"
+#include "SVTK_ViewWindow.h"
+#include "SALOME_Event.hxx"
+#include "SALOME_ListIO.hxx"
+#include "SALOME_ListIteratorOfListIO.hxx"
-#include <strstream>
-#include <TCollection_AsciiString.hxx>
-#include <TColStd_SequenceOfAsciiString.hxx>
+#include "utilities.h"
-#include <omnithread.h>
+// IDL Headers
+#include <omnithread.h>
#include CORBA_SERVER_HEADER(SALOME_Session)
#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
+// QT Includes
#include <qstring.h>
#include <qfileinfo.h>
+
+// VTK Includes
+#include <vtkRenderer.h>
+#include <vtkActorCollection.h>
+
+// OCCT Includes
+#include <TCollection_AsciiString.hxx>
+#include <TColStd_SequenceOfAsciiString.hxx>
+
+// STL Includes
+#include <strstream>
+
#include "Utils_ExceptHandlers.hxx"
using namespace std;
UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
-extern "C" VISU::VISU_Gen_ptr GetImpl(CORBA::ORB_ptr theORB,
- PortableServer::POA_ptr thePOA,
- SALOME_NamingService* theNamingService,
+extern "C" VISU::VISU_Gen_ptr GetImpl(CORBA::ORB_ptr theORB,
+ PortableServer::POA_ptr thePOA,
+ SALOME_NamingService* theNamingService,
QMutex* theMutex)
{
if(MYDEBUG) MESSAGE("extern \"C\" GetImpl");
aStudyBuilder->NewCommand();
int aLocked = theStudyDocument->GetProperties()->IsLocked();
if (aLocked) theStudyDocument->GetProperties()->SetLocked(false);
- aSComponent = aStudyBuilder->NewComponent("VISU");
+ aSComponent = aStudyBuilder->NewComponent("VISU");
_PTR(GenericAttribute) anAttr =
aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
_PTR(AttributeName) aName (anAttr);
aStudyBuilder->CommitCommand();
}
return aSComponent;
- }
+ }
SALOMEDS::SComponent_var FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument){
SALOMEDS::SComponent_var aSComponent = theStudyDocument->FindComponent("VISU");
aStudyBuilder->NewCommand();
int aLocked = theStudyDocument->GetProperties()->IsLocked();
if (aLocked) theStudyDocument->GetProperties()->SetLocked(false);
- aSComponent = aStudyBuilder->NewComponent("VISU");
+ aSComponent = aStudyBuilder->NewComponent("VISU");
SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributePixMap");
SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
aPixmap->SetPixMap( "ICON_OBJBROWSER_Visu" );
-
+
VISU_Gen_var aVisuGen = Base_i::GetVisuGenImpl()->_this();
aStudyBuilder->DefineComponentInstance(aSComponent,aVisuGen);
if (aLocked) theStudyDocument->GetProperties()->SetLocked(true);
aStudyBuilder->CommitCommand();
}
return aSComponent;
- }
+ }
void RegistryStorable() {
Storable::Registry(Result_i::myComment.c_str(),&(Result_i::Restore));
//===========================================================================
- VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA,
+ VISU_Gen_i::VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA,
SALOME_NamingService* theNamingService, QMutex* theMutex) :
Engines_Component_i()
{
bool isMultiFile)
{
Mutex mt(myMutex);
- SALOMEDS::Study_var aStudy = theComponent->GetStudy();
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
+ SALOMEDS::Study_var aStudy = theComponent->GetStudy();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
const char* aDir = isMultiFile? theURL: SALOMEDS_Tool::GetTmpDir().c_str();
TCollection_AsciiString aTmpDir(const_cast<char*>(aDir));
VisuTmpDir = aTmpDir.ToCString();
CORBA::Boolean VISU_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
const SALOMEDS::TMPFile & theStream,
const char* theURL,
- bool isMultiFile)
+ bool isMultiFile)
{
return Load(theComponent, theStream, theURL, isMultiFile);
}
char* VISU_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
const char* aLocalPersistentID,
CORBA::Boolean isMultiFile,
- CORBA::Boolean isASCII)
+ CORBA::Boolean isASCII)
{
CORBA::String_var aString("");
if(strcmp(aLocalPersistentID,"") != 0) {
if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
int aCounter = 0;
TColStd_SequenceOfAsciiString aFileNames;
- SALOMEDS::Study_var aStudy = theComponent->GetStudy();
+ SALOMEDS::Study_var aStudy = theComponent->GetStudy();
//CORBA::Boolean anIsValidScript;
//Engines::TMPFile_var aDump = DumpPython(aStudy,false,anIsValidScript);
QString aFileName = aPrefix + "_" + (pResult->GetName()).c_str();
static QString aCommand;
aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1());
-
+
int aRes = system(aCommand);
if(aRes){
if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Cann't execute the command :"<<aCommand);
continue;
}else
if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aCommand = "<<aCommand);
-
+
TCollection_AsciiString aString(strdup(aFileName.latin1()));
aFileNames.Append(aString);
}}
SALOMEDS::TMPFile* VISU_Gen_i::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
const char* theURL,
- bool isMultiFile)
+ bool isMultiFile)
{
Mutex mt(myMutex);
const char* aDir = isMultiFile? theURL: SALOMEDS_Tool::GetTmpDir().c_str();
if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
int aCounter = 0;
TColStd_SequenceOfAsciiString aFileNames;
- SALOMEDS::Study_var aStudy = theComponent->GetStudy();
+ SALOMEDS::Study_var aStudy = theComponent->GetStudy();
SALOMEDS::ChildIterator_var itBig = aStudy->NewChildIterator(theComponent);
for (; itBig->More(); itBig->Next()) {
SALOMEDS::SObject_var gotBranch = itBig->Value();
aCommand.sprintf("cp %s %s%s",aFileInfo.filePath().latin1(),aTmpDir.ToCString(),aFileName.latin1());
int aRes = system(aCommand);
- if(aRes){
+ if(aRes){
if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - Can't execute the command :"<<aCommand);
continue;
}else
if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aCommand);
TCollection_AsciiString aString(strdup(aFileName.latin1()));
-
+
HDFascii::ConvertFromHDFToASCII(strdup((aTmpDir + aString).ToCString()), true);
-
+
aFileNames.Append(aString);
}}
}
char* VISU_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
const char* IORString,
CORBA::Boolean isMultiFile,
- CORBA::Boolean isASCII)
+ CORBA::Boolean isASCII)
{
CORBA::String_var aString(IORString);
- if(strcmp(IORString,"") != 0){
+ if(strcmp(IORString,"") != 0){
CORBA::ORB_ptr anORB = GetORB();
CORBA::Object_var anObj = anORB->string_to_object(aString);
if(!CORBA::is_nil(anObj)){
}
SALOMEDS::SObject_ptr VISU_Gen_i::ImportTables(const char* theFileName){
- if(myStudyDocument->GetProperties()->IsLocked())
+ if(myStudyDocument->GetProperties()->IsLocked())
return SALOMEDS::SObject::_nil();
Mutex mt(myMutex);
SALOMEDS::SObject_var aRes = VISU::ImportTables(theFileName,myStudyDocument);
}
Result_ptr VISU_Gen_i::ImportFile(const char* theFileName){
- if(myStudyDocument->GetProperties()->IsLocked())
+ if(myStudyDocument->GetProperties()->IsLocked())
return Result::_nil();
Mutex mt(myMutex);
aFileInfo.setFile(theFileName);
Result_i* pResult = new Result_i(myStudyDocument,
Result_i::eFile,
Result_i::eImportFile);
- if(pResult->Create(theFileName) != NULL)
+ if(pResult->Create(theFileName) != NULL)
return pResult->_this();
else{
pResult->_remove_ref();
}
Result_ptr VISU_Gen_i::CopyAndImportFile(const char* theFileName){
- if(myStudyDocument->GetProperties()->IsLocked())
+ if(myStudyDocument->GetProperties()->IsLocked())
return Result::_nil();
Mutex mt(myMutex);
VISU::Result_var aResult;
Result_i* pResult = new Result_i(myStudyDocument,
Result_i::eRestoredFile,
Result_i::eCopyAndImportFile);
- if(pResult->Create(theFileName) != NULL)
+ if(pResult->Create(theFileName) != NULL)
aResult = pResult->_this();
return aResult._retn();
}
Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject){
- if(myStudyDocument->GetProperties()->IsLocked())
+ if(myStudyDocument->GetProperties()->IsLocked())
return Result::_nil();
Mutex mt(myMutex);
Result_i* pResult = new Result_i(myStudyDocument,
}
Result_ptr VISU_Gen_i::ImportMedField(SALOME_MED::FIELD_ptr theField){
- if(myStudyDocument->GetProperties()->IsLocked())
+ if(myStudyDocument->GetProperties()->IsLocked())
return Result::_nil();
Mutex mt(myMutex);
Result_i* pResult = new Result_i(myStudyDocument,
}
}
- Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult,
- const char* theMeshName,
+ Mesh_ptr VISU_Gen_i::MeshOnEntity(Result_ptr theResult,
+ const char* theMeshName,
VISU::Entity theEntity)
{
- if(myStudyDocument->GetProperties()->IsLocked())
+ if(myStudyDocument->GetProperties()->IsLocked())
return Mesh::_nil();
Mutex mt(myMutex);
if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
return VISU::Mesh::_nil();
}
- Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
+ Mesh_ptr VISU_Gen_i::FamilyMeshOnEntity(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
const char* theFamilyName)
{
- if(myStudyDocument->GetProperties()->IsLocked())
+ if(myStudyDocument->GetProperties()->IsLocked())
return Mesh::_nil();
Mutex mt(myMutex);
if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
return VISU::Mesh::_nil();
}
- Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult,
- const char* theMeshName,
+ Mesh_ptr VISU_Gen_i::GroupMesh(Result_ptr theResult,
+ const char* theMeshName,
const char* theGroupName)
{
- if(myStudyDocument->GetProperties()->IsLocked())
+ if(myStudyDocument->GetProperties()->IsLocked())
return Mesh::_nil();
Mutex mt(myMutex);
if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(theResult).in())){
return VISU::Mesh::_nil();
}
- ScalarMap_ptr VISU_Gen_i::ScalarMapOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
+ ScalarMap_ptr VISU_Gen_i::ScalarMapOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
CORBA::Double theIteration)
{
return Prs3dOnField<VISU::ScalarMap_i>(theResult,theMeshName,theEntity,theFieldName,theIteration,true)._retn();
}
- DeformedShape_ptr VISU_Gen_i::DeformedShapeOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
+ DeformedShape_ptr VISU_Gen_i::DeformedShapeOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
CORBA::Double theIteration)
{
return Prs3dOnField<VISU::DeformedShape_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
- Vectors_ptr VISU_Gen_i::VectorsOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
+ Vectors_ptr VISU_Gen_i::VectorsOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
CORBA::Double theIteration)
{
return Prs3dOnField<VISU::Vectors_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
- IsoSurfaces_ptr VISU_Gen_i::IsoSurfacesOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
+ IsoSurfaces_ptr VISU_Gen_i::IsoSurfacesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
CORBA::Double theIteration)
{
return Prs3dOnField<VISU::IsoSurfaces_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
- StreamLines_ptr VISU_Gen_i::StreamLinesOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
+ StreamLines_ptr VISU_Gen_i::StreamLinesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
CORBA::Double theIteration)
{
return Prs3dOnField<VISU::StreamLines_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
- CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
+ CutPlanes_ptr VISU_Gen_i::CutPlanesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
CORBA::Double theIteration)
{
return Prs3dOnField<VISU::CutPlanes_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
- CutLines_ptr VISU_Gen_i::CutLinesOnField(Result_ptr theResult,
- const char* theMeshName,
- VISU::Entity theEntity,
- const char* theFieldName,
+ CutLines_ptr VISU_Gen_i::CutLinesOnField(Result_ptr theResult,
+ const char* theMeshName,
+ VISU::Entity theEntity,
+ const char* theFieldName,
CORBA::Double theIteration)
{
return Prs3dOnField<VISU::CutLines_i>(theResult,theMeshName,theEntity,theFieldName,theIteration)._retn();
}
Table_ptr VISU_Gen_i::CreateTable(const char* theTableEntry){
- if(myStudyDocument->GetProperties()->IsLocked())
+ if(myStudyDocument->GetProperties()->IsLocked())
return Table::_nil();
Mutex mt(myMutex);
Table_i* pPresent = new Table_i(myStudyDocument,theTableEntry);
}
}
- Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable,
- CORBA::Long theHRow,
+ Curve_ptr VISU_Gen_i::CreateCurve(Table_ptr theTable,
+ CORBA::Long theHRow,
CORBA::Long theVRow)
{
- if(myStudyDocument->GetProperties()->IsLocked())
+ if(myStudyDocument->GetProperties()->IsLocked())
return Curve::_nil();
Mutex mt(myMutex);
PortableServer::POA_ptr aPOA = GetPOA();
}
Container_ptr VISU_Gen_i::CreateContainer(){
- if(myStudyDocument->GetProperties()->IsLocked())
+ if(myStudyDocument->GetProperties()->IsLocked())
return Container::_nil();
Mutex mt(myMutex);
Container_i* pPresent = new Container_i(myStudyDocument);
}
Animation_ptr VISU_Gen_i::CreateAnimation(View3D_ptr theView3D){
- if(myStudyDocument->GetProperties()->IsLocked())
+ if(myStudyDocument->GetProperties()->IsLocked())
return Animation::_nil();
Mutex mt(myMutex);
if(VISU_TimeAnimation_i* anAnim = new VISU_TimeAnimation_i(myStudyDocument,theView3D)){
return VISU::Animation::_nil();
}
+ void DeletePrs3d (Prs3d_ptr thePrs3d)
+ {
+ Prs3d_i* aPrs3d = dynamic_cast<Prs3d_i*>(GetServant(thePrs3d).in());
+ if (!aPrs3d)
+ return;
+
+ // 1. Find appropriate application (code like in VISU_ViewManager_i.cxx)
+ SALOMEDS::Study_var myStudyDocument = aPrs3d->GetStudyDocument();
+ SalomeApp_Application* anApp = NULL;
+ CORBA::String_var studyName = myStudyDocument->Name();
+ std::string aStudyName = studyName.in();
+ SUIT_Session* aSession = SUIT_Session::session();
+ QPtrList<SUIT_Application> anApplications = aSession->applications();
+ QPtrListIterator<SUIT_Application> anIter (anApplications);
+ while (SUIT_Application* aSUITApp = anIter.current()) {
+ ++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;
+ }
+ }
+ }
+ }
+ }
+ if (!anApp)
+ return;
+
+ // 2. Remove corresponding IO from selection
+ SALOMEDS::SObject_var aSObject = aPrs3d->GetSObject();
+ CORBA::String_var anEntry = aSObject->GetID();
+
+ SalomeApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr();
+ SALOME_ListIO aListIO, aNewListIO;
+ aSelectionMgr->selectedObjects(aListIO);
+
+ for (SALOME_ListIteratorOfListIO it (aListIO); it.More(); it.Next()) {
+ if (it.Value()->hasEntry()) {
+ std::string aCurEntry (it.Value()->getEntry());
+ if (aCurEntry != anEntry) {
+ aNewListIO.Append(it.Value());
+ }
+ }
+ }
+
+ aSelectionMgr->setSelectedObjects(aNewListIO);
+
+ // 3. Remove Actors
+ ViewManagerList aViewManagerList;
+ anApp->viewManagers(SVTK_Viewer::Type(), aViewManagerList);
+ QPtrListIterator<SUIT_ViewManager> anVMIter (aViewManagerList);
+ for (; anVMIter.current(); ++anVMIter) {
+ SUIT_ViewManager* aViewManager = anVMIter.current();
+ QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
+ for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
+ if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
+ if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
+ //VISU_Actor* anActor = aVISUViewManager->GetActor(aPrs3d, vw);
+ VISU_Actor* anActor = NULL;
+ vtkActorCollection *anActColl = vw->getRenderer()->GetActors();
+ anActColl->InitTraversal();
+ vtkActor *aVTKActor = anActColl->GetNextActor();
+ for (; !anActor && aVTKActor; aVTKActor = anActColl->GetNextActor()) {
+ if (VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(aVTKActor)) {
+ if (aPrs3d == anVISUActor->GetPrs3d()) {
+ anActor = anVISUActor->GetParent();
+ }
+ }
+ }
+ if (anActor) {
+ vw->RemoveActor(anActor);
+ anActor->Delete();
+ }
+ }
+ }
+ }
+ }
+
+ aPrs3d->RemoveFromStudy();
+ aPrs3d->Destroy();
+
+ //jfa tmp:theModule->updateObjBrowser(); //update Object browser
+ }
+
+ void VISU_Gen_i::DeleteResult (Result_ptr theResult)
+ {
+ class TEvent: public SALOME_Event {
+ Result_ptr myResult;
+ public:
+ TEvent(Result_ptr theResult): myResult(theResult) {}
+ virtual void Execute(){
+ if (Result_i* aResult = dynamic_cast<Result_i*>(GetServant(myResult).in())) {
+ SALOMEDS::SObject_var aSObject = aResult->GetSObject();
+ SALOMEDS::Study_var aStudyDocument = aSObject->GetStudy();
+ SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->NewChildIterator(aSObject);
+ for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
+ SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
+ CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
+ if(CORBA::is_nil(aChildObj)) continue;
+ VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
+ if(CORBA::is_nil(aPrs3d)) continue;
+ VISU::DeletePrs3d(aPrs3d);
+ }
+
+ aResult->RemoveFromStudy();
+ aResult->Destroy();
+
+ //jfa tmp:if (QAD_Desktop* aDesktop = QAD_Application::getDesktop())
+ //jfa tmp: if (QAD_Study* aStudy = aDesktop->findStudy(aStudyDocument))
+ //jfa tmp: aStudy->updateObjBrowser(); //update Object browser
+ }
+ }
+ };
+
+ if (myStudyDocument->GetProperties()->IsLocked())
+ return;
+ Mutex mt(myMutex); // jfa ???
+
+ ProcessVoidEvent(new TEvent(theResult));
+ }
+
+ void VISU_Gen_i::DeletePrs3d (Prs3d_ptr thePrs3d)
+ {
+ class TEvent: public SALOME_Event {
+ Prs3d_ptr myPrs3d;
+ public:
+ TEvent(Prs3d_ptr thePrs3d): myPrs3d(thePrs3d) {}
+ virtual void Execute() {
+ VISU::DeletePrs3d(myPrs3d);
+ }
+ };
+
+ if (myStudyDocument->GetProperties()->IsLocked())
+ return;
+ Mutex mt(myMutex); // jfa ???
+
+ ProcessVoidEvent(new TEvent(thePrs3d));
+ }
+
void VISU_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent){
}
SALOMEDS::SObject_ptr VISU_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject,
CORBA::Object_ptr theObject,
- const char* theName)
- throw (SALOME::SALOME_Exception)
+ const char* theName)
+ throw (SALOME::SALOME_Exception)
{
Unexpect aCatch(SalomeException);
if(MYDEBUG) MESSAGE("VISU_Gen_i::PublishInStudy : "<<myMutex);
aResultSO = theStudy->FindObjectID(anEntry);
return aResultSO._retn();
}
-
+
CORBA::Boolean VISU_Gen_i::CanCopy(SALOMEDS::SObject_ptr theObject) {
Mutex mt(myMutex);
SALOMEDS::GenericAttribute_var anAttr;
if(Result_i* pResult = dynamic_cast<Result_i*>(GetServant(aResultObj).in())){
switch(pResult->GetCreationId()){
case Result_i::eImportFile:
- case Result_i::eCopyAndImportFile:
+ case Result_i::eCopyAndImportFile:
return true;
}
}
SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
PortableServer::POA_ptr aPOA = GetPOA();
-
+
SALOMEDS::GenericAttribute_var anAttr;
if (!theObject->FindAttribute(anAttr,"AttributeIOR")) return NULL;
SALOMEDS::AttributeIOR_var anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
if (CORBA::is_nil(aCorbaObj)) {
return NULL;
}
-
+
Storable* pStorable = dynamic_cast<Storable*>(GetServant(aCorbaObj).in());
if (!pStorable) {
return NULL;
string aStr = pStorable->ToString().c_str();
stmOut2<<aStr<<endl;
stmOut2.close();
-
+
if (Result_i* aResultObj = dynamic_cast<Result_i*>(aPOA->reference_to_servant(aCorbaObj))) {
string aFileName = string(SALOMEDS_Tool::GetNameFromPath(theObject->GetStudy()->URL())) + "_";
if(strlen(aFileName.c_str()) == 1) aFileName="";
aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), false);
SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true);
-
+
// Assign an ID = 1 the the type VISU::Result
theObjectID = 1;
-
-
+
+
SALOMEDS::SComponent_var aSComponent = theObject->GetStudy()->FindComponent("VISU");
return aStreamFile._retn();
}
CORBA::Boolean VISU_Gen_i::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
// The VISU component can paste only objects copied by VISU component
// and with the object type = 1
- if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1)
+ if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1)
return false;
return true;
}
SALOMEDS::SObject_ptr VISU_Gen_i::PasteInto(const SALOMEDS::TMPFile& theStream,
CORBA::Long theObjectID,
- SALOMEDS::SObject_ptr theObject)
+ SALOMEDS::SObject_ptr theObject)
{
Mutex mt(myMutex);
SALOMEDS::SObject_var aResultSO;
- if (theObjectID != 1)
+ if (theObjectID != 1)
return aResultSO._retn();
string aTmpDir = SALOMEDS_Tool::GetTmpDir();
SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir.c_str(), false);
-
+
ifstream stmIn((aTmpDir + string("copy_persistent")).c_str());
stmIn.seekg(0, ios::end);
int aLength = stmIn.tellg();
stmIn.read(aString, aLength);
aString[aLength] = 0;
myIsMultiFile = false;
-
+
string aFileName(aTmpDir);
string aBasicFileName;
if(aSeq->length() > 1) {
SALOMEDS::Study_var aStudy = theObject->GetStudy();
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
CORBA::String_var aComponentID(aComponent->GetID()), aSObjID(theObject->GetID());
-
+
if (strcmp(aComponentID, aSObjID) == 0) //create the new result SObject
aResultSO = aStudyBuilder->NewObject(aComponent);
- else
+ else
aResultSO = SALOMEDS::SObject::_duplicate(theObject);
-
+
//Just for Result::Restore to find the Comment attribute :(
SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeComment");
-
+
Storable* aStorable = Storable::Create(aResultSO,aFileName,aString);
-
+
SALOMEDS::ListOfFileNames_var aSeqToRm = new SALOMEDS::ListOfFileNames;
aSeqToRm->length(1);
aSeqToRm[0] = "copy_persistent";
SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeqToRm.in(), true);
-
+
anAttr = aStudyBuilder->FindOrCreateAttribute(aResultSO, "AttributeIOR");
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
CORBA::String_var anIORValue(aStorable->GetID());
// File : VISU_GEN_i.h file
// Author : Alexey Petrov
// Module : VISU
-// $Header:
+// $Header:
#ifndef __VISU_GEN_I_H__
#define __VISU_GEN_I_H__
VISU_Gen_i();
VISU_Gen_i(const VISU::VISU_Gen_i &);
public:
- VISU_Gen_i(CORBA::ORB_ptr theORB,
- PortableServer::POA_ptr thePOA,
- SALOME_NamingService* theNamingService,
+ VISU_Gen_i(CORBA::ORB_ptr theORB,
+ PortableServer::POA_ptr thePOA,
+ SALOME_NamingService* theNamingService,
QMutex* theMutex);
virtual ~VISU_Gen_i();
//Create Presentation Of Submeshes
virtual Mesh_ptr MeshOnEntity(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity);
- virtual Mesh_ptr FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName,
+ virtual Mesh_ptr FamilyMeshOnEntity(Result_ptr theResult, const char* theMeshName,
VISU::Entity theEntity, const char* theFamilyName);
virtual Mesh_ptr GroupMesh(Result_ptr theResult, const char* theMeshName, const char* theGroupName);
//Create 3D collored Presentation Of Different Types
- template<typename TPrs3d_i> typename TPrs3d_i::TInterface::_var_type
- Prs3dOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+ template<typename TPrs3d_i> typename TPrs3d_i::TInterface::_var_type
+ Prs3dOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
const char* theFieldName, CORBA::Double theIteration, bool theAddToStudy = true)
{
typedef typename TPrs3d_i::TInterface TPrs3d;
return TPrs3d::_nil();
}
- virtual ScalarMap_ptr ScalarMapOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+ virtual ScalarMap_ptr ScalarMapOnField(Result_ptr theResult,
+ const char* theMeshName, VISU::Entity theEntity,
const char* theFieldName, CORBA::Double theIteration);
- virtual DeformedShape_ptr DeformedShapeOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+ virtual DeformedShape_ptr DeformedShapeOnField(Result_ptr theResult,
+ const char* theMeshName, VISU::Entity theEntity,
const char* theFieldName, CORBA::Double theIteration);
- virtual Vectors_ptr VectorsOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+ virtual Vectors_ptr VectorsOnField(Result_ptr theResult,
+ const char* theMeshName, VISU::Entity theEntity,
const char* theFieldName, CORBA::Double theIteration);
- virtual IsoSurfaces_ptr IsoSurfacesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+ virtual IsoSurfaces_ptr IsoSurfacesOnField(Result_ptr theResult,
+ const char* theMeshName, VISU::Entity theEntity,
const char* theFieldName, CORBA::Double theIteration);
- virtual CutPlanes_ptr CutPlanesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+ virtual CutPlanes_ptr CutPlanesOnField(Result_ptr theResult,
+ const char* theMeshName, VISU::Entity theEntity,
const char* theFieldName, CORBA::Double theIteration);
- virtual CutLines_ptr CutLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+ virtual CutLines_ptr CutLinesOnField(Result_ptr theResult,
+ const char* theMeshName, VISU::Entity theEntity,
const char* theFieldName, CORBA::Double theIteration);
- virtual StreamLines_ptr StreamLinesOnField(Result_ptr theResult, const char* theMeshName, VISU::Entity theEntity,
+ virtual StreamLines_ptr StreamLinesOnField(Result_ptr theResult,
+ const char* theMeshName, VISU::Entity theEntity,
const char* theFieldName, CORBA::Double theIteration);
//Create Digital Presentation
virtual Table_ptr CreateTable(const char* theTableEntry);
virtual Curve_ptr CreateCurve(Table_ptr theTable, CORBA::Long theHRow, CORBA::Long theVRow);
virtual Container_ptr CreateContainer();
virtual Animation_ptr CreateAnimation(View3D_ptr theView3d);
-
- virtual void DeleteResult(Result_ptr theResult) {} // apo
- virtual void DeletePrs3d(Prs3d_ptr thePrs3d) {} // apo
+
+ virtual void DeleteResult(Result_ptr theResult);
+ virtual void DeletePrs3d(Prs3d_ptr thePrs3d);
// inherited methods from Engines::Component
- virtual
- Engines::TMPFile*
+ virtual
+ Engines::TMPFile*
DumpPython(CORBA::Object_ptr theStudy,
CORBA::Boolean theIsPublished,
CORBA::Boolean& theIsValidScript);
const char* theURL,
bool isMultiFile);
- virtual void Close(SALOMEDS::SComponent_ptr IORSComponent);
+ virtual void Close(SALOMEDS::SComponent_ptr IORSComponent);
virtual char* ComponentDataType();
const char* aLocalPersistentID,
CORBA::Boolean isMultiFile,
CORBA::Boolean isASCII);
-
+
virtual bool CanPublishInStudy(CORBA::Object_ptr theIOR);
virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject,
SALOMEDS::SObject_ptr theObject);
};
}
-#endif
+#endif
#include "VISU_Table_i.hh"
#include "VISU_ViewManager_i.hh"
+#include "VisuGUI_TableDlg.h"
+
#include "VISU_Actor.h"
#include "SALOME_Event.hxx"
#include "SVTK_ViewWindow.h"
#include "SVTK_ViewModel.h"
+#include "SPlot2d_ViewModel.h"
+
#include "Plot2d_ViewFrame.h"
#include "Plot2d_ViewModel.h"
} else {
myViewWindow = myViewManager->getActiveView();
}
- //jfa tmp:myView = dynamic_cast<Plot2d_ViewFrame*>(myViewWindow->getRightFrame()->getViewFrame());
- //jfa tmp:myView->Repaint();
+ ////myView = dynamic_cast<Plot2d_ViewFrame*>(myViewWindow->getRightFrame()->getViewFrame());
+ //SPlot2d_Viewer* aView = dynamic_cast<SPlot2d_Viewer*>(myViewManager->getViewModel());
+ //myView = aView->getActiveViewFrame();
+ if (myViewWindow) {
+ Plot2d_ViewWindow* aPlot2dVW = dynamic_cast<Plot2d_ViewWindow*>(myViewWindow);
+ if (aPlot2dVW) {
+ myView = aPlot2dVW->getViewFrame();
+ if (myView) {
+ myView->Repaint();
+ }
+ }
+ }
return this;
}
class TXYPlotViewEvent: public SALOME_Event
{
- _PTR(Study) myStudy;
- Plot2d_ViewFrame* myView;
- PrsObject_ptr myPrsObj;
- int myDisplaing;
+ SalomeApp_Application* myApplication;
+ Plot2d_ViewFrame* myView;
+ PrsObject_ptr myPrsObj;
+ int myDisplaing;
public:
- TXYPlotViewEvent(_PTR(Study) theStudy,
- Plot2d_ViewFrame* theView,
- PrsObject_ptr thePrsObj,
- int theDisplaing)
- : myStudy(theStudy),
+ TXYPlotViewEvent(SalomeApp_Application* theApplication,
+ Plot2d_ViewFrame* theView,
+ PrsObject_ptr thePrsObj,
+ int theDisplaing)
+ : myApplication(theApplication),
myView(theView),
myPrsObj(thePrsObj),
myDisplaing(theDisplaing)
}
// is it Table ?
if (Table_i* aTable = dynamic_cast<Table_i*>(VISU::GetServant(myPrsObj).in())) {
- _PTR(SObject) TableSO = myStudy->FindObjectID(aTable->GetEntry().latin1());
+ _PTR(Study) aCStudy;
+ if (SUIT_Study* aSStudy = myApplication->activeStudy()) {
+ if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
+ aCStudy = aStudy->studyDS();
+ }
+ }
+ if (!aCStudy) return;
+ _PTR(SObject) TableSO = aCStudy->FindObjectID(aTable->GetEntry().latin1());
if (TableSO) {
- _PTR(ChildIterator) Iter = myStudy->NewChildIterator(TableSO);
+ _PTR(ChildIterator) Iter = aCStudy->NewChildIterator(TableSO);
for (; Iter->More(); Iter->Next()) {
CORBA::Object_var childObject = VISU::ClientSObjectToObject(Iter->Value());
if (!CORBA::is_nil(childObject)) {
void XYPlot_i::Display (PrsObject_ptr thePrsObj)
{
- //jfa tmp:ProcessVoidEvent(new TXYPlotViewEvent (myStudy,myView,thePrsObj,eDisplay));
+ ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplay));
}
void XYPlot_i::Erase (PrsObject_ptr thePrsObj)
{
- //jfa tmp:ProcessVoidEvent(new TXYPlotViewEvent (myStudy,myView,thePrsObj,eErase));
+ ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eErase));
}
void XYPlot_i::DisplayOnly (PrsObject_ptr thePrsObj)
{
- //jfa tmp:ProcessVoidEvent(new TXYPlotViewEvent (myStudy,myView,thePrsObj,eDisplayOnly));
+ ProcessVoidEvent(new TXYPlotViewEvent (myApplication,myView,thePrsObj,eDisplayOnly));
}
void XYPlot_i::EraseAll()
//===========================================================================
TableView_i::TableView_i (SalomeApp_Application* theApplication)
- : View_i(theApplication, theApplication->getViewManager("???"/*jfa tmp*/, true))
+ : View_i(theApplication, NULL)
{
}
VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(theTable).in());
if (MYDEBUG) MESSAGE("TableView_i::Create - dynamic_cast = " << table);
if (table != NULL) {
-
- if (SUIT_Study* aSStudy = myViewManager->study()) {
+ 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(table->GetObjectEntry());
if (aSObject) {
- //jfa tmp:myView = new SALOMEGUI_TableDlg (QAD_Application::getDesktop(),
- //jfa tmp: aSObject,
- //jfa tmp: false,
- //jfa tmp: SALOMEGUI_TableDlg::ttAuto,
- //jfa tmp: Qt::Vertical);
- //jfa tmp:myView->show();
+ myView = new VisuGUI_TableDlg (myApplication->desktop(),
+ aSObject,
+ false,
+ VisuGUI_TableDlg::ttAuto,
+ Qt::Vertical);
+ myView->show();
return this;
}
}
TableView_i::~TableView_i()
{
if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
- //jfa tmp:delete myView;
+ delete myView;
}
void TableView_i::SetTitle (const char* theTitle)
{
- //jfa tmp:ProcessVoidEvent(new TVoidMemFun1ArgEvent<SALOMEGUI_TableDlg,const QString&,QString>
- //jfa tmp: (myView, &SALOMEGUI_TableDlg::setCaption, QString(theTitle)));
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<VisuGUI_TableDlg,const QString&,QString>
+ (myView, &VisuGUI_TableDlg::setCaption, QString(theTitle)));
}
char* TableView_i::GetTitle()
{
- //jfa tmp:return CORBA::string_dup(myView->caption().latin1());
+ return CORBA::string_dup(myView->caption().latin1());
return "";
}
void TableView_i::Close()
{
- //jfa tmp:myView->close();
+ myView->close();
}
CORBA::Boolean View3D_i::SavePicture (const char* theFileName)
{
- //jfa tmp:return ProcessEvent(new TSavePictureEvent
- //jfa tmp: (myView->getViewWidget(), theFileName));
+ //jfa tmp:return ProcessEvent(new TSavePictureEvent(myView->getViewWidget(), theFileName));
return false;
}
class QWidget;
+class VisuGUI_TableDlg;
+
class SalomeApp_Application;
class SUIT_ViewManager;
class View_i : public virtual POA_VISU::View,
public virtual Storable
{
- SalomeApp_Application *myApplication;
-
public:
- QWidget* myWorkspace;
- SUIT_ViewWindow* myViewWindow;
+ QWidget *myWorkspace;
+ SUIT_ViewWindow *myViewWindow;
protected:
- SUIT_ViewManager* myViewManager;
+ SalomeApp_Application *myApplication;
+ SUIT_ViewManager *myViewManager;
View_i (SalomeApp_Application *theApplication,
SUIT_ViewManager* theViewManager);
virtual void Close();
protected:
- //SALOMEGUI_TableDlg* myView;
+ VisuGUI_TableDlg* myView;
public:
virtual Storable* Create (VISU::Table_ptr theTable);
};
print "myView.FitAll()"
myView.FitAll();
+aWidth = myView.GetViewWidth()
+print "a View Width before = ", aWidth
+myView.SetViewWidth(aWidth/2)
+aWidth = myView.GetViewWidth()
+print "a View Width after = ", aWidth
myView = myViewManager.Create3DView();