--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef TABLEVIEWER_H
+#define TABLEVIEWER_H
+
+#if defined TABLEVIEWER_EXPORTS
+#if defined WIN32
+#define TABLEVIEWER_EXPORT __declspec( dllexport )
+#else
+#define TABLEVIEWER_EXPORT
+#endif
+#else
+#if defined WIN32
+#define TABLEVIEWER_EXPORT __declspec( dllimport )
+#else
+#define TABLEVIEWER_EXPORT
+#endif
+#endif
+
+#if defined SOLARIS
+#define bool int
+#define false 0
+#define true 1
+#endif
+
+#if defined WIN32
+#pragma warning ( disable: 4251 )
+#endif
+
+#if defined ( _DEBUG ) || defined ( DEBUG )
+#include <assert.h>
+#define TABLEVIEWER_VERIFY(x) assert( x );
+#define TABLEVIEWER_ASSERT(x) assert( x );
+#else
+#define TABLEVIEWER_VERIFY(x) x
+#define TABLEVIEWER_ASSERT(x)
+#endif
+
+#endif
--- /dev/null
+TEMPLATE = lib
+
+DESTDIR = ../../$(CONFIG_ID)/lib
+MOC_DIR = ../../moc
+OBJECTS_DIR = ../../$(CONFIG_ID)/obj/$$TARGET
+
+CASROOT = $$(CASROOT)
+CAS_CPPFLAGS = $${CASROOT}/inc
+CAS_KERNEL = -L$${CASROOT}/Linux/lib -lTKernel
+
+INCLUDEPATH = ../../include $${CAS_CPPFLAGS}
+LIBS += -L../../$(CONFIG_ID)/lib -lSUIT $${CAS_KERNEL} -lHTMLService
+
+CONFIG -= debug release debug_and_release
+CONFIG += qt thread debug dll shared
+
+win32:DEFINES += WIN32
+DEFINES += TABLE_VIEWER_EXPORTS OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS
+
+HEADERS = *.h
+
+SOURCES = *.cxx
+
+TRANSLATIONS = resources/TableViewer_images.ts \
+ resources/TableViewer_msg_en.ts
+
+ICONS = resources/*.png
+
+includes.files = $$HEADERS
+includes.path = ../../include
+
+resources.files = $$ICONS resources/*.qm
+resources.path = ../../resources
+
+INSTALLS += includes resources
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// TableViewer_ViewModel.cxx: implementation of the TableViewer_ViewModel class.
+
+#include "TableViewer_Tool.h"
+
+#include <TCollection_ExtendedString.hxx>
+#include <Quantity_Color.hxx>
+
+#include <QString>
+#include <QColor>
+
+//================================================================
+// Function : ToExtString
+// Purpose :
+//================================================================
+
+TCollection_ExtendedString TableViewer_Tool::ToExtString( const QString& src )
+{
+ if ( src.isEmpty() )
+ return TCollection_ExtendedString();
+
+ Standard_Integer len = src.length();
+ Standard_ExtString extStr = new Standard_ExtCharacter [( len + 1 ) * 2];
+ memcpy( extStr, src.unicode(), len * 2 );
+ extStr[len] = 0;
+
+ TCollection_ExtendedString trg( extStr );
+
+ delete [] extStr;
+
+ return trg;
+}
+
+//================================================================
+// Function : ToDouble
+// Purpose : convert string to double
+//================================================================
+double TableViewer_Tool::ToDouble( const QString& txt )
+{
+ bool isDone = true;
+ return TableViewer_Tool::ToDouble( txt, isDone );
+}
+
+//================================================================
+// Function : ToDouble
+// Purpose : convert string to double
+//================================================================
+double TableViewer_Tool::ToDouble( const QString& txt, bool& isDone )
+{
+ return txt.toDouble( &isDone );
+}
+
+//================================================================
+// Function : DoubleToQString
+// Purpose : convert string to double
+//================================================================
+QString TableViewer_Tool::DoubleToQString( const double val, const bool replaceDot )
+{
+ QString txt = QString::number( val );
+ if ( replaceDot )
+ txt.replace( '.', ',' );
+ return txt;
+}
+
+//================================================================
+// Function : DoubleToQString
+// Purpose : convert Qt color to OpenCascade color
+//================================================================
+Quantity_Color TableViewer_Tool::Color( const QColor& c )
+{
+ return Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
+}
+
+//================================================================
+// Function : DoubleToQString
+// Purpose : convert OpenCascade color to Qt color
+//================================================================
+QColor TableViewer_Tool::Color( const Quantity_Color& c )
+{
+ return QColor( (int)( 255 * c.Red() ), (int)( 255 * c.Green() ), (int)( 255 * c.Blue() ) );
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#if !defined(TABLEVIEWER_TOLL_H)
+#define TABLEVIEWER_TOOL_H
+
+#include "TableViewer.h"
+
+class TCollection_ExtendedString;
+class QString;
+class Quantity_Color;
+class QColor;
+
+class TABLEVIEWER_EXPORT TableViewer_Tool
+{
+public:
+ static TCollection_ExtendedString ToExtString( const QString& );
+ static double ToDouble( const QString& );
+ static double ToDouble( const QString&, bool& );
+ static QString DoubleToQString( const double, const bool = false );
+
+ static Quantity_Color Color( const QColor& );
+ static QColor Color( const Quantity_Color& );
+};
+
+#endif // !defined(TABLEVIEWER_TOOL_H)
+
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "TableViewer_ViewManager.h"
+#include "TableViewer_ViewModel.h"
+#include "TableViewer_ViewWindow.h"
+
+#include <SUIT_Study.h>
+#include <SUIT_Desktop.h>
+
+/*!
+ Constructor
+*/
+TableViewer_ViewManager::TableViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* desk )
+: SUIT_ViewManager( study, desk, new TableViewer_Viewer() )
+{
+ setTitle( tr( "TABLE_VIEWER_VIEW_TITLE" ) );
+}
+
+/*!
+ Destructor
+*/
+TableViewer_ViewManager::~TableViewer_ViewManager()
+{
+}
+
+/*!
+ \return corresponding viewer
+*/
+TableViewer_Viewer* TableViewer_ViewManager::getTableModel() const
+{
+ return (TableViewer_Viewer*)myViewModel;
+}
+
+/*!
+ Adds new view
+ \param theView - view to be added
+*/
+/*bool TableViewer_ViewManager::insertView( SUIT_ViewWindow* theView )
+{
+ bool res = SUIT_ViewManager::insertView( theView );
+ if ( res )
+ {
+ TableViewer_ViewWindow* view = (TableViewer_ViewWindow*)theView;
+ connect( view, SIGNAL( cloneView() ), this, SLOT( onCloneView() ) );
+ }
+ return res;
+}
+*/
+/*!
+ Creates new view
+*/
+void TableViewer_ViewManager::createView()
+{
+ createViewWindow();
+}
+
+/*!
+ SLOT: called if action "Clone view" is activated, emits signal cloneView()
+*/
+/*void TableViewer_ViewManager::onCloneView()
+{
+ SUIT_ViewWindow* vw = createViewWindow();
+
+ TableViewer_ViewWindow *newWnd = 0, *clonedWnd = 0;
+ if( vw && vw->inherits( "TableViewer_ViewWindow" ) )
+ newWnd = ( TableViewer_ViewWindow* )vw;
+ if( sender() && sender()->inherits( "TableViewer_ViewWindow" ) )
+ clonedWnd = ( TableViewer_ViewWindow* )sender();
+
+ if( newWnd && clonedWnd )
+ emit cloneView( clonedWnd->getViewFrame(), newWnd->getViewFrame() );
+}
+*/
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef TABLEVIEWER_VIEWMANAGER_H
+#define TABLEVIEWER_VIEWMANAGER_H
+
+#include "TableViewer.h"
+#include "SUIT_ViewManager.h"
+
+class SUIT_Study;
+class SUIT_Desktop;
+class TableViewer_Viewer;
+class TableViewer_ViewFrame;
+
+class TABLEVIEWER_EXPORT TableViewer_ViewManager : public SUIT_ViewManager
+{
+ Q_OBJECT
+
+public:
+ TableViewer_ViewManager( SUIT_Study*, SUIT_Desktop* );
+ ~TableViewer_ViewManager();
+
+ TableViewer_Viewer* getTableModel() const;
+
+//protected:
+// bool insertView(SUIT_ViewWindow* theView);
+
+public slots:
+ void createView();
+
+//protected slots:
+// void onCloneView();
+
+//signals:
+// void cloneView( TableViewer_ViewFrame*, TableViewer_ViewFrame* );
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// TableViewer_ViewModel.cxx: implementation of the TableViewer_ViewModel class.
+
+#include "TableViewer_ViewModel.h"
+#include "TableViewer_ViewWindow.h"
+#include "TableViewer_ViewManager.h"
+
+#include <QtxTable.h>
+/*!
+ Constructor
+*/
+TableViewer_Viewer::TableViewer_Viewer()
+:SUIT_ViewModel()
+{
+}
+
+/*!
+ Destructor
+*/
+TableViewer_Viewer::~TableViewer_Viewer()
+{
+}
+
+/*!
+ Create new instance of view window on desktop \a theDesktop.
+ \retval SUIT_ViewWindow* - created view window pointer.
+*/
+SUIT_ViewWindow* TableViewer_Viewer::createView( SUIT_Desktop* theDesktop )
+{
+ TableViewer_ViewWindow* vw = new TableViewer_ViewWindow( theDesktop, this );
+ QtxTable* tbl = vw->table();
+ if ( tbl && getViewManager() )
+ tbl->viewport()->installEventFilter( getViewManager() );
+ return vw;
+}
+
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#if !defined(TABLEVIEWER_VIEWMODEL_H)
+#define TABLEVIEWER_VIEWMODEL_H
+
+#include "TableViewer.h"
+#include "SUIT_ViewModel.h"
+
+class SUIT_ViewWindow;
+class SUIT_Desktop;
+class QString;
+
+class TABLEVIEWER_EXPORT TableViewer_Viewer: public SUIT_ViewModel
+{
+ Q_OBJECT
+
+public:
+ static QString Type() { return "TableViewer"; }
+
+ TableViewer_Viewer();
+ ~TableViewer_Viewer();
+
+ virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
+ virtual QString getType() const { return Type(); }
+};
+
+#endif // !defined(TABLEVIEWER_VIEWMODEL_H)
+
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// TableViewer_ViewModel.cxx: implementation of the TableViewer_ViewModel class.
+
+#include "TableViewer_ViewWindow.h"
+#include "TableViewer_ViewModel.h"
+#include "TableViewer_Tool.h"
+
+#include <SUIT_Desktop.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SUIT_Application.h>
+#include <SUIT_ViewManager.h>
+
+#include <HTMLService_HTMLTable.hxx>
+#include <HTMLService_HTMLTableCell.hxx>
+
+#include <QtxToolBar.h>
+
+#include <QtxTable.h>
+#include <QImage>
+#include <QPixmap>
+#include <QApplication>
+#include <QFont>
+
+/*!
+ Constructor
+*/
+TableViewer_ViewWindow::TableViewer_ViewWindow( SUIT_Desktop* theDesktop,
+ TableViewer_Viewer* theModel )
+:SUIT_ViewWindow( theDesktop )
+{
+ myModel = theModel;
+ myTable = new QtxTable( this );
+
+ //myTable->setReadOnly( true );
+ setCentralWidget( myTable );
+
+ myToolBar = new QtxToolBar( true, tr("LBL_TOOLBAR_LABEL"), this );
+
+ createActions();
+ createToolBar();
+
+ // fill table
+ myTable->setColumnCount(3);
+ myTable->setRowCount(5);
+ myTable->setCellBackground( 1, 1, Qt::red );
+ myTable->setCellForeground( 1, 1, Qt::blue );
+ QFont aFont = myTable->font();
+ aFont.setBold( true );
+ myTable->setCellFont( 1, 1, aFont );
+ myTable->setCellFont( 0, 0, aFont );
+
+ aFont.setUnderline( true );
+ myTable->setCellFont( 0, 1, aFont );
+
+
+ myTable->setCellBackground( 2, 2, myTable->cellBackground( 1, 1 ) );
+ myTable->setCellForeground( 2, 2, myTable->cellForeground( 1, 1 ) );
+ aFont = myTable->cellFont( 1, 1 );
+ myTable->setCellFont( 2, 2, aFont );
+ myTable->setCellBackground( 0, 1, myTable->cellBackground( 0, 0 ) );
+
+ myTable->setHeaderData( Qt::Horizontal, 1, "Caption");
+ myTable->setHeaderBackground( Qt::Horizontal, 1, Qt::green );
+ myTable->setHeaderFont(Qt::Vertical, 2, aFont );
+ myTable->setHeaderFont(Qt::Horizontal, 0, aFont );
+}
+
+/*!
+ Destructor
+*/
+TableViewer_ViewWindow::~TableViewer_ViewWindow()
+{
+}
+
+QtxTable* TableViewer_ViewWindow::table() const
+{
+ return myTable;
+}
+
+QImage TableViewer_ViewWindow::dumpView()
+{
+ return QPixmap::grabWindow( table()->winId() ).toImage();
+}
+
+void TableViewer_ViewWindow::createActions()
+{
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+
+ createAction( DumpId, tr( "MEN_DUMP" ),
+ resMgr->loadPixmap( "TableViewer", tr( "ICON_DUMP" ) ),
+ tr( "TIP_DUMP" ), tr( "PRP_DUMP" ) );
+
+ createAction( CopyId, tr( "MEN_COPY" ),
+ resMgr->loadPixmap( "STD", tr( "ICON_EDIT_COPY" ) ),
+ tr( "TIP_COPY" ), tr( "PRP_COPY" ) );
+
+ createAction( PrintId, tr( "MEN_PRINT" ),
+ resMgr->loadPixmap( "STD", tr( "ICON_PRINT" ) ),
+ tr( "TIP_PRINT" ), tr( "PRP_PRINT" ) );
+
+ createAction( ExportId, tr( "MEN_EXPORT" ),
+ resMgr->loadPixmap( "TableViewer", tr( "ICON_EXPORT" ) ),
+ tr( "TIP_EXPORT" ), tr( "PRP_EXPORT" ) );
+}
+
+int TableViewer_ViewWindow::numRows( const ContentType type ) const
+{
+ int aRows = 0;
+ switch ( type ) {
+ case HorizontalHeader:
+ aRows = 1;
+ break;
+ case Cells:
+ case VerticalHeader:
+ aRows = myTable->rowCount();
+ break;
+ default:
+ break;
+ }
+ return aRows;
+}
+
+int TableViewer_ViewWindow::numCols( const ContentType type ) const
+{
+ int aCols = 0;
+ switch ( type ) {
+ case VerticalHeader:
+ aCols = 1;
+ break;
+ case Cells:
+ case HorizontalHeader:
+ aCols = myTable->columnCount();
+ break;
+ default:
+ break;
+ }
+ return aCols;
+}
+
+QString TableViewer_ViewWindow::text( const ContentType type, const int row, const int col ) const
+{
+ QString aTxt = "";
+ switch ( type ) {
+ case VerticalHeader:
+ aTxt = myTable->headerData( Qt::Vertical, row ).toString();
+ break;
+ case HorizontalHeader:
+ aTxt = myTable->headerData( Qt::Horizontal, col ).toString();
+ break;
+ case Cells:
+ if ( myTable->item( row, col ) )
+ aTxt = myTable->item( row, col )->text();
+ break;
+ default:
+ break;
+ }
+ return aTxt;
+}
+
+QString TableViewer_ViewWindow::image( const ContentType type, const int row, const int col ) const
+{
+ return "";
+}
+
+int TableViewer_ViewWindow::fontFlags( const ContentType type, const int row, const int col ) const
+{
+ int aFlags = 0;
+ QFont aFont = myTable->font();
+ switch ( type ) {
+ case VerticalHeader:
+ aFont = myTable->headerFont( Qt::Horizontal, row );
+ break;
+ case HorizontalHeader:
+ aFont = myTable->headerFont( Qt::Vertical, col );
+ break;
+ case Cells:
+ aFont = myTable->cellFont( row, col );
+ break;
+ default:
+ break;
+ }
+ if ( aFont.bold() )
+ aFlags |= HTMLService_HTMLText::Bold;
+ if ( aFont.italic() )
+ aFlags |= HTMLService_HTMLText::Bold;
+ if ( aFont.underline() )
+ aFlags |= HTMLService_HTMLText::Underline;
+ if ( aFont.strikeOut() )
+ aFlags |= HTMLService_HTMLText::StrikeOut;
+ //Subscript
+
+ return aFlags;
+}
+
+QColor TableViewer_ViewWindow::foregroundColor( const ContentType type, const int row,
+ const int col ) const
+{
+ QColor aColor;
+ switch ( type ) {
+ case VerticalHeader:
+ case HorizontalHeader: {
+ bool aHor = type == HorizontalHeader;
+ aColor = myTable->headerForeground( aHor ? Qt::Horizontal : Qt::Vertical,
+ aHor ? col : row );
+ }
+ break;
+ case Cells:
+ aColor = myTable->cellForeground( row, col );
+ break;
+ default:
+ break;
+ }
+ return aColor;
+}
+
+QColor TableViewer_ViewWindow::backgroundColor( const ContentType type, const int row,
+ const int col ) const
+{
+ QColor aColor;
+ switch ( type ) {
+ case VerticalHeader:
+ case HorizontalHeader: {
+ bool aHor = type == HorizontalHeader;
+ aColor = myTable->headerForeground( aHor ? Qt::Horizontal : Qt::Vertical,
+ aHor ? col : row );
+ }
+ break;
+ case Cells:
+ aColor = myTable->cellBackground( row, col );
+ break;
+ default:
+ break;
+ }
+ return aColor;
+}
+
+void TableViewer_ViewWindow::createToolBar()
+{
+ myToolBar->addAction( myActionsMap[DumpId] );
+ myToolBar->addAction( myActionsMap[CopyId] );
+ myToolBar->addAction( myActionsMap[PrintId] );
+ myToolBar->addAction( myActionsMap[ExportId] );
+}
+
+void TableViewer_ViewWindow::actionActivated( const int id )
+{
+ switch ( id ) {
+ case DumpId:
+ onDumpView();
+ break;
+ case ExportId:
+ exportData();
+ break;
+ }
+}
+
+void TableViewer_ViewWindow::registerAction( const int id, QtxAction* a )
+{
+ if ( !a )
+ return;
+
+ myActionsMap.insert( id, a );
+ connect( a, SIGNAL( activated() ), this, SLOT( onActivated() ) );
+}
+
+QtxAction* TableViewer_ViewWindow::createAction( const int id, const QString& menu, const QPixmap& ico,
+ const QString& tip, const QString& status,
+ const int accel, QObject* parent )
+{
+ QtxAction* a = new QtxAction( menu, ico, menu, accel, parent ? parent : myDesktop );
+ a->setToolTip( tip );
+ a->setStatusTip( status );
+ registerAction( id, a );
+ return a;
+}
+
+void TableViewer_ViewWindow::onActivated()
+{
+ const QObject* obj = sender();
+ const QtxAction* a = ::qobject_cast<const QtxAction*>( obj );
+ if ( !a )
+ return;
+
+ int id = -1;
+ for ( ActionsMap::const_iterator it = myActionsMap.begin();
+ it != myActionsMap.end() && id == -1; ++it ) {
+ if ( it.value() == a )
+ id = it.key();
+ }
+
+ if ( id == -1 )
+ return;
+
+ actionActivated( id );
+}
+
+void TableViewer_ViewWindow::exportData()
+{
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ QString fileName = app->getFileName( false, QString::null, tr( "EXPORT_FILTER" ),
+ tr( "EXPORT_TABLE" ), 0 );
+ if ( fileName.isEmpty() )
+ return;
+
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+
+ int rows = numRows( Cells );
+ int cols = numCols( Cells );
+ int horOffset = numRows( HorizontalHeader );
+ int verOffset = numCols( VerticalHeader );
+
+ Handle(HTMLService_HTMLTable) table = new HTMLService_HTMLTable( rows + horOffset,
+ cols + verOffset );
+ QString title = getViewManager()->getTitle();
+ SUIT_ViewWindow* anActiveWnd = getViewManager()->getActiveView();
+ if ( anActiveWnd )
+ title = anActiveWnd->windowTitle();
+
+ table->SetTitle( TableViewer_Tool::ToExtString( title ) );
+ table->SetWidth( 100, true );
+ table->SetBorder( 2 );
+
+ exportTableData( table, HorizontalHeader, 0, verOffset );
+ exportTableData( table, VerticalHeader, horOffset, 0 );
+ exportTableData( table, Cells, horOffset, verOffset );
+
+ Handle(HTMLService_HTMLTableCell) ltCell = table->GetCell( 0, 0 );
+ if ( !ltCell.IsNull() ) {
+ ltCell->SetHeaderCell( true );
+ ltCell->SetBackgroundColor( Quantity_NOC_GRAY );
+ }
+ table->GenerateFile( TableViewer_Tool::ToExtString( fileName ), true );
+
+ QApplication::restoreOverrideCursor();
+}
+
+void TableViewer_ViewWindow::exportTableData( Handle(HTMLService_HTMLTable)& table,
+ const ContentType type,
+ const int rowOffset, const int colOffset )
+{
+ if ( table.IsNull() )
+ return;
+
+ bool isExpImg = true;
+ bool dotToComma = false;
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ if ( resMgr ) {
+ isExpImg = resMgr->booleanValue( "TableViewer", "export_table_images", true );
+ dotToComma = resMgr->booleanValue( "TableViewer", "replace_dot_by_comma", true );
+ }
+
+ for ( int c = 0, nbC = numCols( type ); c < nbC; c++ ) {
+ for ( int r = 0, nbR = numRows( type ); r < nbR; r++ ) {
+ Handle(HTMLService_HTMLTableCell) cell =
+ table->GetCell( r + rowOffset, c + colOffset );
+ if ( cell.IsNull() )
+ continue;
+ cell->SetHeaderCell( type != Cells );
+ if ( cell->IsHeaderCell() )
+ cell->SetBackgroundColor( Quantity_NOC_GRAY );
+ if ( isExpImg ) {
+ QString img = image( type, r, c );
+ if ( !img.isEmpty() )
+ cell->InsertImage( TableViewer_Tool::ToExtString( img ), 32, 32 );
+ }
+ QString txt = text( type, r, c );
+ if ( !txt.isEmpty() ) {
+ bool aDbl = false;
+ double aVal = TableViewer_Tool::ToDouble( txt, aDbl );
+ if ( aDbl )
+ cell->InsertText( TableViewer_Tool::ToExtString(
+ TableViewer_Tool::DoubleToQString( aVal, dotToComma ) ) );
+ else
+ cell->InsertText( TableViewer_Tool::ToExtString( txt ) );
+ }
+ if ( foregroundColor( type, r, c ).isValid() )
+ cell->SetForegroundColor( TableViewer_Tool::Color( foregroundColor( type, r, c ) ) );
+ if ( backgroundColor( type, r, c ).isValid() )
+ cell->SetBackgroundColor( TableViewer_Tool::Color( backgroundColor( type, r, c ) ) );
+ cell->SetFontFlags( fontFlags( type, r, c ) );
+ }
+ }
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#if !defined(TABLEVIEWER_VIEWWINDOW_H)
+#define TABLEVIEWER_VIEWWINDOW_H
+
+#include "TableViewer.h"
+#include "SUIT_ViewWindow.h"
+#include "QtxAction.h"
+
+#include "HTMLService_HTMLTable.hxx"
+
+class TableViewer_Viewer;
+class SUIT_ViewWindow;
+class SUIT_Desktop;
+class Handle(HTMLService_HTMLTable);
+class QImage;
+class QtxTable;
+class QToolBar;
+
+class TABLEVIEWER_EXPORT TableViewer_ViewWindow: public SUIT_ViewWindow
+{
+ Q_OBJECT
+
+public:
+ TableViewer_ViewWindow( SUIT_Desktop* , TableViewer_Viewer* );
+ ~TableViewer_ViewWindow();
+
+ QtxTable* table() const;
+ QToolBar* getToolBar() { return myToolBar; }
+
+ virtual QImage dumpView();
+
+protected:
+ typedef enum { VerticalHeader, HorizontalHeader, Cells } ContentType;
+ typedef enum { DumpId, CopyId, PrintId, ExportId, Custom } ActionId;
+ typedef QMap<int, QtxAction*> ActionsMap;
+
+ virtual void createActions();
+ virtual void createToolBar();
+ virtual void actionActivated( const int );
+ virtual void exportTableData( Handle(HTMLService_HTMLTable)&,
+ const ContentType, const int, const int );
+
+ void registerAction( const int, QtxAction* );
+ QtxAction* createAction( const int, const QString&, const QPixmap&, const QString&,
+ const QString&, const int = 0, QObject* = 0 );
+
+ int numRows( const ContentType ) const;
+ int numCols( const ContentType ) const;
+
+ QString text( const ContentType, const int, const int ) const;
+ QString image( const ContentType, const int, const int ) const;
+ int fontFlags( const ContentType, const int, const int ) const;
+ QColor foregroundColor( const ContentType, const int, const int ) const;
+ QColor backgroundColor( const ContentType, const int, const int ) const;
+
+private slots:
+ void onActivated();
+
+private:
+ void exportData();
+
+protected:
+ TableViewer_Viewer* myModel;
+ ActionsMap myActionsMap;
+
+private:
+ QtxTable* myTable;
+ QToolBar* myToolBar;
+};
+
+#endif // !defined(TABLEVIEWER_VIEWWINDOW_H)
+
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS><TS version="1.1" language="ru_RU">
+<context>
+ <name>TableViewer_ViewManager</name>
+ <message>
+ <location filename="TableViewer_ViewManager.cxx" line="32"/>
+ <source>TABLE_VIEWER_VIEW_TITLE</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>TableViewer_ViewWindow</name>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="100"/>
+ <source>ICON_DUMP</source>
+ <translation type="unfinished">table_camera_dump.png</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="112"/>
+ <source>ICON_EXPORT</source>
+ <translation type="unfinished">table_export.png</translation>
+ </message>
+</context>
+</TS>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS><TS version="1.1" language="ru_RU">
+<context>
+ <name>TableViewer_ViewManager</name>
+ <message>
+ <location filename="TableViewer_ViewManager.cxx" line="32"/>
+ <source>TABLE_VIEWER_VIEW_TITLE</source>
+ <translation type="unfinished">TableViewer scene:%M - viewer %V</translation>
+ </message>
+</context>
+<context>
+ <name>TableViewer_ViewWindow</name>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="55"/>
+ <source>LBL_TOOLBAR_LABEL</source>
+ <translation type="unfinished">View operations</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="99"/>
+ <source>MEN_DUMP</source>
+ <translation type="unfinished">Dump view...</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="101"/>
+ <source>TIP_DUMP</source>
+ <translation type="unfinished">Dump view</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="101"/>
+ <source>PRP_DUMP</source>
+ <translation type="unfinished">Dump view</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="103"/>
+ <source>MEN_COPY</source>
+ <translation type="unfinished">Copy</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="105"/>
+ <source>TIP_COPY</source>
+ <translation type="unfinished">Copy</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="105"/>
+ <source>PRP_COPY</source>
+ <translation type="unfinished">Copy</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="107"/>
+ <source>MEN_PRINT</source>
+ <translation type="unfinished">Print view</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="109"/>
+ <source>TIP_PRINT</source>
+ <translation type="unfinished">Print view</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="109"/>
+ <source>PRP_PRINT</source>
+ <translation type="unfinished">Print view</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="111"/>
+ <source>MEN_EXPORT</source>
+ <translation type="unfinished">Export to HTML...</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="113"/>
+ <source>TIP_EXPORT</source>
+ <translation type="unfinished">Export as HTML file</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="113"/>
+ <source>PRP_EXPORT</source>
+ <translation type="unfinished">Export to HTML file</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="296"/>
+ <source>EXPORT_FILTER</source>
+ <translation type="unfinished">Hyper text document (*.htm *.html)</translation>
+ </message>
+ <message>
+ <location filename="TableViewer_ViewWindow.cxx" line="297"/>
+ <source>EXPORT_TABLE</source>
+ <translation type="unfinished">Export table to file</translation>
+ </message>
+</context>
+</TS>