--- /dev/null
+// File: LightApp.h\r
+// Created: June, 2005\r
+// Author: OCC team\r
+// Copyright (C) CEA 2005\r
+\r
+\r
+// The following ifdef block is the standard way of creating macros which make exporting \r
+// from a DLL simpler. All files within this DLL are compiled with the LightApp_EXPORTS\r
+// symbol defined on the command line. this symbol should not be defined on any project\r
+// that uses this DLL. This way any other project whose source files include this file see \r
+// LightApp_API functions as being imported from a DLL, wheras this DLL sees symbols\r
+// defined with this macro as being exported.\r
+#ifdef WNT\r
+\r
+#ifdef LIGHTAPP_EXPORTS\r
+#define LIGHTAPP_EXPORT __declspec(dllexport)\r
+#else\r
+#define LIGHTAPP_EXPORT __declspec(dllimport)\r
+#endif\r
+\r
+#else\r
+#define LIGHTAPP_EXPORT\r
+#endif //WNT\r
+\r
+#define APP_VERSION "0.1"\r
+\r
+#pragma warning ( disable:4251 )\r
+#pragma warning ( disable:4786 )\r
--- /dev/null
+// File: LightApp_AboutDlg.cxx
+// Created: 03.06.2005 13:52:45
+// Author: Sergey TELKOV
+// Copyright (C) CEA 2005
+
+#include "LightApp_AboutDlg.h"
+
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpixmap.h>
+#include <qgroupbox.h>
+
+/*!Constructor.*/
+LightApp_AboutDlg::LightApp_AboutDlg( const QString& defName, const QString& defVer, QWidget* parent )
+: QtxDialog( parent, "salome_about_dialog", true, false, None )
+{
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+
+ QPixmap ico = resMgr->loadPixmap( "LightApp", tr( "ICO_ABOUT" ), false );
+ if ( !ico.isNull() )
+ setIcon( ico );
+
+ QPalette pal = palette();
+ QColorGroup cg = pal.active();
+ cg.setColor( QColorGroup::Foreground, Qt::darkBlue );
+ cg.setColor( QColorGroup::Background, Qt::white );
+ pal.setActive( cg ); pal.setInactive( cg ); pal.setDisabled( cg );
+ setPalette(pal);
+
+ QVBoxLayout* main = new QVBoxLayout( mainFrame() );
+ QGroupBox* base = new QGroupBox( 1, Qt::Horizontal, "", mainFrame() );
+ base->setFrameStyle( QFrame::NoFrame );
+ base->setInsideMargin( 0 );
+ main->addWidget( base );
+
+ QLabel* screen = new QLabel( base );
+ screen->setScaledContents( true );
+ screen->setAlignment( Qt::AlignCenter );
+ screen->setFrameStyle( QFrame::Box | QFrame::Plain );
+
+ QLabel* title = new QLabel( base );
+ title->setAlignment( Qt::AlignCenter );
+ changeFont( title, true, false, false, 5 );
+
+ QLabel* version = new QLabel( base );
+ version->setAlignment( Qt::AlignCenter );
+ changeFont( version, false, true, false, 2 );
+
+ QLabel* copyright = new QLabel( base );
+ copyright->setAlignment( Qt::AlignCenter );
+ changeFont( copyright, false, false, false, 1 );
+
+ QLabel* license = new QLabel( base );
+ license->setAlignment( Qt::AlignCenter );
+ changeFont( license, false, false, false, 1 );
+
+ screen->setPixmap( resMgr->loadPixmap( "LightApp", tr( "ABOUT" ), false ) );
+ checkLabel( screen );
+
+ QString titleText = tr( "ABOUT_TITLE" );
+ if ( titleText == "ABOUT_TITLE" )
+ titleText = defName;
+ title->setText( titleText );
+ checkLabel( title );
+
+ QString verText = tr( "ABOUT_VERSION" );
+ if ( verText.contains( "%1" ) )
+ verText = verText.arg( defVer );
+ version->setText( verText );
+ checkLabel( version );
+
+ copyright->setText( tr( "ABOUT_COPYRIGHT" ) );
+ checkLabel( copyright );
+
+ license->setText( tr( "ABOUT_LICENSE" ) );
+ checkLabel( license );
+
+ QString capText = tr( "ABOUT_CAPTION" );
+ if ( capText.contains( "%1" ) )
+ capText = capText.arg( defName );
+ setCaption( capText );
+
+ setSizeGripEnabled( false );
+}
+
+/*!Destructor.*/
+LightApp_AboutDlg::~LightApp_AboutDlg()
+{
+ //! Do nothing.
+}
+
+/*!On mouse press event.*/
+void LightApp_AboutDlg::mousePressEvent( QMouseEvent* )
+{
+ accept();
+}
+
+/*!Change font of widget \a wid.
+ *\param wid - QWidget
+ *\param bold - boolean value
+ *\param italic - boolean value
+ *\param underline - boolean value
+ *\param inc - integer increment for font point size.
+ */
+void LightApp_AboutDlg::changeFont( QWidget* wid, const bool bold, const bool italic,
+ const bool underline, const int inc ) const
+{
+ if ( !wid )
+ return;
+
+ QFont widFont = wid->font();
+ widFont.setBold( bold );
+ widFont.setItalic( italic );
+ widFont.setUnderline( underline );
+ widFont.setPointSize( widFont.pointSize() + inc );
+}
+
+/*!Check lable \a lab.*/
+void LightApp_AboutDlg::checkLabel( QLabel* lab ) const
+{
+ if ( !lab )
+ return;
+
+ bool vis = !lab->text().stripWhiteSpace().isEmpty() ||
+ ( lab->pixmap() && !lab->pixmap()->isNull() );
+ vis ? lab->show() : lab->hide();
+}
--- /dev/null
+// File: LightApp_AboutDlg.h
+// Created: 03.06.2005 13:49:25
+// Author: Sergey TELKOV
+// Copyright (C) CEA 2005
+
+#ifndef LIGHTAPP_ABOUTDLG_H
+#define LIGHTAPP_ABOUTDLG_H
+
+#include "LightApp.h"
+
+#include <QtxDialog.h>
+
+/*!
+ Descr: LightApp help about dialog
+*/
+
+class QLabel;
+
+class LIGHTAPP_EXPORT LightApp_AboutDlg : public QtxDialog
+{
+ Q_OBJECT
+
+public:
+ LightApp_AboutDlg( const QString&, const QString&, QWidget* = 0 );
+ virtual ~LightApp_AboutDlg();
+
+protected:
+ virtual void mousePressEvent( QMouseEvent* );
+
+private:
+ void checkLabel( QLabel* ) const;
+ void changeFont( QWidget*, const bool = false, const bool = false,
+ const bool = false, const int = 0 ) const;
+};
+
+#endif
--- /dev/null
+// File: LightApp_Application.cxx
+// Created: 6/20/2005 18:39:45 PM
+// Author: Natalia Donis
+// Copyright (C) CEA 2005
+
+#include "PythonConsole_PyInterp.h" // WARNING! This include must be the first!
+
+#include "LightApp_Application.h"
+#include "LightApp_WidgetContainer.h"
+#include "LightApp_Module.h"
+#include "LightApp_DataModel.h"
+#include "LightApp_Study.h"
+#include "LightApp_Preferences.h"
+#include "LightApp_PreferencesDlg.h"
+#include "LightApp_ModuleDlg.h"
+#include "LightApp_AboutDlg.h"
+
+#include "LightApp_OBFilter.h"
+
+#include "LightApp_GLSelector.h"
+#include "LightApp_OBSelector.h"
+#include "LightApp_OCCSelector.h"
+#include "LightApp_VTKSelector.h"
+#include "LightApp_SelectionMgr.h"
+
+#include <CAM_Module.h>
+#include <CAM_DataModel.h>
+#include <CAM_Study.h>
+#include <STD_TabDesktop.h>
+
+#include <SUIT_Session.h>
+#include <SUIT_Study.h>
+#include <SUIT_FileDlg.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Tools.h>
+#include <SUIT_Accel.h>
+
+#include <QtxMRUAction.h>
+#include <QtxDockAction.h>
+#include <QtxToolBar.h>
+
+#include <LogWindow.h>
+#include <OB_Browser.h>
+#include <PythonConsole_PyConsole.h>
+
+#include <GLViewer_Viewer.h>
+#include <GLViewer_ViewManager.h>
+
+#include <Plot2d_ViewManager.h>
+#include <Plot2d_ViewModel.h>
+#include <SPlot2d_ViewModel.h>
+
+#include <OCCViewer_ViewManager.h>
+#include <SOCC_ViewModel.h>
+
+#include <SVTK_ViewModel.h>
+#include <SVTK_ViewManager.h>
+#include <VTKViewer_ViewModel.h>
+
+#include <qdir.h>
+#include <qimage.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qstringlist.h>
+#include <qfile.h>
+#include <qapplication.h>
+#include <qmap.h>
+#include <qstatusbar.h>
+#include <qthread.h>
+
+#define OBJECT_BROWSER_WIDTH 300
+#define OBJECT_COLUMN_WIDTH 150
+
+#define DEFAULT_BROWSER "mozilla"
+
+#define FIRST_HELP_ID 1000000
+
+#include "SALOME_InteractiveObject.hxx"
+#include "SALOME_ListIO.hxx"
+
+static const char* imageEmptyIcon[] = {
+"20 20 1 1",
+". c None",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"....................",
+"...................."};
+
+/*!Create new instance of LightApp_Application.*/
+extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication()
+{
+ return new LightApp_Application();
+}
+
+LightApp_Preferences* LightApp_Application::_prefs_ = 0;
+
+/*
+ Class : LightApp_Application
+ Description : Application containing LightApp module
+*/
+
+/*!Constructor.*/
+LightApp_Application::LightApp_Application()
+: CAM_Application( false ),
+myPrefs( 0 )
+{
+ STD_TabDesktop* desk = new STD_TabDesktop();
+
+ setDesktop( desk );
+
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
+
+ desktop()->setIcon( aLogo );
+ desktop()->setDockableMenuBar( true );
+ desktop()->setDockableStatusBar( false );
+
+ // base logo (salome itself)
+ desktop()->addLogo( "_app_base", aResMgr->loadPixmap( "LightApp", tr( "APP_BASE_LOGO" ), false ) );
+ // extra logo (salome-based application)
+ desktop()->addLogo( "_app_extra", aResMgr->loadPixmap( "LightApp", tr( "APP_EXTRA_LOGO" ), false ) );
+
+ clearViewManagers();
+
+ mySelMgr = new LightApp_SelectionMgr( this );
+
+ myAccel = new SUIT_Accel( desktop() );
+ myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, OCCViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, OCCViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, OCCViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::PanDown, CTRL+Key_Down, OCCViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::ZoomIn, CTRL+Key_Plus, OCCViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::ZoomOut, CTRL+Key_Minus, OCCViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::ZoomFit, CTRL+Key_Asterisk, OCCViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::RotateLeft, ALT+Key_Left, OCCViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right, OCCViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::RotateUp, ALT+Key_Up, OCCViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::RotateDown, ALT+Key_Down, OCCViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::PanLeft, CTRL+Key_Left, VTKViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::PanRight, CTRL+Key_Right, VTKViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::PanUp, CTRL+Key_Up, VTKViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::PanDown, CTRL+Key_Down, VTKViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::ZoomIn, CTRL+Key_Plus, VTKViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::ZoomOut, CTRL+Key_Minus, VTKViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::ZoomFit, CTRL+Key_Asterisk, VTKViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::RotateLeft, ALT+Key_Left, VTKViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::RotateRight, ALT+Key_Right, VTKViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::RotateUp, ALT+Key_Up, VTKViewer_Viewer::Type() );
+ myAccel->setActionKey( SUIT_Accel::RotateDown, ALT+Key_Down, VTKViewer_Viewer::Type() );
+
+ connect( mySelMgr, SIGNAL( selectionChanged() ), this, SLOT( onSelection() ) );
+}
+
+/*!Destructor.
+ *\li Save window geometry.
+ *\li Save desktop geometry.
+ *\li Save resource maneger.
+ *\li Delete selection manager.
+ */
+LightApp_Application::~LightApp_Application()
+{
+ saveWindowsGeometry();
+
+ if ( resourceMgr() )
+ {
+ if ( desktop() )
+ desktop()->saveGeometry( resourceMgr(), "desktop" );
+ resourceMgr()->save();
+ }
+ delete mySelMgr;
+}
+
+/*!Start application.*/
+void LightApp_Application::start()
+{
+ if ( desktop() )
+ desktop()->loadGeometry( resourceMgr(), "desktop" );
+
+ CAM_Application::start();
+
+ QAction* a = action( ViewWindowsId );
+ if ( a && a->inherits( "QtxDockAction" ) )
+ ((QtxDockAction*)a)->setAutoPlace( true );
+
+ updateWindows();
+ updateViewManagers();
+
+ putInfo( "" );
+ desktop()->statusBar()->message( "" );
+}
+
+/*!Gets application name.*/
+QString LightApp_Application::applicationName() const
+{
+ return tr( "APP_NAME" );
+}
+
+/*!Gets application version.*/
+QString LightApp_Application::applicationVersion() const
+{
+ static QString _app_version;
+
+ if ( _app_version.isEmpty() )
+ {
+ QString resVersion = tr( "APP_VERSION" );
+ if ( resVersion != "APP_VERSION" )
+ {
+ _app_version = resVersion;
+ }
+ else
+ {
+ QString path( ::getenv( "GUI_ROOT_DIR" ) );
+ if ( !path.isEmpty() )
+ path += QDir::separator();
+ path += QString( "bin/salome/VERSION" );
+
+ QFile vf( path );
+ if ( vf.open( IO_ReadOnly ) )
+ {
+ QString line;
+ vf.readLine( line, 1024 );
+ vf.close();
+
+ if ( !line.isEmpty() )
+ {
+ while ( !line.isEmpty() && line.at( line.length() - 1 ) == QChar( '\n' ) )
+ line.remove( line.length() - 1, 1 );
+
+ int idx = line.findRev( ":" );
+ if ( idx != -1 )
+ _app_version = line.mid( idx + 1 ).stripWhiteSpace();
+ }
+ }
+ }
+ }
+ return _app_version;
+}
+
+/*!Load module by \a name.*/
+CAM_Module* LightApp_Application::loadModule( const QString& name )
+{
+ CAM_Module* mod = CAM_Application::loadModule( name );
+ if ( mod )
+ {
+ connect( this, SIGNAL( studyOpened() ), mod, SLOT( onModelOpened() ) );
+ connect( this, SIGNAL( studySaved() ), mod, SLOT( onModelSaved() ) );
+ connect( this, SIGNAL( studyClosed() ), mod, SLOT( onModelClosed() ) );
+ }
+ return mod;
+}
+
+/*!Activate module by \a modName*/
+bool LightApp_Application::activateModule( const QString& modName )
+{
+ QString actName;
+ CAM_Module* prevMod = activeModule();
+
+ if ( prevMod )
+ actName = prevMod->moduleName();
+
+ if ( actName == modName )
+ return true;
+
+ putInfo( tr( "ACTIVATING_MODULE" ).arg( modName ) );
+
+ saveWindowsGeometry();
+
+ bool status = CAM_Application::activateModule( modName );
+
+ updateModuleActions();
+
+ putInfo( "" );
+
+ if ( !status )
+ return false;
+
+ updateWindows();
+ updateViewManagers();
+
+ return true;
+}
+
+bool LightApp_Application::useStudy(const QString& theName)
+{
+ createEmptyStudy();
+ LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>(activeStudy());
+ bool res = false;
+ if (aStudy)
+ res = aStudy->loadDocument( theName );
+ updateDesktopTitle();
+ updateCommandsStatus();
+ return res;
+}
+
+/*!Gets selection manager.*/
+LightApp_SelectionMgr* LightApp_Application::selectionMgr() const
+{
+ return mySelMgr;
+}
+
+/*!Create actions:*/
+void LightApp_Application::createActions()
+{
+ STD_Application::createActions();
+
+ SUIT_Desktop* desk = desktop();
+ SUIT_ResourceMgr* resMgr = resourceMgr();
+
+ //! Preferences
+ createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIconSet(),
+ tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
+ CTRL+Key_P, desk, false, this, SLOT( onPreferences() ) );
+
+ //! Help for modules
+ int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
+ int helpModuleMenu = createMenu( tr( "MEN_DESK_MODULE_HELP" ), helpMenu, -1, 0 );
+ createMenu( separator(), helpMenu, -1, 1 );
+
+ QStringList aModuleList;
+ modules( aModuleList, false );
+
+ int id = LightApp_Application::UserID + FIRST_HELP_ID;
+ // help for KERNEL and GUI
+ QCString dir;
+ QAction* a;
+ if (dir = getenv("GUI_ROOT_DIR")) {
+ a = createAction( id, tr( QString("Kernel & GUI Help") ), QIconSet(),
+ tr( QString("Kernel && GUI Help") ),
+ tr( QString("Kernel & GUI Help") ),
+ 0, desk, false, this, SLOT( onHelpContentsModule() ) );
+ a->setName( QString("GUI") );
+ createMenu( a, helpModuleMenu, -1 );
+ id++;
+ }
+ // help for other existing modules
+ for ( QStringList::Iterator it = aModuleList.begin(); it != aModuleList.end(); ++it )
+ {
+ if ( (*it).isEmpty() )
+ continue;
+
+ QString modName = moduleName( *it );
+ if ( modName.compare("GEOM") == 0 ) { // to be removed when documentation for other modules will be done
+ QAction* a = createAction( id, tr( moduleTitle(modName) + QString(" Help") ), QIconSet(),
+ tr( moduleTitle(modName) + QString(" Help") ),
+ tr( moduleTitle(modName) + QString(" Help") ),
+ 0, desk, false, this, SLOT( onHelpContentsModule() ) );
+ a->setName( modName );
+ createMenu( a, helpModuleMenu, -1 );
+ id++;
+ }
+ }
+
+ //! MRU
+ QtxMRUAction* mru = new QtxMRUAction( tr( "TOT_DESK_MRU" ), tr( "MEN_DESK_MRU" ), desk );
+ connect( mru, SIGNAL( activated( QString ) ), this, SLOT( onMRUActivated( QString ) ) );
+ registerAction( MRUId, mru );
+
+ // default icon for neutral point ('SALOME' module)
+ QPixmap defIcon = resMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false );
+ if ( defIcon.isNull() )
+ defIcon = QPixmap( imageEmptyIcon );
+
+ //! default icon for any module
+ QPixmap modIcon = resMgr->loadPixmap( "LightApp", tr( "APP_MODULE_ICO" ), false );
+ if ( modIcon.isNull() )
+ modIcon = QPixmap( imageEmptyIcon );
+
+ QToolBar* modTBar = new QtxToolBar( true, desk );
+ modTBar->setLabel( tr( "INF_TOOLBAR_MODULES" ) );
+
+ QActionGroup* modGroup = new QActionGroup( this );
+ modGroup->setExclusive( true );
+ modGroup->setUsesDropDown( true );
+
+ a = createAction( -1, tr( "APP_NAME" ), defIcon, tr( "APP_NAME" ),
+ tr( "PRP_APP_MODULE" ), 0, desk, true );
+ modGroup->add( a );
+ myActions.insert( QString(), a );
+
+ QMap<QString, QString> iconMap;
+ moduleIconNames( iconMap );
+
+ const int iconSize = 20;
+
+ modGroup->addTo( modTBar );
+ modTBar->addSeparator();
+
+ QStringList modList;
+ modules( modList, false );
+
+ for ( QStringList::Iterator it = modList.begin(); it != modList.end(); ++it )
+ {
+ if ( (*it).isEmpty() )
+ continue;
+
+ QString iconName;
+ if ( iconMap.contains( *it ) )
+ iconName = iconMap[*it];
+
+ QString modName = moduleName( *it );
+
+ QPixmap icon = resMgr->loadPixmap( modName, iconName, false );
+ if ( icon.isNull() )
+ icon = modIcon;
+
+ icon.convertFromImage( icon.convertToImage().smoothScale( iconSize, iconSize, QImage::ScaleMin ) );
+
+ QAction* a = createAction( -1, *it, icon, *it, tr( "PRP_MODULE" ).arg( *it ), 0, desk, true );
+ a->addTo( modTBar );
+ modGroup->add( a );
+
+ myActions.insert( *it, a );
+ }
+
+ SUIT_Tools::simplifySeparators( modTBar );
+
+ // New window
+ int windowMenu = createMenu( tr( "MEN_DESK_WINDOW" ), -1, 100 );
+ int newWinMenu = createMenu( tr( "MEN_DESK_NEWWINDOW" ), windowMenu, -1, 0 );
+ createMenu( separator(), windowMenu, -1, 1 );
+
+ QMap<int, int> accelMap;
+ accelMap[NewGLViewId] = ALT+Key_G;
+ accelMap[NewPlot2dId] = ALT+Key_P;
+ accelMap[NewOCCViewId] = ALT+Key_O;
+ accelMap[NewVTKViewId] = ALT+Key_K;
+
+ for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
+ {
+ QAction* a = createAction( id, tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ), QIconSet(),
+ tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
+ tr( QString( "NEW_WINDOW_%1" ).arg( id - NewGLViewId ) ),
+ accelMap.contains( id ) ? accelMap[id] : 0, desk, false, this, SLOT( onNewWindow() ) );
+ createMenu( a, newWinMenu, -1 );
+ }
+
+ connect( modGroup, SIGNAL( selected( QAction* ) ), this, SLOT( onModuleActivation( QAction* ) ) );
+
+ int fileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1 );
+ createMenu( PreferencesId, fileMenu, 15, -1 );
+ createMenu( separator(), fileMenu, -1, 15, -1 );
+
+ /*
+ createMenu( separator(), fileMenu, -1, 100, -1 );
+ createMenu( MRUId, fileMenu, 100, -1 );
+ createMenu( separator(), fileMenu, -1, 100, -1 );
+ */
+}
+
+/*!On module activation action.*/
+void LightApp_Application::onModuleActivation( QAction* a )
+{
+ if ( !a )
+ return;
+
+ QString modName = a->menuText();
+ if ( modName == tr( "APP_NAME" ) )
+ modName = QString::null;
+
+ // Force user to create/open a study before module activation
+ QMap<QString, QString> iconMap;
+ moduleIconNames( iconMap );
+ QPixmap icon = resourceMgr()->loadPixmap( moduleName( modName ), iconMap[ modName ], false );
+ if ( icon.isNull() )
+ icon = resourceMgr()->loadPixmap( "LightApp", tr( "APP_MODULE_BIG_ICO" ), false ); // default icon for any module
+
+ bool cancelled = false;
+ while ( !modName.isEmpty() && !activeStudy() && !cancelled ){
+ LightApp_ModuleDlg aDlg( desktop(), modName, icon );
+ int res = aDlg.exec();
+
+ switch ( res ){
+ case 1:
+ onNewDoc();
+ break;
+ case 2:
+ onOpenDoc();
+ break;
+ case 3:
+ //onLoadStudy();
+ //break;
+ case 0:
+ default:
+ putInfo( tr("INF_CANCELLED") );
+ myActions[QString()]->setOn( true );
+ cancelled = true;
+ }
+ }
+
+ if ( !cancelled )
+ activateModule( modName );
+}
+
+/*!Default module activation.*/
+QString LightApp_Application::defaultModule() const
+{
+ QStringList aModuleNames;
+ modules( aModuleNames, false ); // obtain a complete list of module names for the current configuration
+ //! If there's the one and only module --> activate it automatically
+ //! TODO: Possible improvement - default module can be taken from preferences
+ return aModuleNames.count() > 1 ? "" : ( aModuleNames.count() ? aModuleNames.first() : "" );
+}
+
+/*!On new window slot.*/
+void LightApp_Application::onNewWindow()
+{
+ const QObject* obj = sender();
+ if ( !obj || !obj->inherits( "QAction" ) )
+ return;
+
+ QString type;
+ int id = actionId( (QAction*)obj );
+ switch ( id )
+ {
+ case NewGLViewId:
+ type = GLViewer_Viewer::Type();
+ break;
+ case NewPlot2dId:
+ type = Plot2d_Viewer::Type();
+ break;
+ case NewOCCViewId:
+ type = OCCViewer_Viewer::Type();
+ break;
+ case NewVTKViewId:
+ type = VTKViewer_Viewer::Type();
+ break;
+ }
+
+ if ( !type.isEmpty() )
+ createViewManager( type );
+}
+
+//=======================================================================
+// name : onNewDoc
+/*! Purpose : SLOT. Create new document*/
+//=======================================================================
+void LightApp_Application::onNewDoc()
+{
+ SUIT_Study* study = activeStudy();
+
+ saveWindowsGeometry();
+
+ CAM_Application::onNewDoc();
+
+ if ( !study ) // new study will be create in THIS application
+ {
+ updateWindows();
+ updateViewManagers();
+ }
+}
+
+//=======================================================================
+// name : onOpenDoc
+/*! Purpose : SLOT. Open new document*/
+//=======================================================================
+void LightApp_Application::onOpenDoc()
+{
+ SUIT_Study* study = activeStudy();
+ saveWindowsGeometry();
+
+ CAM_Application::onOpenDoc();
+
+ if ( !study ) // new study will be create in THIS application
+ {
+ updateWindows();
+ updateViewManagers();
+ }
+}
+
+#include "SUIT_MessageBox.h"
+/*! Purpose : SLOT. Open new document with \a aName.*/
+bool LightApp_Application::onOpenDoc( const QString& aName )
+{
+ bool isAlreadyOpen = false;
+
+ // Look among opened studies
+ if (activeStudy()) { // at least one study is opened
+ SUIT_Session* aSession = SUIT_Session::session();
+ QPtrList<SUIT_Application> aAppList = aSession->applications();
+ QPtrListIterator<SUIT_Application> it (aAppList);
+ SUIT_Application* aApp = 0;
+ // iterate on all applications
+ for (; (aApp = it.current()) && !isAlreadyOpen; ++it) {
+ if (aApp->activeStudy()->studyName() == aName) {
+ isAlreadyOpen = true; // Already opened, ask user what to do
+
+ // The document ... is already open.
+ // Do you want to reload it?
+ int aAnswer = SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"),
+ tr("QUE_DOC_ALREADYOPEN").arg(aName),
+ tr("BUT_YES"), tr("BUT_NO"), 1, 2, 2);
+ if (aAnswer == 1) { // reload
+ if (activeStudy()->studyName() == aName && aAppList.count() > 1) {
+ // Opened in THIS (active) application.
+ STD_Application* app1 = (STD_Application*)aAppList.at(0);
+ STD_Application* app2 = (STD_Application*)aAppList.at(1);
+ if (!app1 || !app2) {
+ // Error
+ return false;
+ }
+ if (app1->activeStudy()->studyName() == aName) {
+ // app1 is this application, we need another one
+ app1 = app2;
+ }
+ // Close document of this application. This application will be destroyed.
+ onCloseDoc(/*ask = */false);
+ // Open the file with another application, as this one will be destroyed.
+ return app1->onOpenDoc(aName);
+ } else {
+ // Opened in another application.
+ STD_Application* app = (STD_Application*)aApp;
+ if (app)
+ app->onCloseDoc(/*ask = */false);
+ }
+ } else { // do not reload
+ // OK, the study will not be reloaded, but we call
+ // CAM_Application::onOpenDoc( aName ) all the same.
+ // It will activate a desktop of the study <aName>.
+ }
+ }
+ }
+ }
+
+ bool res = CAM_Application::onOpenDoc( aName );
+
+ QAction* a = action( MRUId );
+ if ( a && a->inherits( "QtxMRUAction" ) )
+ {
+ QtxMRUAction* mru = (QtxMRUAction*)a;
+ if ( res )
+ mru->insert( aName );
+ else
+ mru->remove( aName );
+ }
+ return res;
+}
+
+//=======================================================================
+// name : onHelpAbout
+/*! Purpose : SLOT. Display "About" message box*/
+//=======================================================================
+void LightApp_Application::onHelpAbout()
+{
+ LightApp_AboutDlg* dlg = new LightApp_AboutDlg( applicationName(), applicationVersion(), desktop() );
+ dlg->exec();
+ delete dlg;
+}
+
+/*!SLOT. Load document with \a aName.*/
+bool LightApp_Application::onLoadDoc( const QString& aName )
+{
+ bool res = CAM_Application::onLoadDoc( aName );
+
+ /*jfa tmp:QAction* a = action( MRUId );
+ if ( a && a->inherits( "QtxMRUAction" ) )
+ {
+ QtxMRUAction* mru = (QtxMRUAction*)a;
+ if ( res )
+ mru->insert( aName );
+ else
+ mru->remove( aName );
+ }*/
+ return res;
+}
+
+/*!Private SLOT. Selection.*/
+void LightApp_Application::onSelection()
+{
+ onSelectionChanged();
+
+ if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
+ ((LightApp_Module*)activeModule())->selectionChanged();
+}
+
+/*!Set active study.
+ *\param study - SUIT_Study.
+ */
+void LightApp_Application::setActiveStudy( SUIT_Study* study )
+{
+ CAM_Application::setActiveStudy( study );
+
+ activateWindows();
+}
+
+//=======================================================================
+// name : updateCommandsStatus
+/*! Purpose : Enable/Disable menu items and toolbar buttons. Rebuild menu*/
+//=======================================================================
+void LightApp_Application::updateCommandsStatus()
+{
+ CAM_Application::updateCommandsStatus();
+
+ for ( int id = NewGLViewId; id <= NewVTKViewId; id++ )
+ {
+ QAction* a = action( id );
+ if ( a )
+ a->setEnabled( activeStudy() );
+ }
+}
+
+// Helps to execute command
+class RunBrowser: public QThread {
+public:
+
+ RunBrowser(QString theApp, QString theParams, QString theHelpFile, QString theContext=NULL):
+ myApp(theApp), myParams(theParams), myHelpFile("file:" + theHelpFile + theContext), myStatus(0) {};
+
+ virtual void run()
+ {
+ QString aCommand;
+
+ if ( !myApp.isEmpty())
+ {
+ aCommand.sprintf("%s %s %s",myApp.latin1(),myParams.latin1(),myHelpFile.latin1());
+ myStatus = system(aCommand);
+ if(myStatus != 0)
+ {
+ QCustomEvent* ce2000 = new QCustomEvent (2000);
+ postEvent (qApp, ce2000);
+ }
+ }
+
+ if( myStatus != 0 || myApp.isEmpty())
+ {
+ myParams = "";
+ aCommand.sprintf("%s %s %s", QString(DEFAULT_BROWSER).latin1(),myParams.latin1(), myHelpFile.latin1());
+ myStatus = system(aCommand);
+ if(myStatus != 0)
+ {
+ QCustomEvent* ce2001 = new QCustomEvent (2001);
+ postEvent (qApp, ce2001);
+ }
+ }
+ }
+
+private:
+ QString myApp;
+ QString myParams;
+ QString myHelpFile;
+ int myStatus;
+
+};
+
+//=======================================================================
+// name : onHelpContentsModule
+/*! Purpose : SLOT. Display help contents for choosen module*/
+//=======================================================================
+void LightApp_Application::onHelpContentsModule()
+{
+ const QAction* obj = (QAction*) sender();
+
+ QString aComponentName = obj->name();
+ QString aFileName = aComponentName.lower() + ".htm";
+
+ QCString dir;
+ QString root;
+ QString homeDir;
+ if (dir = getenv( aComponentName + "_ROOT_DIR")) {
+ root = Qtx::addSlash( Qtx::addSlash(dir) + Qtx::addSlash("doc") + Qtx::addSlash("salome") + Qtx::addSlash(aComponentName));
+ if ( QFileInfo( root + aFileName ).exists() ) {
+ homeDir = root;
+ } else {
+ SUIT_MessageBox::warn1( desktop(), tr("WRN_WARNING"),
+ QString( "%1"+ aFileName + " doesn't exist." ).arg(root), tr ("BUT_OK") );
+ return;
+ }
+ }
+
+ QString helpFile = QFileInfo( homeDir + aFileName ).absFilePath();
+ SUIT_ResourceMgr* resMgr = resourceMgr();
+ QString anApp = resMgr->stringValue("ExternalBrowser", "application");
+ QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
+
+ RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile);
+ rs->start();
+}
+
+/*!Sets enable or disable some actions on selection changed.*/
+void LightApp_Application::onSelectionChanged()
+{
+}
+
+/*!Return window.
+ *\param flag - key for window
+ *\param studyId - study id
+ * Flag used how identificator of window in windows list.
+ */
+QWidget* LightApp_Application::window( const int flag, const int studyId ) const
+{
+ QWidget* wid = 0;
+
+ int sId = studyId;
+ if ( sId < 0 )
+ {
+ if ( !activeStudy() )
+ return 0;
+ else
+ sId = activeStudy()->id();
+ }
+
+ if ( myWindows.contains( flag ) )
+ wid = myWindows[flag]->widget( sId );
+
+ return wid;
+}
+
+/*!Adds window to application.
+ *\param wid - QWidget
+ *\param flag - key wor window
+ *\param studyId - study id
+ * Flag used how identificator of window in windows list.
+ */
+void LightApp_Application::addWindow( QWidget* wid, const int flag, const int studyId )
+{
+ if ( !wid )
+ return;
+
+ int sId = studyId;
+ if ( sId < 0 )
+ {
+ if ( !activeStudy() )
+ return;
+ else
+ sId = activeStudy()->id();
+ }
+
+ if ( !myWindows.contains( flag ) )
+ {
+ QMap<int, int> winMap;
+ currentWindows( winMap );
+
+ myWindows.insert( flag, new LightApp_WidgetContainer( flag, desktop() ) );
+ if ( winMap.contains( flag ) )
+ desktop()->moveDockWindow( myWindows[flag], (Dock)winMap[flag] );
+
+ myWindows[flag]->setResizeEnabled( true );
+ myWindows[flag]->setCloseMode( QDockWindow::Always );
+ myWindows[flag]->setName( QString( "dock_window_%1" ).arg( flag ) );
+ }
+
+ QFont f;
+ if( wid->inherits( "PythonConsole" ) )
+ f = ( ( PythonConsole* )wid )->font();
+ else
+ f = wid->font();
+
+ myWindows[flag]->insert( sId, wid );
+ wid->setFont(f);
+
+ setWindowShown( flag, !myWindows[flag]->isEmpty() );
+}
+
+/*!Remove window from application.
+ *\param flag - key wor window
+ *\param studyId - study id
+ * Flag used how identificator of window in windows list.
+ */
+void LightApp_Application::removeWindow( const int flag, const int studyId )
+{
+ if ( !myWindows.contains( flag ) )
+ return;
+
+ int sId = studyId;
+ if ( sId < 0 )
+ {
+ if ( !activeStudy() )
+ return;
+ else
+ sId = activeStudy()->id();
+ }
+
+ QWidget* wid = myWindows[flag]->widget( sId );
+ myWindows[flag]->remove( sId );
+ delete wid;
+
+ setWindowShown( flag, !myWindows[flag]->isEmpty() );
+}
+
+/*!Gets window.
+ *\param flag - key wor window
+ *\param studyId - study id
+ * Flag used how identificator of window in windows list.
+ */
+QWidget* LightApp_Application::getWindow( const int flag, const int studyId )
+{
+ QWidget* wid = window( flag, studyId );
+ if ( !wid )
+ addWindow( wid = createWindow( flag ), flag, studyId );
+
+ return wid;
+}
+
+/*!Check is window visible?(with identificator \a type)*/
+bool LightApp_Application::isWindowVisible( const int type ) const
+{
+ bool res = false;
+ if ( myWindows.contains( type ) )
+ {
+ SUIT_Desktop* desk = ((LightApp_Application*)this)->desktop();
+ res = desk && desk->appropriate( myWindows[type] );
+ }
+ return res;
+}
+
+/*!Sets window show or hide.
+ *\param type - window identificator.
+ *\param on - true/false (window show/hide)
+ */
+void LightApp_Application::setWindowShown( const int type, const bool on )
+{
+ if ( !desktop() || !myWindows.contains( type ) )
+ return;
+
+ QDockWindow* dw = myWindows[type];
+ desktop()->setAppropriate( dw, on );
+ on ? dw->show() : dw->hide();
+}
+
+/*!Gets "ObjectBrowser".*/
+OB_Browser* LightApp_Application::objectBrowser()
+{
+ OB_Browser* ob = 0;
+ QWidget* wid = getWindow( WT_ObjectBrowser );
+ if ( wid->inherits( "OB_Browser" ) )
+ ob = (OB_Browser*)wid;
+ return ob;
+}
+
+/*!Gets "LogWindow".*/
+LogWindow* LightApp_Application::logWindow()
+{
+ LogWindow* lw = 0;
+ QWidget* wid = getWindow( WT_LogWindow );
+ if ( wid->inherits( "LogWindow" ) )
+ lw = (LogWindow*)wid;
+ return lw;
+}
+
+/*!Get "PythonConsole"*/
+PythonConsole* LightApp_Application::pythonConsole()
+{
+ PythonConsole* console = 0;
+ QWidget* wid = getWindow( WT_PyConsole );
+ if ( wid->inherits( "PythonConsole" ) )
+ console = (PythonConsole*)wid;
+ return console;
+}
+
+/*!Update obect browser*/
+void LightApp_Application::updateObjectBrowser( const bool updateModels )
+{
+ // update existing data models
+ if ( updateModels )
+ {
+ LightApp_Study* study = dynamic_cast<LightApp_Study*>(activeStudy());
+ if ( study ) {
+ CAM_Study::ModelList dm_list;
+ study->dataModels( dm_list );
+ for ( CAM_Study::ModelListIterator it( dm_list ); it.current(); ++it ) {
+ CAM_DataModel* camDM = it.current();
+ if ( camDM && camDM->inherits( "LightApp_DataModel" ) )
+ ((LightApp_DataModel*)camDM)->update();
+ }
+ }
+ }
+ if ( objectBrowser() )
+ {
+ objectBrowser()->updateGeometry();
+ objectBrowser()->updateTree();
+ }
+}
+
+/*!Gets preferences.*/
+LightApp_Preferences* LightApp_Application::preferences() const
+{
+ return preferences( false );
+}
+
+/*!Gets view manager*/
+SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, const bool create )
+{
+ SUIT_ViewManager* aVM = viewManager( vmType );
+ SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
+
+ if ( anActiveVM && anActiveVM->getType() == vmType )
+ aVM = anActiveVM;
+
+ if ( aVM && create )
+ {
+ if ( !aVM->getActiveView() )
+ aVM->createView();
+ else
+ aVM->getActiveView()->setFocus();
+ }
+ else if ( create )
+ aVM = createViewManager( vmType );
+
+ return aVM;
+}
+
+/*!Create view manager.*/
+SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
+{
+ SUIT_ResourceMgr* resMgr = resourceMgr();
+
+ SUIT_ViewManager* viewMgr = 0;
+ if ( vmType == GLViewer_Viewer::Type() )
+ {
+ viewMgr = new GLViewer_ViewManager( activeStudy(), desktop() );
+ new LightApp_GLSelector( (GLViewer_Viewer2d*)viewMgr->getViewModel(), mySelMgr );
+ }
+ else if ( vmType == Plot2d_Viewer::Type() )
+ {
+ viewMgr = new Plot2d_ViewManager( activeStudy(), desktop() );
+ viewMgr->setViewModel( new SPlot2d_Viewer() );// custom view model, which extends SALOME_View interface
+ }
+ else if ( vmType == OCCViewer_Viewer::Type() )
+ {
+ viewMgr = new OCCViewer_ViewManager( activeStudy(), desktop() );
+ SOCC_Viewer* vm = new SOCC_Viewer();
+ vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) );
+ vm->setTrihedronSize( resMgr->integerValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) );
+ int u( 1 ), v( 1 );
+ vm->isos( u, v );
+ u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
+ v = resMgr->integerValue( "OCCViewer", "iso_number_v", v );
+ vm->setIsos( u, v );
+ viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
+ new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
+ }
+ else if ( vmType == SVTK_Viewer::Type() )
+ {
+ viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
+ SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
+ if( vm )
+ {
+ vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
+ vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ) );
+ new LightApp_VTKSelector( vm, mySelMgr );
+ }
+ }
+
+ if ( !viewMgr )
+ return 0;
+
+ addViewManager( viewMgr );
+ SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
+
+ if ( viewWin && desktop() )
+ viewWin->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) );
+
+ connect( viewMgr, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
+ this, SLOT( onCloseView( SUIT_ViewManager* ) ) );
+
+ return viewMgr;
+}
+
+//=======================================================================
+// name : onCloseView
+/*! Purpose : SLOT. Remove view manager from application*/
+//=======================================================================
+void LightApp_Application::onCloseView( SUIT_ViewManager* theVM )
+{
+ removeViewManager( theVM );
+}
+
+/*!Protected SLOT. On study created.*/
+void LightApp_Application::onStudyCreated( SUIT_Study* theStudy )
+{
+ SUIT_DataObject* aRoot = 0;
+ if ( theStudy && theStudy->root() )
+ {
+ aRoot = theStudy->root();
+ //aRoot->setName( tr( "DATA_MODELS" ) );
+ }
+ if ( objectBrowser() != 0 )
+ objectBrowser()->setRootObject( aRoot );
+
+ activateModule( defaultModule() );
+
+ activateWindows();
+}
+
+/*!Protected SLOT. On study opened.*/
+void LightApp_Application::onStudyOpened( SUIT_Study* theStudy )
+{
+ SUIT_DataObject* aRoot = 0;
+ if ( theStudy && theStudy->root() )
+ {
+ aRoot = theStudy->root();
+ //aRoot->dump();
+ }
+ if ( objectBrowser() != 0 ) {
+ objectBrowser()->setRootObject( aRoot );
+ }
+
+ activateModule( defaultModule() );
+
+ activateWindows();
+
+ emit studyOpened();
+}
+
+/*!Protected SLOT. On study saved.*/
+void LightApp_Application::onStudySaved( SUIT_Study* )
+{
+ emit studySaved();
+}
+
+/*!Protected SLOT. On study closed.*/
+void LightApp_Application::onStudyClosed( SUIT_Study* )
+{
+ emit studyClosed();
+
+ activateModule( "" );
+
+ // Bug 10396: remove all selectors
+ delete mySelMgr;
+ mySelMgr = new LightApp_SelectionMgr( this );
+
+ saveWindowsGeometry();
+}
+
+/*!Protected SLOT.On desktop activated.*/
+void LightApp_Application::onDesktopActivated()
+{
+ CAM_Application::onDesktopActivated();
+ LightApp_Module* aModule = dynamic_cast<LightApp_Module*>(activeModule());
+ if(aModule)
+ aModule->studyActivated();
+}
+
+/*!Gets file filter.
+ *\retval QString "(*.bin)"
+ */
+QString LightApp_Application::getFileFilter() const
+{
+ return "(*.bin)";
+}
+
+/*! Gets file name*/
+QString LightApp_Application::getFileName( bool open, const QString& initial, const QString& filters,
+ const QString& caption, QWidget* parent )
+{
+ if ( !parent )
+ parent = desktop();
+ QStringList fls = QStringList::split( ";;", filters, false );
+ return SUIT_FileDlg::getFileName( parent, initial, fls, caption, open, true );
+}
+
+/*! Gets directory*/
+QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
+{
+ if ( !parent )
+ parent = desktop();
+ return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
+}
+
+/*! Get open file names*/
+QStringList LightApp_Application::getOpenFileNames( const QString& initial, const QString& filters,
+ const QString& caption, QWidget* parent )
+{
+ if ( !parent )
+ parent = desktop();
+ QStringList fls = QStringList::split( ";;", filters, false );
+ return SUIT_FileDlg::getOpenFileNames( parent, initial, fls, caption, true );
+}
+
+/*!Private SLOT. Update object browser.*/
+void LightApp_Application::onRefresh()
+{
+ updateObjectBrowser( true );
+}
+
+/*!Private SLOT. On preferences.*/
+void LightApp_Application::onPreferences()
+{
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ LightApp_PreferencesDlg* prefDlg = new LightApp_PreferencesDlg( preferences( true ), desktop());
+
+ QApplication::restoreOverrideCursor();
+
+ if ( !prefDlg )
+ return;
+
+ prefDlg->exec();
+
+ delete prefDlg;
+}
+
+/*!Protected SLOT. On preferences changed.*/
+void LightApp_Application::onPreferenceChanged( QString& modName, QString& section, QString& param )
+{
+ LightApp_Module* sMod = 0;
+ CAM_Module* mod = module( modName );
+ if ( mod && mod->inherits( "LightApp_Module" ) )
+ sMod = (LightApp_Module*)mod;
+
+ if ( sMod )
+ sMod->preferencesChanged( section, param );
+ else
+ preferencesChanged( section, param );
+}
+
+/*!Private SLOT. On open document with name \a aName.*/
+void LightApp_Application::onMRUActivated( QString aName )
+{
+ onOpenDoc( aName );
+}
+
+/*!Remove all windows from study.*/
+void LightApp_Application::beforeCloseDoc( SUIT_Study* s )
+{
+ CAM_Application::beforeCloseDoc( s );
+
+ for ( WindowMap::ConstIterator itr = myWindows.begin(); s && itr != myWindows.end(); ++itr )
+ removeWindow( itr.key(), s->id() );
+}
+
+/*!Update actions.*/
+void LightApp_Application::updateActions()
+{
+ updateCommandsStatus();
+}
+
+//=======================================================================
+// name : createNewStudy
+/*! Purpose : Create new study*/
+//=======================================================================
+SUIT_Study* LightApp_Application::createNewStudy()
+{
+ LightApp_Study* aStudy = new LightApp_Study( this );
+
+ // Set up processing of major study-related events
+ connect( aStudy, SIGNAL( created( SUIT_Study* ) ), this, SLOT( onStudyCreated( SUIT_Study* ) ) );
+ connect( aStudy, SIGNAL( opened ( SUIT_Study* ) ), this, SLOT( onStudyOpened ( SUIT_Study* ) ) );
+ connect( aStudy, SIGNAL( saved ( SUIT_Study* ) ), this, SLOT( onStudySaved ( SUIT_Study* ) ) );
+ connect( aStudy, SIGNAL( closed ( SUIT_Study* ) ), this, SLOT( onStudyClosed ( SUIT_Study* ) ) );
+
+ return aStudy;
+}
+
+/*!Create window.*/
+QWidget* LightApp_Application::createWindow( const int flag )
+{
+ QWidget* wid = 0;
+ if ( flag == WT_ObjectBrowser )
+ {
+ OB_Browser* ob = new OB_Browser( desktop() );
+ ob->setAutoUpdate( true );
+ ob->setAutoOpenLevel( 1 );
+ ob->setCaption( tr( "OBJECT_BROWSER" ) );
+ ob->listView()->setColumnWidth( 0, OBJECT_COLUMN_WIDTH );
+ ob->resize( OBJECT_BROWSER_WIDTH, ob->height() );
+ ob->setFilter( new LightApp_OBFilter( selectionMgr() ) );
+
+ ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) );
+
+ // Create OBSelector
+ new LightApp_OBSelector( ob, mySelMgr );
+
+ wid = ob;
+
+ ob->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
+ }
+ else if ( flag == WT_PyConsole )
+ {
+ PythonConsole* pyCons = new PythonConsole( desktop() );
+ pyCons->setCaption( tr( "PYTHON_CONSOLE" ) );
+ wid = pyCons;
+ // pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
+ }
+ else if ( flag == WT_LogWindow )
+ {
+ LogWindow* logWin = new LogWindow( desktop() );
+ logWin->setCaption( tr( "LOG_WINDOW" ) );
+ wid = logWin;
+ logWin->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
+ }
+ return wid;
+}
+
+/*!Default windows(Object Browser, Python Console).
+ * Adds to map \a aMap.
+ */
+void LightApp_Application::defaultWindows( QMap<int, int>& aMap ) const
+{
+ aMap.insert( WT_ObjectBrowser, Qt::DockLeft );
+ aMap.insert( WT_PyConsole, Qt::DockBottom );
+ // aMap.insert( WT_LogWindow, Qt::DockBottom );
+}
+
+/*!Default view manager.*/
+void LightApp_Application::defaultViewManagers( QStringList& ) const
+{
+ /*!Do nothing.*/
+}
+
+/*!Gets preferences.
+ * Create preferences, if \a crt = true.
+ */
+LightApp_Preferences* LightApp_Application::preferences( const bool crt ) const
+{
+ if ( myPrefs )
+ return myPrefs;
+
+ LightApp_Application* that = (LightApp_Application*)this;
+
+ if ( !_prefs_ && crt )
+ {
+ _prefs_ = new LightApp_Preferences( resourceMgr() );
+ that->createPreferences( _prefs_ );
+ }
+
+ that->myPrefs = _prefs_;
+
+ QPtrList<SUIT_Application> appList = SUIT_Session::session()->applications();
+ for ( QPtrListIterator<SUIT_Application> appIt ( appList ); appIt.current(); ++appIt )
+ {
+ if ( !appIt.current()->inherits( "LightApp_Application" ) )
+ continue;
+
+ LightApp_Application* app = (LightApp_Application*)appIt.current();
+
+ QStringList modNameList;
+ app->modules( modNameList, false );
+ for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
+ {
+ int id = _prefs_->addPreference( *it );
+ _prefs_->setItemProperty( id, "info", tr( "PREFERENCES_NOT_LOADED" ).arg( *it ) );
+ }
+
+ ModuleList modList;
+ app->modules( modList );
+ for ( ModuleListIterator itr( modList ); itr.current(); ++itr )
+ {
+ LightApp_Module* mod = 0;
+ if ( itr.current()->inherits( "LightApp_Module" ) )
+ mod = (LightApp_Module*)itr.current();
+
+ if ( mod && !_prefs_->hasModule( mod->moduleName() ) )
+ {
+ int modCat = _prefs_->addPreference( mod->moduleName() );
+ _prefs_->setItemProperty( modCat, "info", QString::null );
+ mod->createPreferences();
+ }
+ }
+ }
+
+ connect( myPrefs, SIGNAL( preferenceChanged( QString&, QString&, QString& ) ),
+ this, SLOT( onPreferenceChanged( QString&, QString&, QString& ) ) );
+
+ return myPrefs;
+}
+
+/*!Add new module to application.*/
+void LightApp_Application::moduleAdded( CAM_Module* mod )
+{
+ CAM_Application::moduleAdded( mod );
+
+ LightApp_Module* lightMod = 0;
+ if ( mod && mod->inherits( "LightApp_Module" ) )
+ lightMod = (LightApp_Module*)mod;
+
+ if ( myPrefs && lightMod && !myPrefs->hasModule( lightMod->moduleName() ))
+ {
+ int modCat = myPrefs->addPreference( mod->moduleName() );
+ myPrefs->setItemProperty( modCat, "info", QString::null );
+ lightMod->createPreferences();
+ }
+}
+
+/*!Create preferences.*/
+void LightApp_Application::createPreferences( LightApp_Preferences* pref )
+{
+ if ( !pref )
+ return;
+
+ int salomeCat = pref->addPreference( tr( "PREF_CATEGORY_SALOME" ) );
+
+ int genTab = pref->addPreference( tr( "PREF_TAB_GENERAL" ), salomeCat );
+ int studyGroup = pref->addPreference( tr( "PREF_GROUP_STUDY" ), genTab );
+ pref->setItemProperty( studyGroup, "columns", 1 );
+
+ pref->addPreference( tr( "PREF_MULTI_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "multi_file" );
+ pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" );
+ int undoPref = pref->addPreference( tr( "PREF_UNDO_LEVEL" ), studyGroup, LightApp_Preferences::IntSpin, "Study", "undo_level" );
+ pref->setItemProperty( undoPref, "min", 1 );
+ pref->setItemProperty( undoPref, "max", 100 );
+
+ int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
+ pref->setItemProperty( extgroup, "columns", 1 );
+ int apppref = pref->addPreference( tr( "PREF_APP" ), extgroup, LightApp_Preferences::File, "ExternalBrowser", "application" );
+ pref->setItemProperty( apppref, "existing", true );
+ pref->setItemProperty( apppref, "flags", QFileInfo::ExeUser );
+
+ pref->addPreference( tr( "PREF_PARAM" ), extgroup, LightApp_Preferences::String, "ExternalBrowser", "parameters" );
+
+ int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab );
+ pref->setItemProperty( pythonConsoleGroup, "columns", 1 );
+ pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" );
+
+ int viewTab = pref->addPreference( tr( "PREF_TAB_VIEWERS" ), salomeCat );
+
+ int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), viewTab );
+
+ int vtkGroup = pref->addPreference( tr( "PREF_GROUP_VTKVIEWER" ), viewTab );
+
+ int plot2dGroup = pref->addPreference( tr( "PREF_GROUP_PLOT2DVIEWER" ), viewTab );
+
+ pref->setItemProperty( occGroup, "columns", 1 );
+ pref->setItemProperty( vtkGroup, "columns", 1 );
+ pref->setItemProperty( plot2dGroup, "columns", 1 );
+
+ int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup,
+ LightApp_Preferences::IntSpin, "OCCViewer", "trihedron_size" );
+ pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup,
+ LightApp_Preferences::Color, "OCCViewer", "background" );
+
+ pref->setItemProperty( occTS, "min", 1 );
+ pref->setItemProperty( occTS, "max", 150 );
+
+ int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup,
+ LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" );
+ int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup,
+ LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" );
+
+ pref->setItemProperty( isoU, "min", 0 );
+ pref->setItemProperty( isoU, "max", 100000 );
+
+ pref->setItemProperty( isoV, "min", 0 );
+ pref->setItemProperty( isoV, "max", 100000 );
+
+ int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup,
+ LightApp_Preferences::IntSpin, "VTKViewer", "trihedron_size" );
+ pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup,
+ LightApp_Preferences::Color, "VTKViewer", "background" );
+
+ pref->setItemProperty( vtkTS, "min", 1 );
+ pref->setItemProperty( vtkTS, "max", 150 );
+
+ pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup,
+ LightApp_Preferences::Bool, "Plot2d", "ShowLegend" );
+
+ int legendPosition = pref->addPreference( tr( "PREF_LEGEND_POSITION" ), plot2dGroup,
+ LightApp_Preferences::Selector, "Plot2d", "LegendPos" );
+ QStringList aLegendPosList;
+ aLegendPosList.append( tr("PREF_LEFT") );
+ aLegendPosList.append( tr("PREF_RIGHT") );
+ aLegendPosList.append( tr("PREF_TOP") );
+ aLegendPosList.append( tr("PREF_BOTTOM") );
+
+ QValueList<QVariant> anIndexesList;
+ anIndexesList.append(0);
+ anIndexesList.append(1);
+ anIndexesList.append(2);
+ anIndexesList.append(3);
+
+ pref->setItemProperty( legendPosition, "strings", aLegendPosList );
+ pref->setItemProperty( legendPosition, "indexes", anIndexesList );
+
+ int curveType = pref->addPreference( tr( "PREF_CURVE_TYPE" ), plot2dGroup,
+ LightApp_Preferences::Selector, "Plot2d", "CurveType" );
+ QStringList aCurveTypesList;
+ aCurveTypesList.append( tr("PREF_POINTS") );
+ aCurveTypesList.append( tr("PREF_LINES") );
+ aCurveTypesList.append( tr("PREF_SPLINE") );
+
+ anIndexesList.clear();
+ anIndexesList.append(0);
+ anIndexesList.append(1);
+ anIndexesList.append(2);
+
+ pref->setItemProperty( curveType, "strings", aCurveTypesList );
+ pref->setItemProperty( curveType, "indexes", anIndexesList );
+
+ int markerSize = pref->addPreference( tr( "PREF_MARKER_SIZE" ), plot2dGroup,
+ LightApp_Preferences::IntSpin, "Plot2d", "MarkerSize" );
+
+ pref->setItemProperty( markerSize, "min", 0 );
+ pref->setItemProperty( markerSize, "max", 100 );
+
+ QStringList aScaleModesList;
+ aScaleModesList.append( tr("PREF_LINEAR") );
+ aScaleModesList.append( tr("PREF_LOGARITHMIC") );
+
+ anIndexesList.clear();
+ anIndexesList.append(0);
+ anIndexesList.append(1);
+
+ int horScale = pref->addPreference( tr( "PREF_HOR_AXIS_SCALE" ), plot2dGroup,
+ LightApp_Preferences::Selector, "Plot2d", "HorScaleMode" );
+
+ pref->setItemProperty( horScale, "strings", aScaleModesList );
+ pref->setItemProperty( horScale, "indexes", anIndexesList );
+
+ int verScale = pref->addPreference( tr( "PREF_VERT_AXIS_SCALE" ), plot2dGroup,
+ LightApp_Preferences::Selector, "Plot2d", "VerScaleMode" );
+
+ pref->setItemProperty( verScale, "strings", aScaleModesList );
+ pref->setItemProperty( verScale, "indexes", anIndexesList );
+
+ pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), plot2dGroup,
+ LightApp_Preferences::Color, "Plot2d", "Background" );
+
+ int dirTab = pref->addPreference( tr( "PREF_TAB_DIRECTORIES" ), salomeCat );
+ int dirGroup = pref->addPreference( tr( "PREF_GROUP_DIRECTORIES" ), dirTab );
+ pref->setItemProperty( dirGroup, "columns", 1 );
+ pref->addPreference( tr( "" ), dirGroup,
+ LightApp_Preferences::DirList, "FileDlg", "QuickDirList" );
+}
+
+/*!Changed preferences */
+void LightApp_Application::preferencesChanged( const QString& sec, const QString& param )
+{
+ SUIT_ResourceMgr* resMgr = resourceMgr();
+ if ( !resMgr )
+ return;
+
+ if ( sec == QString( "OCCViewer" ) && param == QString( "trihedron_size" ) )
+ {
+ int sz = resMgr->integerValue( sec, param, -1 );
+ QPtrList<SUIT_ViewManager> lst;
+ viewManagers( OCCViewer_Viewer::Type(), lst );
+ for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
+ {
+ SUIT_ViewModel* vm = it.current()->getViewModel();
+ if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
+ continue;
+
+ OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
+ occVM->setTrihedronSize( sz );
+ occVM->getAISContext()->UpdateCurrentViewer();
+ }
+ }
+
+ if ( sec == QString( "VTKViewer" ) && param == QString( "trihedron_size" ) )
+ {
+ int sz = resMgr->integerValue( sec, param, -1 );
+ QPtrList<SUIT_ViewManager> lst;
+ viewManagers( SVTK_Viewer::Type(), lst );
+ for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current() && sz >= 0; ++it )
+ {
+ SUIT_ViewModel* vm = it.current()->getViewModel();
+ if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
+ continue;
+
+ SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
+ if( vtkVM )
+ {
+ vtkVM->setTrihedronSize( sz );
+ vtkVM->Repaint();
+ }
+ }
+ }
+
+ if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) )
+ {
+ QPtrList<SUIT_ViewManager> lst;
+ viewManagers( OCCViewer_Viewer::Type(), lst );
+ int u = resMgr->integerValue( sec, "iso_number_u" );
+ int v = resMgr->integerValue( sec, "iso_number_v" );
+ for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it )
+ ((OCCViewer_Viewer*)it.current())->setIsos( u, v );
+ }
+
+ if( sec=="ObjectBrowser" )
+ {
+ if( param=="auto_size" )
+ {
+ OB_Browser* ob = objectBrowser();
+ if( !ob )
+ return;
+
+ bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
+ ob->setWidthMode( autoSize ? QListView::Maximum : QListView::Manual );
+
+ updateObjectBrowser( false );
+ }
+ }
+
+ if( sec=="PyConsole" )
+ {
+ if( param=="font" )
+ if( pythonConsole() )
+ pythonConsole()->setFont( resMgr->fontValue( "PyConsole", "font" ) );
+ }
+}
+
+/*!Update desktop title.*/
+void LightApp_Application::updateDesktopTitle() {
+ QString aTitle = applicationName();
+ QString aVer = applicationVersion();
+ if ( !aVer.isEmpty() )
+ aTitle += QString( " " ) + aVer;
+
+ desktop()->setCaption( aTitle );
+}
+
+/*!Update windows after close document.*/
+void LightApp_Application::afterCloseDoc()
+{
+ updateWindows();
+
+ CAM_Application::afterCloseDoc();
+}
+
+/*!Update module action.*/
+void LightApp_Application::updateModuleActions()
+{
+ QString modName;
+ if ( activeModule() )
+ modName = activeModule()->moduleName();
+
+ if ( myActions.contains( modName ) )
+ myActions[modName]->setOn( true );
+}
+
+/*!Gets current windows.
+ *\param winMap - output current windows map.
+ */
+void LightApp_Application::currentWindows( QMap<int, int>& winMap ) const
+{
+ winMap.clear();
+ if ( !activeStudy() )
+ return;
+
+ if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
+ ((LightApp_Module*)activeModule())->windows( winMap );
+ else
+ defaultWindows( winMap );
+}
+
+/*!Gets current view managers.
+ *\param lst - output current view managers list.
+ */
+void LightApp_Application::currentViewManagers( QStringList& lst ) const
+{
+ lst.clear();
+ if ( !activeStudy() )
+ return;
+
+ if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
+ ((LightApp_Module*)activeModule())->viewManagers( lst );
+ else
+ defaultViewManagers( lst );
+}
+
+/*!Update windows.*/
+void LightApp_Application::updateWindows()
+{
+ QMap<int, int> winMap;
+ currentWindows( winMap );
+
+ for ( QMap<int, int>::ConstIterator it = winMap.begin(); it != winMap.end(); ++it )
+ getWindow( it.key() );
+
+ loadWindowsGeometry();
+
+ for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
+ setWindowShown( itr.key(), !itr.data()->isEmpty() && winMap.contains( itr.key() ) );
+}
+
+/*!Update view managers.*/
+void LightApp_Application::updateViewManagers()
+{
+ QStringList lst;
+ currentViewManagers( lst );
+
+ for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it )
+ getViewManager( *it, true );
+}
+
+/*!Load windows geometry.*/
+void LightApp_Application::loadWindowsGeometry()
+{
+ QtxDockAction* dockMgr = 0;
+
+ QAction* a = action( ViewWindowsId );
+ if ( a && a->inherits( "QtxDockAction" ) )
+ dockMgr = (QtxDockAction*)a;
+
+ if ( !dockMgr )
+ return;
+
+ QString modName;
+ if ( activeModule() )
+ modName = activeModule()->name("");
+
+ QString section = QString( "windows_geometry" );
+ if ( !modName.isEmpty() )
+ section += QString( "." ) + modName;
+
+ dockMgr->loadGeometry( resourceMgr(), section, false );
+ dockMgr->restoreGeometry();
+}
+
+/*!Save windows geometry.*/
+void LightApp_Application::saveWindowsGeometry()
+{
+ QtxDockAction* dockMgr = 0;
+
+ QAction* a = action( ViewWindowsId );
+ if ( a && a->inherits( "QtxDockAction" ) )
+ dockMgr = (QtxDockAction*)a;
+
+ if ( !dockMgr )
+ return;
+
+ QString modName;
+ if ( activeModule() )
+ modName = activeModule()->name("");
+
+ QString section = QString( "windows_geometry" );
+ if ( !modName.isEmpty() )
+ section += QString( "." ) + modName;
+
+ dockMgr->storeGeometry();
+ dockMgr->saveGeometry( resourceMgr(), section, false );
+}
+
+/*!Activate windows.*/
+void LightApp_Application::activateWindows()
+{
+ if ( activeStudy() )
+ {
+ for ( WindowMap::Iterator itr = myWindows.begin(); itr != myWindows.end(); ++itr )
+ itr.data()->activate( activeStudy()->id() );
+ }
+}
+
+/*!Adds icon names for modules.*/
+void LightApp_Application::moduleIconNames( QMap<QString, QString>& iconMap ) const
+{
+ iconMap.clear();
+
+ SUIT_ResourceMgr* resMgr = resourceMgr();
+ if ( !resMgr )
+ return;
+
+ QStringList modList;
+ modules( modList, false );
+
+ for ( QStringList::const_iterator it = modList.begin(); it != modList.end(); ++it )
+ {
+ QString modName = *it;
+ QString modIntr = moduleName( modName );
+ QString modIcon = resMgr->stringValue( modIntr, "icon", QString::null );
+
+ if ( modIcon.isEmpty() )
+ continue;
+
+ if ( SUIT_Tools::extension( modIcon ).isEmpty() )
+ modIcon += QString( ".png" );
+
+ iconMap.insert( modName, modIcon );
+ }
+}
+
+/*!Insert items in popup, which necessary for current application*/
+void LightApp_Application::contextMenuPopup( const QString& type, QPopupMenu* thePopup, QString& title )
+{
+ CAM_Application::contextMenuPopup( type, thePopup, title );
+
+ OB_Browser* ob = objectBrowser();
+ if ( !ob || type != ob->popupClientType() )
+ return;
+
+ thePopup->insertSeparator();
+ thePopup->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
+}
+
+/*!Create empty study.*/
+void LightApp_Application::createEmptyStudy()
+{
+ CAM_Application::createEmptyStudy();
+ if ( objectBrowser() )
+ objectBrowser()->updateTree();
+}
+
+/*!Activate module \a mod.*/
+bool LightApp_Application::activateModule( CAM_Module* mod )
+{
+ bool res = CAM_Application::activateModule( mod );
+ if ( objectBrowser() )
+ objectBrowser()->updateTree();
+ return res;
+}
+
+/*!return keyborad accelerators manager object */
+SUIT_Accel* LightApp_Application::accel() const
+{
+ return myAccel;
+}
--- /dev/null
+// File: LightApp_Application.h
+// Created: 6/20/2005 18:39:25 PM
+// Author: OCC team
+// Copyright (C) CEA 2005
+
+#ifndef LIGHTAPP_APPLICATION_H
+#define LIGHTAPP_APPLICATION_H
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "LightApp.h"
+#include <CAM_Application.h>
+
+class LogWindow;
+class OB_Browser;
+class PythonConsole;
+class STD_Application;
+class LightApp_WidgetContainer;
+class LightApp_Preferences;
+class LightApp_SelectionMgr;
+class SUIT_Study;
+class SUIT_Accel;
+class CAM_Module;
+
+class QString;
+class QWidget;
+class QStringList;
+class QPixmap;
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+/*!
+ Description : Application containing only LightApp module
+*/
+
+class LIGHTAPP_EXPORT LightApp_Application : public CAM_Application
+{
+ Q_OBJECT
+
+public:
+ typedef enum { WT_ObjectBrowser, WT_PyConsole, WT_LogWindow, WT_User } WindowTypes;
+
+ enum { NewGLViewId = STD_Application::UserID, NewPlot2dId, NewOCCViewId, NewVTKViewId,
+ PreferencesId, MRUId, UserID };
+public:
+ LightApp_Application();
+ virtual ~LightApp_Application();
+
+ virtual QString applicationName() const;
+ virtual QString applicationVersion() const;
+
+ virtual CAM_Module* loadModule( const QString& );
+ virtual bool activateModule( const QString& );
+
+ virtual bool useStudy( const QString& );
+
+ LightApp_SelectionMgr* selectionMgr() const;
+
+ LogWindow* logWindow();
+ OB_Browser* objectBrowser();
+ PythonConsole* pythonConsole();
+
+ virtual void updateObjectBrowser( const bool = true );
+
+ LightApp_Preferences* preferences() const;
+
+ virtual QString getFileFilter() const;
+
+ virtual QString getFileName( bool open, const QString& initial, const QString& filters,
+ const QString& caption, QWidget* parent );
+ virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent );
+ virtual QStringList getOpenFileNames( const QString& initial, const QString& filters,
+ const QString& caption, QWidget* parent );
+
+ void updateActions();
+
+ SUIT_ViewManager* getViewManager( const QString&, const bool );
+ QWidget* getWindow( const int, const int = -1 );
+ QWidget* window( const int, const int = -1 ) const;
+ void addWindow( QWidget*, const int, const int = -1 );
+ void removeWindow( const int, const int = -1 );
+
+ bool isWindowVisible( const int ) const;
+ void setWindowShown( const int, const bool );
+
+ virtual void start();
+
+ virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& );
+
+ virtual void createEmptyStudy();
+
+ SUIT_Accel* accel() const;
+
+signals:
+ void studyOpened();
+ void studySaved();
+ void studyClosed();
+
+public slots:
+ virtual void onHelpContentsModule();
+ virtual void onNewDoc();
+ virtual void onOpenDoc();
+ virtual void onHelpAbout();
+ virtual bool onOpenDoc( const QString& );
+ virtual bool onLoadDoc( const QString& );
+
+protected:
+ virtual void createActions();
+ virtual SUIT_Study* createNewStudy();
+ virtual QWidget* createWindow( const int );
+ virtual void defaultWindows( QMap<int, int>& ) const;
+ void defaultViewManagers( QStringList& ) const;
+
+ virtual void setActiveStudy( SUIT_Study* );
+ virtual void updateCommandsStatus();
+ virtual void onSelectionChanged();
+
+ virtual void beforeCloseDoc( SUIT_Study* );
+ virtual void afterCloseDoc();
+ virtual void moduleAdded( CAM_Module* );
+ virtual bool activateModule( CAM_Module* = 0 );
+
+ LightApp_Preferences* preferences( const bool ) const;
+ virtual void createPreferences( LightApp_Preferences* );
+ virtual void preferencesChanged( const QString&, const QString& );
+ virtual void updateDesktopTitle();
+
+protected slots:
+ virtual void onDesktopActivated();
+
+ void onNewWindow();
+ void onModuleActivation( QAction* );
+ void onCloseView( SUIT_ViewManager* );
+
+ void onStudyCreated( SUIT_Study* );
+ void onStudyOpened( SUIT_Study* );
+ void onStudySaved( SUIT_Study* );
+ void onStudyClosed( SUIT_Study* );
+
+private slots:
+ void onSelection();
+ void onRefresh();
+ void onPreferences();
+ void onMRUActivated( QString );
+ void onPreferenceChanged( QString&, QString&, QString& );
+
+protected:
+ void updateWindows();
+ void updateViewManagers();
+ void updateModuleActions();
+
+ void loadWindowsGeometry();
+ void saveWindowsGeometry();
+
+ void updatePreference( const QString&, const QString&, const QString& );
+
+ QString defaultModule() const;
+ void currentWindows( QMap<int, int>& ) const;
+ void currentViewManagers( QStringList& ) const;
+ virtual SUIT_ViewManager* createViewManager( const QString& vmType );
+ void moduleIconNames( QMap<QString, QString>& ) const;
+
+ void activateWindows();
+
+protected:
+ typedef QMap<QString, QAction*> ActionMap;
+ typedef QMap<int, LightApp_WidgetContainer*> WindowMap;
+
+protected:
+ LightApp_Preferences* myPrefs;
+ LightApp_SelectionMgr* mySelMgr;
+ ActionMap myActions;
+ WindowMap myWindows;
+
+ SUIT_Accel* myAccel;
+
+ static LightApp_Preferences* _prefs_;
+};
+
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif
--- /dev/null
+// File: LightApp_DataModel.cxx
+// Created: 10/25/2004 10:36:06 AM
+// Author: Sergey LITONIN
+// Copyright (C) CEA 2004
+
+#include "LightApp_DataModel.h"
+#include "LightApp_Study.h"
+#include "LightApp_RootObject.h"
+#include "LightApp_Module.h"
+#include "LightApp_Application.h"
+
+#include <CAM_DataObject.h>
+
+#include <SUIT_Application.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+#include <SUIT_DataObject.h>
+
+//=======================================================================
+// name : LightApp_DataModel::LightApp_DataModel
+/*!Purpose : Constructor*/
+//=======================================================================
+LightApp_DataModel::LightApp_DataModel( CAM_Module* theModule )
+: CAM_DataModel( theModule )
+{
+}
+
+//=======================================================================
+// name : LightApp_DataModel::~LightApp_DataModel
+/*! Purpose : Destructor*/
+//=======================================================================
+LightApp_DataModel::~LightApp_DataModel()
+{
+}
+
+//================================================================
+// Function : open
+/*! Purpose : Emit opened()*/
+//================================================================
+bool LightApp_DataModel::open( const QString&, CAM_Study* study, QStringList )
+{
+ emit opened(); //TODO: is it really needed? to be removed maybe...
+ return true;
+}
+
+//================================================================
+// Function : save
+/*! Purpose : Emit saved()*/
+//================================================================
+bool LightApp_DataModel::save( QStringList& )
+{
+ emit saved();
+ return true;
+}
+
+//================================================================
+// Function : saveAs
+/*! Purpose : Emit saved()*/
+//================================================================
+bool LightApp_DataModel::saveAs( const QString&, CAM_Study*, QStringList& )
+{
+ emit saved();
+ return true;
+}
+
+//================================================================
+// Function : close
+/*! Purpose : Emit closed()*/
+//================================================================
+bool LightApp_DataModel::close()
+{
+ emit closed();
+ return true;
+}
+
+//================================================================
+// Function : update
+/*! Purpose : Update application (empty virtual function).*/
+//================================================================
+void LightApp_DataModel::update( LightApp_DataObject*, LightApp_Study* study )
+{
+}
+
+//================================================================
+// Function : getModule
+/*! Purpose : gets module*/
+//================================================================
+
+LightApp_Module* LightApp_DataModel::getModule() const
+{
+ return dynamic_cast<LightApp_Module*>( module() );
+}
+
+//================================================================
+// Function : getStudy
+/*! Purpose : gets study */
+//================================================================
+LightApp_Study* LightApp_DataModel::getStudy() const
+{
+ LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>( root()->root() );
+ if ( !aRoot )
+ return 0;
+ return aRoot->study();
+}
+
+//================================================================
+// Function : isModified
+/*! Purpose : default implementation, always returns false so as not to mask study's isModified()*/
+//================================================================
+bool LightApp_DataModel::isModified() const
+{
+ return false;
+}
+
+//================================================================
+// Function : isSaved
+/*! Purpose : default implementation, always returns true so as not to mask study's isSaved()*/
+//================================================================
+bool LightApp_DataModel::isSaved() const
+{
+ return true;
+}
--- /dev/null
+// File: LightApp_DataModel.h
+// Created: 10/25/2004 10:32:33 AM
+// Author: Sergey LITONIN
+// Copyright (C) CEA 2004
+
+#ifndef LIGHTAPP_DATAMODEL_H
+#define LIGHTAPP_DATAMODEL_H
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "LightApp.h"
+#include "CAM_DataModel.h"
+
+class LightApp_Module;
+class LightApp_Study;
+class LightApp_DataObject;
+
+/*!
+ Description : Base class of data model
+*/
+class LIGHTAPP_EXPORT LightApp_DataModel : public CAM_DataModel
+{
+ Q_OBJECT
+
+public:
+ LightApp_DataModel ( CAM_Module* theModule );
+ virtual ~LightApp_DataModel();
+
+ virtual bool open( const QString&, CAM_Study*, QStringList );
+ virtual bool save( QStringList& );
+ virtual bool saveAs( const QString&, CAM_Study*, QStringList& );
+ virtual bool close();
+
+ virtual void update( LightApp_DataObject* = 0, LightApp_Study* = 0 );
+
+ virtual bool isModified() const;
+ virtual bool isSaved() const;
+
+ LightApp_Module* getModule() const;
+
+signals:
+ void opened();
+ void saved();
+ void closed();
+
+protected:
+ LightApp_Study* getStudy() const;
+
+};
+
+#endif
--- /dev/null
+#include "LightApp_DataObject.h"
+
+#include "LightApp_Study.h"
+#include "LightApp_RootObject.h"
+
+#include "CAM_DataModel.h"
+#include "CAM_Module.h"
+
+#include <SUIT_Application.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_DataObjectKey.h>
+
+#include <qobject.h>
+
+/*!
+ Class: LightApp_DataObject::Key
+ Level: Internal
+*/
+class LightApp_DataObject::Key : public SUIT_DataObjectKey
+{
+public:
+ Key( const QString& );
+ virtual ~Key();
+
+ virtual bool isLess( const SUIT_DataObjectKey* ) const;
+ virtual bool isEqual( const SUIT_DataObjectKey* ) const;
+
+private:
+ QString myEntry;
+};
+
+/*!Constructor. Initialize by \a entry.*/
+LightApp_DataObject::Key::Key( const QString& entry )
+: SUIT_DataObjectKey(),
+ myEntry( entry )
+{
+}
+
+/*!Destructor. Do nothing.*/
+LightApp_DataObject::Key::~Key()
+{
+}
+
+/*!Checks: Is current key less than \a other.*/
+bool LightApp_DataObject::Key::isLess( const SUIT_DataObjectKey* other ) const
+{
+ Key* that = (Key*)other;
+ return myEntry < that->myEntry;
+}
+
+/*!Checks: Is current key equal with \a other.*/
+bool LightApp_DataObject::Key::isEqual( const SUIT_DataObjectKey* other ) const
+{
+ Key* that = (Key*)other;
+ return myEntry == that->myEntry;
+}
+
+/*
+ Class: LightApp_DataObject
+ Level: Public
+*/
+/*!Constructor. Initialize by \a parent*/
+LightApp_DataObject::LightApp_DataObject( SUIT_DataObject* parent )
+: CAM_DataObject( parent )
+{
+}
+
+/*!Destructor. Do nothing.*/
+LightApp_DataObject::~LightApp_DataObject()
+{
+}
+
+/*!Gets object ID.
+ *\retval QString
+ */
+QString LightApp_DataObject::entry() const
+{
+ return QString::null;
+}
+
+/*!Create and return new key object.*/
+SUIT_DataObjectKey* LightApp_DataObject::key() const
+{
+ QString str = entry();
+ return new Key( str );
+}
+
+/*!Gets component object.
+ *\retval SUIT_DataObject.
+ */
+SUIT_DataObject* LightApp_DataObject::componentObject() const
+{
+ SUIT_DataObject* compObj = 0; // for root object
+
+ if ( parent() && parent() == root() )
+ compObj = (SUIT_DataObject*)this; // for component-level objects
+ else
+ {
+ compObj = parent(); // for lower level objects
+ while ( compObj && compObj->parent() != root() )
+ compObj = compObj->parent();
+ }
+ return compObj;
+}
+
+/*!Get component type.*/
+QString LightApp_DataObject::componentDataType() const
+{
+ SUIT_DataObject* aCompObj = componentObject();
+ LightApp_ModuleObject* anObj = dynamic_cast<LightApp_ModuleObject*>( aCompObj );
+ if ( anObj ) {
+ CAM_DataModel* aModel = anObj->dataModel();
+ if ( aModel )
+ return aModel->module()->name();
+ }
+ return "";
+}
+
+/*
+ Class: LightApp_ModuleObject
+ Level: Public
+*/
+
+/*!Constructor.Initialize by \a parent.*/
+LightApp_ModuleObject::LightApp_ModuleObject( SUIT_DataObject* parent )
+: CAM_RootObject( parent ),
+ CAM_DataObject( parent )
+{
+}
+
+/*!Constructor.Initialize by \a module and parent.*/
+LightApp_ModuleObject::LightApp_ModuleObject( CAM_DataModel* dm, SUIT_DataObject* parent )
+: CAM_RootObject( dm, parent ),
+ CAM_DataObject( parent )
+{
+}
+
+/*!Destructor. Do nothing.*/
+LightApp_ModuleObject::~LightApp_ModuleObject()
+{
+}
+
+/*!Returns module name */
+QString LightApp_ModuleObject::name() const
+{
+ return CAM_RootObject::name();
+}
+
+/*!Insert new child object to the children list at specified position
+ *\add component in Study for this module object if it necessary*/
+void LightApp_ModuleObject::insertChild( SUIT_DataObject* theObj, int thePosition )
+{
+ CAM_RootObject::insertChild(theObj, thePosition);
+
+ CAM_DataModel* aModel = dataModel();
+
+ LightApp_RootObject* aRoot = dynamic_cast<LightApp_RootObject*>(parent());
+
+ if (aRoot)
+ aRoot->study()->addComponent(aModel);
+
+
+}
--- /dev/null
+#ifndef LIGHTAPP_DATAOBJECT_H
+#define LIGHTAPP_DATAOBJECT_H
+
+#include "LightApp.h"
+
+#include "CAM_DataObject.h"
+#include "CAM_DataModel.h"
+#include "CAM_RootObject.h"
+
+class LightApp_Study;
+
+/*!Description : Data Object has empty entry so it's children must redefine metod entry() and return some unique string*/
+// to do : decomment virtual inheritance
+class LIGHTAPP_EXPORT LightApp_DataObject : public virtual CAM_DataObject
+{
+ class Key;
+
+public:
+ enum { CT_Value, CT_Entry, CT_IOR, CT_RefEntry };
+
+public:
+ LightApp_DataObject( SUIT_DataObject* = 0 );
+ virtual ~LightApp_DataObject();
+
+ virtual SUIT_DataObjectKey* key() const;
+ virtual QString entry() const;
+
+ virtual SUIT_DataObject* componentObject() const;
+ virtual QString componentDataType() const;
+
+};
+
+/*!
+ * LightApp_ModuleObject - class for optimized access to DataModel from
+ * CAM_RootObject.h.
+ * In modules which will be redefine LightApp_DataObject, LightApp_ModuleObject must be children from rederined DataObject for having necessary properties and children from LightApp_ModuleObject.
+ */
+
+class LIGHTAPP_EXPORT LightApp_ModuleObject : public CAM_RootObject
+{
+public:
+ LightApp_ModuleObject( SUIT_DataObject* = 0 );
+ LightApp_ModuleObject ( CAM_DataModel*, SUIT_DataObject* = 0 );
+
+ virtual ~LightApp_ModuleObject();
+
+ virtual QString name() const;
+ virtual void insertChild( SUIT_DataObject*, int thePosition );
+};
+
+#endif
--- /dev/null
+#include "LightApp_DataOwner.h"
+
+#include "LightApp_DataObject.h"
+
+#ifdef WNT
+#include <typeinfo.h>
+#endif
+
+#include <iostream>
+
+/*!Constructor. Initialize by \a theEntry.*/
+LightApp_DataOwner
+::LightApp_DataOwner( const QString& theEntry ):
+ myEntry( theEntry )
+{
+}
+
+/*!Constructor. Initialize by \a SALOME_InteractiveObject.*/
+LightApp_DataOwner
+::LightApp_DataOwner( const Handle(SALOME_InteractiveObject)& theIO ):
+ myEntry(!theIO.IsNull()? theIO->getEntry(): ""),
+ myIO(theIO)
+{
+}
+
+/*!Destructor. Do nothing.*/
+LightApp_DataOwner
+::~LightApp_DataOwner()
+{
+}
+
+/*!Checks: Is current data owner equal \a obj.*/
+bool
+LightApp_DataOwner
+::isEqual( const SUIT_DataOwner& obj ) const
+{
+ const LightApp_DataOwner* other = dynamic_cast<const LightApp_DataOwner*>( &obj );
+
+ return other && entry() == other->entry();
+}
+
+/*!Gets entry.*/
+QString
+LightApp_DataOwner
+::entry() const
+{
+ return myEntry;
+}
+
+/*!Gets SALOME_InteractiveObject.*/
+const Handle(SALOME_InteractiveObject)&
+LightApp_DataOwner
+::IO() const
+{
+ return myIO;
+}
--- /dev/null
+
+#ifndef LIGHTAPP_DATAOWNER_H
+#define LIGHTAPP_DATAOWNER_H
+
+#include "LightApp.h"
+#include "SUIT_DataOwner.h"
+#include "SALOME_InteractiveObject.hxx"
+
+/*!
+ This class provide data owner objects.
+*/
+class LIGHTAPP_EXPORT LightApp_DataOwner : public SUIT_DataOwner
+{
+public:
+ LightApp_DataOwner( const Handle(SALOME_InteractiveObject)& theIO );
+ LightApp_DataOwner( const QString& );
+ virtual ~LightApp_DataOwner();
+
+ virtual bool isEqual( const SUIT_DataOwner& ) const;
+ const Handle(SALOME_InteractiveObject)& IO() const;
+ QString entry() const;
+
+private:
+ QString myEntry;
+ Handle(SALOME_InteractiveObject) myIO;
+};
+
+typedef SMART(LightApp_DataOwner) LightApp_DataOwnerPtr;
+
+#endif
--- /dev/null
+#include "LightApp_DataSubOwner.h"
+
+#include "LightApp_DataObject.h"
+
+#ifdef WNT
+#include <typeinfo.h>
+#endif
+
+/*!Constructor.Initialize by \a entry and \a index*/
+LightApp_DataSubOwner::LightApp_DataSubOwner( const QString& entry, const int index )
+: LightApp_DataOwner( entry ),
+myIndex( index )
+{
+}
+
+/*!Destructor. Do nothing.*/
+LightApp_DataSubOwner::~LightApp_DataSubOwner()
+{
+}
+
+/*!Checks: Is current data sub owner equal \a obj.*/
+bool LightApp_DataSubOwner::isEqual( const SUIT_DataOwner& obj ) const
+{
+ const LightApp_DataSubOwner* other = dynamic_cast<const LightApp_DataSubOwner*>( &obj );
+
+ return other && entry() == other->entry() && index() == other->index();
+}
+
+/*!Gets index.*/
+int LightApp_DataSubOwner::index() const
+{
+ return myIndex;
+}
--- /dev/null
+
+#ifndef LIGHTAPP_DATASUBOWNER_H
+#define LIGHTAPP_DATASUBOWNER_H
+
+#include <LightApp.h>
+#include <LightApp_DataOwner.h>
+
+/*!
+ Class provide sub owner.
+ */
+class LIGHTAPP_EXPORT LightApp_DataSubOwner : public LightApp_DataOwner
+{
+public:
+ LightApp_DataSubOwner( const QString&, const int );
+ virtual ~LightApp_DataSubOwner();
+
+ virtual bool isEqual( const SUIT_DataOwner& ) const;
+ int index() const;
+
+private:
+ int myIndex;
+};
+
+#endif
--- /dev/null
+// File: LightApp_Dialog.cxx
+// Author: Alexander SOLOVYOV
+
+#include <LightApp_Dialog.h>
+#include <SUIT_Session.h>
+
+#include <qtoolbutton.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+
+/*
+ Class : LightApp_Dialog
+ Description : Base class for all dialogs
+*/
+
+//=======================================================================
+// name : LightApp_Dialog
+// Purpose : Constructor
+//=======================================================================
+LightApp_Dialog::LightApp_Dialog( QWidget* parent, const char* name, bool modal,
+ bool allowResize, const int f, WFlags wf )
+: QtxDialog( parent, name, modal, allowResize, f, wf ),
+ myIsExclusive( true ),
+ myIsBusy( false )
+{
+ setObjectPixmap( "LightApp", tr( "ICON_SELECT" ) );
+}
+
+//=======================================================================
+// name : ~LightApp_Dialog
+// Purpose : Destructor
+//=======================================================================
+LightApp_Dialog::~LightApp_Dialog()
+{
+}
+
+//=======================================================================
+// name : show
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::show()
+{
+ QtxDialog::show();
+}
+
+//=======================================================================
+// name : isExclusive
+// Purpose :
+//=======================================================================
+bool LightApp_Dialog::isExclusive() const
+{
+ return myIsExclusive;
+}
+
+//=======================================================================
+// name : updateButtons
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::updateButtons( const int _id )
+{
+ if( !myIsExclusive )
+ return;
+
+ int id = _id;
+
+ ObjectMap::const_iterator anIt = myObjects.begin(),
+ aLast = myObjects.end();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ QToolButton* but = (QToolButton*)anIt.data().myBtn;
+ if( but && but->isOn() )
+ {
+ if( id==-1 )
+ id = anIt.key();
+
+ if( anIt.key()!=id )
+ but->setOn( false );
+ }
+ }
+}
+
+//=======================================================================
+// name : setExclusive
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::setExclusive( const bool ex )
+{
+ myIsExclusive = ex;
+ updateButtons();
+}
+
+//=======================================================================
+// name : showObject
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::showObject( const int id )
+{
+ setObjectShown( id, true );
+}
+
+//=======================================================================
+// name : hideObject
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::hideObject( const int id )
+{
+ setObjectShown( id, false );
+}
+
+//=======================================================================
+// name : setObjectShown
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::setObjectShown( const int id, const bool shown )
+{
+ if( myObjects.contains( id ) && isObjectShown( id )!=shown )
+ {
+ Object& obj = myObjects[ id ];
+ obj.myEdit->setShown( shown );
+ obj.myBtn->setShown( shown );
+ obj.myLabel->setShown( shown );
+ if( !shown )
+ ( ( QToolButton* )obj.myBtn )->setOn( false );
+ }
+}
+
+//=======================================================================
+// name : isObjectShown
+// Purpose :
+//=======================================================================
+bool LightApp_Dialog::isObjectShown( const int id ) const
+{
+ return myObjects.contains( id ) && myObjects[ id ].myEdit->isShown();
+}
+
+//=======================================================================
+// name : setObjectEnabled
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::setObjectEnabled( const int id, const bool en )
+{
+ if( myObjects.contains( id ) && isObjectEnabled( id )!=en )
+ {
+ Object& obj = myObjects[ id ];
+ obj.myEdit->setEnabled( en );
+ obj.myBtn->setEnabled( en );
+// obj.myLabel->setEnabled( en );
+ if( !en )
+ ( ( QToolButton* )obj.myBtn )->setOn( false );
+ }
+}
+
+//=======================================================================
+// name : isObjectEnabled
+// Purpose :
+//=======================================================================
+bool LightApp_Dialog::isObjectEnabled( const int id ) const
+{
+ return myObjects.contains( id ) && myObjects[ id ].myEdit->isEnabled();
+}
+
+//=======================================================================
+// name : selectObject
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::selectObject( const QString& name, const int type, const QString& id, const bool update )
+{
+ QStringList names; names.append( name );
+ TypesList types; types.append( type );
+ QStringList ids; ids.append( id );
+ selectObject( names, types, ids, update );
+}
+
+//=======================================================================
+// name : selectObject
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::selectObject( const QStringList& _names,
+ const TypesList& _types,
+ const QStringList& _ids,
+ const bool update )
+{
+ ObjectMap::iterator anIt = myObjects.begin(),
+ aLast = myObjects.end();
+ for( ; anIt!=aLast; anIt++ )
+ if( anIt.data().myBtn->isOn() )
+ selectObject( anIt.key(), _names, _types, _ids, update );
+}
+
+//=======================================================================
+// name : hasSelection
+// Purpose :
+//=======================================================================
+bool LightApp_Dialog::hasSelection( const int id ) const
+{
+ return myObjects.contains( id ) && !myObjects[ id ].myIds.isEmpty();
+}
+
+//=======================================================================
+// name : clearSelection
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::clearSelection( const int id )
+{
+ if( id==-1 )
+ {
+ ObjectMap::const_iterator anIt = myObjects.begin(),
+ aLast = myObjects.end();
+ for( ; anIt!=aLast; anIt++ )
+ clearSelection( anIt.key() );
+ }
+
+ else if( myObjects.contains( id ) )
+ {
+ myObjects[ id ].myIds.clear();
+ myObjects[ id ].myTypes.clear();
+ myObjects[ id ].myNames.clear();
+
+ myObjects[ id ].myEdit->setText( QString::null );
+ emit selectionChanged( id );
+ }
+}
+
+//=======================================================================
+// name : objectWg
+// Purpose :
+//=======================================================================
+QWidget* LightApp_Dialog::objectWg( const int theId, const int theWgId ) const
+{
+ QWidget* aResWg = 0;
+ if( myObjects.contains( theId ) )
+ {
+ if ( theWgId == Label )
+ aResWg = myObjects[ theId ].myLabel;
+ else if ( theWgId == Btn )
+ aResWg = myObjects[ theId ].myBtn;
+ else if ( theWgId == Control )
+ aResWg = myObjects[ theId ].myEdit;
+ }
+ return aResWg;
+}
+
+//=======================================================================
+// name : objectText
+// Purpose :
+//=======================================================================
+QString LightApp_Dialog::objectText( const int theId ) const
+{
+ return myObjects.contains( theId ) ? myObjects[ theId ].myEdit->text() : "";
+}
+
+//=======================================================================
+// name : setObjectText
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::setObjectText( const int theId, const QString& theText )
+{
+ if ( myObjects.contains( theId ) )
+ myObjects[ theId ].myEdit->setText( theText );
+}
+
+//=======================================================================
+// name : selectedObject
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::selectedObject( const int id, QStringList& list ) const
+{
+ if( myObjects.contains( id ) )
+ list = myObjects[ id ].myIds;
+}
+
+//=======================================================================
+// name : selectedObject
+// Purpose :
+//=======================================================================
+QString LightApp_Dialog::selectedObject( const int id ) const
+{
+ if ( myObjects.contains( id ) && myObjects[ id ].myIds.count() > 0 )
+ return myObjects[ id ].myIds.first();
+ else
+ return "";
+}
+
+//=======================================================================
+// name : objectSelection
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::objectSelection( SelectedObjects& objs ) const
+{
+ //objs.clear();
+ ObjectMap::const_iterator anIt = myObjects.begin(),
+ aLast = myObjects.end();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ QStringList ids;
+ selectedObject( anIt.key(), ids );
+ if( !ids.isEmpty() )
+ objs.insert( anIt.key(), ids );
+ }
+}
+
+//=======================================================================
+// name : createObject
+// Purpose :
+//=======================================================================
+int LightApp_Dialog::createObject( const QString& label, QWidget* parent, const int id )
+{
+ int nid = id;
+ if( nid<0 )
+ for( nid=0; myObjects.contains( nid ); nid++ );
+
+ if( !myObjects.contains( nid ) )
+ {
+ QLabel* lab = new QLabel( label, parent );
+ myObjects[ nid ].myLabel = lab;
+
+ QToolButton* but = new QToolButton( parent );
+ but->setIconSet( QIconSet( myPixmap ) );
+ but->setToggleButton( true );
+ but->setMaximumWidth( but->height() );
+ but->setMinimumWidth( but->height() );
+ connect( but, SIGNAL( toggled( bool ) ), this, SLOT( onToggled( bool ) ) );
+ myObjects[ nid ].myBtn = but;
+
+ QLineEdit* ne = new QLineEdit( parent );
+ ne->setReadOnly( true );
+ ne->setMinimumWidth( 150 );
+ connect( ne, SIGNAL( textChanged( const QString& ) ), this, SLOT( onTextChanged( const QString& ) ) );
+ myObjects[ nid ].myEdit = ne;
+
+ myObjects[ nid ].myNI = OneNameOrCount;
+ }
+ return nid;
+}
+
+//=======================================================================
+// name : renameObject
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::renameObject( const int id, const QString& label )
+{
+ if( myObjects.contains( id ) )
+ myObjects[ id ].myLabel->setText( label );
+}
+
+//=======================================================================
+// name : setObjectType
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::setObjectType( const int id, const int type1, ... )
+{
+ TypesList types;
+
+ const int* tt = &type1;
+ while( *tt>=0 )
+ {
+ types.append( *tt );
+ tt++;
+ }
+
+ setObjectType( id, types );
+}
+
+//=======================================================================
+// name : setObjectType
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::setObjectType( const int id, const TypesList& list )
+{
+ if( !myObjects.contains( id ) )
+ return;
+
+ TypesList& internal = myObjects[ id ].myPossibleTypes;
+
+ QMap<int,int> types;
+ TypesList::const_iterator anIt = list.begin(),
+ aLast = list.end();
+ for( ; anIt!=aLast; anIt++ )
+ types.insert( *anIt, 0 );
+
+
+ internal.clear();
+ QMap<int,int>::const_iterator aMIt = types.begin(),
+ aMLast = types.end();
+ for( ; aMIt!=aMLast; aMIt++ )
+ internal.append( aMIt.key() );
+
+ updateObject( id );
+}
+
+//=======================================================================
+// name : addObjectType
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::addObjectType( const int id, const int type1, const int, ... )
+{
+ TypesList types; objectTypes( id, types );
+
+ const int* tt = &type1;
+ while( *tt>=0 )
+ {
+ types.append( *tt );
+ tt++;
+ }
+
+ setObjectType( id, types );
+}
+
+//=======================================================================
+// name : addObjectType
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::addObjectType( const int id, const TypesList& list )
+{
+ TypesList types = list; objectTypes( id, types );
+ setObjectType( id, types );
+}
+
+//=======================================================================
+// name : addObjectType
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::addObjectType( const int id, const int type )
+{
+ TypesList types; objectTypes( id, types );
+ types.append( type );
+ setObjectType( id, types );
+}
+
+//=======================================================================
+// name : removeObjectType
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::removeObjectType( const int id )
+{
+ TypesList types;
+ setObjectType( id, types );
+}
+
+//=======================================================================
+// name : removeObjectType
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::removeObjectType( const int id, const TypesList& list )
+{
+ if( !myObjects.contains( id ) )
+ return;
+
+ TypesList& internal = myObjects[ id ].myPossibleTypes;
+
+ QMap<int,int> types;
+ TypesList::const_iterator anIt = internal.begin(),
+ aLast = internal.end();
+ for( ; anIt!=aLast; anIt++ )
+ types.insert( *anIt, 0 );
+ anIt = list.begin(); aLast = list.end();
+ for( ; anIt!=aLast; anIt++ )
+ types.remove( *anIt );
+
+
+ internal.clear();
+ QMap<int,int>::const_iterator aMIt = types.begin(),
+ aMLast = types.end();
+ for( ; aMIt!=aMLast; aMIt++ )
+ internal.append( aMIt.key() );
+
+ updateObject( id );
+}
+
+//=======================================================================
+// name : removeObjectType
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::removeObjectType( const int id, const int type )
+{
+ TypesList list; list.append( type );
+ removeObjectType( id, list );
+}
+
+//=======================================================================
+// name : hasObjectType
+// Purpose :
+//=======================================================================
+bool LightApp_Dialog::hasObjectType( const int id, const int type ) const
+{
+ if( myObjects.contains( id ) )
+ return myObjects[ id ].myPossibleTypes.contains( type );
+ else
+ return false;
+}
+
+//=======================================================================
+// name : objectTypes
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::objectTypes( const int id, TypesList& list ) const
+{
+ if( myObjects.contains( id ) )
+ {
+ TypesList::const_iterator anIt = myObjects[ id ].myPossibleTypes.begin(),
+ aLast = myObjects[ id ].myPossibleTypes.end();
+ for( ; anIt!=aLast; anIt++ )
+ list.append( *anIt );
+ }
+}
+
+//=======================================================================
+// name : onToggled
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::onToggled( bool on )
+{
+ QButton* but = ( QButton* )sender();
+ int id = -1;
+
+ if( !but )
+ return;
+
+ ObjectMap::const_iterator anIt = myObjects.begin(),
+ aLast = myObjects.end();
+ for( ; anIt!=aLast && id==-1; anIt++ )
+ if( anIt.data().myBtn==but )
+ id = anIt.key();
+
+ if( id!=-1 )
+ if( on )
+ {
+ updateButtons( id );
+ emit objectActivated( id );
+ }
+ else
+ emit objectDeactivated( id );
+}
+
+//=======================================================================
+// name : updateObject
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::updateObject( const int id, bool emit_signal )
+{
+ if( hasSelection( id ) )
+ {
+ Object& obj = myObjects[ id ];
+ filterTypes( id, obj.myNames, obj.myTypes, obj.myIds );
+ obj.myEdit->setText( selectionDescription( obj.myNames, obj.myTypes, obj.myNI ) );
+ if( emit_signal )
+ emit selectionChanged( id );
+ }
+}
+
+//=======================================================================
+// name : filterTypes
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::filterTypes( const int id, QStringList& names, TypesList& types, QStringList& ids ) const
+{
+ if( !myObjects.contains( id ) )
+ return;
+
+ const Object& obj = myObjects[ id ];
+ if( obj.myPossibleTypes.isEmpty() )
+ return;
+
+ QStringList new_names, new_ids;
+ TypesList new_types;
+
+ TypesList::const_iterator anIt1 = types.begin(),
+ aLast = types.end();
+ QStringList::const_iterator anIt2 = names.begin(),
+ anIt3 = ids.begin();
+ for( ; anIt1!=aLast; anIt1++, anIt2++, anIt3++ )
+ if( obj.myPossibleTypes.contains( *anIt1 ) )
+ {
+ if( new_types.count()==1 && !multipleSelection( id ) )
+ break;
+
+ new_names.append( *anIt2 );
+ new_types.append( *anIt1 );
+ new_ids.append( *anIt3 );
+ }
+ names = new_names;
+ types = new_types;
+ ids = new_ids;
+}
+
+//=======================================================================
+// name : resMgr
+// Purpose :
+//=======================================================================
+SUIT_ResourceMgr* LightApp_Dialog::resMgr() const
+{
+ return SUIT_Session::session()->resourceMgr();
+}
+
+//=======================================================================
+// name : setObjectPixmap
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::setObjectPixmap( const QPixmap& p )
+{
+ myPixmap = p;
+ ObjectMap::const_iterator anIt = myObjects.begin(),
+ aLast = myObjects.end();
+ for( ; anIt!=aLast; anIt++ )
+ ( ( QToolButton* )anIt.data().myBtn )->setIconSet( p );
+}
+
+//=======================================================================
+// name : setObjectPixmap
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::setObjectPixmap( const QString& section, const QString& file )
+{
+ SUIT_ResourceMgr* mgr = resMgr();
+ if( mgr )
+ setObjectPixmap( mgr->loadPixmap( section, file ) );
+}
+
+//=======================================================================
+// name : multipleSelection
+// Purpose :
+//=======================================================================
+bool LightApp_Dialog::multipleSelection( const int id ) const
+{
+ return nameIndication( id )!=OneName;
+}
+
+//=======================================================================
+// name : nameIndication
+// Purpose :
+//=======================================================================
+LightApp_Dialog::NameIndication LightApp_Dialog::nameIndication( const int id ) const
+{
+ if( myObjects.contains( id ) )
+ return myObjects[ id ].myNI;
+ else
+ return OneNameOrCount;
+}
+
+//=======================================================================
+// name : setNameIndication
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::setNameIndication( const int id, const NameIndication ni )
+{
+ if( id==-1 )
+ {
+ ObjectMap::iterator anIt = myObjects.begin(),
+ aNext,
+ aLast = myObjects.end();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ anIt.data().myNI = ni;
+ setReadOnly( anIt.key(), isReadOnly( anIt.key() ) );
+ aNext = anIt; aNext++;
+ updateObject( anIt.key(), aNext==aLast );
+ }
+ }
+ else if( myObjects.contains( id ) )
+ {
+ myObjects[ id ].myNI = ni;
+ setReadOnly( id, isReadOnly( id ) );
+ updateObject( id, true );
+ }
+}
+
+//=======================================================================
+// name : selectionDescription
+// Purpose :
+//=======================================================================
+QString LightApp_Dialog::selectionDescription( const QStringList& names, const TypesList& types, const NameIndication ni ) const
+{
+ if( names.count()!=types.count() )
+ return "LightApp_Dialog::selectionDescription(): Error!!!";
+
+ if( names.isEmpty() )
+ return QString::null;
+
+ switch( ni )
+ {
+ case OneName:
+ return names.first();
+ break;
+
+ case OneNameOrCount:
+ if( names.count()==1 )
+ return names.first();
+ else
+ return countOfTypes( types );
+ break;
+
+ case ListOfNames:
+ return names.join( " " );
+ break;
+
+ case Count:
+ return countOfTypes( types );
+ break;
+ };
+ return QString::null;
+}
+
+//=======================================================================
+// name : countOfTypes
+// Purpose :
+//=======================================================================
+QString LightApp_Dialog::countOfTypes( const TypesList& types ) const
+{
+ QMap<int, int> typesCount;
+ QStringList typeCount;
+
+ TypesList::const_iterator anIt = types.begin(),
+ aLast = types.end();
+ for( ; anIt!=aLast; anIt++ )
+ if( typesCount.contains( *anIt ) )
+ typesCount[ *anIt ]++;
+ else
+ typesCount[ *anIt ] = 1;
+
+ QMap<int,int>::const_iterator aMIt = typesCount.begin(),
+ aMLast = typesCount.end();
+ for( ; aMIt!=aMLast; aMIt++ )
+ typeCount.append( QString( "%1 %2" ).arg( aMIt.data() ).arg( typeName( aMIt.key() ) ) );
+
+ return typeCount.join( ", " );
+}
+
+//=======================================================================
+// name : typeName
+// Purpose :
+//=======================================================================
+QString& LightApp_Dialog::typeName( const int type )
+{
+ return myTypeNames[ type ];
+}
+
+//=======================================================================
+// name : typeName
+// Purpose :
+//=======================================================================
+const QString& LightApp_Dialog::typeName( const int type ) const
+{
+ return myTypeNames[ type ];
+}
+
+
+//=======================================================================
+// name : activateObject
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::activateObject( const int theId )
+{
+ if ( myObjects.contains( theId ) && !myObjects[ theId ].myBtn->isOn() )
+ myObjects[ theId ].myBtn->toggle();
+}
+
+//=======================================================================
+// name : deactivateAll
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::deactivateAll()
+{
+ ObjectMap::iterator anIt = myObjects.begin(),
+ aLast = myObjects.end();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ QToolButton* btn = ( QToolButton* )anIt.data().myBtn;
+ btn->setOn( false );
+ }
+}
+
+//=======================================================================
+// name : selectObject
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::selectObject( const int id, const QString& name, const int type, const QString& selid, const bool update )
+{
+ QStringList names; names.append( name );
+ TypesList types; types.append( type );
+ QStringList ids; ids.append( selid );
+ selectObject( id, names, types, ids, update );
+}
+
+//=======================================================================
+// name : selectObject
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::selectObject( const int id, const QStringList& _names, const TypesList& _types,
+ const QStringList& _ids, const bool update )
+{
+ if( !myObjects.contains( id ) )
+ return;
+
+ QStringList names = _names, ids = _ids;
+ TypesList types = _types;
+
+ filterTypes( id, names, types, ids );
+
+ Object& obj = myObjects[ id ];
+ if( update )
+ obj.myEdit->setText( selectionDescription( names, types, obj.myNI ) );
+ obj.myTypes = types;
+ obj.myIds = ids;
+ obj.myNames = names;
+
+ emit selectionChanged( id );
+}
+
+//=======================================================================
+// name : setReadOnly
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::setReadOnly( const int id, const bool ro )
+{
+ if( myObjects.contains( id ) )
+ myObjects[ id ].myEdit->setReadOnly( nameIndication( id )==ListOfNames || nameIndication( id )==OneName ? ro : true );
+}
+
+//=======================================================================
+// name : isReadOnly
+// Purpose :
+//=======================================================================
+bool LightApp_Dialog::isReadOnly( const int id ) const
+{
+ if( myObjects.contains( id ) )
+ return myObjects[ id ].myEdit->isReadOnly();
+ else
+ return true;
+}
+
+//=======================================================================
+// name : onTextChanged
+// Purpose :
+//=======================================================================
+void LightApp_Dialog::onTextChanged( const QString& text )
+{
+ if( myIsBusy )
+ return;
+
+ myIsBusy = true;
+
+ if( sender() && sender()->inherits( "QLineEdit" ) )
+ {
+ QLineEdit* edit = ( QLineEdit* )sender();
+ int id = -1;
+ ObjectMap::const_iterator anIt = myObjects.begin(),
+ aLast = myObjects.end();
+ for( ; anIt!=aLast; anIt++ )
+ if( anIt.data().myEdit == edit )
+ id = anIt.key();
+
+ if( id>=0 && !isReadOnly( id ) )
+ {
+ QStringList list = QStringList::split( " ", text );
+ emit objectChanged( id, list );
+ }
+ }
+
+ myIsBusy = false;
+}
--- /dev/null
+// File: LightApp_Dialog.h
+// Author: Alexander SOLOVYOV
+
+#ifndef LIGHTAPP_DIALOG_H
+#define LIGHTAPP_DIALOG_H
+
+#include "LightApp.h"
+#include <QtxDialog.h>
+
+#include <qvaluelist.h>
+#include <qmap.h>
+#include <qpixmap.h>
+
+class QLineEdit;
+class QButton;
+class QLabel;
+
+class SUIT_ResourceMgr;
+
+/*
+ Class : LightApp_Dialog
+ Description : Base class for all LightApp dialogs
+*/
+class LIGHTAPP_EXPORT LightApp_Dialog : public QtxDialog
+{
+ Q_OBJECT
+
+public:
+ typedef QValueList<int> TypesList;
+ typedef QMap<int,QStringList> SelectedObjects;
+
+ enum ObjectWg
+ {
+ Label = 0x00000001,
+ Btn = 0x00000002,
+ Control = 0x00000004
+ };
+
+ typedef enum
+ {
+ OneName, //<! only one object can be selected and it's name is shown
+ OneNameOrCount, //<! if one object is selected, it's name is shown otherwise
+ // "<count> <type>" is shown
+ ListOfNames, //! list of all names is shown
+ Count //! In every case "<count> <type>" is shown
+
+ } NameIndication;
+ //! The enumeration describing how names of selected objects will be shown in line edit
+ //! For more details see above
+
+public:
+ LightApp_Dialog( QWidget* = 0, const char* = 0, bool = false,
+ bool = false, const int = Standard, WFlags = 0 );
+ virtual ~LightApp_Dialog();
+
+ virtual void show();
+
+ //! Check if buttons is exclusive (as radiobuttons)
+ bool isExclusive() const;
+
+ //! Set exclusive state
+ void setExclusive( const bool );
+
+ //! Check if operation according to dialog will be resumed automatically when mouse enter the dialog
+ bool isAutoResumed() const;
+
+ //! Set auto resumed state
+ void setAutoResumed( const bool );
+
+ //! Show widgets corresponding to id
+ void showObject( const int );
+
+ //! Hide widgets corresponding to id
+ void hideObject( const int );
+
+ //! Change the shown state of widgets corresponding to id
+ void setObjectShown( const int, const bool );
+
+ //! Check the shown state
+ bool isObjectShown( const int ) const;
+
+ //! Change the enabled state of widgets corresponding to id
+ void setObjectEnabled( const int, const bool );
+
+ //! Check the enabled state
+ bool isObjectEnabled( const int ) const;
+
+ //! Get widget of object (see ObjectWg enumeration)
+ QWidget* objectWg( const int theId, const int theWgId ) const;
+
+ //! Pass to all active widgets name, type and id of selected object
+ void selectObject( const QString&, const int, const QString&, const bool = true );
+
+ /*!
+ Pass to all active widgets list of names, types and ids of selected objects
+ Every active widget filters list and accept only objects with possible types
+ */
+ void selectObject( const QStringList&, const TypesList&, const QStringList&, const bool = true );
+
+ //! Get text of object's control
+ QString objectText( const int ) const;
+
+ //! Set text of object's control
+ void setObjectText( const int, const QString& );
+
+ //! Select in certain widget avoiding check if there is active widget
+ void selectObject( const int, const QString&, const int, const QString&, const bool = true );
+ void selectObject( const int, const QStringList&, const TypesList&, const QStringList&, const bool = true );
+
+ //! Check if certain widget has selection
+ bool hasSelection( const int ) const;
+
+ //! Clear selection in widgets. If parameter is -1, then selection in all widgets will be cleared
+ void clearSelection( const int = -1 );
+
+ //! Get ids list of object selected in certain widget
+ void selectedObject( const int, QStringList& ) const;
+
+ //! Get ids list of object selected in certain widget
+ QString selectedObject( const int ) const;
+
+ //! Get map "widget id -> ids list"
+ void objectSelection( SelectedObjects& ) const;
+
+ //! Activate object selection button
+ void activateObject( const int );
+
+ //! Set all object selection buttons to inactive state
+ void deactivateAll();
+
+signals:
+ //! selection in certain widget is changed
+ void selectionChanged ( int );
+
+ //! selection in certain widget is on
+ void objectActivated ( int );
+
+ //! selection in certain widget is off
+ void objectDeactivated( int );
+
+ /*
+ text representation of selection is changed
+ it is emitted only if "read only" state of line edit is false
+ */
+ void objectChanged( int, const QStringList& );
+
+protected:
+ //! Finds and returns resource manager
+ SUIT_ResourceMgr* resMgr() const;
+
+ /*! Create label, button and line edit for object selection
+ * If passed id is negative, then id will be calculated automatically (first free id)
+ * Returns the same id (if id>=0) or calculated
+ */
+ int createObject ( const QString&, QWidget*, const int = -1 );
+
+ //! Set pixmap as icon for all selection buttons
+ void setObjectPixmap ( const QPixmap& );
+
+ //! Load pixmap with section, name using resource manager and set as icon for all selection buttons
+ void setObjectPixmap ( const QString&, const QString& );
+
+ //! Change label
+ void renameObject ( const int, const QString& );
+
+ //! Set possible types for certain id. The list of arguments must be finished by negative integer
+ void setObjectType ( const int, const int, ... );
+
+ //! Set list as possible types for object selection
+ void setObjectType ( const int, const TypesList& );
+
+ /*!
+ Add types to list of possible types
+ The list of arguments must be finished by negative integer
+ */
+ void addObjectType ( const int, const int, const int, ... );
+
+ //! Add types to list of possible types
+ void addObjectType ( const int, const TypesList& );
+
+ //! Add type to list of possible types
+ void addObjectType ( const int, const int );
+
+ //! Clear list of possible types (it means, that all types are welcome)
+ void removeObjectType( const int );
+
+ //! Remove types in list from list of possible types
+ void removeObjectType( const int, const TypesList& );
+
+ //! Remove a type from list of possible types
+ void removeObjectType( const int, const int );
+
+ //! Check if list of possible types contains this one
+ bool hasObjectType ( const int, const int ) const;
+
+ //! Return list of possible types
+ void objectTypes ( const int, TypesList& ) const;
+
+ //!Change and get type name for indicating in selection widget
+ QString& typeName( const int );
+ const QString& typeName( const int ) const;
+
+ //! Create string contains selection list by list of names, list of types and current name indication state
+ virtual QString selectionDescription( const QStringList&, const TypesList&, const NameIndication ) const;
+
+ //! Create string by pattern "<count> <type>" for current list of types
+ virtual QString countOfTypes( const TypesList& ) const;
+
+ //! Get and set name indication for certain widget
+ NameIndication nameIndication( const int ) const;
+ void setNameIndication( const int, const NameIndication );
+
+ //! Check using name indication if multiple selection in possible
+ bool multipleSelection( const int ) const;
+
+ //! Set the "read only" state of object selection line edit
+ //! The "read only" will be false only if name indication is ListOfNames
+ void setReadOnly( const int, const bool );
+
+ //! Check the "read only" state of object selection line edit
+ bool isReadOnly( const int ) const;
+
+private slots:
+ //! emits if the object selection button changes state
+ void onToggled( bool );
+
+ //! text in some line edit is changed
+ void onTextChanged( const QString& );
+
+private:
+ /*!
+ If buttons are exclusive, set to "off" all buttons except one with id
+ If id=-1, then all buttons, except first with "on" state, will be set to "off"
+ */
+ void updateButtons( const int = -1 );
+
+ /*!
+ Filter types and update selection string in line edit
+ If bool is true, then signal is emitted
+ */
+ void updateObject( const int, bool = true );
+
+ //! Remove from list not possible types and remove from names and ids lists the corresponding items
+ void filterTypes( const int, QStringList&, TypesList&, QStringList& ) const;
+
+private:
+ typedef struct
+ {
+ QLineEdit* myEdit;
+ QButton* myBtn;
+ QLabel* myLabel;
+ QStringList myNames, myIds;
+ TypesList myTypes, myPossibleTypes;
+ NameIndication myNI;
+
+ } Object;
+
+ typedef QMap<int, Object> ObjectMap;
+
+private:
+ ObjectMap myObjects;
+ QMap<int,QString> myTypeNames;
+ bool myIsExclusive, myIsBusy;
+ QPixmap myPixmap;
+};
+
+#endif
--- /dev/null
+
+#include "LightApp_Displayer.h"
+#include "LightApp_Application.h"
+
+#include <SALOME_InteractiveObject.hxx>
+
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_ViewModel.h>
+#include <SUIT_ViewWindow.h>
+
+#include <qstring.h>
+
+LightApp_Displayer::LightApp_Displayer()
+{
+}
+
+LightApp_Displayer::~LightApp_Displayer()
+{
+}
+
+void LightApp_Displayer::Display( const QString& entry, const bool updateViewer, SALOME_View* theViewFrame )
+{
+ SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+ if ( vf )
+ {
+ SALOME_Prs* prs = buildPresentation( entry, vf );
+
+ if ( prs )
+ {
+ vf->BeforeDisplay( this );
+ vf->Display( prs );
+ vf->AfterDisplay( this );
+
+ if ( updateViewer )
+ vf->Repaint();
+
+ delete prs; // delete presentation because displayer is its owner
+ }
+ }
+}
+
+void LightApp_Displayer::Redisplay( const QString& entry, const bool updateViewer )
+{
+ // Remove the object permanently (<forced> == true)
+ SUIT_Session* ses = SUIT_Session::session();
+ SUIT_Application* app = ses->activeApplication();
+ if ( app )
+ {
+ SUIT_Desktop* desk = app->desktop();
+ QPtrList<SUIT_ViewWindow> wnds = desk->windows();
+ SUIT_ViewWindow* wnd;
+ for ( wnd = wnds.first(); wnd; wnd = wnds.next() )
+ {
+ SUIT_ViewManager* vman = wnd->getViewManager();
+ if( !vman )
+ continue;
+
+ SUIT_ViewModel* vmodel = vman->getViewModel();
+ if( !vmodel )
+ continue;
+
+ SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel);
+ if( view && ( IsDisplayed( entry, view ) || view == GetActiveView() ) )
+ {
+ Erase( entry, true, false, view );
+ Display( entry, updateViewer, view );
+ }
+ }
+ }
+}
+
+void LightApp_Displayer::Erase( const QString& entry, const bool forced,
+ const bool updateViewer, SALOME_View* theViewFrame )
+{
+ SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+
+ if ( vf ) {
+ SALOME_Prs* prs = vf->CreatePrs( entry.latin1() );
+ if ( prs ) {
+ vf->Erase( prs, forced );
+ if ( updateViewer )
+ vf->Repaint();
+ delete prs; // delete presentation because displayer is its owner
+ }
+ }
+}
+
+void LightApp_Displayer::EraseAll( const bool forced, const bool updateViewer, SALOME_View* theViewFrame ) const
+{
+ SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+
+ if ( vf ) {
+ vf->EraseAll( forced );
+ if ( updateViewer )
+ vf->Repaint();
+ }
+}
+
+bool LightApp_Displayer::IsDisplayed( const QString& entry, SALOME_View* theViewFrame ) const
+{
+ SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+ if( vf )
+ {
+ Handle( SALOME_InteractiveObject ) temp = new SALOME_InteractiveObject();
+ temp->setEntry( entry.latin1() );
+ return vf->isVisible( temp );
+ }
+ else
+ return false;
+}
+
+void LightApp_Displayer::UpdateViewer() const
+{
+ SALOME_View* vf = GetActiveView();
+ if ( vf )
+ vf->Repaint();
+}
+
+SALOME_Prs* LightApp_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame )
+{
+ SALOME_Prs* prs = 0;
+
+ SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
+
+ if ( vf )
+ prs = vf->CreatePrs( entry.latin1() );
+
+ return prs;
+}
+
+SALOME_View* LightApp_Displayer::GetActiveView()
+{
+ SUIT_Session* session = SUIT_Session::session();
+ if ( SUIT_Application* app = session->activeApplication() ) {
+ if ( LightApp_Application* sApp = dynamic_cast<LightApp_Application*>( app ) ) {
+ if( SUIT_ViewManager* vman = sApp->activeViewManager() ) {
+ if ( SUIT_ViewModel* vmod = vman->getViewModel() )
+ return dynamic_cast<SALOME_View*>( vmod );
+ }
+ }
+ }
+ return 0;
+}
--- /dev/null
+
+#ifndef LIGHTAPP_DISPLAYER_HEADER
+#define LIGHTAPP_DISPLAYER_HEADER
+
+#include <SALOME_Prs.h>
+
+class QString;
+
+class LightApp_Displayer : public SALOME_Displayer
+{
+public:
+ LightApp_Displayer();
+ virtual ~LightApp_Displayer();
+
+ void Display( const QString&, const bool = true, SALOME_View* = 0 );
+ void Redisplay( const QString&, const bool = true );
+ void Erase( const QString&, const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 );
+ void EraseAll( const bool forced = false, const bool updateViewer = true, SALOME_View* = 0 ) const;
+ bool IsDisplayed( const QString&, SALOME_View* = 0 ) const;
+ void UpdateViewer() const;
+
+ static SALOME_View* GetActiveView();
+
+protected:
+ virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 );
+};
+
+#endif
--- /dev/null
+#include "LightApp_Driver.h"\r
+\r
+#include <TCollection_AsciiString.hxx> \r
+\r
+#include <OSD_Path.hxx>\r
+#include <OSD_File.hxx>\r
+#include <OSD_Directory.hxx>\r
+#include <OSD_Process.hxx>\r
+#include <OSD_Directory.hxx>\r
+#include <OSD_Protection.hxx>\r
+#include <OSD_SingleProtection.hxx>\r
+#include <OSD_FileIterator.hxx>\r
+\r
+#ifdef WIN32\r
+#include <time.h>\r
+#endif\r
+\r
+/*! Constructor.*/\r
+LightApp_Driver::LightApp_Driver()\r
+{\r
+}\r
+ \r
+/*! Destructor.*/\r
+LightApp_Driver::~LightApp_Driver()\r
+{\r
+}\r
+\r
+using namespace std;\r
+\r
+//================================================================\r
+// Function : SaveDatasInFile\r
+/*! Purpose : save in file 'theFileName' datas from this driver*/\r
+//================================================================\r
+bool LightApp_Driver::SaveDatasInFile( const char* theFileName, bool isMultiFile )\r
+{\r
+ int aNbModules = 0;\r
+ std::map<std::string, ListOfFiles>::const_iterator it;\r
+ for (it = myMap.begin(); it != myMap.end(); ++it)\r
+ aNbModules++;\r
+\r
+ unsigned char** aBuffer = new unsigned char*[aNbModules]; \r
+ long* aBufferSize = new long[aNbModules];\r
+ char** aModuleName = new char*[aNbModules];\r
+\r
+ if(aBuffer == NULL || aBufferSize == NULL || aModuleName == NULL)\r
+ return false;\r
+\r
+ int aFileBufferSize = 4; //4 bytes for a number of the modules that will be written to the stream;\r
+ int i = 0;\r
+ for (it = myMap.begin(); it != myMap.end(); ++it) {\r
+ aModuleName[i] = const_cast<char*>(it->first.c_str());//(it->first);\r
+ aFileBufferSize += 4; //Add 4 bytes: a length of the module name\r
+ aFileBufferSize += strlen(aModuleName[i])+1;\r
+ std::string aName(aModuleName[i]);\r
+ PutFilesToStream(aName, aBuffer[i], aBufferSize[i], isMultiFile);\r
+ aFileBufferSize += 8; //Add 8 bytes: a length of the buffer\r
+ aFileBufferSize += aBufferSize[i];\r
+ // Remove the files and tmp directory, created by the component storage procedure\r
+ if (!isMultiFile)\r
+ RemoveTemporaryFiles(aModuleName[i], true);\r
+ i++;\r
+ }\r
+ int n = i;\r
+\r
+ unsigned char* aFileBuffer = new unsigned char[aFileBufferSize];\r
+ if(aFileBuffer == NULL)\r
+ return false;\r
+\r
+ int aCurrentPos = 0;\r
+\r
+ //Initialize 4 bytes of the buffer by 0\r
+ memset(aFileBuffer, 0, 4); \r
+ //Copy the number of modules that will be written to the stream\r
+ memcpy(aFileBuffer, &aNbModules, ((sizeof(int) > 4) ? 4 : sizeof(int)));\r
+ aCurrentPos += 4;\r
+\r
+ int aBufferNameSize = 0;\r
+ for (i = 0; i < n; i++) {\r
+ aBufferNameSize = strlen(aModuleName[i])+1;\r
+ //Initialize 4 bytes of the buffer by 0\r
+ memset((aFileBuffer + aCurrentPos), 0, 4); \r
+ //Copy the length of the module name to the buffer\r
+ memcpy((aFileBuffer + aCurrentPos), &aBufferNameSize, ((sizeof(int) > 4) ? 4 : sizeof(int))); \r
+ aCurrentPos += 4;\r
+ //Copy the module name to the buffer\r
+ memcpy((aFileBuffer + aCurrentPos), aModuleName[i], aBufferNameSize);\r
+ aCurrentPos += aBufferNameSize;\r
+\r
+ //Initialize 8 bytes of the buffer by 0\r
+ memset((aFileBuffer + aCurrentPos), 0, 8);\r
+ //Copy the length of the module buffer to the buffer\r
+ memcpy((aFileBuffer + aCurrentPos), (aBufferSize + i), ((sizeof(long) > 8) ? 8 : sizeof(long)));\r
+ aCurrentPos += 8;\r
+ //Copy the module buffer to the buffer\r
+ memcpy((aFileBuffer + aCurrentPos), aBuffer[i], aBufferSize[i]);\r
+ aCurrentPos += aBufferSize[i];\r
+ }\r
+\r
+ ofstream aFile(theFileName);\r
+ aFile.write((char*)aFileBuffer, aFileBufferSize); \r
+ aFile.close(); \r
+\r
+ delete[] aBuffer;\r
+ delete[] aBufferSize;\r
+ delete[] aModuleName;\r
+ delete[] aFileBuffer;\r
+ return true;\r
+}\r
+\r
+//=======================================================================\r
+// name : ReaDatasFromFile\r
+/*! Purpose : filling current driver from file 'theFileName'*/\r
+//=======================================================================\r
+bool LightApp_Driver::ReadDatasFromFile( const char* theFileName, bool isMultiFile )\r
+{\r
+#ifdef WNT\r
+ ifstream aFile(theFileName, ios::binary);\r
+#else\r
+ ifstream aFile(theFileName);\r
+#endif \r
+\r
+ aFile.seekg(0, ios::end);\r
+ int aFileBufferSize = aFile.tellg();\r
+ unsigned char* aFileBuffer = new unsigned char[aFileBufferSize];\r
+ aFile.seekg(0, ios::beg);\r
+ aFile.read((char*)aFileBuffer, aFileBufferSize);\r
+ aFile.close();\r
+\r
+ int aNbModules = 0;\r
+ //Copy the number of files in the stream\r
+ memcpy(&aNbModules, aFileBuffer, sizeof(int));\r
+ long aCurrentPos = 4;\r
+ int aModuleNameSize;\r
+\r
+ for (int i = 0; i < aNbModules; i++) {\r
+ //Put a length of the module name to aModuleNameSize\r
+ memcpy(&aModuleNameSize, (aFileBuffer + aCurrentPos), ((sizeof(int) > 4) ? 4 : sizeof(int))); \r
+ aCurrentPos += 4;\r
+\r
+ char *aModuleName = new char[aModuleNameSize];\r
+ //Put a module name to aModuleName\r
+ memcpy(aModuleName, (aFileBuffer + aCurrentPos), aModuleNameSize); \r
+ aCurrentPos += aModuleNameSize;\r
+\r
+ //Put a length of the file buffer to aBufferSize\r
+ long aBufferSize;\r
+ memcpy(&aBufferSize, (aFileBuffer + aCurrentPos), ((sizeof(long) > 8) ? 8 : sizeof(long))); \r
+ aCurrentPos += 8;\r
+ unsigned char *aBuffer = new unsigned char[aBufferSize];\r
+ \r
+ //Put a buffer for current module to aBuffer\r
+ memcpy(aBuffer, (aFileBuffer + aCurrentPos), aBufferSize); \r
+ aCurrentPos += aBufferSize;\r
+\r
+ // Put buffer to aListOfFiles and set to myMap\r
+ ListOfFiles aListOfFiles = PutStreamToFiles(aBuffer, aBufferSize, isMultiFile);\r
+ SetListOfFiles(aModuleName, aListOfFiles);\r
+\r
+ delete[] aModuleName;\r
+ delete[] aBuffer;\r
+ }\r
+ delete[] aFileBuffer;\r
+ return true;\r
+}\r
+\r
+//================================================================\r
+// Function : GetTmpDir\r
+/*! Purpose : returns temp directory for path 'theURL'*/\r
+//================================================================\r
+std::string LightApp_Driver::GetTmpDir (const char* theURL, const bool isMultiFile)\r
+{\r
+ std::string anURLDir = GetDirFromPath(theURL);\r
+ std::string aTmpDir = isMultiFile ? anURLDir : GetTmpDir();\r
+\r
+ return aTmpDir;\r
+}\r
+\r
+//================================================================\r
+// Function : GetListOfFiles\r
+/*! Purpose : returns list of files for module with name 'theModuleName'*/\r
+//================================================================\r
+LightApp_Driver::ListOfFiles LightApp_Driver::GetListOfFiles( const char* theModuleName )\r
+{\r
+ ListOfFiles aListOfFiles;\r
+\r
+ std::string aName(theModuleName);\r
+ if (myMap.count(aName))\r
+ aListOfFiles = myMap[aName];\r
+\r
+ return aListOfFiles;\r
+}\r
+\r
+//================================================================\r
+// Function : SetListOfFiles\r
+/*! Purpose : sets list of files for module with name 'theModuleName'*/\r
+//================================================================\r
+void LightApp_Driver::SetListOfFiles( const char* theModuleName, const ListOfFiles theListOfFiles )\r
+{\r
+ std::string aName (theModuleName);\r
+ myMap[aName] = theListOfFiles;\r
+}\r
+\r
+//============================================================================\r
+// function : PutFilesToStream\r
+/*! Purpose : converts files which was created from module <theModuleName> into a byte sequence unsigned char*/\r
+//============================================================================\r
+void LightApp_Driver::PutFilesToStream( const std::string& theModuleName, unsigned char*& theBuffer,\r
+ long& theBufferSize, bool theNamesOnly )\r
+{\r
+ ListOfFiles aFiles = myMap[theModuleName];\r
+ // aFiles must contain temporary directory name in its first item\r
+ // and names of files (relatively the temporary directory) in the others\r
+\r
+ int i, aLength = aFiles.size() - 1;\r
+ if(aLength <= 0) {\r
+ theBufferSize = 0;\r
+ theBuffer = new unsigned char[theBufferSize];\r
+ return;\r
+ }\r
+ //Get a temporary directory for saved a file\r
+ TCollection_AsciiString aTmpDir(const_cast<char*>(aFiles[0].c_str()));\r
+\r
+ long aBufferSize = 0;\r
+ long aCurrentPos;\r
+ int aNbFiles = 0;\r
+ int* aFileNameSize= new int[aLength];\r
+ long* aFileSize= new long[aLength];\r
+\r
+ //Determine the required size of the buffer\r
+ TCollection_AsciiString aFileName;\r
+ for (i = 0; i < aLength; i++) {\r
+ char* aFName = const_cast<char*>(aFiles[i+1].c_str());\r
+ aFileName = aFName;\r
+ //Check if the file exists\r
+ if (!theNamesOnly) { // mpv 15.01.2003: if only file names must be stroed, then size of files is zero\r
+ TCollection_AsciiString aFullPath = aTmpDir + aFileName; \r
+ OSD_Path anOSDPath(aFullPath);\r
+ OSD_File anOSDFile(anOSDPath);\r
+ if(!anOSDFile.Exists()) continue;\r
+#ifdef WNT\r
+ ifstream aFile(aFullPath.ToCString(), ios::binary);\r
+#else\r
+ ifstream aFile(aFullPath.ToCString());\r
+#endif\r
+ aFile.seekg(0, ios::end);\r
+ aFileSize[i] = aFile.tellg();\r
+ aBufferSize += aFileSize[i]; //Add a space to store the file\r
+ }\r
+ aFileNameSize[i] = strlen(aFName) + 1;\r
+ aBufferSize += aFileNameSize[i]; //Add a space to store the file name\r
+ aBufferSize += (theNamesOnly)?4:12; //Add 4 bytes: a length of the file name,\r
+ // 8 bytes: length of the file itself\r
+ aNbFiles++;\r
+ delete[] aFName;\r
+ }\r
+\r
+ aBufferSize += 4; //4 bytes for a number of the files that will be written to the stream;\r
+ theBuffer = new unsigned char[aBufferSize]; \r
+ if(theBuffer == NULL) {\r
+ theBufferSize = 0;\r
+ theBuffer = 0;\r
+ return;\r
+ }\r
+ //Initialize 4 bytes of the buffer by 0\r
+ memset(theBuffer, 0, 4); \r
+ //Copy the number of files that will be written to the stream\r
+ memcpy(theBuffer, &aNbFiles, ((sizeof(int) > 4) ? 4 : sizeof(int))); \r
+\r
+ aCurrentPos = 4;\r
+\r
+ for(i = 0; i < aLength; i++) {\r
+ ifstream *aFile;\r
+ if (!theNamesOnly) { // mpv 15.01.2003: we don't open any file if theNamesOnly = true\r
+ TCollection_AsciiString aName(const_cast<char*>(aFiles[i+1].c_str()));\r
+ TCollection_AsciiString aFullPath = aTmpDir + aName;\r
+ OSD_Path anOSDPath(aFullPath);\r
+ OSD_File anOSDFile(anOSDPath);\r
+ if(!anOSDFile.Exists()) continue;\r
+#ifdef WNT\r
+ aFile = new ifstream(aFullPath.ToCString(), ios::binary);\r
+#else\r
+ aFile = new ifstream(aFullPath.ToCString());\r
+#endif\r
+ }\r
+ //Initialize 4 bytes of the buffer by 0\r
+ memset((theBuffer + aCurrentPos), 0, 4); \r
+ //Copy the length of the file name to the buffer\r
+ memcpy((theBuffer + aCurrentPos), (aFileNameSize + i), ((sizeof(int) > 4) ? 4 : sizeof(int))); \r
+ aCurrentPos += 4;\r
+\r
+ //Copy the file name to the buffer\r
+ char* aFName = const_cast<char*>(aFiles[i+1].c_str());\r
+ memcpy((theBuffer + aCurrentPos), aFName, aFileNameSize[i]);\r
+ aCurrentPos += aFileNameSize[i];\r
+ \r
+ if (!theNamesOnly) { // mpv 15.01.2003: we don't copy file content to the buffer if !theNamesOnly\r
+ //Initialize 8 bytes of the buffer by 0\r
+ memset((theBuffer + aCurrentPos), 0, 8); \r
+ //Copy the length of the file to the buffer\r
+ memcpy((theBuffer + aCurrentPos), (aFileSize + i), ((sizeof(long) > 8) ? 8 : sizeof(long)));\r
+ aCurrentPos += 8;\r
+ \r
+ aFile->seekg(0, ios::beg);\r
+ aFile->read((char *)(theBuffer + aCurrentPos), aFileSize[i]);\r
+ aFile->close();\r
+ delete(aFile);\r
+ aCurrentPos += aFileSize[i];\r
+ }\r
+ }\r
+ delete[] aFileNameSize;\r
+ delete[] aFileSize;\r
+\r
+ theBufferSize = aBufferSize;\r
+}\r
+\r
+//============================================================================\r
+// function : PutStreamToFile\r
+/*! Purpose : converts a byte sequence <theBuffer> to files and return list of them*/\r
+//============================================================================\r
+LightApp_Driver::ListOfFiles LightApp_Driver::PutStreamToFiles( const unsigned char* theBuffer,\r
+ const long theBufferSize, bool theNamesOnly )\r
+{\r
+ if(theBufferSize == 0 || theBuffer == 0)\r
+ return ListOfFiles();\r
+\r
+ // Create a temporary directory for the component's data files\r
+ std::string aDir = GetTmpDir();\r
+\r
+ //Get a temporary directory for saving a file\r
+ TCollection_AsciiString aTmpDir(const_cast<char*>(aDir.c_str()));\r
+\r
+ long aFileSize, aCurrentPos = 4;\r
+ int i, aFileNameSize, aNbFiles = 0;\r
+\r
+ //Copy the number of files in the stream\r
+ memcpy(&aNbFiles, theBuffer, sizeof(int)); \r
+\r
+ const int n = aNbFiles + 1;\r
+ ListOfFiles aFiles(n);\r
+ aFiles[0] = aDir;\r
+\r
+ for(i = 0; i < aNbFiles; i++) {\r
+ //Put a length of the file name to aFileNameSize\r
+ memcpy(&aFileNameSize, (theBuffer + aCurrentPos), ((sizeof(int) > 4) ? 4 : sizeof(int))); \r
+ aCurrentPos += 4;\r
+\r
+ char *aFileName = new char[aFileNameSize];\r
+ //Put a file name to aFileName\r
+ memcpy(aFileName, (theBuffer + aCurrentPos), aFileNameSize); \r
+ aCurrentPos += aFileNameSize;\r
+ \r
+ //Put a length of the file to aFileSize\r
+ if (!theNamesOnly) {\r
+ memcpy(&aFileSize, (theBuffer + aCurrentPos), ((sizeof(long) > 8) ? 8 : sizeof(long)));\r
+ aCurrentPos += 8; \r
+ \r
+ TCollection_AsciiString aFullPath = aTmpDir + aFileName;\r
+ ofstream aFile(aFullPath.ToCString());\r
+ aFile.write((char *)(theBuffer+aCurrentPos), aFileSize); \r
+ aFile.close(); \r
+ aCurrentPos += aFileSize;\r
+ }\r
+ std::string aStrFileName(aFileName);\r
+ aFiles[i+1] = aStrFileName;\r
+ delete[] aFileName;\r
+ }\r
+ return aFiles;\r
+}\r
+\r
+//============================================================================\r
+// function : RemoveTemporaryFiles\r
+/*! Purpose : removes files which was created from module theModuleName if <IsDirDeleted> is true tmp directory is also deleted if it is empty*/\r
+//============================================================================\r
+void LightApp_Driver::RemoveTemporaryFiles( const char* theModuleName, const bool IsDirDeleted )\r
+{\r
+ std::string aModuleName(theModuleName);\r
+ ListOfFiles aFiles = myMap[aModuleName];\r
+ // aFiles must contain temporary directory name in its first item\r
+ // and names of files (relatively the temporary directory) in the others\r
+\r
+ int i, aLength = aFiles.size() - 1;\r
+ if(aLength <= 0) {\r
+ return;\r
+ }\r
+ //Get a temporary directory for saved a file\r
+ TCollection_AsciiString aDirName(const_cast<char*>(aFiles[0].c_str()));\r
+\r
+ for(i = 0; i < aLength; i++) {\r
+ TCollection_AsciiString aFile(aDirName);\r
+ aFile += const_cast<char*>(aFiles[i+1].c_str());\r
+ OSD_Path anOSDPath(aFile);\r
+ OSD_File anOSDFile(anOSDPath);\r
+ if(!anOSDFile.Exists()) continue;\r
+\r
+ OSD_Protection aProtection = anOSDFile.Protection();\r
+ aProtection.SetUser(OSD_RW);\r
+ anOSDFile.SetProtection(aProtection);\r
+\r
+ anOSDFile.Remove();\r
+ }\r
+\r
+ if(IsDirDeleted) {\r
+ OSD_Path aPath(aDirName);\r
+ OSD_Directory aDir(aPath);\r
+ OSD_FileIterator anIterator(aPath, '*');\r
+\r
+ if(aDir.Exists() && !anIterator.More()) aDir.Remove();\r
+ }\r
+}\r
+\r
+//============================================================================\r
+// function : ClearDriverContents\r
+/*! Purpose : clear map of list files*/ \r
+//============================================================================ \r
+void LightApp_Driver::ClearDriverContents()\r
+{\r
+ myMap.clear();\r
+}\r
+\r
+//============================================================================\r
+// function : GetTempDir\r
+/*! Purpose : return a temp directory to store created files like "/tmp/sub_dir/" */\r
+//============================================================================ \r
+std::string LightApp_Driver::GetTmpDir()\r
+{\r
+ //Find a temporary directory to store a file\r
+ TCollection_AsciiString aTmpDir;\r
+\r
+ char *Tmp_dir = getenv("SALOME_TMP_DIR");\r
+ if(Tmp_dir != NULL) {\r
+ aTmpDir = TCollection_AsciiString(Tmp_dir);\r
+#ifdef WIN32\r
+ if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\';\r
+#else\r
+ if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/';\r
+#endif \r
+ }\r
+ else {\r
+#ifdef WIN32\r
+ aTmpDir = TCollection_AsciiString("C:\\");\r
+#else\r
+ aTmpDir = TCollection_AsciiString("/tmp/");\r
+#endif\r
+ }\r
+\r
+ srand((unsigned int)time(NULL));\r
+ int aRND = 999 + (int)(100000.0*rand()/(RAND_MAX+1.0)); //Get a random number to present a name of a sub directory\r
+ TCollection_AsciiString aSubDir(aRND);\r
+ if(aSubDir.Length() <= 1) aSubDir = TCollection_AsciiString("123409876");\r
+\r
+ aTmpDir += aSubDir; //Get RND sub directory\r
+\r
+#ifdef WIN32\r
+ if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\';\r
+#else\r
+ if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/';\r
+#endif\r
+\r
+ OSD_Path aPath(aTmpDir);\r
+ OSD_Directory aDir(aPath);\r
+\r
+ for(aRND = 0; aDir.Exists(); aRND++) {\r
+ aTmpDir.Insert((aTmpDir.Length() - 1), TCollection_AsciiString(aRND)); //Build a unique directory name\r
+ aPath = OSD_Path(aTmpDir);\r
+ aDir = OSD_Directory(aPath);\r
+ }\r
+\r
+ OSD_Protection aProtection(OSD_RW, OSD_RWX, OSD_RX, OSD_RX);\r
+ aDir.Build(aProtection);\r
+\r
+ return aTmpDir.ToCString();\r
+}\r
+\r
+//============================================================================\r
+// function : GetDirFromPath\r
+/*! Purpose : returns the dir by the path*/\r
+//============================================================================\r
+std::string LightApp_Driver::GetDirFromPath( const std::string& thePath ) {\r
+ if(thePath == "")\r
+ return "";\r
+ OSD_Path aPath = OSD_Path(TCollection_AsciiString(const_cast<char*>(thePath.c_str())));\r
+ TCollection_AsciiString aDirString(aPath.Trek());\r
+ aDirString.ChangeAll('|','/');\r
+ return aDirString.ToCString();\r
+}\r
+\r
--- /dev/null
+#ifndef LIGHTAPP_DRIVER_H\r
+#define LIGHTAPP_DRIVER_H\r
+\r
+#include <LightApp.h>\r
+\r
+#include "string"\r
+#include "vector"\r
+#include "map"\r
+\r
+#ifdef WIN32\r
+#pragma warning( disable:4251 )\r
+#endif\r
+\r
+/*!Description : Driver can save to file and read from file list of files for light modules*/\r
+\r
+class LIGHTAPP_EXPORT LightApp_Driver\r
+{\r
+public:\r
+ LightApp_Driver();\r
+ virtual ~LightApp_Driver();\r
+\r
+\r
+ typedef std::vector<std::string> ListOfFiles;\r
+\r
+ bool SaveDatasInFile (const char* theFileName, bool isMultiFile );\r
+ bool ReadDatasFromFile (const char* theFileName, bool isMultiFile );\r
+ virtual std::string GetTmpDir (const char* theURL, const bool isMultiFile);\r
+\r
+ ListOfFiles GetListOfFiles (const char* theModuleName);\r
+ virtual void SetListOfFiles (const char* theModuleName, const ListOfFiles theListOfFiles);\r
+ virtual void RemoveTemporaryFiles(const char* theModuleName, const bool IsDirDeleted);\r
+\r
+ virtual void ClearDriverContents();\r
+\r
+private:\r
+ void PutFilesToStream(const std::string& theModuleName, unsigned char*& theBuffer,\r
+ long& theBufferSize, bool theNamesOnly = false);\r
+ ListOfFiles PutStreamToFiles(const unsigned char* theBuffer,\r
+ const long theBufferSize, bool theNamesOnly = false);\r
+\r
+ std::string GetTmpDir();\r
+ std::string GetDirFromPath(const std::string& thePath);\r
+\r
+private:\r
+ typedef std::map<std::string, ListOfFiles> MapOfListOfFiles;\r
+ MapOfListOfFiles myMap;\r
+};\r
+\r
+#endif \r
--- /dev/null
+#include "LightApp_GLSelector.h"
+
+#include "LightApp_DataOwner.h"
+
+#include <SALOME_GLOwner.h>
+
+#include <GLViewer_Context.h>
+
+/*!Constructor. Initialize by GLViewer_Viewer2d and SUIT_SelectionMgr.*/
+LightApp_GLSelector::LightApp_GLSelector( GLViewer_Viewer2d* viewer, SUIT_SelectionMgr* mgr )
+: SUIT_Selector( mgr, viewer ),
+ myViewer( viewer )
+{
+ if ( myViewer )
+ connect( myViewer, SIGNAL( selectionChanged( SelectionChangeStatus ) ),
+ this, SLOT( onSelectionChanged() ) );
+}
+
+/*!Destructor. Do nothing.*/
+LightApp_GLSelector::~LightApp_GLSelector()
+{
+}
+
+/*!Gets viewer*/
+GLViewer_Viewer2d* LightApp_GLSelector::viewer() const
+{
+ return myViewer;
+}
+
+/*!On selection changed event.*/
+void LightApp_GLSelector::onSelectionChanged()
+{
+ selectionChanged();
+}
+
+/*!Gets list of selected Data Owner objects.*/
+void LightApp_GLSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
+{
+ if ( !myViewer )
+ return;
+
+ GLViewer_Context* cont = myViewer->getGLContext();
+ if ( !cont )
+ return;
+
+ for ( cont->InitSelected(); cont->MoreSelected(); cont->NextSelected() )
+ {
+ GLViewer_Object* obj = cont->SelectedObject();
+ if ( obj )
+ {
+ SALOME_GLOwner* owner = dynamic_cast< SALOME_GLOwner* >( obj->owner() );
+ if( owner )
+ aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( owner->entry() ) ) );
+ }
+ }
+}
+
+/*!Sets to selected list of Data Owner objects.*/
+void LightApp_GLSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
+{
+ if ( !myViewer )
+ return;
+
+ GLViewer_Context* cont = myViewer->getGLContext();
+ if ( !cont )
+ return;
+
+ QMap<QString, GLViewer_Object*> aDisplayed;
+ const ObjList& displayed = cont->getObjects();
+ for ( ObjList::const_iterator it = displayed.begin(); it != displayed.end(); ++it )
+ {
+ GLViewer_Object* obj = *it;
+ if ( obj && obj->getVisible() )
+ {
+ SALOME_GLOwner* owner = dynamic_cast< SALOME_GLOwner* >( obj->owner() );
+ if ( owner )
+ aDisplayed.insert( owner->entry(), obj );
+ }
+ }
+
+ int Nb = 0;
+ cont->clearSelected( false );
+ for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
+ {
+ const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
+
+ if ( !owner )
+ continue;
+
+ if ( aDisplayed.contains( owner->entry() ) )
+ {
+ cont->setSelected( aDisplayed[owner->entry()], false );
+ Nb++;
+ }
+ }
+
+ if ( Nb > 0 )
+ myViewer->updateAll();
+}
--- /dev/null
+#ifndef LIGHTAPP_GLSELECTOR_H
+#define LIGHTAPP_GLSELECTOR_H
+
+#include "LightApp.h"
+
+#include <SUIT_Selector.h>
+
+#include <GLViewer_Viewer2d.h>
+
+class LIGHTAPP_EXPORT LightApp_GLSelector : public SUIT_Selector
+{
+ Q_OBJECT
+
+public:
+ LightApp_GLSelector( GLViewer_Viewer2d*, SUIT_SelectionMgr* );
+ virtual ~LightApp_GLSelector();
+
+ GLViewer_Viewer2d* viewer() const;
+
+ virtual QString type() const { return GLViewer_Viewer2d::Type(); }
+
+private slots:
+ void onSelectionChanged();
+
+protected:
+ virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
+ virtual void setSelection( const SUIT_DataOwnerPtrList& );
+
+private:
+ GLViewer_Viewer2d* myViewer;
+};
+
+#endif
--- /dev/null
+// File: LightApp_Module.cxx
+// Created: 6/20/2005 16:30:56 AM
+// Author: OCC team
+// Copyright (C) CEA 2005
+
+#include "LightApp_Module.h"
+
+#include "CAM_Application.h"
+
+#include "LightApp_Application.h"
+#include "LightApp_DataModel.h"
+#include "LightApp_Study.h"
+#include "LightApp_Preferences.h"
+#include "LightApp_Selection.h"
+#include "LightApp_Operation.h"
+#include "LightApp_SwitchOp.h"
+#include "LightApp_UpdateFlags.h"
+#include "LightApp_ShowHideOp.h"
+
+#include "SUIT_Operation.h"
+#include <SUIT_Study.h>
+#include <SUIT_DataObject.h>
+#include <SUIT_ResourceMgr.h>
+
+#include <SVTK_ViewWindow.h>
+#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewPort3d.h>
+#include <GLViewer_ViewFrame.h>
+#include <GLViewer_ViewPort.h>
+#include <Plot2d_ViewWindow.h>
+#include <Plot2d_ViewFrame.h>
+
+#include <OB_Browser.h>
+
+#include <QtxPopupMgr.h>
+
+#include <qvariant.h>
+#include <qstring.h>
+#include <qstringlist.h>
+
+/*!Constructor.*/
+LightApp_Module::LightApp_Module( const QString& name )
+: CAM_Module( name ),
+ myPopupMgr( 0 ),
+ mySwitchOp( 0 ),
+ myDisplay( -1 ),
+ myErase( -1 ),
+ myDisplayOnly( -1 )
+{
+}
+
+/*!Destructor.*/
+LightApp_Module::~LightApp_Module()
+{
+ if ( mySwitchOp )
+ delete mySwitchOp;
+}
+
+/*!Initialize module.*/
+void LightApp_Module::initialize( CAM_Application* app )
+{
+ CAM_Module::initialize( app );
+
+ SUIT_ResourceMgr* resMgr = app ? app->resourceMgr() : 0;
+ if ( resMgr )
+ resMgr->raiseTranslators( name() );
+}
+
+/*!NOT IMPLEMENTED*/
+void LightApp_Module::windows( QMap<int, int>& ) const
+{
+}
+
+/*!NOT IMPLEMENTED*/
+void LightApp_Module::viewManagers( QStringList& ) const
+{
+}
+
+/*!Context menu popup.*/
+void LightApp_Module::contextMenuPopup( const QString& client, QPopupMenu* menu, QString& /*title*/ )
+{
+ LightApp_Selection* sel = createSelection();
+ sel->init( client, getApp()->selectionMgr() );
+ popupMgr()->updatePopup( menu, sel );
+ delete sel;
+}
+
+/*!Update object browser.
+ * For updating model or whole object browser use update() method can be used.
+*/
+void LightApp_Module::updateObjBrowser( bool updateDataModel, SUIT_DataObject* root )
+{
+ if( updateDataModel )
+ if( CAM_DataModel* aDataModel = dataModel() )
+ if( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) )
+ aModel->update( 0, dynamic_cast<LightApp_Study*>( getApp()->activeStudy() ) );
+ getApp()->objectBrowser()->updateTree( root );
+}
+
+/*!NOT IMPLEMENTED*/
+void LightApp_Module::selectionChanged()
+{
+}
+
+/*!Activate module.*/
+bool LightApp_Module::activateModule( SUIT_Study* study )
+{
+ bool res = CAM_Module::activateModule( study );
+
+ if ( res && application() && application()->resourceMgr() )
+ application()->resourceMgr()->raiseTranslators( name() );
+
+ if ( mySwitchOp == 0 )
+ mySwitchOp = new LightApp_SwitchOp( this );
+
+ return res;
+}
+
+/*!Deactivate module.*/
+bool LightApp_Module::deactivateModule( SUIT_Study* )
+{
+ delete mySwitchOp;
+ mySwitchOp = 0;
+
+ return true;
+}
+
+/*!NOT IMPLEMENTED*/
+void LightApp_Module::MenuItem()
+{
+}
+
+/*!NOT IMPLEMENTED*/
+void LightApp_Module::createPreferences()
+{
+}
+
+/*!NOT IMPLEMENTED*/
+void LightApp_Module::preferencesChanged( const QString&, const QString& )
+{
+}
+
+/*!Gets application.*/
+LightApp_Application* LightApp_Module::getApp() const
+{
+ return (LightApp_Application*)application();
+}
+
+/*!
+ * \brief Update something in accordance with update flags
+ * \param theFlags - update flags
+*
+* Update viewer or/and object browser etc. in accordance with update flags ( see
+* LightApp_UpdateFlags enumeration ). Derived modules can redefine this method for their
+* own purposes
+*/
+void LightApp_Module::update( const int theFlags )
+{
+ if ( theFlags & UF_Model )
+ {
+ if( CAM_DataModel* aDataModel = dataModel() )
+ if( LightApp_DataModel* aModel = dynamic_cast<LightApp_DataModel*>( aDataModel ) )
+ aModel->update( 0, dynamic_cast<LightApp_Study*>( getApp()->activeStudy() ) );
+ }
+ if ( theFlags & UF_ObjBrowser )
+ getApp()->objectBrowser()->updateTree( 0 );
+ if ( theFlags & UF_Controls )
+ updateControls();
+ if ( theFlags & UF_Viewer )
+ {
+ if ( SUIT_ViewManager* viewMgr = getApp()->activeViewManager() )
+ if ( SUIT_ViewWindow* viewWnd = viewMgr->getActiveView() )
+ {
+ if ( viewWnd->inherits( "SVTK_ViewWindow" ) )
+ ( (SVTK_ViewWindow*)viewWnd )->Repaint();
+ else if ( viewWnd->inherits( "OCCViewer_ViewWindow" ) )
+ ( (OCCViewer_ViewWindow*)viewWnd )->getViewPort()->onUpdate();
+ else if ( viewWnd->inherits( "Plot2d_ViewWindow" ) )
+ ( (Plot2d_ViewWindow*)viewWnd )->getViewFrame()->Repaint();
+ else if ( viewWnd->inherits( "GLViewer_ViewFrame" ) )
+ ( (GLViewer_ViewFrame*)viewWnd )->getViewPort()->onUpdate();
+ }
+ }
+}
+/*!
+ * \brief Updates controls
+*
+* Updates (i.e. disable/enable) controls states (menus, tool bars etc.). This method is
+* called from update( UF_Controls ). You may redefine it in concrete module.
+*/
+void LightApp_Module::updateControls()
+{
+}
+
+/*!Create new instance of data model and return it.*/
+CAM_DataModel* LightApp_Module::createDataModel()
+{
+ return new LightApp_DataModel(this);
+}
+
+/*!Create and return instance of LightApp_Selection.*/
+LightApp_Selection* LightApp_Module::createSelection() const
+{
+ return new LightApp_Selection();
+}
+
+/*!NOT IMPLEMENTED*/
+void LightApp_Module::onModelOpened()
+{
+}
+
+/*!NOT IMPLEMENTED*/
+void LightApp_Module::onModelSaved()
+{
+}
+
+/*!NOT IMPLEMENTED*/
+void LightApp_Module::onModelClosed()
+{
+}
+
+/*!Gets popup manager.(create if not exist)*/
+QtxPopupMgr* LightApp_Module::popupMgr()
+{
+ if ( !myPopupMgr )
+ {
+ myPopupMgr = new QtxPopupMgr( 0, this );
+
+ QPixmap p;
+ SUIT_Desktop* d = application()->desktop();
+
+ QAction
+ *disp = createAction( -1, tr( "TOP_DISPLAY" ), p, tr( "MEN_DISPLAY" ), tr( "STB_DISPLAY" ),
+ 0, d, false, this, SLOT( onShowHide() ) ),
+ *erase = createAction( -1, tr( "TOP_ERASE" ), p, tr( "MEN_ERASE" ), tr( "STB_ERASE" ),
+ 0, d, false, this, SLOT( onShowHide() ) ),
+ *dispOnly = createAction( -1, tr( "TOP_DISPLAY_ONLY" ), p, tr( "MEN_DISPLAY_ONLY" ), tr( "STB_DISPLAY_ONLY" ),
+ 0, d, false, this, SLOT( onShowHide() ) );
+ myDisplay = actionId( disp );
+ myErase = actionId( erase );
+ myDisplayOnly = actionId( dispOnly );
+
+ myPopupMgr->insert( disp, -1, 0 );
+ myPopupMgr->insert( erase, -1, 0 );
+ myPopupMgr->insert( dispOnly, -1, 0 );
+ myPopupMgr->insert( separator(), -1, 0 );
+
+ QString uniform = "( count( $component ) = 1 ) and ( component != activeModule ) and ( activeModule = '%1' )";
+ uniform = uniform.arg( name() );
+ myPopupMgr->setRule( disp, QString( "( not isVisible ) and " ) + uniform, true );
+ myPopupMgr->setRule( erase, QString( "( isVisible ) and " ) + uniform, true );
+ myPopupMgr->setRule( dispOnly, uniform, true );
+ }
+ return myPopupMgr;
+}
+
+/*!Gets preferences.*/
+LightApp_Preferences* LightApp_Module::preferences() const
+{
+ LightApp_Preferences* pref = 0;
+ if ( getApp() )
+ pref = getApp()->preferences();
+ return pref;
+}
+
+/*!Add preference to preferences.*/
+int LightApp_Module::addPreference( const QString& label )
+{
+ LightApp_Preferences* pref = preferences();
+ if ( !pref )
+ return -1;
+
+ int catId = pref->addPreference( moduleName(), -1 );
+ if ( catId == -1 )
+ return -1;
+
+ return pref->addPreference( label, catId );
+}
+
+/*!Add preference to preferences.*/
+int LightApp_Module::addPreference( const QString& label, const int pId, const int type,
+ const QString& section, const QString& param )
+{
+ LightApp_Preferences* pref = preferences();
+ if ( !pref )
+ return -1;
+
+ return pref->addPreference( moduleName(), label, pId, type, section, param );
+}
+
+/*!Gets property of preferences.*/
+QVariant LightApp_Module::preferenceProperty( const int id, const QString& prop ) const
+{
+ QVariant var;
+ LightApp_Preferences* pref = preferences();
+ if ( pref )
+ var = pref->itemProperty( id, prop );
+ return var;
+}
+
+/*!Set property of preferences.*/
+void LightApp_Module::setPreferenceProperty( const int id, const QString& prop, const QVariant& var )
+{
+ LightApp_Preferences* pref = preferences();
+ if ( pref )
+ pref->setItemProperty( id, prop, var );
+}
+
+/*!
+ * \brief Starts operation with given identifier
+ * \param id - identifier of operation to be started
+*
+* Module stores operations in map. This method starts operation by id.
+* If operation isn't in map, then it will be created by createOperation method
+* and will be inserted to map
+*/
+void LightApp_Module::startOperation( const int id )
+{
+ LightApp_Operation* op = 0;
+ if( myOperations.contains( id ) )
+ op = myOperations[ id ];
+ else
+ {
+ op = createOperation( id );
+ if( op )
+ {
+ myOperations.insert( id, op );
+ op->setModule( this );
+ connect( op, SIGNAL( stopped( SUIT_Operation* ) ), this, SLOT( onOperationStopped( SUIT_Operation* ) ) );
+ connect( op, SIGNAL( destroyed() ), this, SLOT( onOperationDestroyed() ) );
+ }
+ }
+
+ if( op )
+ op->start();
+}
+
+/*!
+ * \brief Creates operation with given identifier
+ * \param id - identifier of operation to be started
+ * \return Pointer on created operation or NULL if operation is not created
+*
+* Creates operation with given id. You should not call this method, it will be called
+* automatically from startOperation. You may redefine this method in concrete module to
+* create operations.
+*/
+LightApp_Operation* LightApp_Module::createOperation( const int id ) const
+{
+ if( id==-1 )
+ return 0;
+
+ if( id==myDisplay )
+ return new LightApp_ShowHideOp( LightApp_ShowHideOp::DISPLAY );
+ else if( id==myErase )
+ return new LightApp_ShowHideOp( LightApp_ShowHideOp::ERASE );
+ else if( id==myDisplayOnly )
+ return new LightApp_ShowHideOp( LightApp_ShowHideOp::DISPLAY_ONLY );
+ else
+ return 0;
+}
+
+/*!
+ * \brief Virtual protected slot called when operation stopped
+ * \param theOp - stopped operation
+*
+* Virtual protected slot called when operation stopped. Redefine this slot if you want to
+* perform actions after stopping operation
+*/
+void LightApp_Module::onOperationStopped( SUIT_Operation* /*theOp*/ )
+{
+}
+
+/*!
+ * \brief Virtual protected slot called when operation destroyed
+ * \param theOp - destroyed operation
+*
+* Virtual protected slot called when operation destroyed. Redefine this slot if you want to
+* perform actions after destroying operation. Base implementation removes pointer on
+* destroyed operation from the map of operations
+*/
+void LightApp_Module::onOperationDestroyed()
+{
+ const QObject* s = sender();
+ if( s && s->inherits( "LightApp_Operation" ) )
+ {
+ const LightApp_Operation* op = ( LightApp_Operation* )s;
+ MapOfOperation::const_iterator anIt = myOperations.begin(),
+ aLast = myOperations.end();
+ for( ; anIt!=aLast; anIt++ )
+ if( anIt.data()==op )
+ {
+ myOperations.remove( anIt.key() );
+ break;
+ }
+ }
+}
+
+LightApp_Displayer* LightApp_Module::displayer()
+{
+ return 0;
+}
+
+void LightApp_Module::onShowHide()
+{
+ if( !sender()->inherits( "QAction" ) || !popupMgr() )
+ return;
+
+ QAction* act = ( QAction* )sender();
+ int id = actionId( act );
+ if( id!=-1 )
+ startOperation( id );
+}
--- /dev/null
+// File: LightApp_Module.h
+// Created: 6/20/2005 16:25:06 AM
+// Author: OCC team
+// Copyright (C) CEA 2005
+
+#ifndef LIGHTAPP_MODULE_H
+#define LIGHTAPP_MODULE_H
+
+#include "LightApp.h"
+#include <CAM_Module.h>
+
+class LightApp_Application;
+class LightApp_Preferences;
+class LightApp_Selection;
+class LightApp_Operation;
+class LightApp_SwitchOp;
+class LightApp_Displayer;
+
+class SUIT_Study;
+class SUIT_DataObject;
+class SUIT_Operation;
+class CAM_Application;
+
+class QtxPopupMgr;
+
+class QString;
+class QVariant;
+
+/*
+ Class : LightApp_Module
+ Description : Base class for all light modules
+*/
+
+class LIGHTAPP_EXPORT LightApp_Module : public CAM_Module
+{
+ Q_OBJECT
+
+public:
+ LightApp_Module( const QString& );
+ virtual ~LightApp_Module();
+
+ virtual void initialize( CAM_Application* );
+ virtual void windows( QMap<int, int>& ) const;
+ virtual void viewManagers( QStringList& ) const;
+
+ virtual void contextMenuPopup( const QString&, QPopupMenu*, QString& );
+
+ virtual void createPreferences();
+
+ LightApp_Application* getApp() const;
+
+ virtual void update( const int );
+ // Update viewer or/and object browser etc. in accordance with update flags
+ // ( see SalomeApp_UpdateFlags enumeration ). Derived modules can redefine this method
+ // for their own purposes
+
+ virtual void updateObjBrowser( bool = true, SUIT_DataObject* = 0 );
+ // Update object bropwser ( for updating model or whole object browser use update() method
+ // can be used )
+
+ virtual void selectionChanged();
+ virtual void preferencesChanged( const QString&, const QString& );
+
+ virtual void studyActivated() {};
+
+ virtual LightApp_Displayer* displayer();
+
+public slots:
+ virtual bool activateModule( SUIT_Study* );
+ virtual bool deactivateModule( SUIT_Study* );
+
+ void MenuItem();
+
+protected slots:
+ virtual void onModelSaved();
+ virtual void onModelOpened();
+ virtual void onModelClosed();
+
+ virtual void onOperationStopped( SUIT_Operation* );
+ virtual void onOperationDestroyed();
+ virtual void onShowHide();
+
+protected:
+ virtual QtxPopupMgr* popupMgr();
+ LightApp_Preferences* preferences() const;
+
+ virtual CAM_DataModel* createDataModel();
+ virtual LightApp_Selection* createSelection() const;
+
+ int addPreference( const QString& label );
+ int addPreference( const QString& label, const int pId, const int = -1,
+ const QString& section = QString::null,
+ const QString& param = QString::null );
+ QVariant preferenceProperty( const int, const QString& ) const;
+ void setPreferenceProperty( const int, const QString&, const QVariant& );
+
+ /*! Module stores operations in map. This method starts operation by id.
+ * If operation isn't in map, then it will be created by createOperation method
+ * and will be inserted to map
+ */
+ void startOperation( const int );
+ /*! Create operation by its id. You must not call this method, it will be called automatically
+ * by startOperation. Please redefine this method in current module
+ */
+ virtual LightApp_Operation* createOperation( const int ) const;
+
+ virtual void updateControls();
+
+private:
+ typedef QMap<int,LightApp_Operation*> MapOfOperation;
+
+private:
+ QtxPopupMgr* myPopupMgr;
+ MapOfOperation myOperations;
+ LightApp_SwitchOp* mySwitchOp;
+ int myDisplay, myErase, myDisplayOnly;
+};
+
+#endif
--- /dev/null
+// File : LightApp_ModuleDlg.cxx\r
+// Author : Michael Zorin (mzn)\r
+// Module : LightApp\r
+\r
+#include <LightApp_ModuleDlg.h>\r
+\r
+#include <qframe.h>\r
+#include <qlabel.h>\r
+#include <qpushbutton.h>\r
+#include <qlayout.h>\r
+#include <qpixmap.h>\r
+\r
+#ifndef WIN32\r
+using namespace std;\r
+#endif\r
+\r
+/*!Default icon*/\r
+static const char* const default_icon[] = { \r
+"48 48 17 1",\r
+". c None",\r
+"# c #161e4c",\r
+"b c #1d3638",\r
+"e c #2f585b",\r
+"i c #345b5e",\r
+"c c #386266",\r
+"g c #3f7477",\r
+"d c #4d8589",\r
+"m c #519099",\r
+"o c #6abbc1",\r
+"a c #70c9d3",\r
+"f c #79ddea",\r
+"n c #7adff2",\r
+"k c #7ce2f4",\r
+"j c #993550",\r
+"h c #d84b71",\r
+"l c #ef537d",\r
+"................................................",\r
+"................................................",\r
+"................................................",\r
+"................................................",\r
+"................................................",\r
+"................########.########.########......",\r
+"...............#aaaaaa###aaaaaa###aaaaaa##......",\r
+"..............#aaaaaa#b#aaaaaa#b#aaaaaa#c#......",\r
+".............########b########b########cc#......",\r
+".............#dddddd#b#dddddd#b#dddddd#cc#......",\r
+"...........########d########d########d#cc#......",\r
+"..........#aaaaaa###aaaaaa###aaaaaa##d#cc#......",\r
+".........#aaaaaa#b#aaaaaa#b#aaaaaa#c#d#cc#......",\r
+"........########b########e########cc#d#c#.......",\r
+"........#dddddd#b#dddddd#e#ffffff#cc#d####......",\r
+"......########d########d########f#cc###g##......",\r
+".....#aaaaaa###aaaaaa###hhhhhh##f#cc#gg#c#......",\r
+"....#aaaaaa#b#aaaaaa#i#hhhhhh#j#f#cc###cc#......",\r
+"...########b########i########jj#f#c#gg#cc#......",\r
+"...#kkkkkk#b#kkkkkk#i#llllll#jj#f####g#cc#......",\r
+"...#kkkkkk#b#kkkkkk#i#llllll#jj###m##g#cc#......",\r
+"...#knnkkk#b#kkkkkk#i#llllll#jj#mm#c#g#cc#......",\r
+"...#knnkkk#b#kkkkkk#i#llllll#jj###cc#g#c#.......",\r
+"...#kkkkkk#b#kkkkkk#i#llllll#j#dd#cc#g####......",\r
+"...#kkkkkk###kkkkkk###llllll####d#cc###g##......",\r
+"...########g########g########o##d#cc#gg#c#......",\r
+"....#gggggg#b#gggggg#b#oooooo#c#d#cc###cc#......",\r
+"...########b########b########cc#d#c#gg#cc#......",\r
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#d####g#cc#......",\r
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###g##g#cc#......",\r
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#gg#c#g#cc#......",\r
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###cc#g#c#.......",\r
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#gg#cc#g##........",\r
+"...#kkkkkk###kkkkkk###kkkkkk####g#cc###.........",\r
+"...########g########g########g##g#cc#...........",\r
+"....#gggggg#b#gggggg#b#gggggg#c#g#cc#...........",\r
+"...########b########b########cc#g#c#............",\r
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#g##.............",\r
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###..............",\r
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",\r
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",\r
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#.................",\r
+"...#kkkkkk###kkkkkk###kkkkkk##..................",\r
+"...########.########.########...................",\r
+"................................................",\r
+"................................................",\r
+"................................................",\r
+"................................................"};\r
+\r
+//==============================================================================================================================\r
+/*!\r
+ * LightApp_ModuleDlg::LightApp_ModuleDlg \n\r
+ *\r
+ * Constructor.\r
+ */\r
+//==============================================================================================================================\r
+LightApp_ModuleDlg::LightApp_ModuleDlg ( QWidget * parent, const QString& component, const QPixmap icon )\r
+ : QDialog ( parent, "ActivateModuleDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )\r
+{\r
+ QPixmap defaultIcon( ( const char** ) default_icon );\r
+ setCaption( tr( "CAPTION" ) );\r
+ setSizeGripEnabled( TRUE );\r
+ \r
+ QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this ); \r
+ ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 );\r
+\r
+ // Module's name and icon\r
+ myComponentFrame = new QFrame( this, "myComponentFrame" );\r
+ myComponentFrame->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) );\r
+ myComponentFrame->setMinimumHeight( 100 );\r
+ myComponentFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );\r
+ \r
+ QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame ); \r
+ myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 );\r
+\r
+ // --> icon\r
+ myComponentIcon = new QLabel( myComponentFrame, "myComponentIcon" );\r
+ myComponentIcon->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );\r
+ myComponentIcon->setPixmap( !icon.isNull() ? icon : defaultIcon );\r
+ myComponentIcon->setScaledContents( false );\r
+ myComponentIcon->setAlignment( AlignCenter );\r
+ // --> name\r
+ myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" );\r
+ QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt ); \r
+ myComponentLab->setAlignment( AlignCenter );\r
+\r
+ myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 );\r
+ myComponentFrameLayout->addWidget( myComponentLab, 0, 1 );\r
+\r
+ // Info\r
+ QVBoxLayout* infoLayout = new QVBoxLayout();\r
+ infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 );\r
+ \r
+ // --> top line\r
+ QFrame* myLine1 = new QFrame( this, "myLine1" );\r
+ myLine1->setFrameStyle( QFrame::HLine | QFrame::Plain );\r
+ // --> info label \r
+ myInfoLabel = new QLabel( tr ("ActivateComponent_DESCRIPTION"), this, "myInfoLabel" );\r
+ myInfoLabel->setAlignment( AlignCenter );\r
+ // --> bottom line\r
+ QFrame* myLine2 = new QFrame( this, "myLine2" );\r
+ myLine2->setFrameStyle( QFrame::HLine | QFrame::Plain );\r
+ \r
+ infoLayout->addStretch();\r
+ infoLayout->addWidget( myLine1 );\r
+ infoLayout->addWidget( myInfoLabel );\r
+ infoLayout->addWidget( myLine2 );\r
+ infoLayout->addStretch();\r
+ \r
+ // Buttons\r
+ QHBoxLayout* btnLayout = new QHBoxLayout(); \r
+ btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );\r
+ \r
+ // --> New\r
+ myNewBtn = new QPushButton( tr( "NEW" ), this, "myNewBtn" );\r
+ myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true );\r
+ // --> Open\r
+ myOpenBtn = new QPushButton( tr( "OPEN" ), this, "myOpenBtn" );\r
+ myOpenBtn->setAutoDefault( true );\r
+ // --> Load\r
+ myLoadBtn = new QPushButton( tr( "LOAD" ), this, "myLoadBtn" );\r
+ myLoadBtn->setAutoDefault( true );\r
+ // --> Cancel\r
+ myCancelBtn = new QPushButton( tr( "CANCEL" ), this, "myCancelBtn" );\r
+ myCancelBtn->setAutoDefault( true );\r
+ \r
+ btnLayout->addWidget( myNewBtn );\r
+ btnLayout->addWidget( myOpenBtn );\r
+ btnLayout->addWidget( myLoadBtn );\r
+ btnLayout->addStretch();\r
+ btnLayout->addSpacing( 70 );\r
+ btnLayout->addStretch();\r
+ btnLayout->addWidget( myCancelBtn );\r
+\r
+ ActivateModuleDlgLayout->addWidget( myComponentFrame, 0, 0 );\r
+ ActivateModuleDlgLayout->addLayout( infoLayout, 0, 1 );\r
+ ActivateModuleDlgLayout->addMultiCellLayout( btnLayout, 1, 1, 0, 1 );\r
+\r
+ // signals and slots connections\r
+ connect( myNewBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );\r
+ connect( myOpenBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );\r
+ connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );\r
+ connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );\r
+}\r
+\r
+//==============================================================================================================================\r
+/*!\r
+ * LightApp_ModuleDlg::onButtonClicked\r
+ *\r
+ * Buttons slot\r
+ */\r
+//==============================================================================================================================\r
+void LightApp_ModuleDlg::onButtonClicked()\r
+{\r
+ QPushButton* btn = ( QPushButton* )sender();\r
+ if ( btn == myNewBtn )\r
+ done( 1 );\r
+ if ( btn == myOpenBtn )\r
+ done( 2 );\r
+ if ( btn == myLoadBtn )\r
+ done( 3 );\r
+}\r
--- /dev/null
+// SALOME SALOMEGUI : implementation of desktop and GUI kernel
+//
+// Copyright (C) 2005 CEA/DEN, EDF R&D
+//
+//
+//
+// File : LightApp_ModuleDlg.h
+// Author : Michael ZORIN (mzn)
+// Module : SALOME
+
+#ifndef LIGHTAPP_MODULEDLG_H
+#define LIGHTAPP_MODULEDLG_H
+
+#include "LightApp.h"
+#include <qdialog.h>
+#include <qpixmap.h>
+
+class QFrame;
+class QLabel;
+class QPushButton;
+
+class LIGHTAPP_EXPORT LightApp_ModuleDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ LightApp_ModuleDlg ( QWidget* parent, const QString& component, const QPixmap icon = QPixmap() ) ;
+ ~LightApp_ModuleDlg ( ) { };
+
+private slots:
+ void onButtonClicked();
+
+private:
+ QFrame* myComponentFrame;
+ QLabel* myComponentLab;
+ QLabel* myComponentIcon;
+ QLabel* myInfoLabel;
+ QPushButton* myNewBtn;
+ QPushButton* myOpenBtn;
+ QPushButton* myLoadBtn;
+ QPushButton* myCancelBtn;
+};
+
+#endif
+
--- /dev/null
+// File : LightApp_NameDlg.cxx\r
+// Author : Vadim SANDLER\r
+// $Header$\r
+\r
+#include <LightApp_NameDlg.h>\r
+#include <SUIT_Application.h>\r
+#include <SUIT_Desktop.h>\r
+#include <SUIT_Tools.h>\r
+\r
+#include <qgroupbox.h>\r
+#include <qlabel.h>\r
+#include <qlineedit.h>\r
+#include <qpushbutton.h>\r
+#include <qlayout.h>\r
+\r
+#ifndef WIN32\r
+using namespace std;\r
+#endif\r
+\r
+/*!\r
+ Constructor\r
+*/\r
+LightApp_NameDlg::LightApp_NameDlg( QWidget* parent )\r
+: QDialog( parent ? parent : NULL,//application()->desktop(), \r
+"LightApp_NameDlg",\r
+true,\r
+WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )\r
+{\r
+ setCaption( tr("TLT_RENAME") );\r
+ setSizeGripEnabled( TRUE );\r
+\r
+ QVBoxLayout* topLayout = new QVBoxLayout( this );\r
+ topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );\r
+\r
+ /***************************************************************/\r
+ QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );\r
+ GroupC1->setColumnLayout(0, Qt::Vertical );\r
+ GroupC1->layout()->setMargin( 0 ); GroupC1->layout()->setSpacing( 0 );\r
+ QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1->layout() );\r
+ GroupC1Layout->setAlignment( Qt::AlignTop );\r
+ GroupC1Layout->setMargin( 11 ); GroupC1Layout->setSpacing( 6 );\r
+ \r
+ QLabel* TextLabel = new QLabel( GroupC1, "TextLabel1" );\r
+ TextLabel->setText( tr( "NAME_LBL" ) );\r
+ GroupC1Layout->addWidget( TextLabel );\r
+ \r
+ myLineEdit = new QLineEdit( GroupC1, "LineEdit1" );\r
+ myLineEdit->setMinimumSize( 250, 0 );\r
+ GroupC1Layout->addWidget( myLineEdit );\r
+ \r
+ /***************************************************************/\r
+ QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );\r
+ GroupButtons->setColumnLayout(0, Qt::Vertical );\r
+ GroupButtons->layout()->setMargin( 0 ); GroupButtons->layout()->setSpacing( 0 ); \r
+ QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() );\r
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );\r
+ GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 );\r
+ \r
+ myButtonOk = new QPushButton( GroupButtons, "buttonOk" );\r
+ myButtonOk->setText( tr( "BUT_OK" ) );\r
+ myButtonOk->setAutoDefault( TRUE ); myButtonOk->setDefault( TRUE );\r
+ GroupButtonsLayout->addWidget( myButtonOk );\r
+\r
+ GroupButtonsLayout->addStretch();\r
+ \r
+ myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" );\r
+ myButtonCancel->setText( tr( "BUT_CANCEL" ) );\r
+ myButtonCancel->setAutoDefault( TRUE );\r
+ GroupButtonsLayout->addWidget( myButtonCancel );\r
+ /***************************************************************/\r
+ \r
+ topLayout->addWidget( GroupC1 );\r
+ topLayout->addWidget( GroupButtons );\r
+ \r
+ // signals and slots connections\r
+ connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );\r
+ connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );\r
+ \r
+ /* Move widget on the botton right corner of main widget */\r
+ SUIT_Tools::centerWidget( this, parent );\r
+}\r
+\r
+/*!\r
+ Destructor\r
+*/\r
+LightApp_NameDlg::~LightApp_NameDlg()\r
+{\r
+}\r
+\r
+/*!\r
+ Sets name\r
+*/\r
+void LightApp_NameDlg::setName( const QString& name )\r
+{\r
+ myLineEdit->setText( name );\r
+ myLineEdit->end(false);\r
+ myLineEdit->home(true);\r
+}\r
+\r
+/*!\r
+ Returns name entered by user\r
+*/\r
+QString LightApp_NameDlg::name()\r
+{\r
+ return myLineEdit->text();\r
+}\r
+\r
+void LightApp_NameDlg::accept()\r
+{\r
+ if ( name().stripWhiteSpace().isEmpty() )\r
+ return;\r
+ QDialog::accept();\r
+}\r
+\r
+/*!\r
+ Creates modal <Rename> dialog and returns name entered [ static ]\r
+*/\r
+QString LightApp_NameDlg::getName( QWidget* parent, const QString& oldName )\r
+{\r
+ QString n;\r
+ LightApp_NameDlg* dlg = new LightApp_NameDlg( parent );\r
+ if ( !oldName.isNull() )\r
+ dlg->setName( oldName );\r
+ if ( dlg->exec() == QDialog::Accepted ) \r
+ n = dlg->name();\r
+ delete dlg;\r
+ return n;\r
+}\r
--- /dev/null
+// SALOME SalomeApp : implementation of desktop and GUI kernel
+//
+// Copyright (C) 2003 CEA/DEN, EDF R&D
+//
+//
+//
+// File : LightApp_NameDlg.h
+// Author : Vadim SANDLER
+// Module : SALOME
+// $Header$
+
+#ifndef LIGHTAPP_NAMEDLG_H
+#define LIGHTAPP_NAMEDLG_H
+
+#include "LightApp.h"
+#include <qdialog.h>
+
+class QLineEdit;
+class QPushButton;
+
+//=================================================================================
+// class : LightApp_NameDlg
+/*! purpose : Common <Rename> dialog box class*/
+//=================================================================================
+class LIGHTAPP_EXPORT LightApp_NameDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ LightApp_NameDlg( QWidget* parent = 0 );
+ ~LightApp_NameDlg();
+
+ void setName( const QString& name );
+ QString name();
+
+ static QString getName( QWidget* parent = 0, const QString& oldName = QString::null );
+
+protected slots:
+ void accept();
+
+private:
+ QPushButton* myButtonOk;
+ QPushButton* myButtonCancel;
+ QLineEdit* myLineEdit;
+};
+
+#endif // LightApp_NAMEDLG_H
--- /dev/null
+#include "LightApp_OBFilter.h"
+
+#include "LightApp_SelectionMgr.h"
+#include "LightApp_DataObject.h"
+#include "LightApp_DataOwner.h"
+
+/*!
+ Constructor.
+*/
+LightApp_OBFilter::LightApp_OBFilter( LightApp_SelectionMgr* theSelMgr )
+{
+ mySelMgr = theSelMgr;
+}
+
+/*!Destructor.*/
+LightApp_OBFilter::~LightApp_OBFilter()
+{
+}
+
+/*!Checks: data object is ok?*/
+bool LightApp_OBFilter::isOk( const SUIT_DataObject* theDataObj ) const
+{
+ const LightApp_DataObject* obj = dynamic_cast<const LightApp_DataObject*>( theDataObj );
+ if ( obj )
+ return mySelMgr->isOk( new LightApp_DataOwner( obj->entry() ) );
+
+ return true;
+}
+
--- /dev/null
+#ifndef LIGHTAPP_OBFILTER_H
+#define LIGHTAPP_OBFILTER_H
+
+#include "LightApp.h"
+#include "OB_Filter.h"
+
+class LightApp_SelectionMgr;
+
+class LIGHTAPP_EXPORT LightApp_OBFilter: public OB_Filter
+{
+public:
+ LightApp_OBFilter( LightApp_SelectionMgr* theSelMgr );
+ ~LightApp_OBFilter();
+
+ virtual bool isOk( const SUIT_DataObject* ) const;
+
+private:
+ LightApp_SelectionMgr* mySelMgr;
+
+};
+
+#endif
--- /dev/null
+#include "LightApp_OBSelector.h"
+
+#include "LightApp_DataOwner.h"
+#include "LightApp_DataObject.h"
+
+#include <OB_Browser.h>
+
+#include <SUIT_DataObjectIterator.h>
+
+/*!
+ Constructor
+*/
+LightApp_OBSelector::LightApp_OBSelector( OB_Browser* ob, SUIT_SelectionMgr* mgr )
+: SUIT_Selector( mgr, ob ),
+ myBrowser( ob )
+{
+ if ( myBrowser ) {
+ connect( myBrowser, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
+ }
+}
+
+/*!
+ Destructor
+*/
+LightApp_OBSelector::~LightApp_OBSelector()
+{
+}
+
+/*!
+ Gets browser.
+*/
+OB_Browser* LightApp_OBSelector::browser() const
+{
+ return myBrowser;
+}
+
+/*!
+ Gets selection.
+*/
+void LightApp_OBSelector::getSelection( SUIT_DataOwnerPtrList& theList ) const
+{
+ if ( !myBrowser )
+ return;
+
+ DataObjectList objlist;
+ myBrowser->getSelected( objlist );
+ for ( DataObjectListIterator it( objlist ); it.current(); ++it )
+ {
+ LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( it.current() );
+ if ( obj )
+ {
+ Handle( SALOME_InteractiveObject ) aSObj = new SALOME_InteractiveObject
+ ( obj->entry(), obj->componentDataType(), obj->name() );
+ LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
+ theList.append( SUIT_DataOwnerPtr( owner ) );
+ }
+ }
+}
+
+/*!Sets selection.*/
+void LightApp_OBSelector::setSelection( const SUIT_DataOwnerPtrList& theList )
+{
+ if ( !myBrowser )
+ return;
+
+ QMap<QString, LightApp_DataObject*> themap;
+ fillEntries( themap );
+
+ DataObjectList objList;
+ for ( SUIT_DataOwnerPtrList::const_iterator it = theList.begin(); it != theList.end(); ++it )
+ {
+ const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
+ if ( owner && themap.contains( owner->entry() ) )
+ objList.append( themap[owner->entry()] );
+ }
+
+ myBrowser->setSelected( objList );
+}
+
+/*!On selection changed.*/
+void LightApp_OBSelector::onSelectionChanged()
+{
+ selectionChanged();
+}
+
+/*!Fill entries.*/
+void LightApp_OBSelector::fillEntries( QMap<QString, LightApp_DataObject*>& entires )
+{
+ entires.clear();
+
+ if ( !myBrowser )
+ return;
+
+ for ( SUIT_DataObjectIterator it( myBrowser->getRootObject(),
+ SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it )
+ {
+ LightApp_DataObject* obj = dynamic_cast<LightApp_DataObject*>( it.current() );
+ if ( obj )
+ entires.insert( obj->entry(), obj );
+ }
+}
--- /dev/null
+#ifndef LIGHTAPP_OBSELECTOR_H
+#define LIGHTAPP_OBSELECTOR_H
+
+#include "LightApp.h"
+
+#include <SUIT_Selector.h>
+
+class OB_Browser;
+class LightApp_DataObject;
+
+class LIGHTAPP_EXPORT LightApp_OBSelector : public SUIT_Selector
+{
+ Q_OBJECT
+
+public:
+ LightApp_OBSelector( OB_Browser*, SUIT_SelectionMgr* );
+ virtual ~LightApp_OBSelector();
+
+ OB_Browser* browser() const;
+
+ /*!Return "ObjectBrowser"*/
+ virtual QString type() const { return "ObjectBrowser"; }
+
+private slots:
+ void onSelectionChanged();
+
+protected:
+ virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
+ virtual void setSelection( const SUIT_DataOwnerPtrList& );
+
+private:
+ void fillEntries( QMap<QString, LightApp_DataObject*>& );
+
+private:
+ OB_Browser* myBrowser;
+};
+
+#endif
--- /dev/null
+
+#include "LightApp_DataOwner.h"
+#include "LightApp_OCCSelector.h"
+
+#include <SALOME_InteractiveObject.hxx>
+
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+
+/*!
+ Constructor
+*/
+LightApp_OCCSelector::LightApp_OCCSelector( OCCViewer_Viewer* viewer, SUIT_SelectionMgr* mgr )
+: SUIT_Selector( mgr, viewer ),
+ myViewer( viewer )
+{
+ if ( myViewer )
+ connect( myViewer, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
+}
+
+/*!
+ Destructor.
+*/
+LightApp_OCCSelector::~LightApp_OCCSelector()
+{
+}
+
+/*!
+ Gets viewer.
+*/
+OCCViewer_Viewer* LightApp_OCCSelector::viewer() const
+{
+ return myViewer;
+}
+
+/*!On selection changed.*/
+void LightApp_OCCSelector::onSelectionChanged()
+{
+ selectionChanged();
+}
+
+/*!Gets selection list.*/
+void LightApp_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const
+{
+ if ( !myViewer )
+ return;
+
+ AIS_ListOfInteractive aSelList;
+ myViewer->getSelectedObjects( aSelList );
+ for ( AIS_ListIteratorOfListOfInteractive anIt( aSelList ); anIt.More(); anIt.Next() )
+ if ( !anIt.Value().IsNull() )
+ {
+ Handle(SALOME_InteractiveObject) anObj = Handle(SALOME_InteractiveObject)::DownCast(anIt.Value()->GetOwner());
+ if( !anObj.IsNull() )
+ aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( anObj ) ) );
+ }
+}
+
+/*!Sets selection list.*/
+void LightApp_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList )
+{
+ if ( !myViewer )
+ return;
+
+ QMap<QString, Handle(AIS_InteractiveObject)> aDisplayed;
+ Handle(AIS_InteractiveContext) aContext = myViewer->getAISContext();
+ if ( aContext.IsNull() )
+ return;
+
+ AIS_ListOfInteractive aDispList, aSelList;
+ aContext->DisplayedObjects( aDispList );
+
+ for ( AIS_ListIteratorOfListOfInteractive it( aDispList ); it.More(); it.Next() )
+ {
+ QString entryStr = entry( it.Value() );
+ if ( !entryStr.isEmpty() )
+ aDisplayed.insert( entryStr, it.Value() );
+ }
+
+ for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
+ {
+ const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
+ if ( owner && aDisplayed.contains( owner->entry() ) )
+ aSelList.Append( aDisplayed[owner->entry()] );
+ }
+
+ myViewer->unHighlightAll( false );
+ myViewer->setObjectsSelected( aSelList );
+}
+
+/*!Gets entry ob object.*/
+QString LightApp_OCCSelector::entry( const Handle(AIS_InteractiveObject)& anAIS ) const
+{
+ if ( anAIS.IsNull() || !anAIS->HasOwner() )
+ return QString::null;
+
+ Handle(SALOME_InteractiveObject) anObj = Handle(SALOME_InteractiveObject)::DownCast(anAIS->GetOwner());
+
+ QString res;
+ if ( !anObj.IsNull() )
+ res = QString( anObj->getEntry() );
+ return res;
+}
--- /dev/null
+#ifndef LIGHTAPP_OCCSELECTOR_H
+#define LIGHTAPP_OCCSELECTOR_H
+
+#include "LightApp.h"
+
+#include <SUIT_Selector.h>
+
+#include <OCCViewer_ViewModel.h>
+
+class Handle_AIS_InteractiveObject;
+
+class LIGHTAPP_EXPORT LightApp_OCCSelector : public SUIT_Selector
+{
+ Q_OBJECT
+
+public:
+ LightApp_OCCSelector( OCCViewer_Viewer*, SUIT_SelectionMgr* );
+ virtual ~LightApp_OCCSelector();
+
+ OCCViewer_Viewer* viewer() const;
+
+ virtual QString type() const { return OCCViewer_Viewer::Type(); }
+
+private slots:
+ virtual void onSelectionChanged();
+
+protected:
+ virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
+ virtual void setSelection( const SUIT_DataOwnerPtrList& );
+
+ QString entry( const Handle_AIS_InteractiveObject& ) const;
+
+private:
+ OCCViewer_Viewer* myViewer;
+};
+
+#endif
--- /dev/null
+// LIGHT LightApp
+//
+// Copyright (C) 2005 CEA/DEN, EDF R&D
+//
+//
+//
+// File : LightApp_Operation.h
+// Author : Sergey LITONIN
+// Module : LIGHT
+
+#include <LightApp_Operation.h>
+#include <LightApp_Module.h>
+#include <LightApp_Application.h>
+#include <LightApp_Operation.h>
+#include <LightApp_SelectionMgr.h>
+#include <LightApp_Dialog.h>
+
+#include <SUIT_Desktop.h>
+
+#include <qapplication.h>
+
+
+/*!
+ * \brief Constructor
+*
+* Constructor sets myModule in NULL and myIsAutoResumed in TRUE
+*/
+LightApp_Operation::LightApp_Operation()
+: SUIT_Operation( 0 ),
+ myModule( 0 ),
+ myIsAutoResumed( true )
+{
+}
+
+/*!
+ * \brief Destructor
+*
+* Destructor does nothing
+*/
+LightApp_Operation::~LightApp_Operation()
+{
+
+}
+
+/*!
+ * \brief Gets module of operation
+ * \return Pointer to the module
+*
+* Gets pointer to the module or NULL if module was not set. It is strongly recomended to
+* set valid pointer on the module before start of operation
+*/
+LightApp_Module* LightApp_Operation::module() const
+{
+ return myModule;
+}
+
+
+/*!
+ * \brief Sets module of operation
+ * \param theModule - module to be set
+*
+* Sets pointer to the module. It is strongly recomended to set valid pointer on the
+* module before start of operation
+*/
+void LightApp_Operation::setModule( LightApp_Module* theModule )
+{
+ myModule = theModule;
+ setApplication( myModule ? myModule->application() : 0 );
+ setStudy( application() ? application()->activeStudy() : 0 );
+}
+
+/*!
+ * \brief Gets desktop of operation
+ * \return Pointer to the desktop
+*
+* Gets pointer to the desktop or NULL if application was not set. It is strongly recomended
+* to set valid pointer on the application before start of operation
+*/
+SUIT_Desktop* LightApp_Operation::desktop() const
+{
+ return application() != 0 ? application()->desktop() : 0;
+}
+
+/*!
+ * \brief Enable dialog of operation
+*
+* Virtual method redefined from the base class. Enable dialog if it was desabled (in
+* suspend method) and activate selection
+*/
+void LightApp_Operation::resumeOperation()
+{
+ SUIT_Operation::resumeOperation();
+ setDialogActive( true );
+}
+
+/*!
+ * \brief Performs actions needed for starting operation
+*
+* Virtual method redefined from the base class. Connect signal of selection manager to
+* onSelectionDone() slot
+*/
+void LightApp_Operation::startOperation()
+{
+ if( selectionMgr() )
+ connect( selectionMgr(), SIGNAL( selectionChanged() ), SLOT( onSelectionDone() ) );
+
+ //If suspended operation was stopped during starting other operation,
+ //the dialog is inactive now, We must activate it
+ setDialogActive( true );
+}
+
+/*!
+ * \brief Performs actions needed for suspending operation
+*
+* Virtual method redefined from the base class. This implementation calls corresponding
+* method of base class and cals setDialogActive( false )
+*/
+void LightApp_Operation::suspendOperation()
+{
+ SUIT_Operation::suspendOperation();
+ setDialogActive( false );
+}
+
+//=======================================================================
+// name : abortOperation
+// Purpose : Hide dialog box (if it is exists)
+//=======================================================================
+/*!
+ * \brief Performs actions needed for aborting operation
+*
+* Virtual method redefined from the base class calls corresponding method of base class
+* and hides dialog box (if it is exists), disconnect slots from selection manager
+*/
+void LightApp_Operation::abortOperation()
+{
+ SUIT_Operation::abortOperation();
+ setDialogActive( true );
+ if ( dlg() )
+ dlg()->hide();
+
+ if( selectionMgr() )
+ disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) );
+}
+
+/*!
+ * \brief Performs actions needed for committing operation
+*
+* Virtual method redefined from the base class calls corresponding method of base class
+* and hides dialog box (if it is exists), disconnect slots from selection manager
+*/
+void LightApp_Operation::commitOperation()
+{
+ SUIT_Operation::commitOperation();
+ setDialogActive( true );
+ if ( dlg() )
+ dlg()->hide();
+
+ if( selectionMgr() )
+ disconnect( selectionMgr(), SIGNAL( selectionChanged() ), this, SLOT( onSelectionDone() ) );
+}
+
+/*!
+ * \brief Gets dialog
+ * \return Pointer to the dialog of this operation or NULL if it does not exist
+*
+* This method should be redefined in derived classes if they use dialogs. If this
+* function returns pointer to dialog then dialog will be correctly
+* -# deactivated in suspendOperation method
+* -# activated in resumeOperation method
+* -# hidden in abortOperation and commitOperation methods
+*/
+LightApp_Dialog* LightApp_Operation::dlg() const
+{
+ return 0;
+}
+
+/*!
+ * \brief Activates selection
+*
+* Virtual method should be redefined in derived classes if they use own selection modes
+* (different from default)
+*/
+void LightApp_Operation::activateSelection()
+{
+}
+
+/*!
+ * \brief Virtual method called when selection is changed
+*
+* Virtual method should be redefined in derived classes if they works with selection
+* to provide reaction on the change of selection
+*/
+void LightApp_Operation::selectionDone()
+{
+}
+
+/*!
+ * \brief Gets active operation
+*
+* This method provided for convinience calls SUIT_Study::activeOperation() one
+*/
+SUIT_Operation* LightApp_Operation::activeOperation() const
+{
+ return study() != 0 ? study()->activeOperation() : 0;
+}
+
+/*!
+ * \brief Gets selection manager
+*
+* This method provided for convinience calls LightApp_Application::selectionMgr() one
+*/
+LightApp_SelectionMgr* LightApp_Operation::selectionMgr() const
+{
+ SUIT_Application* app = application();
+ if ( app != 0 && app->inherits( "LightApp_Application" ) )
+ return ( (LightApp_Application*)app )->selectionMgr();
+ else
+ return 0;
+}
+
+/*!
+ * \brief Call selectionDone() method
+*
+* Call selectionDone() method if operator is an active one (see selectionDone() for more
+* description )
+*/
+void LightApp_Operation::onSelectionDone()
+{
+ if ( isActive() )
+ selectionDone();
+}
+
+/*!
+ * \brief Update object browser or/and viewer etc.
+ * \param flags - update flags
+*
+* This method provided for convinience calls LightApp_Module::update() one (see
+* LightApp_Module::update() for more description)
+*/
+void LightApp_Operation::update( const int flags )
+{
+ if ( myModule != 0 )
+ myModule->update( flags );
+}
+
+/*!
+ * \brief Activate/Deactivate dialog of operation
+ * \param active - State of the dialog to be set
+*
+* Activate/Deactivate dialog of operation. This method called from startOperation(),
+* suspendOperation() ones and so on
+*/
+void LightApp_Operation::setDialogActive( const bool active )
+{
+ if( dlg() )
+ {
+ if( active )
+ {
+ activateSelection();
+ dlg()->setActiveWindow();
+ }
+ }
+}
+
+/*!
+ * \brief Gets autoresume property
+ * \return Autoresume property.
+*
+* Autoresume property is used during automatic resuming operation. If operation is
+* suspended and cursor is moved above dialog of the operation then operation is resumed
+* automatically (if possible). It can be resumed only program call otherwise (see
+* LightApp_SwitchOp for more description). This property is TRUE by default and may be
+* changed with setAutoResumed() method call.
+*/
+bool LightApp_Operation::isAutoResumed() const
+{
+ return myIsAutoResumed;
+}
+
+/*!
+ * \brief Sets autoresume property
+ * \param on - Value to be set
+ * \return Autoresume property.
+*
+* Sets autoresume property (see isAutoResumed() for more description)
+*/
+void LightApp_Operation::setAutoResumed( const bool on )
+{
+ myIsAutoResumed = on;
+}
--- /dev/null
+// LIGHT LightApp
+//
+// Copyright (C) 2005 CEA/DEN, EDF R&D
+//
+//
+//
+// File : LightApp_Operation.h
+// Author : Sergey LITONIN
+// Module : LIGHT
+
+
+#ifndef LightApp_Operation_H
+#define LightApp_Operation_H
+
+#include "LightApp.h"
+#include <SUIT_Operation.h>
+
+class LightApp_Module;
+class LightApp_Application;
+class LightApp_Operation;
+class LightApp_SelectionMgr;
+class LightApp_Dialog;
+class SUIT_Desktop;
+
+/*
+ Class : LightApp_Operation
+ Description : Base class for all operations
+*/
+
+/*!
+ * \brief Base class for all operations
+ *
+ * Base class for all operations (see SUIT_Operation for more description)
+*/
+class LIGHTAPP_EXPORT LightApp_Operation : public SUIT_Operation
+{
+ Q_OBJECT
+
+public:
+ LightApp_Operation();
+ virtual ~LightApp_Operation();
+
+ virtual void setModule( LightApp_Module* );
+ LightApp_Module* module() const;
+
+ bool isAutoResumed() const;
+
+ virtual LightApp_Dialog* dlg() const;
+
+protected:
+
+ // Methods redefined from base class
+
+ virtual void startOperation();
+ virtual void suspendOperation();
+ virtual void resumeOperation();
+ virtual void abortOperation();
+ virtual void commitOperation();
+
+ // Additional virtual methods may be redefined by derived classes
+
+ virtual void setDialogActive( const bool );
+ virtual void activateSelection();
+ virtual void selectionDone();
+
+
+ // Axiluary methods
+
+ SUIT_Desktop* desktop() const;
+ SUIT_Operation* activeOperation() const;
+ LightApp_SelectionMgr* selectionMgr() const;
+ void update( const int );
+ void setAutoResumed( const bool );
+
+private slots:
+
+ virtual void onSelectionDone();
+
+private:
+
+ LightApp_Module* myModule;
+ bool myIsAutoResumed;
+};
+
+#endif
+
+
+
+
+
+
--- /dev/null
+// File: LightApp_Preferences.cxx
+// Author: Sergey TELKOV
+
+#include "LightApp_Preferences.h"
+
+#include <QtxListResourceEdit.h>
+
+#include <qlayout.h>
+
+/*!
+ Constructor.Initialize by resource manager and parent QWidget.
+*/
+LightApp_Preferences::LightApp_Preferences( QtxResourceMgr* resMgr, QWidget* parent )
+: QtxListResourceEdit( resMgr, parent )
+{
+}
+
+/*!
+ Destructor.
+*/
+LightApp_Preferences::~LightApp_Preferences()
+{
+}
+
+/*!
+ Adds preference.
+*/
+int LightApp_Preferences::addPreference( const QString& label, const int pId, const int type,
+ const QString& section, const QString& param )
+{
+ return addItem( label, pId, type, section, param );
+}
+
+/*!
+ Adds preference.
+*/
+int LightApp_Preferences::addPreference( const QString& mod, const QString& label, const int pId,
+ const int type, const QString& section, const QString& param )
+{
+ int id = addItem( label, pId, type, section, param );
+ if ( id != -1 && !mod.isEmpty() )
+ myPrefMod.insert( id, mod );
+ return id;
+}
+
+/*
+ Checks: is preferences has module with name \a mod.
+*/
+bool LightApp_Preferences::hasModule( const QString& mod ) const
+{
+ bool res = false;
+ for ( PrefModuleMap::ConstIterator it = myPrefMod.begin(); it != myPrefMod.end() && !res; ++it )
+ res = it.data() == mod;
+ return res;
+}
+
+/*!Do nothing.*/
+void LightApp_Preferences::onHelp()
+{
+}
+
+/*!Store preferences on apply.*/
+void LightApp_Preferences::onApply()
+{
+ store();
+}
+
+/*!Emit preference changed.*/
+void LightApp_Preferences::changedResources( const QMap<Item*, QString>& map )
+{
+ for ( QMap<Item*, QString>::ConstIterator it = map.begin(); it != map.end(); ++it )
+ {
+ QString sec, param;
+ it.key()->resource( sec, param );
+ QString mod = module( it.key()->id() );
+ emit preferenceChanged( mod, sec, param );
+ }
+}
+
+/*!Gets module name by \a id, if exist.*/
+QString LightApp_Preferences::module( const int id ) const
+{
+ QString mod;
+ if ( myPrefMod.contains( id ) )
+ mod = myPrefMod[id];
+ return mod;
+}
--- /dev/null
+// File: LightApp_Preferences.h
+// Author: Sergey TELKOV
+
+#ifndef LIGHTAPP_PREFERENCES_H
+#define LIGHTAPP_PREFERENCES_H
+
+#include <LightApp.h>
+
+#include <QtxDialog.h>
+#include <QtxListResourceEdit.h>
+
+#include <qmap.h>
+
+class QtxResourceMgr;
+
+class LIGHTAPP_EXPORT LightApp_Preferences : public QtxListResourceEdit
+{
+ Q_OBJECT
+
+public:
+ LightApp_Preferences( QtxResourceMgr*, QWidget* = 0 );
+ virtual ~LightApp_Preferences();
+
+ int addPreference( const QString& label, const int pId = -1, const int = -1,
+ const QString& section = QString::null, const QString& param = QString::null );
+ int addPreference( const QString& modName, const QString& label, const int pId = -1, const int = -1,
+ const QString& section = QString::null, const QString& param = QString::null );
+
+ bool hasModule( const QString& ) const;
+
+signals:
+ void preferenceChanged( QString&, QString&, QString& );
+
+private slots:
+ void onHelp();
+ void onApply();
+ virtual void changedResources( const QMap<Item*, QString>& );
+
+private:
+ QString module( const int ) const;
+
+private:
+ typedef QMap<int, QString> PrefModuleMap;
+
+private:
+ PrefModuleMap myPrefMod;
+};
+
+#endif
--- /dev/null
+// File: LightApp_PreferencesDlg.cxx
+// Author: Sergey TELKOV
+
+#include "LightApp_PreferencesDlg.h"
+
+#include "LightApp_Preferences.h"
+
+#include <qvbox.h>
+#include <qlayout.h>
+
+/*!
+ Constructor.
+*/
+LightApp_PreferencesDlg::LightApp_PreferencesDlg( LightApp_Preferences* prefs, QWidget* parent )
+: QtxDialog( parent, 0, true, false, OK | Close | Apply ),
+myPrefs( prefs )
+{
+ setCaption( tr( "CAPTION" ) );
+
+ QVBoxLayout* main = new QVBoxLayout( mainFrame(), 5 );
+
+ QVBox* base = new QVBox( mainFrame() );
+ main->addWidget( base );
+
+ myPrefs->reparent( base, QPoint( 0, 0 ), true );
+
+ setFocusProxy( myPrefs );
+
+ setButtonPosition( Right, Close );
+
+ setDialogFlags( AlignOnce );
+
+ connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
+ connect( this, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
+}
+
+/*!
+ Destructor.
+*/
+LightApp_PreferencesDlg::~LightApp_PreferencesDlg()
+{
+ if ( !myPrefs )
+ return;
+
+ myPrefs->reparent( 0, QPoint( 0, 0 ), false );
+ myPrefs = 0;
+}
+
+/*!Show dialog.*/
+void LightApp_PreferencesDlg::show()
+{
+ myPrefs->retrieve();
+ myPrefs->toBackup();
+
+ QtxDialog::show();
+}
+
+/*!Store preferences on accept.*/
+void LightApp_PreferencesDlg::accept()
+{
+ QtxDialog::accept();
+
+ myPrefs->store();
+}
+
+/*!Reject. Restore preferences from backup.*/
+void LightApp_PreferencesDlg::reject()
+{
+ QtxDialog::reject();
+
+ myPrefs->fromBackup();
+}
+
+/*!Do nothing.*/
+void LightApp_PreferencesDlg::onHelp()
+{
+}
+
+/*!Store preferences on apply.*/
+void LightApp_PreferencesDlg::onApply()
+{
+ myPrefs->store();
+ myPrefs->toBackup();
+}
--- /dev/null
+// File: LightApp_PreferencesDlg.h
+// Author: Sergey TELKOV
+
+#ifndef LIGHTAPP_PREFERENCESDLG_H
+#define LIGHTAPP_PREFERENCESDLG_H
+
+#include <LightApp.h>
+
+#include <QtxDialog.h>
+
+class LightApp_Preferences;
+
+class LIGHTAPP_EXPORT LightApp_PreferencesDlg : public QtxDialog
+{
+ Q_OBJECT
+
+public:
+ LightApp_PreferencesDlg( LightApp_Preferences*, QWidget* = 0 );
+ virtual ~LightApp_PreferencesDlg();
+
+ virtual void show();
+ virtual void accept();
+ virtual void reject();
+
+private slots:
+ void onHelp();
+ void onApply();
+
+private:
+ LightApp_Preferences* myPrefs;
+};
+
+#endif
--- /dev/null
+#ifndef LIGHTAPP_ROOTOBJECT_H
+#define LIGHTAPP_ROOTOBJECT_H
+
+#include "LightApp.h"
+#include "SUIT_DataObject.h"
+
+class LightApp_Study;
+
+/*!
+ LightApp_RootObject - class to be instanciated by only one object -
+ root object of LightApp data object tree. This object is not shown
+ in object browser (invisible), so it has no re-definition of name(), icon(),
+ etc. methods. The goal of this class is to provide a unified access
+ to LightApp_Study object from LightApp_DataObject instances.
+*/
+class LIGHTAPP_EXPORT LightApp_RootObject : public SUIT_DataObject
+{
+public:
+ LightApp_RootObject( LightApp_Study* study )
+ : myStudy( study )
+ {}
+
+ virtual ~LightApp_RootObject() {}
+
+ void setStudy( LightApp_Study* study ) { myStudy = study; }
+ LightApp_Study* study() const { return myStudy; }
+
+private:
+ LightApp_Study* myStudy;
+
+};
+
+#endif
--- /dev/null
+
+#include "LightApp_Selection.h"
+#include "LightApp_SelectionMgr.h"
+#include "LightApp_DataOwner.h"
+#include "LightApp_Study.h"
+#include "LightApp_Application.h"
+#include "LightApp_Displayer.h"
+
+#include "SUIT_Session.h"
+#include "SUIT_ViewWindow.h"
+
+/*!
+ Constructor
+*/
+LightApp_Selection::LightApp_Selection()
+: myStudy( 0 )
+{
+}
+
+/*!
+ Destructor.
+*/
+LightApp_Selection::~LightApp_Selection()
+{
+}
+
+/*!
+ Initializetion.
+*/
+void LightApp_Selection::init( const QString& client, LightApp_SelectionMgr* mgr)
+{
+ myPopupClient = client;
+
+ if( mgr )
+ {
+ if ( mgr->application() )
+ myStudy = dynamic_cast<LightApp_Study*>( mgr->application()->activeStudy() );
+ if ( !myStudy )
+ return;
+
+ SUIT_DataOwnerPtrList sel;
+ mgr->selected( sel, client );
+ SUIT_DataOwnerPtrList::const_iterator anIt = sel.begin(), aLast = sel.end();
+
+ QString entry, curEntry;
+ for( ; anIt!=aLast; anIt++ )
+ {
+ SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() );
+ LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>( owner );
+ if( sowner ) {
+ curEntry = sowner->entry();
+ entry = myStudy->referencedToEntry( curEntry );
+ myEntries.append( entry );
+ if ( curEntry == entry )
+ myIsReferences.append( true );
+ else
+ myIsReferences.append( false );
+ processOwner( sowner );
+ }
+ }
+ }
+}
+
+/*!
+ Gets count of entries.
+*/
+int LightApp_Selection::count() const
+{
+ return myEntries.count();
+}
+
+/*!
+ Gets QtxValue();
+*/
+QtxValue LightApp_Selection::param( const int ind, const QString& p ) const
+{
+ if( !( ind>=0 && ind<count() ) )
+ return QtxValue();
+
+ if( p=="isVisible" )
+ {
+ LightApp_Displayer d;
+ bool vis = d.IsDisplayed( myEntries[ ind ] );
+ return QtxValue( vis, 0 );
+ }
+ else if( p=="component" ) {
+ return myStudy->componentDataType( myEntries[ ind ] );
+ }
+ else if( p=="isReference" )
+ return QtxValue( isReference( ind ), false );
+
+ return QtxValue();
+}
+
+/*!
+ Gets global parameters. client, isActiveView, activeView etc.
+*/
+QtxValue LightApp_Selection::globalParam( const QString& p ) const
+{
+ if ( p == "client" ) return QtxValue( myPopupClient );
+ else if ( p == "activeModule" )
+ {
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>( myStudy->application() );
+ QString mod_name = app ? QString( app->activeModule()->name() ) : QString::null;
+ //cout << "activeModule : " << mod_name.latin1() << endl;
+ if( !mod_name.isEmpty() )
+ return mod_name;
+ else
+ return QtxValue();
+ }
+ else if ( p == "isActiveView" ) return QtxValue( (bool)activeVW() );
+ else if ( p == "activeView" ) return QtxValue( activeViewType() );
+#ifndef WNT
+ else return QtxPopupMgr::Selection::globalParam( p );
+#else
+ else return Selection::globalParam( p );
+#endif
+}
+
+/*!
+ Do nothing.
+*/
+void LightApp_Selection::processOwner( const LightApp_DataOwner* )
+{
+}
+
+/*!
+ Gets entry with index \a index.
+*/
+QString LightApp_Selection::entry( const int index ) const
+{
+ if ( index >= 0 && index < count() )
+ return myEntries[ index ];
+ return QString();
+}
+
+/*!
+ Returns true if i-th selected object was reference to object with entry( i )
+*/
+bool LightApp_Selection::isReference( const int index ) const
+{
+ if( index >= 0 && index < count() )
+ return myIsReferences[ index ];
+ else
+ return false;
+}
+
+/*!
+ Gets type of active view manager.
+*/
+QString LightApp_Selection::activeViewType() const
+{
+ SUIT_ViewWindow* win = activeVW();
+ if ( win ) {
+ SUIT_ViewManager* vm = win->getViewManager();
+ if ( vm )
+ return vm->getType();
+ }
+ return QString::null;
+}
+
+/*!
+ Gets active view window.
+*/
+SUIT_ViewWindow* LightApp_Selection::activeVW() const
+{
+ SUIT_Session* session = SUIT_Session::session();
+ if ( session ) {
+ SUIT_Application* app = session->activeApplication();
+ if ( app ) {
+ SUIT_Desktop* desk = app->desktop();
+ if ( desk )
+ return desk->activeWindow();
+ }
+ }
+ return 0;
+}
--- /dev/null
+// LightApp_Selection
+//
+// 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 : LightApp_Selection.h
+// Author : Alexander SOLOVYOV
+// Module : GUI
+// $Header$
+
+#ifndef LIGHTAPP_SELECTION_HeaderFile
+#define LIGHTAPP_SELECTION_HeaderFile
+
+#include "LightApp.h"
+#include <QtxPopupMgr.h>
+
+class LightApp_SelectionMgr;
+class LightApp_DataOwner;
+class LightApp_Study;
+class SUIT_ViewWindow;
+
+
+class LIGHTAPP_EXPORT LightApp_Selection : public QtxPopupMgr::Selection
+{
+public:
+ LightApp_Selection();
+ virtual ~LightApp_Selection();
+
+ virtual void init( const QString&, LightApp_SelectionMgr* );
+ virtual void processOwner( const LightApp_DataOwner* );
+
+ virtual int count() const;
+ virtual QtxValue param( const int, const QString& ) const;
+ virtual QtxValue globalParam( const QString& ) const;
+ void setModuleName( const QString );
+
+protected:
+ QString entry( const int ) const;
+ bool isReference( const int ) const;
+ /*!Gets study.*/
+ LightApp_Study* study() const { return myStudy; }
+ QString activeViewType() const;
+ SUIT_ViewWindow* activeVW() const;
+
+protected:
+ QString myPopupClient;
+ QStringList myEntries; // entries of selected objects
+ QValueList<bool> myIsReferences; // whether i-th selected object was a reference
+ LightApp_Study* myStudy;
+};
+
+#endif
--- /dev/null
+#include "LightApp_SelectionMgr.h"
+
+#include "LightApp_Study.h"
+#include "LightApp_DataOwner.h"
+#include "LightApp_DataSubOwner.h"
+#include "LightApp_Application.h"
+
+#include <SUIT_Session.h>
+
+#include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
+
+// Open CASCADE Include
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfInteger.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+
+/*!
+ Constructor.
+*/
+LightApp_SelectionMgr::LightApp_SelectionMgr( LightApp_Application* app, const bool fb )
+: SUIT_SelectionMgr( fb ),
+myApp( app )
+{
+}
+
+/*!
+ Destructor.
+*/
+LightApp_SelectionMgr::~LightApp_SelectionMgr()
+{
+}
+
+/*!
+ Gets application.
+*/
+LightApp_Application* LightApp_SelectionMgr::application() const
+{
+ return myApp;
+}
+
+/*!
+ Get all selected objects from selection manager
+*/
+void LightApp_SelectionMgr::selectedObjects( SALOME_ListIO& theList, const QString& theType,
+ const bool convertReferences ) const
+{
+ theList.Clear();
+
+ SUIT_DataOwnerPtrList aList;
+ selected( aList, theType );
+
+ QMap<QString,int> entryMap;
+
+ QString entry;
+ for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
+ {
+ const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
+ if( !owner )
+ continue;
+
+ LightApp_Study* study = dynamic_cast<LightApp_Study*>( application()->activeStudy() );
+ if ( !study )
+ return;
+
+ entry = owner->entry();
+ if ( convertReferences ) {
+ QString refEntry = study->referencedToEntry( entry );
+ if( !entryMap.contains( entry ) ) {
+ if ( refEntry != entry ) {
+ QString component = study->componentDataType( refEntry );
+ theList.Append( new SALOME_InteractiveObject( refEntry, component, ""/*refobj->Name().c_str()*/ ) );
+ }
+ else
+ theList.Append( owner->IO() );
+ }
+ }
+ else {
+ if( !entryMap.contains( entry ) )
+ theList.Append( owner->IO() );
+ }
+
+ entryMap.insert(owner->entry(), 1);
+ }
+}
+
+/*!
+ Append selected objects.
+*/
+void LightApp_SelectionMgr::setSelectedObjects( const SALOME_ListIO& lst, const bool append )
+{
+ SUIT_DataOwnerPtrList owners;
+ for ( SALOME_ListIteratorOfListIO it( lst ); it.More(); it.Next() )
+ {
+ if ( it.Value()->hasEntry() )
+ owners.append( new LightApp_DataOwner( it.Value() ) );
+ }
+
+ setSelected( owners, append );
+}
+
+/*!
+ Emit current selection changed.
+*/
+void LightApp_SelectionMgr::selectionChanged( SUIT_Selector* theSel )
+{
+ SUIT_SelectionMgr::selectionChanged( theSel );
+
+ emit currentSelectionChanged();
+}
+
+/*!
+ get map of indexes for the given SALOME_InteractiveObject
+*/
+void LightApp_SelectionMgr::GetIndexes( const Handle(SALOME_InteractiveObject)& IObject,
+ TColStd_IndexedMapOfInteger& theIndex)
+{
+ theIndex.Clear();
+
+ SUIT_DataOwnerPtrList aList;
+ selected( aList );
+
+ for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
+ {
+ const LightApp_DataSubOwner* subOwner = dynamic_cast<const LightApp_DataSubOwner*>( (*itr).operator->() );
+ if ( subOwner )
+ if ( subOwner->entry() == QString(IObject->getEntry()) )
+ theIndex.Add( subOwner->index() );
+ }
+
+}
+
+/*!
+ get map of indexes for the given entry of SALOME_InteractiveObject
+*/
+void LightApp_SelectionMgr::GetIndexes( const QString& theEntry, TColStd_IndexedMapOfInteger& theIndex )
+{
+ theIndex.Clear();
+
+ SUIT_DataOwnerPtrList aList;
+ selected( aList );
+
+ for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
+ {
+ const LightApp_DataSubOwner* subOwner = dynamic_cast<const LightApp_DataSubOwner*>( (*itr).operator->() );
+ if ( subOwner )
+ if ( subOwner->entry() == theEntry )
+ theIndex.Add( subOwner->index() );
+ }
+
+}
+
+/*!
+ Add or remove interactive objects from selection manager.
+*/
+bool LightApp_SelectionMgr::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject,
+ const TColStd_MapOfInteger& theIndexes,
+ bool modeShift)
+{
+ SUIT_DataOwnerPtrList remainsOwners;
+
+ SUIT_DataOwnerPtrList aList;
+ selected( aList );
+
+ if ( !modeShift ) {
+ for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
+ {
+ const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*itr).operator->() );
+ if ( owner )
+ {
+ if ( owner->entry() != QString(IObject->getEntry()) )
+ {
+ const LightApp_DataSubOwner* subOwner = dynamic_cast<const LightApp_DataSubOwner*>( owner );
+ if ( subOwner )
+ remainsOwners.append( new LightApp_DataSubOwner( subOwner->entry(), subOwner->index() ) );
+ else
+ remainsOwners.append( new LightApp_DataOwner( owner->entry() ) );
+ }
+ }
+ }
+ }
+ else
+ remainsOwners = aList;
+
+ TColStd_MapIteratorOfMapOfInteger It;
+ It.Initialize(theIndexes);
+ for(;It.More();It.Next())
+ remainsOwners.append( new LightApp_DataSubOwner( QString(IObject->getEntry()), It.Key() ) );
+
+ bool append = false;
+ setSelected( remainsOwners, append );
+
+ emit currentSelectionChanged();
+
+ TColStd_IndexedMapOfInteger anIndexes;
+ GetIndexes( IObject, anIndexes );
+ return !anIndexes.IsEmpty();
+
+}
+
+/*!
+ select 'subobjects' with given indexes
+*/
+void LightApp_SelectionMgr::selectObjects( const Handle(SALOME_InteractiveObject)& IObject,
+ TColStd_IndexedMapOfInteger theIndex, bool append )
+{
+ SUIT_DataOwnerPtrList aList;
+
+ if ( theIndex.IsEmpty() )
+ aList.append( new LightApp_DataOwner( QString(IObject->getEntry()) ) );
+ else
+ {
+ int i;
+ for ( i = 1; i <= theIndex.Extent(); i++ )
+ aList.append( new LightApp_DataSubOwner( QString(IObject->getEntry()), theIndex( i ) ) );
+ }
+
+ setSelected( aList, append );
+
+}
+
+/*!
+ select 'subobjects' with given indexes
+*/
+void LightApp_SelectionMgr::selectObjects( MapIOOfMapOfInteger theMapIO, bool append )
+{
+ SUIT_DataOwnerPtrList aList;
+
+ MapIOOfMapOfInteger::Iterator it;
+ for ( it = theMapIO.begin(); it != theMapIO.end(); ++it )
+ {
+ if ( it.data().IsEmpty() )
+ aList.append( new LightApp_DataOwner( QString(it.key()->getEntry()) ) );
+ else
+ {
+ int i;
+ for ( i = 1; i <= it.data().Extent(); i++ )
+ aList.append( new LightApp_DataSubOwner( QString(it.key()->getEntry()), it.data()( i ) ) );
+ }
+ }
+
+ setSelected( aList, append );
+
+}
+
+/*!
+ get map of selected subowners : object's entry <-> map of indexes
+*/
+void LightApp_SelectionMgr::selectedSubOwners( MapEntryOfMapOfInteger& theMap )
+{
+ theMap.clear();
+
+ TColStd_IndexedMapOfInteger anIndexes;
+
+ SUIT_DataOwnerPtrList aList;
+ selected( aList );
+
+ for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
+ {
+ const LightApp_DataSubOwner* subOwner = dynamic_cast<const LightApp_DataSubOwner*>( (*itr).operator->() );
+ if ( subOwner )
+ {
+ if ( !theMap.contains( subOwner->entry() ) )
+ {
+ anIndexes.Clear();
+ GetIndexes( subOwner->entry(), anIndexes );
+ theMap.insert( subOwner->entry(), anIndexes );
+ }
+ }
+ }
+}
--- /dev/null
+#ifndef LIGHTAPP_SELECTIONMGR_H
+#define LIGHTAPP_SELECTIONMGR_H
+
+#include "LightApp.h"
+
+#include <SUIT_SelectionMgr.h>
+#include <SALOME_InteractiveObject.hxx>
+
+#include <qmap.h>
+
+class SALOME_ListIO;
+class LightApp_Application;
+class TColStd_IndexedMapOfInteger;
+class TColStd_MapOfInteger;
+
+class LIGHTAPP_EXPORT LightApp_SelectionMgr : public SUIT_SelectionMgr
+{
+ Q_OBJECT
+
+public:
+ LightApp_SelectionMgr( LightApp_Application*, const bool = true );
+ virtual ~LightApp_SelectionMgr();
+
+ typedef QMap< Handle(SALOME_InteractiveObject), TColStd_IndexedMapOfInteger > MapIOOfMapOfInteger;
+ typedef QMap< QString, TColStd_IndexedMapOfInteger > MapEntryOfMapOfInteger;
+
+ LightApp_Application* application() const;
+
+ void selectedObjects( SALOME_ListIO&, const QString& = QString::null, const bool = true ) const;
+ void setSelectedObjects( const SALOME_ListIO&, const bool = false );
+
+ void GetIndexes( const Handle(SALOME_InteractiveObject)& IObject,
+ TColStd_IndexedMapOfInteger& theIndex );
+ void GetIndexes( const QString& theEntry,
+ TColStd_IndexedMapOfInteger& theIndex );
+
+ bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject,
+ const TColStd_MapOfInteger& theIndices,
+ bool modeShift );
+
+ void selectObjects( const Handle(SALOME_InteractiveObject)& IObject,
+ TColStd_IndexedMapOfInteger theIndex, bool append );
+ void selectObjects( MapIOOfMapOfInteger theMapIO, bool append );
+
+ void selectedSubOwners( MapEntryOfMapOfInteger& theMap );
+
+signals:
+ void currentSelectionChanged();
+
+private:
+ virtual void selectionChanged( SUIT_Selector* );
+
+private:
+ LightApp_Application* myApp;
+};
+
+#endif
--- /dev/null
+
+#include "LightApp_ShowHideOp.h"
+#include "LightApp_Application.h"
+#include "LightApp_DataOwner.h"
+#include "LightApp_Module.h"
+#include "LightApp_Displayer.h"
+#include "CAM_Study.h"
+
+#include "LightApp_SelectionMgr.h"
+#include "LightApp_Selection.h"
+
+#include <SALOME_ListIO.hxx>
+#include <SALOME_ListIteratorOfListIO.hxx>
+
+LightApp_ShowHideOp::LightApp_ShowHideOp( ActionType type )
+: LightApp_Operation(),
+ myActionType( type )
+{
+}
+
+LightApp_ShowHideOp::~LightApp_ShowHideOp()
+{
+}
+
+void LightApp_ShowHideOp::startOperation()
+{
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>( application() );
+ if( !app )
+ {
+ abort();
+ return;
+ }
+
+ LightApp_SelectionMgr* mgr = app->selectionMgr();
+ LightApp_Selection sel; sel.init( "", mgr );
+ if( sel.count()==0 )
+ {
+ abort();
+ return;
+ }
+ QString aStr = sel.param( 0, "component" ).toString();
+ QString mod_name = app->moduleTitle( aStr );//sel.param( 0, "component" ).toString() );
+ LightApp_Module* m = dynamic_cast<LightApp_Module*>( app ? app->module( mod_name ) : 0 );
+ if( !m )
+ {
+ m = dynamic_cast<LightApp_Module*>( app->loadModule( mod_name ) );
+ app->addModule( m );
+ m->connectToStudy( dynamic_cast<CAM_Study*>( app->activeStudy() ) );
+ m->setMenuShown( false );
+ m->setToolShown( false );
+ }
+
+ LightApp_Displayer* d = m ? m->displayer(): 0;
+ if( !d )
+ {
+ abort();
+ return;
+ }
+
+ if( myActionType==DISPLAY_ONLY )
+ d->EraseAll( false, false, 0 );
+
+ SALOME_ListIO selObjs;
+ mgr->selectedObjects( selObjs );
+ SALOME_ListIteratorOfListIO anIt( selObjs );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ if( anIt.Value().IsNull() )
+
+ continue;
+
+ if( myActionType==DISPLAY || myActionType==DISPLAY_ONLY )
+ d->Display( anIt.Value()->getEntry(), false, 0 );
+ else if( myActionType==ERASE )
+ d->Erase( anIt.Value()->getEntry(), false, false, 0 );
+ }
+ d->UpdateViewer();
+ commit();
+}
+
--- /dev/null
+
+#ifndef LIGHTAPP_SHOW_HIDE_OPERATION_HEADER
+#define LIGHTAPP_SHOW_HIDE_OPERATION_HEADER
+
+#include "LightApp_Operation.h"
+
+class LightApp_ShowHideOp : public LightApp_Operation
+{
+ Q_OBJECT
+
+public:
+ typedef enum { DISPLAY, ERASE, DISPLAY_ONLY } ActionType;
+
+public:
+ LightApp_ShowHideOp( ActionType );
+ ~LightApp_ShowHideOp();
+
+protected:
+ virtual void startOperation();
+
+private:
+ ActionType myActionType;
+};
+
+#endif
+
--- /dev/null
+#include "LightApp_Study.h"
+
+#include "CAM_DataModel.h"
+#include "LightApp_Application.h"
+#include "LightApp_DataModel.h"
+#include "LightApp_DataObject.h"
+#include "LightApp_RootObject.h"
+#include "LightApp_Driver.h"
+
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_DataObjectIterator.h"
+
+#include <OB_Browser.h>
+
+#include <TCollection_AsciiString.hxx>
+
+#include <OSD_Path.hxx>
+#include <OSD_File.hxx>
+#include <OSD_Directory.hxx>
+#include <OSD_Process.hxx>
+#include <OSD_Directory.hxx>
+#include <OSD_Protection.hxx>
+#include <OSD_SingleProtection.hxx>
+#include <OSD_FileIterator.hxx>
+
+#include <qstring.h>
+
+/*!
+ Constructor.
+*/
+LightApp_Study::LightApp_Study( SUIT_Application* app )
+: CAM_Study( app )
+{
+ myDriver = new LightApp_Driver();
+}
+
+/*!
+ Destructor.
+*/
+LightApp_Study::~LightApp_Study()
+{
+}
+
+/*!
+ Create document.
+*/
+void LightApp_Study::createDocument()
+{
+ // create myRoot
+ setRoot( new LightApp_RootObject( this ) );
+
+ CAM_Study::createDocument();
+
+ emit created( this );
+}
+
+//=======================================================================
+// name : openDocument
+/*! Purpose : Open document*/
+//=======================================================================
+bool LightApp_Study::openDocument( const QString& theFileName )
+{
+ myDriver->ClearDriverContents();
+ // create files for models from theFileName
+ if( !openStudyData(theFileName))
+ return false;
+
+ setRoot( new LightApp_RootObject( this ) ); // create myRoot
+
+ // update loaded data models: call open() and update() on them.
+ ModelList dm_s;
+ dataModels( dm_s );
+ for ( ModelListIterator it( dm_s ); it.current(); ++it )
+ openDataModel( studyName(), it.current() );
+ // this will build a SUIT_DataObject-s tree under myRoot member field
+ // passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step
+ // but tree that corresponds to not-loaded data models will be updated any way.
+ ((LightApp_Application*)application())->updateObjectBrowser( false );
+
+ bool res = CAM_Study::openDocument( theFileName );
+
+ emit opened( this );
+ return res;
+}
+
+//=======================================================================
+// name : loadDocument
+/*! Purpose : Load document */
+//=======================================================================
+bool LightApp_Study::loadDocument( const QString& theStudyName )
+{
+ myDriver->ClearDriverContents();
+ if( !openStudyData(theStudyName))
+ return false;
+
+ setRoot( new LightApp_RootObject( this ) ); // create myRoot
+
+ //SRN: BugID IPAL9021, put there the same code as in a method openDocument
+
+ // update loaded data models: call open() and update() on them.
+ ModelList dm_s;
+ dataModels( dm_s );
+
+ for ( ModelListIterator it( dm_s ); it.current(); ++it )
+ openDataModel( studyName(), it.current() );
+
+ // this will build a SUIT_DataObject-s tree under myRoot member field
+ // passing "false" in order NOT to rebuild existing data models' trees - it was done in previous step
+ // but tree that corresponds to not-loaded data models will be updated any way.
+ ((LightApp_Application*)application())->updateObjectBrowser( false );
+
+ bool res = CAM_Study::openDocument( theStudyName );
+ emit opened( this );
+ //SRN: BugID IPAL9021: End
+ return res;
+}
+
+//=======================================================================
+// name : saveDocumentAs
+/*! Purpose : Save document */
+//=======================================================================
+bool LightApp_Study::saveDocumentAs( const QString& theFileName )
+{
+ ModelList list; dataModels( list );
+
+ LightApp_DataModel* aModel = (LightApp_DataModel*)list.first();
+
+ myDriver->ClearDriverContents();
+ QStringList listOfFiles;
+ for ( ; aModel; aModel = (LightApp_DataModel*)list.next() ) {
+ listOfFiles.clear();
+ aModel->saveAs( theFileName, this, listOfFiles );
+ if ( !listOfFiles.isEmpty() )
+ saveModuleData(aModel->module()->name(), listOfFiles);
+ }
+
+ bool res = saveStudyData(theFileName);
+ res = res && CAM_Study::saveDocumentAs( theFileName );
+ //SRN: BugID IPAL9377, removed usage of uninitialized variable <res>
+ if ( res )
+ emit saved( this );
+
+ return res;
+}
+
+//=======================================================================
+// name : saveDocument
+/*! Purpose : Save document */
+//=======================================================================
+bool LightApp_Study::saveDocument()
+{
+ ModelList list; dataModels( list );
+
+ LightApp_DataModel* aModel = (LightApp_DataModel*)list.first();
+
+ myDriver->ClearDriverContents();
+ QStringList listOfFiles;
+ for ( ; aModel; aModel = (LightApp_DataModel*)list.next() ) {
+ listOfFiles.clear();
+ aModel->save( listOfFiles );
+ saveModuleData(aModel->module()->name(), listOfFiles);
+ }
+
+ bool res = saveStudyData(studyName());
+ res = res && CAM_Study::saveDocument();
+ if (res)
+ emit saved( this );
+
+ return res;
+}
+
+//================================================================
+// Function : closeDocument
+/*! Purpose : Close document */
+//================================================================
+void LightApp_Study::closeDocument(bool permanently)
+{
+ // Inform everybody that this study is going to close when it's most safe to,
+ // i.e. in the very beginning
+ emit closed( this );
+
+ CAM_Study::closeDocument(permanently);
+}
+
+//================================================================
+// Function : referencedToEntry
+/*! Purpose : Return current entry*/
+//================================================================
+QString LightApp_Study::referencedToEntry( const QString& entry )
+{
+ return entry;
+}
+//================================================================
+// Function : componentDataType
+/*! Purpose : Return component data type from entry*/
+//================================================================
+QString LightApp_Study::componentDataType( const QString& entry )
+{
+ LightApp_DataObject* aCurObj;
+ for ( SUIT_DataObjectIterator it( root(), SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it ) {
+ aCurObj = dynamic_cast<LightApp_DataObject*>( it.current() );
+ if ( aCurObj && aCurObj->entry() == entry ) {
+ return aCurObj->componentDataType();
+ }
+ }
+ return "";
+}
+
+//================================================================
+// Function : isModified
+// Purpose :
+//================================================================
+bool LightApp_Study::isModified() const
+{
+ bool isAnyChanged = CAM_Study::isModified();
+ ModelList list; dataModels( list );
+
+ LightApp_DataModel* aModel = 0;
+ for ( QPtrListIterator<CAM_DataModel> it( list ); it.current() && !isAnyChanged; ++it ){
+ aModel = dynamic_cast<LightApp_DataModel*>( it.current() );
+ if ( aModel )
+ isAnyChanged = aModel->isModified();
+ }
+ return isAnyChanged;
+}
+
+//================================================================
+// Function : isSaved
+/*! Purpose : Check: data model is saved?*/
+//================================================================
+bool LightApp_Study::isSaved() const
+{
+ bool isAllSaved = CAM_Study::isSaved();
+ ModelList list; dataModels( list );
+
+ LightApp_DataModel* aModel = 0;
+ for ( QPtrListIterator<CAM_DataModel> it( list ); it.current() && isAllSaved; ++it ){
+ aModel = dynamic_cast<LightApp_DataModel*>( it.current() );
+ if ( aModel )
+ isAllSaved = aModel->isSaved();
+ }
+ return isAllSaved;
+}
+
+//=======================================================================
+// name : saveModuleData
+/*! Purpose : Create SComponent for module, necessary for SalomeApp study */
+//=======================================================================
+void LightApp_Study::addComponent(const CAM_DataModel* dm)
+{
+}
+
+//=======================================================================
+// name : saveModuleData
+/*! Purpose : save list file for module 'theModuleName' */
+//=======================================================================
+void LightApp_Study::saveModuleData(QString theModuleName, QStringList theListOfFiles)
+{
+ int aNb = theListOfFiles.count();
+ if ( aNb == 0 )
+ return;
+
+ std::vector<std::string> aListOfFiles ( aNb );
+ int anIndex = 0;
+ for ( QStringList::Iterator it = theListOfFiles.begin(); it != theListOfFiles.end(); ++it ) {
+ if ( (*it).isEmpty() )
+ continue;
+ aListOfFiles[anIndex] = (*it).latin1();
+ anIndex++;
+ }
+ myDriver->SetListOfFiles(theModuleName, aListOfFiles);
+}
+
+//=======================================================================
+// name : openModuleData
+/*! Purpose : gets list of file for module 'theModuleNam' */
+//=======================================================================
+void LightApp_Study::openModuleData(QString theModuleName, QStringList& theListOfFiles)
+{
+ std::vector<std::string> aListOfFiles = myDriver->GetListOfFiles(theModuleName);
+ int i, aLength = aListOfFiles.size() - 1;
+ if (aLength < 0)
+ return;
+
+ //Get a temporary directory for saved a file
+ theListOfFiles.append(aListOfFiles[0].c_str());
+ for(i = 0; i < aLength; i++)
+ theListOfFiles.append(aListOfFiles[i+1].c_str());
+}
+
+//=======================================================================
+// name : saveStudyData
+/*! Purpose : save data from study */
+//=======================================================================
+bool LightApp_Study::saveStudyData( const QString& theFileName )
+{
+ ModelList list; dataModels( list );
+ SUIT_ResourceMgr* resMgr = application()->resourceMgr();
+ if( !resMgr )
+ return false;
+ bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
+
+ bool aRes = myDriver->SaveDatasInFile(theFileName.latin1(), isMultiFile);
+ // clear map
+ std::vector<std::string> aList(0);
+ for ( ModelListIterator it( list ); it.current(); ++it )
+ myDriver->SetListOfFiles(it.current()->module()->name(), aList);
+
+ return aRes;
+}
+
+//=======================================================================
+// name : openStudyData
+/*! Purpose : open data for study */
+//=======================================================================
+bool LightApp_Study::openStudyData( const QString& theFileName )
+{
+ SUIT_ResourceMgr* resMgr = application()->resourceMgr();
+ if( !resMgr )
+ return false;
+ bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
+
+ bool aRes = myDriver->ReadDatasFromFile(theFileName.latin1(), isMultiFile);
+ return aRes;
+}
+
+//================================================================
+// Function : openDataModel
+/*! Purpose : Open data model */
+//================================================================
+bool LightApp_Study::openDataModel( const QString& studyName, CAM_DataModel* dm )
+{
+ if (!dm)
+ return false;
+
+ QStringList listOfFiles;
+ openModuleData(dm->module()->name(), listOfFiles);
+ if (dm && dm->open(studyName, this, listOfFiles)) {
+ // Remove the files and temporary directory, created
+ // for this module by LightApp_Driver::OpenStudyData()
+ bool isMultiFile = false; // TODO: decide, how to access this parameter
+ RemoveTemporaryFiles( dm->module()->name(), isMultiFile );
+
+ // Something has been read -> create data model tree
+ LightApp_DataModel* aDM = dynamic_cast<LightApp_DataModel*>( dm );
+ if ( aDM )
+ aDM->update(NULL, this);
+ return true;
+ }
+ return false;
+}
+
+//================================================================
+// Function : GetTmpDir
+/*! Purpose : to be used by modules*/
+//================================================================
+std::string LightApp_Study::GetTmpDir (const char* theURL,
+ const bool isMultiFile)
+{
+ return myDriver->GetTmpDir(theURL, isMultiFile);
+}
+
+//================================================================
+// Function : GetListOfFiles
+/*! Purpose : to be used by modules*/
+//================================================================
+std::vector<std::string> LightApp_Study::GetListOfFiles(const char* theModuleName) const
+{
+ std::vector<std::string> aListOfFiles;
+ aListOfFiles = myDriver->GetListOfFiles(theModuleName);
+ return aListOfFiles;
+}
+
+//================================================================
+// Function : SetListOfFiles
+/*! Purpose : to be used by modules*/
+//================================================================
+void LightApp_Study::SetListOfFiles (const char* theModuleName, const std::vector<std::string> theListOfFiles)
+{
+ myDriver->SetListOfFiles(theModuleName, theListOfFiles);
+}
+
+//================================================================
+// Function : RemoveTemporaryFiles
+/*! Purpose : to be used by modules*/
+//================================================================
+void LightApp_Study::RemoveTemporaryFiles (const char* theModuleName, const bool isMultiFile) const
+{
+ if (isMultiFile)
+ return;
+ bool isDirDeleted = true;
+ myDriver->RemoveTemporaryFiles(theModuleName, isDirDeleted);
+}
--- /dev/null
+#ifndef LIGHTAPP_STUDY_H\r
+#define LIGHTAPP_STUDY_H\r
+\r
+#include <LightApp.h>\r
+#include <LightApp_Driver.h>\r
+\r
+#include <CAM_Study.h>\r
+#include <CAM_DataModel.h>\r
+#include <SUIT_Study.h>\r
+\r
+#include "string"\r
+#include "vector"\r
+\r
+class SUIT_Application;\r
+class CAM_DataModel;\r
+\r
+class LIGHTAPP_EXPORT LightApp_Study : public CAM_Study\r
+{\r
+ Q_OBJECT\r
+\r
+public:\r
+ LightApp_Study( SUIT_Application* );\r
+ virtual ~LightApp_Study();\r
+\r
+ virtual void createDocument();\r
+ virtual bool openDocument( const QString& );\r
+ virtual bool loadDocument( const QString& ); \r
+\r
+ virtual bool saveDocument();\r
+ virtual bool saveDocumentAs( const QString& );\r
+\r
+ virtual void closeDocument(bool permanently = true);\r
+\r
+ virtual bool isSaved() const;\r
+ virtual bool isModified() const;\r
+\r
+ virtual void addComponent ( const CAM_DataModel* dm);\r
+\r
+ virtual std::string GetTmpDir ( const char* theURL, const bool isMultiFile );\r
+\r
+ virtual QString componentDataType( const QString& );\r
+ virtual QString referencedToEntry( const QString& );\r
+\r
+protected:\r
+ virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles );\r
+ virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles );\r
+ virtual bool saveStudyData ( const QString& theFileName );\r
+ virtual bool openStudyData ( const QString& theFileName );\r
+\r
+ virtual std::vector<std::string> GetListOfFiles ( const char* theModuleName ) const;\r
+ virtual void SetListOfFiles ( const char* theModuleName,\r
+ const std::vector<std::string> theListOfFiles );\r
+\r
+ virtual void RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile ) const;\r
+\r
+protected:\r
+ virtual bool openDataModel ( const QString&, CAM_DataModel* );\r
+\r
+signals:\r
+ void saved ( SUIT_Study* );\r
+ void opened ( SUIT_Study* );\r
+ void closed ( SUIT_Study* );\r
+ void created( SUIT_Study* );\r
+\r
+\r
+private:\r
+ LightApp_Driver* myDriver;\r
+};\r
+\r
+#endif \r
--- /dev/null
+/**
+* LIGHT LightApp
+*
+* Copyright (C) 2005 CEA/DEN, EDF R&D
+*
+*
+*
+* File : LightApp_SwitchOp.h
+* Author : Sergey LITONIN
+* Module : LIGHT
+*/
+
+#include "LightApp_SwitchOp.h"
+#include "LightApp_Module.h"
+#include "LightApp_Operation.h"
+#include "LightApp_Dialog.h"
+#include <CAM_Application.h>
+#include <SUIT_Operation.h>
+#include <SUIT_Study.h>
+#include <qevent.h>
+#include <qwidget.h>
+#include <qptrlist.h>
+#include <qapplication.h>
+
+/*!
+ * \brief Constructor
+ * \param theParent - parent of object
+*
+* Creates instance of the object. Connects signals and slots. Install eveny filter
+* on application
+*/
+LightApp_SwitchOp::LightApp_SwitchOp( LightApp_Module* theModule )
+: QObject( 0 ),
+ myModule( theModule )
+{
+ qApp->installEventFilter( this );
+}
+
+/*!
+ * \brief Destructor
+*/
+LightApp_SwitchOp::~LightApp_SwitchOp()
+{
+
+}
+
+/*!
+ * \brief Get module
+*
+* Get module. Module is a parent of this class
+*/
+LightApp_Module* LightApp_SwitchOp::module() const
+{
+ return myModule;
+}
+
+/*!
+ * \brief Get study
+ * \return Active study of application (in current realisation)
+*
+* Get study
+*/
+SUIT_Study* LightApp_SwitchOp::study() const
+{
+ return module()->application()->activeStudy();
+}
+
+/*!
+ * \brief Get operation by widget
+ * \param theWg - key widget to find operation
+ * \return Pointer to the operations if it is found or zero
+*
+* Find operation containing dialog with given widget
+*/
+LightApp_Operation* LightApp_SwitchOp::operation( QWidget* theWg ) const
+{
+ // get dialog from widget
+ LightApp_Dialog* aDlg = 0;
+ QWidget* aParent = theWg;
+ while( aParent && !aParent->inherits( "LightApp_Dialog" ) )
+ aParent = aParent->parentWidget();
+
+ if ( aParent && aParent->inherits( "LightApp_Dialog" ) )
+ aDlg = (LightApp_Dialog*)aParent;
+
+ // try to find operation corresponding to the dialog
+ if ( aDlg != 0 && study() != 0 )
+ {
+ QPtrListIterator<SUIT_Operation> anIter( study()->operations() );
+ while( SUIT_Operation* anOp = anIter.current() )
+ {
+ if ( anOp->inherits( "LightApp_Operation" ) &&
+ ((LightApp_Operation*)anOp)->dlg() == aDlg )
+ return ((LightApp_Operation*)anOp);
+ ++anIter;
+ }
+ }
+
+ return 0;
+}
+
+/*!
+ * \brief Event filter
+ * \param theObj - object
+ * \param theEv - event
+*
+* Event filter. Catched signals off application. If event concerns to dialog then
+* corresponding operation is found and activated.
+*/
+bool LightApp_SwitchOp::eventFilter( QObject* theObj, QEvent* theEv )
+{
+ if ( theObj->inherits( "QWidget" ) && ( theEv->type() == QEvent::Enter ) )
+ {
+ QEvent::Type aType = theEv->type();
+ LightApp_Operation* anOp = operation( (QWidget*)theObj );
+ if ( anOp )
+ {
+ switch ( aType )
+ {
+ case QEvent::Enter:
+ {
+ if ( !anOp->isActive() && anOp->isAutoResumed() &&
+ study() && !study()->blockingOperation( anOp ) )
+ study()->resume( anOp );
+ }
+ break;
+
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonDblClick:
+ case QEvent::MouseMove:
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ {
+ if ( !anOp->isActive() )
+ return true;
+ }
+ break;
+
+ }
+ }
+ }
+
+ return QObject::eventFilter( theObj, theEv );
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null
+/**
+* LIGHT LightApp
+*
+* Copyright (C) 2005 CEA/DEN, EDF R&D
+*
+*
+*
+* File : LightApp_SwitchOp.h
+* Author : Sergey LITONIN
+* Module : LIGHT
+*/
+
+
+
+#ifndef LightApp_SwitchOp_H
+#define LightApp_SwitchOp_H
+
+#include "LightApp.h"
+#include <qobject.h>
+
+class LightApp_Module;
+class LightApp_Operation;
+class QEvent;
+class SUIT_Study;
+
+/*!
+ * \brief This class is intended for controling switching between operation
+ *
+ * Several operation may be launched simultaneously. This class is intended for
+ * controlling switching between such operations. This class works with operations having
+ * dialogs (activation of other operations is performed by SUIT_Study). When several
+ * operations is launched simultaneously corresponding dialogs are shown on the screen.
+ * Only one operation from the launched ones can be active (active operation). Other
+ * operations are suspended. As result only one dialog from shown ones can be active too.
+ * Other dialogs are disabled. This class installs event filter on application. When mouse
+ * cursor is moved above disabled dialog corresponding event is catched by this class.
+ * It finds corresponding operation and verify whether operation can be resumed (see
+ * SUIT_Study::isDenied( SUIT_Operation* ) method). If yes then current active
+ * operation is suspended and new operation activated. Module contains this class as a
+ * field. Then module is created instance of this class created too.
+ */
+class LIGHTAPP_EXPORT LightApp_SwitchOp : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ LightApp_SwitchOp( LightApp_Module* );
+ virtual ~LightApp_SwitchOp();
+
+ // Redefined from base class
+ bool eventFilter( QObject*, QEvent* );
+
+private:
+
+ LightApp_Module* module() const;
+ LightApp_Operation* operation( QWidget* ) const;
+ SUIT_Study* study() const;
+
+private:
+
+ LightApp_Module* myModule;
+
+};
+
+#endif
+
+
+
+
+
+
--- /dev/null
+// LIGHT LightApp
+//
+// Copyright (C) 2005 CEA/DEN, EDF R&D
+//
+//
+//
+// File : LightApp_UpdateFlags.h
+// Author : Sergey LITONIN
+// Module : LIGHT
+
+
+#ifndef LightApp_UpdateFlags_H
+#define LightApp_UpdateFlags_H
+
+/*
+ Enum : UpdateFlags
+ Description : Enumeration for update flags. First byte is reserved for LightApp_Module.
+ Modules derived from this model must use other 3 bytes to define their
+ own update flags
+*/
+
+typedef enum
+{
+ UF_Forced = 0x00000001,
+ UF_Model = 0x00000002,
+ UF_Viewer = 0x00000004,
+ UF_ObjBrowser = 0x00000008,
+ UF_Controls = 0x00000010,
+} UpdateFlags;
+
+#endif
+
+
+
+
+
+
--- /dev/null
+#include "LightApp_VTKSelector.h"
+#include "LightApp_DataOwner.h"
+
+#include "SVTK_ViewModel.h"
+#include "SVTK_Selector.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_Functor.h"
+
+#include "SALOME_Actor.h"
+#include "SALOME_ListIteratorOfListIO.hxx"
+
+#include "VTKViewer_Algorithm.h"
+
+#include <vtkRenderer.h>
+
+/*!
+ Constructor.
+*/
+LightApp_SVTKDataOwner
+::LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO,
+ const TColStd_IndexedMapOfInteger& theIds,
+ Selection_Mode theMode,
+ SALOME_Actor* theActor):
+ LightApp_DataOwner( theIO ),
+ mySelectionMode(theMode),
+ myActor(theActor)
+{
+ myIds = theIds; // workaround - there is no constructor copy for the container
+}
+
+/*!
+ Destuctor.
+*/
+LightApp_SVTKDataOwner
+::~LightApp_SVTKDataOwner()
+{
+}
+
+/*!
+ Gets actor pointer.
+*/
+SALOME_Actor*
+LightApp_SVTKDataOwner
+::GetActor() const
+{
+ return myActor.GetPointer();
+}
+
+/*!
+ Constructor.
+*/
+LightApp_VTKSelector
+::LightApp_VTKSelector( SVTK_Viewer* viewer,
+ SUIT_SelectionMgr* mgr ):
+ SUIT_Selector( mgr, viewer ),
+ myViewer( viewer )
+{
+ if ( myViewer )
+ connect( myViewer, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
+}
+
+/*!
+ Destructor.
+*/
+LightApp_VTKSelector
+::~LightApp_VTKSelector()
+{
+}
+
+/*!
+ Gets viewer.
+*/
+SVTK_Viewer*
+LightApp_VTKSelector
+::viewer() const
+{
+ return myViewer;
+}
+
+/*!
+ Gets type of vtk viewer.
+*/
+QString
+LightApp_VTKSelector
+::type() const
+{
+ return SVTK_Viewer::Type();
+}
+
+/*!
+ On selection changed.
+*/
+void
+LightApp_VTKSelector
+::onSelectionChanged()
+{
+ selectionChanged();
+}
+
+/*!
+ Gets list of selected data owners.(output \a aList).
+*/
+void
+LightApp_VTKSelector
+::getSelection( SUIT_DataOwnerPtrList& aList ) const
+{
+ if(myViewer){
+ if(SUIT_ViewManager* aViewMgr = myViewer->getViewManager()){
+ if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewMgr->getActiveView())){
+ if(SVTK_Selector* aSelector = aView->GetSelector()){
+ Selection_Mode aMode = aSelector->SelectionMode();
+ const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
+ SALOME_ListIteratorOfListIO anIter(aListIO);
+ for(; anIter.More(); anIter.Next()){
+ Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+ if(anIO->hasEntry()){
+ TColStd_IndexedMapOfInteger anIds;
+ aSelector->GetIndex(anIO,anIds);
+ SALOME_Actor* anActor = aSelector->GetActor(anIO);
+ if( !anActor )
+ anActor = VTK::Find<SALOME_Actor>(aView->getRenderer()->GetActors(),VTK::TIsSameIObject<SALOME_Actor>(anIO));
+
+ aList.append(new LightApp_SVTKDataOwner(anIO,anIds,aMode,anActor));
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+/*!
+ Sets selection to selector from data owner list \a theList.
+*/
+void
+LightApp_VTKSelector
+::setSelection( const SUIT_DataOwnerPtrList& theList )
+{
+ if(myViewer){
+ if(SUIT_ViewManager* aViewMgr = myViewer->getViewManager()){
+ if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewMgr->getActiveView())){
+ if(SVTK_Selector* aSelector = aView->GetSelector()){
+ SALOME_ListIO anAppendList;
+ const SALOME_ListIO& aStoredList = aSelector->StoredIObjects();
+ SUIT_DataOwnerPtrList::const_iterator anIter = theList.begin();
+ for(; anIter != theList.end(); ++anIter){
+ const SUIT_DataOwner* aDataOwner = (*anIter).get();
+ if(const LightApp_SVTKDataOwner* anOwner = dynamic_cast<const LightApp_SVTKDataOwner*>(aDataOwner)){
+ aSelector->SetSelectionMode(anOwner->GetMode());
+ Handle(SALOME_InteractiveObject) anIO = anOwner->IO();
+
+ if( anOwner->GetActor() )
+ aSelector->AddIObject( anOwner->GetActor() );
+ else
+ aSelector->AddIObject(anIO);
+
+ anAppendList.Append(anIO);
+ aSelector->AddOrRemoveIndex(anIO,anOwner->GetIds(),false);
+ }else if(const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>(aDataOwner)){
+ Handle(SALOME_InteractiveObject) anIO =
+ new SALOME_InteractiveObject(anOwner->entry().latin1(),"");
+ aSelector->AddIObject(anIO);
+ anAppendList.Append(anIO);
+ }
+ }
+ // To remove IOs, which is not selected.
+ QMap< QString, Handle( SALOME_InteractiveObject )> toRemove;
+ SALOME_ListIteratorOfListIO anIt( aStoredList );
+ for( ; anIt.More(); anIt.Next() )
+ if( !anIt.Value().IsNull() )
+ toRemove[ anIt.Value()->getEntry() ] = anIt.Value();
+
+ anIt = SALOME_ListIteratorOfListIO(anAppendList);
+ for( ; anIt.More(); anIt.Next() )
+ toRemove.remove( anIt.Value()->getEntry() );
+
+ QMap< QString, Handle( SALOME_InteractiveObject )>::const_iterator RIt = toRemove.begin(),
+ REnd = toRemove.end();
+ for( ; RIt!=REnd; RIt++ )
+ aSelector->RemoveIObject( RIt.data() );
+
+ aView->onSelectionChanged();
+ }
+ }
+ }
+ }
+}
--- /dev/null
+#ifndef LIGHTAPP_VTKSELECTOR_H
+#define LIGHTAPP_VTKSELECTOR_H
+
+#include <vtkSmartPointer.h>
+
+#include <TColStd_IndexedMapOfInteger.hxx>
+
+#include "SUIT_Selector.h"
+
+#include "LightApp.h"
+#include "LightApp_DataOwner.h"
+
+#include "SVTK_Selection.h"
+#include "SALOME_InteractiveObject.hxx"
+
+class SALOME_Actor;
+class SVTK_Viewer;
+
+/*!
+ Provide salome vtk data owner list.
+*/
+class LIGHTAPP_EXPORT LightApp_SVTKDataOwner : public LightApp_DataOwner
+{
+ public:
+ LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO,
+ const TColStd_IndexedMapOfInteger& theIds,
+ Selection_Mode theMode = ActorSelection,
+ SALOME_Actor* theActor = NULL);
+ virtual ~LightApp_SVTKDataOwner();
+
+ /*!Gets dataowners ids list.*/
+ const TColStd_IndexedMapOfInteger& GetIds() const
+ {
+ return myIds;
+ }
+
+ /*!Gets selection mode.*/
+ Selection_Mode GetMode() const
+ {
+ return mySelectionMode;
+ }
+
+ SALOME_Actor* GetActor() const;
+
+ protected:
+ TColStd_IndexedMapOfInteger myIds;
+ Selection_Mode mySelectionMode;
+ vtkSmartPointer<SALOME_Actor> myActor;
+};
+
+
+/*!
+ Provide vtk selection of data owners.
+*/
+class LIGHTAPP_EXPORT LightApp_VTKSelector : public SUIT_Selector
+{
+ Q_OBJECT;
+
+public:
+ LightApp_VTKSelector( SVTK_Viewer*, SUIT_SelectionMgr* );
+ virtual ~LightApp_VTKSelector();
+
+ SVTK_Viewer* viewer() const;
+
+ virtual QString type() const;
+
+private slots:
+ void onSelectionChanged();
+
+protected:
+ virtual void getSelection( SUIT_DataOwnerPtrList& ) const;
+ virtual void setSelection( const SUIT_DataOwnerPtrList& );
+
+private:
+ SVTK_Viewer* myViewer;
+};
+
+#endif
--- /dev/null
+#include "LightApp_WidgetContainer.h"
+
+#include <qobjectlist.h>
+#include <qwidgetstack.h>
+
+/*!
+ Constructor.
+*/
+LightApp_WidgetContainer::LightApp_WidgetContainer( const int type, QWidget* parent )
+: QDockWindow( QDockWindow::InDock, parent ),
+myType( type )
+{
+ setWidget( myStack = new QWidgetStack( this ) );
+ myStack->show();
+}
+
+/*!
+ Destructor.
+*/
+LightApp_WidgetContainer::~LightApp_WidgetContainer()
+{
+}
+
+/*!
+ Checks: is widget container is empty?
+*/
+bool LightApp_WidgetContainer::isEmpty() const
+{
+ const QObjectList* lst = myStack->children();
+ if ( !lst )
+ return true;
+
+ bool res = true;
+ for ( QObjectListIt it( *lst ); it.current() && res; ++it )
+ {
+ if ( it.current()->isWidgetType() && myStack->id( (QWidget*)it.current() ) != -1 )
+ res = false;
+ }
+ return res;
+}
+
+/*!
+ Gets type of widget container.
+*/
+int LightApp_WidgetContainer::type() const
+{
+ return myType;
+}
+
+/*!
+ Checks: is container contains widget with id \a id.
+*/
+bool LightApp_WidgetContainer::contains( const int id ) const
+{
+ return myStack->widget( id ) != 0;
+}
+
+/*!
+ * Insert widget(\a wid with id \a id) to container.And return id of widget in stack.
+ *\warning remove widget with id = \a id , if it was in container.
+ */
+int LightApp_WidgetContainer::insert( const int id, QWidget* wid )
+{
+ if ( id == -1 || !wid )
+ return -1;
+
+ if ( contains( id ) )
+ remove( id );
+
+ int stackId = myStack->addWidget( wid, id );
+ if ( !myStack->visibleWidget() )
+ myStack->raiseWidget( wid );
+
+ setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
+
+ return stackId;
+}
+
+/*!
+ Remove widget(\a wid) from stack.
+*/
+void LightApp_WidgetContainer::remove( const int id )
+{
+ remove( myStack->widget( id ) );
+
+ setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
+}
+
+/*!
+ Remove widget(\a wid) from stack.
+*/
+void LightApp_WidgetContainer::remove( QWidget* wid )
+{
+ myStack->removeWidget( wid );
+
+ setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
+}
+
+/*!
+ Raise widget with id = \a id.
+*/
+void LightApp_WidgetContainer::activate( const int id )
+{
+ myStack->raiseWidget( id );
+
+ setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
+}
+
+/*!
+ Raise widget (\a wid).
+*/
+void LightApp_WidgetContainer::activate( QWidget* wid )
+{
+ myStack->raiseWidget( wid );
+
+ setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
+}
+
+/*!
+ Gets widget from container list(stack) by id = \a id.
+*/
+QWidget* LightApp_WidgetContainer::widget( const int id ) const
+{
+ return myStack->widget( id );
+}
+
+/*!
+ Gets visible widget.
+*/
+QWidget* LightApp_WidgetContainer::active() const
+{
+ return myStack->visibleWidget();
+}
--- /dev/null
+#ifndef LIGHTAPP_WIDGETCONTAINER_H
+#define LIGHTAPP_WIDGETCONTAINER_H
+
+#include "LightApp.h"
+
+#include <qdockwindow.h>
+
+class QWidget;
+class QWidgetStack;
+
+/*!
+ Class which privade widget container.
+*/
+class LIGHTAPP_EXPORT LightApp_WidgetContainer : public QDockWindow
+{
+ Q_OBJECT
+
+public:
+ LightApp_WidgetContainer( const int, QWidget* = 0 );
+ virtual ~LightApp_WidgetContainer();
+
+ bool isEmpty() const;
+
+ int type() const;
+
+ int insert( const int, QWidget* );
+ void remove( QWidget* );
+ void remove( const int );
+ bool contains( const int ) const;
+
+ void activate( QWidget* );
+ void activate( const int );
+
+ QWidget* active() const;
+ QWidget* widget( const int ) const;
+
+private:
+ int myType;
+ QWidgetStack* myStack;
+};
+
+#endif
--- /dev/null
+# File : Makefile.in
+# Author : OCC team (OCN)
+# Module : LightApp
+# $Header$
+
+top_srcdir=@top_srcdir@
+top_builddir=../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@srcdir@/resources
+
+
+@COMMENCE@
+
+# header files
+EXPORT_HEADERS= LightApp.h \
+ LightApp_AboutDlg.h \
+ LightApp_Application.h \
+ LightApp_DataModel.h \
+ LightApp_DataObject.h \
+ LightApp_DataOwner.h \
+ LightApp_DataSubOwner.h \
+ LightApp_Dialog.h \
+ LightApp_Displayer.h \
+ LightApp_Driver.h \
+ LightApp_GLSelector.h \
+ LightApp_Module.h \
+ LightApp_ModuleDlg.h \
+ LightApp_NameDlg.h \
+ LightApp_OBFilter.h \
+ LightApp_OBSelector.h \
+ LightApp_OCCSelector.h \
+ LightApp_Operation.h \
+ LightApp_Selection.h \
+ LightApp_SelectionMgr.h \
+ LightApp_ShowHideOp.h \
+ LightApp_Study.h \
+ LightApp_SwitchOp.h \
+ LightApp_Preferences.h \
+ LightApp_PreferencesDlg.h \
+ LightApp_RootObject.h \
+ LightApp_UpdateFlags.h \
+ LightApp_VTKSelector.h \
+ LightApp_WidgetContainer.h
+
+# .po files to transform in .qm
+PO_FILES = LightApp_images.po \
+ LightApp_msg_en.po
+
+# Libraries targets
+LIB = libLightApp.la
+
+LIB_SRC= LightApp_AboutDlg.cxx \
+ LightApp_Application.cxx \
+ LightApp_DataModel.cxx \
+ LightApp_DataObject.cxx \
+ LightApp_DataOwner.cxx \
+ LightApp_DataSubOwner.cxx \
+ LightApp_Dialog.cxx \
+ LightApp_Displayer.cxx \
+ LightApp_Driver.cxx \
+ LightApp_GLSelector.cxx \
+ LightApp_Module.cxx \
+ LightApp_ModuleDlg.cxx \
+ LightApp_NameDlg.cxx \
+ LightApp_OBFilter.cxx \
+ LightApp_OBSelector.cxx \
+ LightApp_OCCSelector.cxx \
+ LightApp_Operation.cxx \
+ LightApp_Selection.cxx \
+ LightApp_SelectionMgr.cxx \
+ LightApp_ShowHideOp.cxx \
+ LightApp_Study.cxx \
+ LightApp_SwitchOp.cxx \
+ LightApp_Preferences.cxx \
+ LightApp_PreferencesDlg.cxx \
+ LightApp_VTKSelector.cxx \
+ LightApp_WidgetContainer.cxx
+
+LIB_MOC = LightApp_AboutDlg.h \
+ LightApp_Application.h \
+ LightApp_DataModel.h \
+ LightApp_Dialog.h \
+ LightApp_Driver.h \
+ LightApp_GLSelector.h \
+ LightApp_OBSelector.h \
+ LightApp_OCCSelector.h \
+ LightApp_Operation.h \
+ LightApp_Module.h \
+ LightApp_ModuleDlg.h \
+ LightApp_NameDlg.h \
+ LightApp_SelectionMgr.h \
+ LightApp_ShowHideOp.h \
+ LightApp_Study.h \
+ LightApp_SwitchOp.h \
+ LightApp_Preferences.h \
+ LightApp_PreferencesDlg.h \
+ LightApp_VTKSelector.h \
+ LightApp_WidgetContainer.h
+
+RESOURCES_FILES = icon_about.png \
+ icon_applogo.png \
+ icon_default.png \
+ icon_module.png \
+ icon_module_big.png \
+ icon_select.png \
+ LightApp.ini \
+ LightApp.xml
+
+CPPFLAGS+=$(PYTHON_INCLUDES) $(QT_INCLUDES) $(QWT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES)
+
+LDFLAGS+=$(PYTHON_LIBS) $(QT_MT_LIBS)
+LIBS+= -lsuit -lstd -lCAM -lObjBrowser -lLogWindow $(CAS_KERNEL) -lPlot2d -lGLViewer -lOCCViewer -lVTKViewer -lSalomeObject -lSOCC -lSVTK -lPyInterp -lPythonConsole
+
+@CONCLUDE@
--- /dev/null
+# The resources mapping file for LightApp application
+
+[language]
+language = en
+
+[launch]
+modules = LIGHT
+
+[resources]
+SUIT = $(SUITRoot)/resources
+STD = $(SUITRoot)/resources
+LightApp = $(SUITRoot)/resources
+Plot2d = $(SUITRoot)/resources
+GLViewer = $(SUITRoot)/resources
+OCCViewer = $(SUITRoot)/resources
+VTKViewer = $(SUITRoot)/resources
+LIGHT = $(LIGHT_ROOT_DIR)/share/salome/resources
+
+[LIGHT]
+name = Light
+icon = LIGHT
--- /dev/null
+<document>
+ <section name="desktop" >
+ <parameter name="state" value="max"/>
+ <parameter name="pos_x" value="100"/>
+ <parameter name="pos_y" value="050"/>
+ <parameter name="width" value="640"/>
+ <parameter name="height" value="480"/>
+ </section>
+ <section name="launch">
+ <parameter name="gui" value="yes"/>
+ <parameter name="splash" value="yes"/>
+ <parameter name="file" value="no"/>
+ <parameter name="key" value="no"/>
+ <parameter name="interp" value="no"/>
+ <parameter name="modules" value="LIGHT"/>
+ </section>
+ <section name="language">
+ <parameter name="language" value="en"/>
+ <parameter name="translators" value="%P_msg_%L.qm|%P_icons.qm|%P_images.qm"/>
+ </section>
+ <section name="resources">
+ <parameter name="SUIT" value="${SUITRoot}/resources"/>
+ <parameter name="STD" value="${SUITRoot}/resources"/>
+ <parameter name="Plot2d" value="${SUITRoot}/resources"/>
+ <parameter name="SPlot2d" value="${SUITRoot}/resources"/>
+ <parameter name="GLViewer" value="${SUITRoot}/resources"/>
+ <parameter name="OCCViewer" value="${SUITRoot}/resources"/>
+ <parameter name="VTKViewer" value="${SUITRoot}/resources"/>
+ <parameter name="SalomeApp" value="${SUITRoot}/resources"/>
+ <parameter name="OB" value="${SUITRoot}/resources"/>
+ <parameter name="CAM" value="${SUITRoot}/resources"/>
+ <parameter name="LightApp" value="${SUITRoot}/resources"/>
+ <parameter name="LIGHT" value="${LIGHT_ROOT_DIR}/share/salome/resources"/>
+ <parameter name="ToolsGUI" value="${SUITRoot}/resources"/>
+ </section>
+ <section name="LIGHT">
+ <parameter name="name" value="Light"/>
+ <parameter name="icon" value="LIGHT.png"/>
+ </section>
+
+<!-- values below this line are just an example, they are not used -->
+ <section name="application">
+ <parameter name="QuickDirList" value=""/>
+ <!-- Here go other common user preferences -->
+ </section>
+ <section name="OCCViewer" >
+ <parameter value="35, 136, 145" name="background" />
+ <parameter value="1" name="iso_number_u" />
+ <parameter value="1" name="iso_number_v" />
+ <parameter value="100" name="trihedron_size" />
+ </section>
+ <section name="VTKViewer" >
+ <parameter value="0, 0, 0" name="background" />
+ <parameter value="100" name="trihedron_size" />
+ </section>
+ <section name="Plot2d" >
+ <parameter value="255, 255, 255" name="Background" />
+ <parameter value="1" name="CurveType" />
+ <parameter value="0" name="HorScaleMode" />
+ <parameter value="1" name="LegendPos" />
+ <parameter value="9" name="MarkerSize" />
+ <parameter value="true" name="ShowLegend" />
+ <parameter value="0" name="VerScaleMode" />
+ </section>
+ <!-- Here go optional sections for other modules -->
+ <section name="resources">
+ <parameter name="salome" value="${KERNEL_ROOT_DIR}/share/salome/res"/>
+ <!-- Here go resource directories for other modules -->
+ </section>
+</document>
--- /dev/null
+// File: LightApp_images.po
+// Created: May, 2005
+// Author: OCC team
+// Copyright (C) CEA 2005
+
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n"
+"PO-Revision-Date: YYYY-MM-DD\n"
+"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+msgid "ABOUT"
+msgstr "icon_about.png"
+
+msgid "ABOUT_SPLASH"
+msgstr "icon_about.png"
+
+msgid "APP_DEFAULT_ICO"
+msgstr "icon_default.png"
+
+msgid "APP_MODULE_ICO"
+msgstr "icon_module.png"
+
+msgid "APP_MODULE_BIG_ICO"
+msgstr "icon_module_big.png"
+
+msgid "ICON_SELECT"
+msgstr "icon_select.png"
+
+msgid "APP_BASE_LOGO"
+msgstr "icon_applogo.png"
--- /dev/null
+# This is a Qt message file in .po format. Each msgid starts with
+# a scope. This scope should *NOT* be translated - eg. "Foo::Bar"
+# would be translated to "Pub", not "Foo::Pub".
+msgid ""
+msgstr ""
+"Project-Id-Version: example-Qt-message-extraction\n"
+"POT-Creation-Date: 1999-02-23 15:38+0200\n"
+"PO-Revision-Date: 1999-02-23 15:38+0200\n"
+"Last-Translator: \n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+msgid "LightApp_Application::ACTIVATING_MODULE"
+msgstr "Trying to activate module \"%1\""
+
+msgid "LightApp_Application::TOT_DESK_PREFERENCES"
+msgstr "Preferences"
+
+msgid "LightApp_Application::MEN_DESK_PREFERENCES"
+msgstr "Preferences..."
+
+msgid "LightApp_Application::TOT_DESK_MRU"
+msgstr "Most recently used"
+
+msgid "LightApp_Application::MEN_DESK_MRU"
+msgstr "Most recently used"
+
+msgid "LightApp_Application::PRP_DESK_PREFERENCES"
+msgstr "Allow to change the preferences"
+
+msgid "LightApp_Application::INF_TOOLBAR_MODULES"
+msgstr "Modules"
+
+msgid "LightApp_Application::APP_NAME"
+msgstr "SALOME"
+
+msgid "LightApp_Application::PRP_APP_MODULE"
+msgstr "Switch to SALOME platform neutral point"
+
+msgid "LightApp_Application::PRP_MODULE"
+msgstr "Switch to the mocule \"%1\""
+
+msgid "LightApp_Application::NEW_WINDOW_0"
+msgstr "GL view"
+
+msgid "LightApp_Application::NEW_WINDOW_1"
+msgstr "Plot2d view"
+
+msgid "LightApp_Application::NEW_WINDOW_2"
+msgstr "OCC view"
+
+msgid "LightApp_Application::NEW_WINDOW_3"
+msgstr "VTK view"
+
+msgid "LightApp_Application::INF_CANCELLED"
+msgstr "Module activation cancelled"
+
+msgid "LightApp_Application::DATA_MODELS"
+msgstr "Data models"
+
+msgid "LightApp_Application::OBJECT_BROWSER"
+msgstr "Object Browser"
+
+msgid "LightApp_Application::OBJ_BROWSER_NAME"
+msgstr "Object"
+
+msgid "LightApp_Application::LOG_WINDOW"
+msgstr "Message Window"
+
+//=======================================================================================
+
+msgid "LightApp_Application::MEN_DESK_MODULE_HELP"
+msgstr "Module help"
+
+//=======================================================================================
+
+msgid "LightApp_Application::PREFERENCES_NOT_LOADED"
+msgstr "Preferences for module \"<b>%1</b>\" will be available when the module will be loaded"
+
+msgid "LightApp_Application::PREF_CATEGORY_SALOME"
+msgstr "SALOME"
+
+msgid "LightApp_Application::PREF_TAB_GENERAL"
+msgstr "General"
+
+msgid "LightApp_Application::PREF_GROUP_STUDY"
+msgstr "Study properties"
+
+msgid "LightApp_Application::PREF_MULTI_FILE"
+msgstr "Multi file save"
+
+msgid "LightApp_Application::PREF_ASCII_FILE"
+msgstr "ASCII save"
+
+msgid "LightApp_Application::PREF_UNDO_LEVEL"
+msgstr "Undo level"
+
+msgid "LightApp_Application::PREF_GROUP_EXT_BROWSER"
+msgstr "External browser"
+
+msgid "LightApp_Application::PREF_APP"
+msgstr "Application"
+
+msgid "LightApp_Application::PREF_PARAM"
+msgstr "Parameters"
+
+msgid "LightApp_Application::PREF_GROUP_PY_CONSOLE"
+msgstr "Python console properties"
+
+msgid "LightApp_Application::PREF_FONT"
+msgstr "Font"
+
+msgid "LightApp_Application::PREF_TAB_OBJBROWSER"
+msgstr "Object browser"
+
+msgid "LightApp_Application::PREF_GROUP_DEF_COLUMNS"
+msgstr "Default columns"
+
+msgid "LightApp_Application::PREF_TAB_VIEWERS"
+msgstr "Viewers"
+
+msgid "LightApp_Application::PREF_GROUP_OCCVIEWER"
+msgstr "OCC Viewer 3d"
+
+msgid "LightApp_Application::PREF_GROUP_VTKVIEWER"
+msgstr "VTK Viewer 3d"
+
+msgid "LightApp_Application::PREF_VIEWER_BACKGROUND"
+msgstr "Background color"
+
+msgid "LightApp_Application::PREF_TRIHEDRON_SIZE"
+msgstr "Trihedron size"
+
+msgid "LightApp_Application::PREF_ISOS_U"
+msgstr "Number of isolines along U"
+msgid "LightApp_Application::PREF_ISOS_V"
+msgstr "Number of isolines along V"
+
+msgid "LightApp_Application::PREF_TRIHEDRON_SHOW"
+msgstr "Show trihedron"
+
+msgid "LightApp_Application::PREF_GROUP_PLOT2DVIEWER"
+msgstr "Plot2d Viewer"
+
+msgid "LightApp_Application::PREF_SHOW_LEGEND"
+msgstr "Show legend"
+
+msgid "LightApp_Application::PREF_LEGEND_POSITION"
+msgstr "Legend position:"
+
+msgid "LightApp_Application::PREF_LEFT"
+msgstr "Left"
+
+msgid "LightApp_Application::PREF_RIGHT"
+msgstr "Right"
+
+msgid "LightApp_Application::PREF_TOP"
+msgstr "Top"
+
+msgid "LightApp_Application::PREF_BOTTOM"
+msgstr "Bottom"
+
+msgid "LightApp_Application::PREF_CURVE_TYPE"
+msgstr "Curve type:"
+
+msgid "LightApp_Application::PREF_POINTS"
+msgstr "Points"
+
+msgid "LightApp_Application::PREF_LINES"
+msgstr "Lines"
+
+msgid "LightApp_Application::PREF_SPLINE"
+msgstr "Spline"
+
+msgid "LightApp_Application::PREF_MARKER_SIZE"
+msgstr "Marker size:"
+
+msgid "LightApp_Application::PREF_LINEAR"
+msgstr "Linear"
+
+msgid "LightApp_Application::PREF_LOGARITHMIC"
+msgstr "Logarithmic"
+
+msgid "LightApp_Application::PREF_HOR_AXIS_SCALE"
+msgstr "Horizontal axis scale:"
+
+msgid "LightApp_Application::PREF_VERT_AXIS_SCALE"
+msgstr "Vertical axis scale:"
+
+msgid "LightApp_Application::PREF_TAB_DIRECTORIES"
+msgstr "Directories"
+
+msgid "LightApp_Application::PREF_GROUP_DIRECTORIES"
+msgstr "Quick directory list"
+
+msgid "LightApp_Application::MEN_REFRESH"
+msgstr "Refresh"
+
+//=======================================================================================
+
+msgid "LightApp_PreferencesDlg::CAPTION"
+msgstr "Preferences"
+
+//=======================================================================================
+
+msgid "LightApp_Module::TOP_DISPLAY"
+msgstr "Display"
+
+msgid "LightApp_Module::MEN_DISPLAY"
+msgstr "Display"
+
+msgid "LightApp_Module::STB_DISPLAY"
+msgstr "Display"
+
+msgid "LightApp_Module::TOP_ERASE"
+msgstr "Erase"
+
+msgid "LightApp_Module::MEN_ERASE"
+msgstr "Erase"
+
+msgid "LightApp_Module::STB_ERASE"
+msgstr "Erase"
+
+msgid "LightApp_Module::TOP_DISPLAY_ONLY"
+msgstr "Display only"
+
+msgid "LightApp_Module::MEN_DISPLAY_ONLY"
+msgstr "Display only"
+
+msgid "LightApp_Module::STB_DISPLAY_ONLY"
+msgstr "Display only"
+
+//=======================================================================================
+
+
+msgid "LightApp_ModuleDlg::CAPTION"
+msgstr "Activate module"
+
+msgid "LightApp_ModuleDlg::NEW"
+msgstr "&New"
+
+msgid "LightApp_ModuleDlg::OPEN"
+msgstr "&Open"
+
+msgid "LightApp_ModuleDlg::LOAD"
+msgstr "&Load"
+
+msgid "LightApp_ModuleDlg::CANCEL"
+msgstr "&Cancel"
+
+msgid "LightApp_ModuleDlg::ActivateComponent_DESCRIPTION"
+msgstr "Create, open or load study."
+