--- /dev/null
+// File: LightApp.h
+// Created: June, 2005
+// Author: OCC team
+// Copyright (C) CEA 2005
+
+
+// The following ifdef block is the standard way of creating macros which make exporting
+// from a DLL simpler. All files within this DLL are compiled with the LightApp_EXPORTS
+// symbol defined on the command line. this symbol should not be defined on any project
+// that uses this DLL. This way any other project whose source files include this file see
+// LightApp_API functions as being imported from a DLL, wheras this DLL sees symbols
+// defined with this macro as being exported.
+#ifdef WNT
+
+#ifdef LIGHTAPP_EXPORTS
+#define LIGHTAPP_EXPORT __declspec(dllexport)
+#else
+#define LIGHTAPP_EXPORT __declspec(dllimport)
+#endif
+
+#else
+#define LIGHTAPP_EXPORT
+#endif //WNT
+
+#define APP_VERSION "0.1"
+
+#if defined WNT
+#pragma warning ( disable: 4251 )
+#endif
+
--- /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 <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 <OCCViewer_ViewManager.h>
+#include <SOCC_ViewModel.h>
+
+#include <SVTK_ViewModel.h>
+#include <SVTK_ViewManager.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>
+
+#define OBJECT_BROWSER_WIDTH 300
+
+#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
+*/
+
+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 );
+
+ 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( desk, SIGNAL( closing( SUIT_Desktop*, QCloseEvent* ) ),
+ this, SLOT( onDesktopClosing( SUIT_Desktop*, QCloseEvent* ) ) );
+
+ 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( "" );
+}
+
+/*!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 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() ) );
+
+ //! 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 );
+
+ QAction* 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 ) {
+ 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();
+ }
+}
+
+//=======================================================================
+// 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;
+}
+
+/*! Purpose : SLOT. Open new document with \a aName.*/
+bool LightApp_Application::onOpenDoc( const QString& 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;
+}
+
+/*!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() );
+ }
+}
+
+/*!Sets enable or disable some actions on selection changed.*/
+void LightApp_Application::onSelectionChanged()
+{
+}
+
+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 (already loaded SComponents)
+ if ( updateModels )
+ {
+ for ( ModuleListIterator it = modules(); it.current(); ++it )
+ {
+ CAM_DataModel* camDM = it.current()->dataModel();
+ 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 Plot2d_Viewer() );
+ }
+ 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 == VTKViewer_Viewer::Type() )
+ {
+ viewMgr = new SVTK_ViewManager( activeStudy(), desktop() );
+ SVTK_Viewer* vm = (SVTK_Viewer*)viewMgr->getViewModel();
+ vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) );
+ vm->setTrihedronSize( resMgr->integerValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ) );
+ new LightApp_VTKSelector((SVTK_Viewer*)viewMgr->getViewModel(),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;
+}
+
+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( "" );
+
+ 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();
+}
+
+/*!*/
+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 );
+}
+
+/*!*/
+QString LightApp_Application::getDirectory( const QString& initial, const QString& caption, QWidget* parent )
+{
+ if ( !parent )
+ parent = desktop();
+ return SUIT_FileDlg::getExistingDirectory( parent, initial, caption, true );
+}
+
+/*!*/
+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->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();
+ }
+}
+
+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" );
+
+}
+
+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 = (SVTK_Viewer*)vm;
+ 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 = moduleLibrary( activeModule()->moduleName(), false );
+
+ 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 = moduleLibrary( activeModule()->moduleName(), false );
+
+ 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 );
+ }
+}
+
+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 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 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 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 : Open data model*/
+//================================================================
+bool LightApp_DataModel::open( const QString&, CAM_Study* study )
+{
+ emit opened(); //TODO: is it really needed? to be removed maybe...
+ return true;
+}
+
+//================================================================
+// Function : save
+/*! Purpose : Emit saved()*/
+//================================================================
+bool LightApp_DataModel::save()
+{
+ emit saved();
+ return true;
+}
+
+//================================================================
+// Function : saveAs
+/*! Purpose : Emit saved() */
+//================================================================
+bool LightApp_DataModel::saveAs( const QString&, CAM_Study* )
+{
+ emit saved();
+ return true;
+}
+
+//================================================================
+// Function : close
+/*! Purpose : Emit closed()*/
+//================================================================
+bool LightApp_DataModel::close()
+{
+ emit closed();
+ return true;
+}
+
+//================================================================
+// Function : update
+/*! Purpose : Update application.*/
+//================================================================
+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;
+
+// Class : LightApp_DataModel
+/// 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* );
+ virtual bool save();
+ virtual bool saveAs( const QString&, CAM_Study* );
+ virtual bool close();
+
+ virtual void update( LightApp_DataObject* = 0, LightApp_Study* = 0 );
+
+ virtual bool isModified() const;
+ virtual bool isSaved() const;
+
+signals:
+ void opened();
+ void saved();
+ void closed();
+
+protected:
+ LightApp_Module* getModule() const;
+ LightApp_Study* getStudy() const;
+
+};
+
+#endif
--- /dev/null
+#include "LightApp_DataObject.h"
+
+#include "LightApp_Study.h"
+#include "LightApp_RootObject.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 (invisible SALOME_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
+{
+ return "";
+}
+
--- /dev/null
+#ifndef LIGHTAPP_DATAOBJECT_H
+#define LIGHTAPP_DATAOBJECT_H
+
+#include "LightApp.h"
+
+#include "CAM_DataObject.h"
+#include "CAM_RootObject.h"
+
+class LightApp_Study;
+
+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;
+
+ SUIT_DataObject* componentObject() const;
+ /*! GEOM, SMESH, VISU, etc.*/
+ QString componentDataType() const;
+
+};
+
+#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 "SUIT_DataOwner.h"
+#include "SALOME_InteractiveObject.hxx"
+
+/*!
+ This class provide data owner objects.
+*/
+class 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_DataOwner.h>
+
+/*!
+ Class provide sub owner.
+ */
+class 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
+#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() ), 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 <SUIT_Study.h>
+#include <SUIT_DataObject.h>
+#include <SUIT_ResourceMgr.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 )
+{
+}
+
+/*!Destructor.*/
+LightApp_Module::~LightApp_Module()
+{
+}
+
+/*!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.*/
+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() );
+
+ return res;
+}
+
+/*!Deactivate module.*/
+bool LightApp_Module::deactivateModule( SUIT_Study* )
+{
+ 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();
+}
+
+/*!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 );
+ 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 );
+}
--- /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 SUIT_Study;
+class SUIT_DataObject;
+class CAM_Application;
+
+class QtxPopupMgr;
+
+class QString;
+class QVariant;
+
+/*
+ Class : LightApp_Module
+ Description : Base class for all salome 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 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() {};
+
+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();
+
+protected:
+ 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& );
+
+private:
+ QtxPopupMgr* myPopupMgr;
+};
+
+#endif
--- /dev/null
+// File : LightApp_ModuleDlg.cxx
+// Author : Michael Zorin (mzn)
+// Module : LightApp
+
+#include "LightApp_ModuleDlg.h"
+
+#include <qframe.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qpixmap.h>
+using namespace std;
+
+/*!Default icon*/
+static const char* const default_icon[] = {
+"48 48 17 1",
+". c None",
+"# c #161e4c",
+"b c #1d3638",
+"e c #2f585b",
+"i c #345b5e",
+"c c #386266",
+"g c #3f7477",
+"d c #4d8589",
+"m c #519099",
+"o c #6abbc1",
+"a c #70c9d3",
+"f c #79ddea",
+"n c #7adff2",
+"k c #7ce2f4",
+"j c #993550",
+"h c #d84b71",
+"l c #ef537d",
+"................................................",
+"................................................",
+"................................................",
+"................................................",
+"................................................",
+"................########.########.########......",
+"...............#aaaaaa###aaaaaa###aaaaaa##......",
+"..............#aaaaaa#b#aaaaaa#b#aaaaaa#c#......",
+".............########b########b########cc#......",
+".............#dddddd#b#dddddd#b#dddddd#cc#......",
+"...........########d########d########d#cc#......",
+"..........#aaaaaa###aaaaaa###aaaaaa##d#cc#......",
+".........#aaaaaa#b#aaaaaa#b#aaaaaa#c#d#cc#......",
+"........########b########e########cc#d#c#.......",
+"........#dddddd#b#dddddd#e#ffffff#cc#d####......",
+"......########d########d########f#cc###g##......",
+".....#aaaaaa###aaaaaa###hhhhhh##f#cc#gg#c#......",
+"....#aaaaaa#b#aaaaaa#i#hhhhhh#j#f#cc###cc#......",
+"...########b########i########jj#f#c#gg#cc#......",
+"...#kkkkkk#b#kkkkkk#i#llllll#jj#f####g#cc#......",
+"...#kkkkkk#b#kkkkkk#i#llllll#jj###m##g#cc#......",
+"...#knnkkk#b#kkkkkk#i#llllll#jj#mm#c#g#cc#......",
+"...#knnkkk#b#kkkkkk#i#llllll#jj###cc#g#c#.......",
+"...#kkkkkk#b#kkkkkk#i#llllll#j#dd#cc#g####......",
+"...#kkkkkk###kkkkkk###llllll####d#cc###g##......",
+"...########g########g########o##d#cc#gg#c#......",
+"....#gggggg#b#gggggg#b#oooooo#c#d#cc###cc#......",
+"...########b########b########cc#d#c#gg#cc#......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#d####g#cc#......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###g##g#cc#......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#gg#c#g#cc#......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###cc#g#c#.......",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#gg#cc#g##........",
+"...#kkkkkk###kkkkkk###kkkkkk####g#cc###.........",
+"...########g########g########g##g#cc#...........",
+"....#gggggg#b#gggggg#b#gggggg#c#g#cc#...........",
+"...########b########b########cc#g#c#............",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#g##.............",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###..............",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
+"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#.................",
+"...#kkkkkk###kkkkkk###kkkkkk##..................",
+"...########.########.########...................",
+"................................................",
+"................................................",
+"................................................",
+"................................................"};
+
+//==============================================================================================================================
+/*!
+ * LightApp_ModuleDlg::LightApp_ModuleDlg \n
+ *
+ * Constructor.
+ */
+//==============================================================================================================================
+LightApp_ModuleDlg::LightApp_ModuleDlg ( QWidget * parent, const QString& component, const QPixmap icon )
+ : QDialog ( parent, "ActivateModuleDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+ QPixmap defaultIcon( ( const char** ) default_icon );
+ setCaption( tr( "CAPTION" ) );
+ setSizeGripEnabled( TRUE );
+
+ QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this );
+ ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 );
+
+ // Module's name and icon
+ myComponentFrame = new QFrame( this, "myComponentFrame" );
+ myComponentFrame->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) );
+ myComponentFrame->setMinimumHeight( 100 );
+ myComponentFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
+
+ QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame );
+ myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 );
+
+ // --> icon
+ myComponentIcon = new QLabel( myComponentFrame, "myComponentIcon" );
+ myComponentIcon->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
+ myComponentIcon->setPixmap( !icon.isNull() ? icon : defaultIcon );
+ myComponentIcon->setScaledContents( false );
+ myComponentIcon->setAlignment( AlignCenter );
+ // --> name
+ myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" );
+ QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt );
+ myComponentLab->setAlignment( AlignCenter );
+
+ myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 );
+ myComponentFrameLayout->addWidget( myComponentLab, 0, 1 );
+
+ // Info
+ QVBoxLayout* infoLayout = new QVBoxLayout();
+ infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 );
+
+ // --> top line
+ QFrame* myLine1 = new QFrame( this, "myLine1" );
+ myLine1->setFrameStyle( QFrame::HLine | QFrame::Plain );
+ // --> info label
+ myInfoLabel = new QLabel( tr ("ActivateComponent_DESCRIPTION"), this, "myInfoLabel" );
+ myInfoLabel->setAlignment( AlignCenter );
+ // --> bottom line
+ QFrame* myLine2 = new QFrame( this, "myLine2" );
+ myLine2->setFrameStyle( QFrame::HLine | QFrame::Plain );
+
+ infoLayout->addStretch();
+ infoLayout->addWidget( myLine1 );
+ infoLayout->addWidget( myInfoLabel );
+ infoLayout->addWidget( myLine2 );
+ infoLayout->addStretch();
+
+ // Buttons
+ QHBoxLayout* btnLayout = new QHBoxLayout();
+ btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );
+
+ // --> New
+ myNewBtn = new QPushButton( tr( "NEW" ), this, "myNewBtn" );
+ myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true );
+ // --> Open
+ myOpenBtn = new QPushButton( tr( "OPEN" ), this, "myOpenBtn" );
+ myOpenBtn->setAutoDefault( true );
+ // --> Load
+ myLoadBtn = new QPushButton( tr( "LOAD" ), this, "myLoadBtn" );
+ myLoadBtn->setAutoDefault( true );
+ // --> Cancel
+ myCancelBtn = new QPushButton( tr( "CANCEL" ), this, "myCancelBtn" );
+ myCancelBtn->setAutoDefault( true );
+
+ btnLayout->addWidget( myNewBtn );
+ btnLayout->addWidget( myOpenBtn );
+ btnLayout->addWidget( myLoadBtn );
+ btnLayout->addStretch();
+ btnLayout->addSpacing( 70 );
+ btnLayout->addStretch();
+ btnLayout->addWidget( myCancelBtn );
+
+ ActivateModuleDlgLayout->addWidget( myComponentFrame, 0, 0 );
+ ActivateModuleDlgLayout->addLayout( infoLayout, 0, 1 );
+ ActivateModuleDlgLayout->addMultiCellLayout( btnLayout, 1, 1, 0, 1 );
+
+ // signals and slots connections
+ connect( myNewBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
+ connect( myOpenBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
+ connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
+ connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
+}
+
+//==============================================================================================================================
+/*!
+ * LightApp_ModuleDlg::onButtonClicked
+ *
+ * Buttons slot
+ */
+//==============================================================================================================================
+void LightApp_ModuleDlg::onButtonClicked()
+{
+ QPushButton* btn = ( QPushButton* )sender();
+ if ( btn == myNewBtn )
+ done( 1 );
+ if ( btn == myOpenBtn )
+ done( 2 );
+ if ( btn == myLoadBtn )
+ done( 3 );
+}
--- /dev/null
+// File : LightApp_ModuleDlg.h
+// Author : Michael ZORIN (mzn)
+// Module : LightApp
+
+#ifndef LIGHTAPP_MODULEDLG_H
+#define LIGHTAPP_MODULEDLG_H
+
+#include <qdialog.h>
+#include <qpixmap.h>
+
+class QFrame;
+class QLabel;
+class QPushButton;
+
+class 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
+// Author : Vadim SANDLER
+// $Header$
+
+#include "LightApp_NameDlg.h"
+#include "SUIT_Application.h"
+#include "SUIT_Desktop.h"
+#include "SUIT_Tools.h"
+
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+using namespace std;
+
+/*!
+ Constructor
+*/
+LightApp_NameDlg::LightApp_NameDlg( QWidget* parent )
+: QDialog( parent ? parent : NULL,//application()->desktop(),
+"LightApp_NameDlg",
+true,
+WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
+{
+ setCaption( tr("TLT_RENAME") );
+ setSizeGripEnabled( TRUE );
+
+ QVBoxLayout* topLayout = new QVBoxLayout( this );
+ topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
+
+ /***************************************************************/
+ QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
+ GroupC1->setColumnLayout(0, Qt::Vertical );
+ GroupC1->layout()->setMargin( 0 ); GroupC1->layout()->setSpacing( 0 );
+ QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1->layout() );
+ GroupC1Layout->setAlignment( Qt::AlignTop );
+ GroupC1Layout->setMargin( 11 ); GroupC1Layout->setSpacing( 6 );
+
+ QLabel* TextLabel = new QLabel( GroupC1, "TextLabel1" );
+ TextLabel->setText( tr( "NAME_LBL" ) );
+ GroupC1Layout->addWidget( TextLabel );
+
+ myLineEdit = new QLineEdit( GroupC1, "LineEdit1" );
+ myLineEdit->setMinimumSize( 250, 0 );
+ GroupC1Layout->addWidget( myLineEdit );
+
+ /***************************************************************/
+ QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
+ GroupButtons->setColumnLayout(0, Qt::Vertical );
+ GroupButtons->layout()->setMargin( 0 ); GroupButtons->layout()->setSpacing( 0 );
+ QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() );
+ GroupButtonsLayout->setAlignment( Qt::AlignTop );
+ GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 );
+
+ myButtonOk = new QPushButton( GroupButtons, "buttonOk" );
+ myButtonOk->setText( tr( "BUT_OK" ) );
+ myButtonOk->setAutoDefault( TRUE ); myButtonOk->setDefault( TRUE );
+ GroupButtonsLayout->addWidget( myButtonOk );
+
+ GroupButtonsLayout->addStretch();
+
+ myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" );
+ myButtonCancel->setText( tr( "BUT_CANCEL" ) );
+ myButtonCancel->setAutoDefault( TRUE );
+ GroupButtonsLayout->addWidget( myButtonCancel );
+ /***************************************************************/
+
+ topLayout->addWidget( GroupC1 );
+ topLayout->addWidget( GroupButtons );
+
+ // signals and slots connections
+ connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+
+ /* Move widget on the botton right corner of main widget */
+ SUIT_Tools::centerWidget( this, parent );
+}
+
+/*!
+ Destructor
+*/
+LightApp_NameDlg::~LightApp_NameDlg()
+{
+}
+
+/*!
+ Sets name
+*/
+void LightApp_NameDlg::setName( const QString& name )
+{
+ myLineEdit->setText( name );
+ myLineEdit->end(false);
+ myLineEdit->home(true);
+}
+
+/*!
+ Returns name entered by user
+*/
+QString LightApp_NameDlg::name()
+{
+ return myLineEdit->text();
+}
+
+void LightApp_NameDlg::accept()
+{
+ if ( name().stripWhiteSpace().isEmpty() )
+ return;
+ QDialog::accept();
+}
+
+/*!
+ Creates modal <Rename> dialog and returns name entered [ static ]
+*/
+QString LightApp_NameDlg::getName( QWidget* parent, const QString& oldName )
+{
+ QString n;
+ LightApp_NameDlg* dlg = new LightApp_NameDlg( parent );
+ if ( !oldName.isNull() )
+ dlg->setName( oldName );
+ if ( dlg->exec() == QDialog::Accepted )
+ n = dlg->name();
+ delete dlg;
+ return n;
+}
--- /dev/null
+// File : LightApp_NameDlg.h
+// Author : Vadim SANDLER
+// $Header$
+
+#ifndef LIGHTAPP_NAMEDLG_H
+#define LIGHTAPP_NAMEDLG_H
+
+#include <qdialog.h>
+
+class QLineEdit;
+class QPushButton;
+
+//=================================================================================
+// class : LightApp_NameDlg
+/*! purpose : Common <Rename> dialog box class*/
+//=================================================================================
+class 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& list ) 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() );
+ list.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aSObj ) ) );
+ }
+ }
+}
+
+/*!Sets selection.*/
+void LightApp_OBSelector::setSelection( const SUIT_DataOwnerPtrList& list )
+{
+ if ( !myBrowser )
+ return;
+
+ QMap<QString, LightApp_DataObject*> map;
+ fillEntries( map );
+
+ DataObjectList objList;
+ for ( SUIT_DataOwnerPtrList::const_iterator it = list.begin(); it != list.end(); ++it )
+ {
+ const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>( (*it).operator->() );
+ if ( owner && map.contains( owner->entry() ) )
+ objList.append( map[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
+// 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, Standard | 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 );
+
+ 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();
+}
--- /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 "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() );
+
+ SUIT_DataOwnerPtrList sel;
+ mgr->selected( sel, client );
+ SUIT_DataOwnerPtrList::const_iterator anIt = sel.begin(), aLast = sel.end();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() );
+ LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>( owner );
+ if( sowner ) {
+ myEntries.append( sowner->entry() );
+ processOwner( sowner );
+ }
+ }
+ }
+}
+
+/*!
+ Gets count of entries.
+*/
+int LightApp_Selection::count() const
+{
+ return myEntries.count();
+}
+
+/*!
+ Gets QtxValue();
+*/
+QtxValue LightApp_Selection::param( const int, const QString& p ) const
+{
+ 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 == "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();
+}
+
+/*!
+ 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 <QtxPopupMgr.h>
+
+class LightApp_SelectionMgr;
+class LightApp_DataOwner;
+class LightApp_Study;
+class SUIT_ViewWindow;
+
+
+class 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;
+
+protected:
+ QString entry( const int ) const;
+ /*!Gets study.*/
+ LightApp_Study* study() const { return myStudy; }
+ QString activeViewType() const;
+ SUIT_ViewWindow* activeVW() const;
+
+protected:
+ QString myPopupClient;
+
+private:
+ QStringList myEntries; // entries of selected objects
+ 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
+{
+ theList.Clear();
+
+ SUIT_DataOwnerPtrList aList;
+ selected( aList, theType );
+
+ QMap<QString,int> entryMap;
+
+ 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 ( !entryMap.contains(owner->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;
+ 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_Study.h"
+
+#include "CAM_DataModel.h"
+#include "LightApp_Application.h"
+#include "LightApp_DataModel.h"
+#include "LightApp_RootObject.h"
+
+#include <OB_Browser.h>
+
+#include <qstring.h>
+
+/*!
+ Constructor.
+*/
+LightApp_Study::LightApp_Study( SUIT_Application* app )
+: CAM_Study( app )
+{
+}
+
+/*!
+ 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 )
+{
+ 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 : saveDocumentAs
+/*! Purpose : Save document */
+//=======================================================================
+bool LightApp_Study::saveDocumentAs( const QString& theFileName )
+{
+ ModelList list; dataModels( list );
+
+ LightApp_DataModel* aModel = (LightApp_DataModel*)list.first();
+ for ( ; aModel; aModel = (LightApp_DataModel*)list.next() )
+ aModel->saveAs( theFileName, this );
+
+ bool res = CAM_Study::saveDocumentAs( theFileName );//SRN: BugID IPAL9377, removed usage of uninitialized variable <res>
+
+ if ( res )
+ emit saved( this );
+
+ return res;
+}
+
+//=======================================================================
+// name : loadDocument
+/*! Purpose : Load document */
+//=======================================================================
+bool LightApp_Study::loadDocument( const QString& theStudyName )
+{
+ 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 : saveDocument
+/*! Purpose : Save document */
+//=======================================================================
+void LightApp_Study::saveDocument()
+{
+ ModelList list; dataModels( list );
+
+ LightApp_DataModel* aModel = (LightApp_DataModel*)list.first();
+ for ( ; aModel; aModel = (LightApp_DataModel*)list.next() )
+ aModel->save();
+
+ CAM_Study::saveDocument();
+
+ emit saved( this );
+}
+
+//================================================================
+// 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 : isModified
+// Purpose :
+//================================================================
+bool LightApp_Study::isModified() const
+{
+ bool isAnyChanged = false;
+ 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 = false;
+ 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;
+}
+
+//================================================================
+// Function : GetListOfFiles
+/*! Purpose : to be used by modules*/
+//================================================================
+std::vector<std::string> LightApp_Study::GetListOfFiles() const
+{
+ std::vector<std::string> aListOfFiles;
+ return aListOfFiles;
+}
+
+//================================================================
+// Function : SetListOfFiles
+/*! Purpose : to be used by modules*/
+//================================================================
+void LightApp_Study::SetListOfFiles (const std::vector<std::string> theListOfFiles)
+{
+}
+
+//================================================================
+// Function : GetTmpDir
+/*! Purpose : to be used by modules*/
+//================================================================
+std::string LightApp_Study::GetTmpDir (const char* theURL,
+ const bool isMultiFile)
+{
+ std::string aTmpDir = "";
+ return aTmpDir;
+}
+
+//================================================================
+// Function : RemoveTemporaryFiles
+/*! Purpose : to be used by CORBAless modules*/
+//================================================================
+void LightApp_Study::RemoveTemporaryFiles (const bool isMultiFile) const
+{
+ if (isMultiFile)
+ return;
+}
--- /dev/null
+#ifndef LIGHTAPP_STUDY_H
+#define LIGHTAPP_STUDY_H
+
+#include "LightApp.h"
+
+#include "CAM_Study.h"
+#include "SUIT_Study.h"
+
+#include "string.h"
+#include "vector.h"
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+class SUIT_Application;
+class CAM_DataModel;
+
+class LIGHTAPP_EXPORT LightApp_Study : public CAM_Study
+{
+ Q_OBJECT
+
+public:
+ LightApp_Study( SUIT_Application* );
+ virtual ~LightApp_Study();
+
+ virtual void createDocument();
+ virtual bool openDocument( const QString& );
+
+ virtual void saveDocument();
+ virtual bool saveDocumentAs( const QString& );
+ virtual bool loadDocument( const QString& );
+
+ virtual void closeDocument(bool permanently = true);
+
+ virtual bool isSaved() const;
+ virtual bool isModified() const;
+
+ /** @name methods to be used by modules*/
+ //@{
+ virtual std::vector<std::string> GetListOfFiles () const;
+ virtual void SetListOfFiles (const std::vector<std::string> theListOfFiles);
+
+ virtual std::string GetTmpDir (const char* theURL,
+ const bool isMultiFile);
+
+ virtual void RemoveTemporaryFiles (const bool isMultiFile) const;
+ //@}
+ // END: methods to be used by modules
+
+signals:
+ void saved( SUIT_Study* );
+ void opened( SUIT_Study* );
+ void closed( SUIT_Study* );
+ void created( SUIT_Study* );
+};
+
+#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 salome 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_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 salome 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_GLSelector.h \
+ LightApp_Module.h \
+ LightApp_ModuleDlg.h \
+ LightApp_NameDlg.h \
+ LightApp_OBFilter.h \
+ LightApp_OBSelector.h \
+ LightApp_OCCSelector.h \
+ LightApp_Selection.h \
+ LightApp_SelectionMgr.h \
+ LightApp_Study.h \
+ LightApp_Preferences.h \
+ LightApp_PreferencesDlg.h \
+ LightApp_RootObject.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_GLSelector.cxx \
+ LightApp_Module.cxx \
+ LightApp_ModuleDlg.cxx \
+ LightApp_NameDlg.cxx \
+ LightApp_OBFilter.cxx \
+ LightApp_OBSelector.cxx \
+ LightApp_OCCSelector.cxx \
+ LightApp_Selection.cxx \
+ LightApp_SelectionMgr.cxx \
+ LightApp_Study.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_GLSelector.h \
+ LightApp_OBSelector.h \
+ LightApp_OCCSelector.h \
+ LightApp_Module.h \
+ LightApp_ModuleDlg.h \
+ LightApp_NameDlg.h \
+ LightApp_SelectionMgr.h \
+ LightApp_Study.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 \
+ LightApp.ini
+
+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
+// 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 "APP_MODULE_BIG_ICO"
+msgstr "icon_module_big.png"
+
+msgid "APP_MODULE_ICO"
+msgstr "icon_module.png"
+
+msgid "ABOUT"
+msgstr "icon_about.png"
+
+msgid "APP_DEFAULT_ICO"
+msgstr "icon_default.png"
+
+msgid "APP_LOGO_ICO"
+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::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_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."
+
+++ /dev/null
-// File: SalomeApp_AboutDlg.cxx
-// Created: 03.06.2005 13:52:45
-// Author: Sergey TELKOV
-// Copyright (C) CEA 2005
-
-#include "SalomeApp_AboutDlg.h"
-
-#include <SUIT_Session.h>
-#include <SUIT_ResourceMgr.h>
-
-#include <qlabel.h>
-#include <qlayout.h>
-#include <qpixmap.h>
-#include <qgroupbox.h>
-
-/*!Constructor.*/
-SalomeApp_AboutDlg::SalomeApp_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( "SalomeApp", 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( "SalomeApp", 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.*/
-SalomeApp_AboutDlg::~SalomeApp_AboutDlg()
-{
- //! Do nothing.
-}
-
-/*!On mouse press event.*/
-void SalomeApp_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 SalomeApp_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 SalomeApp_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: SalomeApp_AboutDlg.h
-// Created: 03.06.2005 13:49:25
-// Author: Sergey TELKOV
-// Copyright (C) CEA 2005
-
-#ifndef SALOMEAPP_ABOUTDLG_H
-#define SALOMEAPP_ABOUTDLG_H
-
-#include "SalomeApp.h"
-
-#include <QtxDialog.h>
-
-/*!
- Descr: Salome help about dialog
-*/
-
-class QLabel;
-
-class SALOMEAPP_EXPORT SalomeApp_AboutDlg : public QtxDialog
-{
- Q_OBJECT
-
-public:
- SalomeApp_AboutDlg( const QString&, const QString&, QWidget* = 0 );
- virtual ~SalomeApp_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
-#include "SalomeApp_DataOwner.h"
-
-#include "SalomeApp_DataObject.h"
-
-#ifdef WNT
-#include <typeinfo.h>
-#endif
-
-#include <iostream>
-
-/*!Constructor. Initialize by \a theEntry.*/
-SalomeApp_DataOwner
-::SalomeApp_DataOwner( const QString& theEntry ):
- myEntry( theEntry )
-{
-}
-
-/*!Constructor. Initialize by \a SALOME_InteractiveObject.*/
-SalomeApp_DataOwner
-::SalomeApp_DataOwner( const Handle(SALOME_InteractiveObject)& theIO ):
- myEntry(!theIO.IsNull()? theIO->getEntry(): ""),
- myIO(theIO)
-{
-}
-
-/*!Destructor. Do nothing.*/
-SalomeApp_DataOwner
-::~SalomeApp_DataOwner()
-{
-}
-
-/*!Checks: Is current data owner equal \a obj.*/
-bool
-SalomeApp_DataOwner
-::isEqual( const SUIT_DataOwner& obj ) const
-{
- const SalomeApp_DataOwner* other = dynamic_cast<const SalomeApp_DataOwner*>( &obj );
-
- return other && entry() == other->entry();
-}
-
-/*!Gets entry.*/
-QString
-SalomeApp_DataOwner
-::entry() const
-{
- return myEntry;
-}
-
-/*!Gets SALOME_InteractiveObject.*/
-const Handle(SALOME_InteractiveObject)&
-SalomeApp_DataOwner
-::IO() const
-{
- return myIO;
-}
+++ /dev/null
-
-#ifndef SALOMEAPP_DATAOWNER_H
-#define SALOMEAPP_DATAOWNER_H
-
-#include <SalomeApp.h>
-#include "SUIT_DataOwner.h"
-#include "SALOME_InteractiveObject.hxx"
-
-/*!
- This class provide data owner objects.
-*/
-class SALOMEAPP_EXPORT SalomeApp_DataOwner : public SUIT_DataOwner
-{
-public:
- SalomeApp_DataOwner( const Handle(SALOME_InteractiveObject)& theIO );
- SalomeApp_DataOwner( const QString& );
- virtual ~SalomeApp_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(SalomeApp_DataOwner) SalomeApp_DataOwnerPtr;
-
-#endif
+++ /dev/null
-#include "SalomeApp_DataSubOwner.h"
-
-#include "SalomeApp_DataObject.h"
-
-#ifdef WNT
-#include <typeinfo.h>
-#endif
-
-/*!Constructor.Initialize by \a entry and \a index*/
-SalomeApp_DataSubOwner::SalomeApp_DataSubOwner( const QString& entry, const int index )
-: SalomeApp_DataOwner( entry ),
-myIndex( index )
-{
-}
-
-/*!Destructor. Do nothing.*/
-SalomeApp_DataSubOwner::~SalomeApp_DataSubOwner()
-{
-}
-
-/*!Checks: Is current data sub owner equal \a obj.*/
-bool SalomeApp_DataSubOwner::isEqual( const SUIT_DataOwner& obj ) const
-{
- const SalomeApp_DataSubOwner* other = dynamic_cast<const SalomeApp_DataSubOwner*>( &obj );
-
- return other && entry() == other->entry() && index() == other->index();
-}
-
-/*!Gets index.*/
-int SalomeApp_DataSubOwner::index() const
-{
- return myIndex;
-}
+++ /dev/null
-
-#ifndef SALOMEAPP_DATASUBOWNER_H
-#define SALOMEAPP_DATASUBOWNER_H
-
-#include <SalomeApp.h>
-#include <SalomeApp_DataOwner.h>
-
-/*!
- Class provide sub owner.
- */
-class SALOMEAPP_EXPORT SalomeApp_DataSubOwner : public SalomeApp_DataOwner
-{
-public:
- SalomeApp_DataSubOwner( const QString&, const int );
- virtual ~SalomeApp_DataSubOwner();
-
- virtual bool isEqual( const SUIT_DataOwner& ) const;
- int index() const;
-
-private:
- int myIndex;
-};
-
-#endif
+++ /dev/null
-#include "SalomeApp_GLSelector.h"
-
-#include "SalomeApp_DataOwner.h"
-
-#include <SALOME_GLOwner.h>
-
-#include <GLViewer_Context.h>
-
-/*!Constructor. Initialize by GLViewer_Viewer2d and SUIT_SelectionMgr.*/
-SalomeApp_GLSelector::SalomeApp_GLSelector( GLViewer_Viewer2d* viewer, SUIT_SelectionMgr* mgr )
-: SUIT_Selector( mgr, viewer ),
- myViewer( viewer )
-{
- if ( myViewer )
- connect( myViewer, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
-}
-
-/*!Destructor. Do nothing.*/
-SalomeApp_GLSelector::~SalomeApp_GLSelector()
-{
-}
-
-/*!Gets viewer*/
-GLViewer_Viewer2d* SalomeApp_GLSelector::viewer() const
-{
- return myViewer;
-}
-
-/*!On selection changed event.*/
-void SalomeApp_GLSelector::onSelectionChanged()
-{
- selectionChanged();
-}
-
-/*!Gets list of selected Data Owner objects.*/
-void SalomeApp_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 SalomeApp_DataOwner( owner->entry() ) ) );
- }
- }
-}
-
-/*!Sets to selected list of Data Owner objects.*/
-void SalomeApp_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 SalomeApp_DataOwner* owner = dynamic_cast<const SalomeApp_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 SALOMEAPP_GLSELECTOR_H
-#define SALOMEAPP_GLSELECTOR_H
-
-#include "SalomeApp.h"
-
-#include <SUIT_Selector.h>
-
-#include <GLViewer_Viewer2d.h>
-
-class SALOMEAPP_EXPORT SalomeApp_GLSelector : public SUIT_Selector
-{
- Q_OBJECT
-
-public:
- SalomeApp_GLSelector( GLViewer_Viewer2d*, SUIT_SelectionMgr* );
- virtual ~SalomeApp_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
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
-//
-// Copyright (C) 2005 CEA/DEN, EDF R&D
-//
-//
-//
-// File : SalomeApp_ModuleDlg.cxx
-// Author : Michael Zorin (mzn)
-// Module : SALOME
-
-#include "SalomeApp_ModuleDlg.h"
-
-#include <qframe.h>
-#include <qlabel.h>
-#include <qpushbutton.h>
-#include <qlayout.h>
-#include <qpixmap.h>
-
-#ifndef WNT
-using namespace std;
-#endif
-
-/*!Default icon*/
-static const char* const default_icon[] = {
-"48 48 17 1",
-". c None",
-"# c #161e4c",
-"b c #1d3638",
-"e c #2f585b",
-"i c #345b5e",
-"c c #386266",
-"g c #3f7477",
-"d c #4d8589",
-"m c #519099",
-"o c #6abbc1",
-"a c #70c9d3",
-"f c #79ddea",
-"n c #7adff2",
-"k c #7ce2f4",
-"j c #993550",
-"h c #d84b71",
-"l c #ef537d",
-"................................................",
-"................................................",
-"................................................",
-"................................................",
-"................................................",
-"................########.########.########......",
-"...............#aaaaaa###aaaaaa###aaaaaa##......",
-"..............#aaaaaa#b#aaaaaa#b#aaaaaa#c#......",
-".............########b########b########cc#......",
-".............#dddddd#b#dddddd#b#dddddd#cc#......",
-"...........########d########d########d#cc#......",
-"..........#aaaaaa###aaaaaa###aaaaaa##d#cc#......",
-".........#aaaaaa#b#aaaaaa#b#aaaaaa#c#d#cc#......",
-"........########b########e########cc#d#c#.......",
-"........#dddddd#b#dddddd#e#ffffff#cc#d####......",
-"......########d########d########f#cc###g##......",
-".....#aaaaaa###aaaaaa###hhhhhh##f#cc#gg#c#......",
-"....#aaaaaa#b#aaaaaa#i#hhhhhh#j#f#cc###cc#......",
-"...########b########i########jj#f#c#gg#cc#......",
-"...#kkkkkk#b#kkkkkk#i#llllll#jj#f####g#cc#......",
-"...#kkkkkk#b#kkkkkk#i#llllll#jj###m##g#cc#......",
-"...#knnkkk#b#kkkkkk#i#llllll#jj#mm#c#g#cc#......",
-"...#knnkkk#b#kkkkkk#i#llllll#jj###cc#g#c#.......",
-"...#kkkkkk#b#kkkkkk#i#llllll#j#dd#cc#g####......",
-"...#kkkkkk###kkkkkk###llllll####d#cc###g##......",
-"...########g########g########o##d#cc#gg#c#......",
-"....#gggggg#b#gggggg#b#oooooo#c#d#cc###cc#......",
-"...########b########b########cc#d#c#gg#cc#......",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#d####g#cc#......",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###g##g#cc#......",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#gg#c#g#cc#......",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###cc#g#c#.......",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#gg#cc#g##........",
-"...#kkkkkk###kkkkkk###kkkkkk####g#cc###.........",
-"...########g########g########g##g#cc#...........",
-"....#gggggg#b#gggggg#b#gggggg#c#g#cc#...........",
-"...########b########b########cc#g#c#............",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#g##.............",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###..............",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
-"...#kkkkkk#b#kkkkkk#b#kkkkkk#c#.................",
-"...#kkkkkk###kkkkkk###kkkkkk##..................",
-"...########.########.########...................",
-"................................................",
-"................................................",
-"................................................",
-"................................................"};
-
-//==============================================================================================================================
-/*!
- * SalomeApp_ModuleDlg::SalomeApp_ModuleDlg \n
- *
- * Constructor.
- */
-//==============================================================================================================================
-SalomeApp_ModuleDlg::SalomeApp_ModuleDlg ( QWidget * parent, const QString& component, const QPixmap icon )
- : QDialog ( parent, "ActivateModuleDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
-{
- QPixmap defaultIcon( ( const char** ) default_icon );
- setCaption( tr( "CAPTION" ) );
- setSizeGripEnabled( TRUE );
-
- QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this );
- ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 );
-
- // Module's name and icon
- myComponentFrame = new QFrame( this, "myComponentFrame" );
- myComponentFrame->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) );
- myComponentFrame->setMinimumHeight( 100 );
- myComponentFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
-
- QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame );
- myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 );
-
- // --> icon
- myComponentIcon = new QLabel( myComponentFrame, "myComponentIcon" );
- myComponentIcon->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
- myComponentIcon->setPixmap( !icon.isNull() ? icon : defaultIcon );
- myComponentIcon->setScaledContents( false );
- myComponentIcon->setAlignment( AlignCenter );
- // --> name
- myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" );
- QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt );
- myComponentLab->setAlignment( AlignCenter );
-
- myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 );
- myComponentFrameLayout->addWidget( myComponentLab, 0, 1 );
-
- // Info
- QVBoxLayout* infoLayout = new QVBoxLayout();
- infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 );
-
- // --> top line
- QFrame* myLine1 = new QFrame( this, "myLine1" );
- myLine1->setFrameStyle( QFrame::HLine | QFrame::Plain );
- // --> info label
- myInfoLabel = new QLabel( tr ("ActivateComponent_DESCRIPTION"), this, "myInfoLabel" );
- myInfoLabel->setAlignment( AlignCenter );
- // --> bottom line
- QFrame* myLine2 = new QFrame( this, "myLine2" );
- myLine2->setFrameStyle( QFrame::HLine | QFrame::Plain );
-
- infoLayout->addStretch();
- infoLayout->addWidget( myLine1 );
- infoLayout->addWidget( myInfoLabel );
- infoLayout->addWidget( myLine2 );
- infoLayout->addStretch();
-
- // Buttons
- QHBoxLayout* btnLayout = new QHBoxLayout();
- btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );
-
- // --> New
- myNewBtn = new QPushButton( tr( "NEW" ), this, "myNewBtn" );
- myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true );
- // --> Open
- myOpenBtn = new QPushButton( tr( "OPEN" ), this, "myOpenBtn" );
- myOpenBtn->setAutoDefault( true );
- // --> Load
- myLoadBtn = new QPushButton( tr( "LOAD" ), this, "myLoadBtn" );
- myLoadBtn->setAutoDefault( true );
- // --> Cancel
- myCancelBtn = new QPushButton( tr( "CANCEL" ), this, "myCancelBtn" );
- myCancelBtn->setAutoDefault( true );
-
- btnLayout->addWidget( myNewBtn );
- btnLayout->addWidget( myOpenBtn );
- btnLayout->addWidget( myLoadBtn );
- btnLayout->addStretch();
- btnLayout->addSpacing( 70 );
- btnLayout->addStretch();
- btnLayout->addWidget( myCancelBtn );
-
- ActivateModuleDlgLayout->addWidget( myComponentFrame, 0, 0 );
- ActivateModuleDlgLayout->addLayout( infoLayout, 0, 1 );
- ActivateModuleDlgLayout->addMultiCellLayout( btnLayout, 1, 1, 0, 1 );
-
- // signals and slots connections
- connect( myNewBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( myOpenBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
- connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
-}
-
-//==============================================================================================================================
-/*!
- * SalomeApp_ModuleDlg::onButtonClicked
- *
- * Buttons slot
- */
-//==============================================================================================================================
-void SalomeApp_ModuleDlg::onButtonClicked()
-{
- QPushButton* btn = ( QPushButton* )sender();
- if ( btn == myNewBtn )
- done( 1 );
- if ( btn == myOpenBtn )
- done( 2 );
- if ( btn == myLoadBtn )
- done( 3 );
-}
+++ /dev/null
-// SALOME SALOMEGUI : implementation of desktop and GUI kernel
-//
-// Copyright (C) 2005 CEA/DEN, EDF R&D
-//
-//
-//
-// File : SalomeApp_ModuleDlg.h
-// Author : Michael ZORIN (mzn)
-// Module : SALOME
-
-#ifndef SALOMEAPP_MODULEDLG_H
-#define SALOMEAPP_MODULEDLG_H
-
-#include <qdialog.h>
-#include <qpixmap.h>
-
-class QFrame;
-class QLabel;
-class QPushButton;
-
-class SalomeApp_ModuleDlg : public QDialog
-{
- Q_OBJECT
-
-public:
- SalomeApp_ModuleDlg ( QWidget* parent, const QString& component, const QPixmap icon = QPixmap() ) ;
- ~SalomeApp_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
-// SALOME SalomeApp : implementation of desktop and GUI kernel
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
-// File : SalomeApp_NameDlg.cxx
-// Author : Vadim SANDLER
-// Module : SALOME
-// $Header$
-
-#include "SalomeApp_NameDlg.h"
-#include "SUIT_Application.h"
-#include "SUIT_Desktop.h"
-#include "SUIT_Tools.h"
-
-#include <qgroupbox.h>
-#include <qlabel.h>
-#include <qlineedit.h>
-#include <qpushbutton.h>
-#include <qlayout.h>
-
-#ifndef WNT
-using namespace std;
-#endif
-
-/*!
- Constructor
-*/
-SalomeApp_NameDlg::SalomeApp_NameDlg( QWidget* parent )
- : QDialog( parent ? parent : NULL,//application()->desktop(),
- "SalomeApp_NameDlg",
- true,
- WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
-{
- setCaption( tr("TLT_RENAME") );
- setSizeGripEnabled( TRUE );
-
- QVBoxLayout* topLayout = new QVBoxLayout( this );
- topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
-
- /***************************************************************/
- QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
- GroupC1->setColumnLayout(0, Qt::Vertical );
- GroupC1->layout()->setMargin( 0 ); GroupC1->layout()->setSpacing( 0 );
- QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1->layout() );
- GroupC1Layout->setAlignment( Qt::AlignTop );
- GroupC1Layout->setMargin( 11 ); GroupC1Layout->setSpacing( 6 );
-
- QLabel* TextLabel = new QLabel( GroupC1, "TextLabel1" );
- TextLabel->setText( tr( "NAME_LBL" ) );
- GroupC1Layout->addWidget( TextLabel );
-
- myLineEdit = new QLineEdit( GroupC1, "LineEdit1" );
- myLineEdit->setMinimumSize( 250, 0 );
- GroupC1Layout->addWidget( myLineEdit );
-
- /***************************************************************/
- QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
- GroupButtons->setColumnLayout(0, Qt::Vertical );
- GroupButtons->layout()->setMargin( 0 ); GroupButtons->layout()->setSpacing( 0 );
- QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() );
- GroupButtonsLayout->setAlignment( Qt::AlignTop );
- GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 );
-
- myButtonOk = new QPushButton( GroupButtons, "buttonOk" );
- myButtonOk->setText( tr( "BUT_OK" ) );
- myButtonOk->setAutoDefault( TRUE ); myButtonOk->setDefault( TRUE );
- GroupButtonsLayout->addWidget( myButtonOk );
-
- GroupButtonsLayout->addStretch();
-
- myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" );
- myButtonCancel->setText( tr( "BUT_CANCEL" ) );
- myButtonCancel->setAutoDefault( TRUE );
- GroupButtonsLayout->addWidget( myButtonCancel );
- /***************************************************************/
-
- topLayout->addWidget( GroupC1 );
- topLayout->addWidget( GroupButtons );
-
- // signals and slots connections
- connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
- connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
-
- /* Move widget on the botton right corner of main widget */
- SUIT_Tools::centerWidget( this, parent );
-}
-
-/*!
- Destructor
-*/
-SalomeApp_NameDlg::~SalomeApp_NameDlg()
-{
-}
-
-/*!
- Sets name
-*/
-void SalomeApp_NameDlg::setName( const QString& name )
-{
- myLineEdit->setText( name );
- myLineEdit->end(false);
- myLineEdit->home(true);
-}
-
-/*!
- Returns name entered by user
-*/
-QString SalomeApp_NameDlg::name()
-{
- return myLineEdit->text();
-}
-
-void SalomeApp_NameDlg::accept()
-{
- if ( name().stripWhiteSpace().isEmpty() )
- return;
- QDialog::accept();
-}
-
-/*!
- Creates modal <Rename> dialog and returns name entered [ static ]
-*/
-QString SalomeApp_NameDlg::getName( QWidget* parent, const QString& oldName )
-{
- QString n;
- SalomeApp_NameDlg* dlg = new SalomeApp_NameDlg( parent );
- if ( !oldName.isNull() )
- dlg->setName( oldName );
- if ( dlg->exec() == QDialog::Accepted )
- n = dlg->name();
- delete dlg;
- return n;
-}
+++ /dev/null
-// SALOME SalomeApp : implementation of desktop and GUI kernel
-//
-// Copyright (C) 2003 CEA/DEN, EDF R&D
-//
-//
-//
-// File : SalomeApp_NameDlg.h
-// Author : Vadim SANDLER
-// Module : SALOME
-// $Header$
-
-#ifndef SALOMEAPP_NAMEDLG_H
-#define SALOMEAPP_NAMEDLG_H
-
-#include <qdialog.h>
-
-class QLineEdit;
-class QPushButton;
-
-//=================================================================================
-// class : SalomeApp_NameDlg
-/*! purpose : Common <Rename> dialog box class*/
-//=================================================================================
-class SalomeApp_NameDlg : public QDialog
-{
- Q_OBJECT
-
-public:
- SalomeApp_NameDlg( QWidget* parent = 0 );
- ~SalomeApp_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 // SalomeApp_NAMEDLG_H
+++ /dev/null
-#include "SalomeApp_OBFilter.h"
-
-#include "SalomeApp_SelectionMgr.h"
-#include "SalomeApp_DataObject.h"
-#include "SalomeApp_DataOwner.h"
-
-/*!
- Constructor.
-*/
-SalomeApp_OBFilter::SalomeApp_OBFilter( SalomeApp_SelectionMgr* theSelMgr )
-{
- mySelMgr = theSelMgr;
-}
-
-/*!Destructor.*/
-SalomeApp_OBFilter::~SalomeApp_OBFilter()
-{
-}
-
-/*!Checks: data object is ok?*/
-bool SalomeApp_OBFilter::isOk( const SUIT_DataObject* theDataObj ) const
-{
- const SalomeApp_DataObject* obj = dynamic_cast<const SalomeApp_DataObject*>( theDataObj );
- if ( obj )
- return mySelMgr->isOk( new SalomeApp_DataOwner( obj->entry() ) );
-
- return true;
-}
-
+++ /dev/null
-#ifndef SALOMEAPP_OBFILTER_H
-#define SALOMEAPP_OBFILTER_H
-
-#include "SalomeApp.h"
-#include "OB_Filter.h"
-
-class SalomeApp_SelectionMgr;
-
-class SALOMEAPP_EXPORT SalomeApp_OBFilter: public OB_Filter
-{
-public:
- SalomeApp_OBFilter( SalomeApp_SelectionMgr* theSelMgr );
- ~SalomeApp_OBFilter();
-
- virtual bool isOk( const SUIT_DataObject* ) const;
-
-private:
- SalomeApp_SelectionMgr* mySelMgr;
-
-};
-
-#endif
+++ /dev/null
-#include "SalomeApp_OBSelector.h"
-
-#include "SalomeApp_DataOwner.h"
-#include "SalomeApp_DataObject.h"
-
-#include <OB_Browser.h>
-
-#include <SUIT_DataObjectIterator.h>
-
-/*!
- Constructor
-*/
-SalomeApp_OBSelector::SalomeApp_OBSelector( OB_Browser* ob, SUIT_SelectionMgr* mgr )
-: SUIT_Selector( mgr, ob ),
- myBrowser( ob )
-{
- if ( myBrowser ) {
- connect( myBrowser, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
- }
-}
-
-/*!
- Destructor
-*/
-SalomeApp_OBSelector::~SalomeApp_OBSelector()
-{
-}
-
-/*!
- Gets browser.
-*/
-OB_Browser* SalomeApp_OBSelector::browser() const
-{
- return myBrowser;
-}
-
-/*!
- Gets selection.
-*/
-void SalomeApp_OBSelector::getSelection( SUIT_DataOwnerPtrList& list ) const
-{
- if ( !myBrowser )
- return;
-
- DataObjectList objlist;
- myBrowser->getSelected( objlist );
- for ( DataObjectListIterator it( objlist ); it.current(); ++it )
- {
- SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>( it.current() );
- if ( obj )
- {
- Handle( SALOME_InteractiveObject ) aSObj = new SALOME_InteractiveObject
- ( obj->entry(), obj->componentDataType(), obj->name() );
- list.append( SUIT_DataOwnerPtr( new SalomeApp_DataOwner( aSObj ) ) );
- }
- }
-}
-
-/*!Sets selection.*/
-void SalomeApp_OBSelector::setSelection( const SUIT_DataOwnerPtrList& list )
-{
- if ( !myBrowser )
- return;
-
- QMap<QString, SalomeApp_DataObject*> map;
- fillEntries( map );
-
- DataObjectList objList;
- for ( SUIT_DataOwnerPtrList::const_iterator it = list.begin(); it != list.end(); ++it )
- {
- const SalomeApp_DataOwner* owner = dynamic_cast<const SalomeApp_DataOwner*>( (*it).operator->() );
- if ( owner && map.contains( owner->entry() ) )
- objList.append( map[owner->entry()] );
- }
-
- myBrowser->setSelected( objList );
-}
-
-/*!On selection changed.*/
-void SalomeApp_OBSelector::onSelectionChanged()
-{
- selectionChanged();
-}
-
-/*!Fill entries.*/
-void SalomeApp_OBSelector::fillEntries( QMap<QString, SalomeApp_DataObject*>& entires )
-{
- entires.clear();
-
- if ( !myBrowser )
- return;
-
- for ( SUIT_DataObjectIterator it( myBrowser->getRootObject(),
- SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it )
- {
- SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>( it.current() );
- if ( obj )
- entires.insert( obj->entry(), obj );
- }
-}
+++ /dev/null
-#ifndef SALOMEAPP_OBSELECTOR_H
-#define SALOMEAPP_OBSELECTOR_H
-
-#include "SalomeApp.h"
-
-#include <SUIT_Selector.h>
-
-class OB_Browser;
-class SalomeApp_DataObject;
-
-class SALOMEAPP_EXPORT SalomeApp_OBSelector : public SUIT_Selector
-{
- Q_OBJECT
-
-public:
- SalomeApp_OBSelector( OB_Browser*, SUIT_SelectionMgr* );
- virtual ~SalomeApp_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, SalomeApp_DataObject*>& );
-
-private:
- OB_Browser* myBrowser;
-};
-
-#endif
+++ /dev/null
-
-#include "SalomeApp_DataOwner.h"
-#include "SalomeApp_OCCSelector.h"
-
-#include <SALOME_InteractiveObject.hxx>
-
-#include <AIS_ListOfInteractive.hxx>
-#include <AIS_ListIteratorOfListOfInteractive.hxx>
-
-/*!
- Constructor
-*/
-SalomeApp_OCCSelector::SalomeApp_OCCSelector( OCCViewer_Viewer* viewer, SUIT_SelectionMgr* mgr )
-: SUIT_Selector( mgr, viewer ),
- myViewer( viewer )
-{
- if ( myViewer )
- connect( myViewer, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
-}
-
-/*!
- Destructor.
-*/
-SalomeApp_OCCSelector::~SalomeApp_OCCSelector()
-{
-}
-
-/*!
- Gets viewer.
-*/
-OCCViewer_Viewer* SalomeApp_OCCSelector::viewer() const
-{
- return myViewer;
-}
-
-/*!On selection changed.*/
-void SalomeApp_OCCSelector::onSelectionChanged()
-{
- selectionChanged();
-}
-
-/*!Gets selection list.*/
-void SalomeApp_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 SalomeApp_DataOwner( anObj ) ) );
- }
-}
-
-/*!Sets selection list.*/
-void SalomeApp_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 SalomeApp_DataOwner* owner = dynamic_cast<const SalomeApp_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 SalomeApp_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 SALOMEAPP_OCCSELECTOR_H
-#define SALOMEAPP_OCCSELECTOR_H
-
-#include "SalomeApp.h"
-
-#include <SUIT_Selector.h>
-
-#include <OCCViewer_ViewModel.h>
-
-class Handle_AIS_InteractiveObject;
-
-class SALOMEAPP_EXPORT SalomeApp_OCCSelector : public SUIT_Selector
-{
- Q_OBJECT
-
-public:
- SalomeApp_OCCSelector( OCCViewer_Viewer*, SUIT_SelectionMgr* );
- virtual ~SalomeApp_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
-// File: SalomeApp_Preferences.cxx
-// Author: Sergey TELKOV
-
-#include "SalomeApp_Preferences.h"
-
-#include <QtxListResourceEdit.h>
-
-#include <qlayout.h>
-
-/*!
- Constructor.Initialize by resource manager and parent QWidget.
-*/
-SalomeApp_Preferences::SalomeApp_Preferences( QtxResourceMgr* resMgr, QWidget* parent )
-: QtxListResourceEdit( resMgr, parent )
-{
-}
-
-/*!
- Destructor.
-*/
-SalomeApp_Preferences::~SalomeApp_Preferences()
-{
-}
-
-/*!
- Adds preference.
-*/
-int SalomeApp_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 SalomeApp_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 SalomeApp_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 SalomeApp_Preferences::onHelp()
-{
-}
-
-/*!Store preferences on apply.*/
-void SalomeApp_Preferences::onApply()
-{
- store();
-}
-
-/*!Emit preference changed.*/
-void SalomeApp_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 SalomeApp_Preferences::module( const int id ) const
-{
- QString mod;
- if ( myPrefMod.contains( id ) )
- mod = myPrefMod[id];
- return mod;
-}
+++ /dev/null
-// File: SalomeApp_Preferences.h
-// Author: Sergey TELKOV
-
-#ifndef SALOMEAPP_PREFERENCES_H
-#define SALOMEAPP_PREFERENCES_H
-
-#include <SalomeApp.h>
-
-#include <QtxDialog.h>
-#include <QtxListResourceEdit.h>
-
-#include <qmap.h>
-
-class QtxResourceMgr;
-
-class SALOMEAPP_EXPORT SalomeApp_Preferences : public QtxListResourceEdit
-{
- Q_OBJECT
-
-public:
- SalomeApp_Preferences( QtxResourceMgr*, QWidget* = 0 );
- virtual ~SalomeApp_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: SalomeApp_PreferencesDlg.cxx
-// Author: Sergey TELKOV
-
-#include "SalomeApp_PreferencesDlg.h"
-
-#include "SalomeApp_Preferences.h"
-
-#include <qvbox.h>
-#include <qlayout.h>
-
-/*!
- Constructor.
-*/
-SalomeApp_PreferencesDlg::SalomeApp_PreferencesDlg( SalomeApp_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.
-*/
-SalomeApp_PreferencesDlg::~SalomeApp_PreferencesDlg()
-{
- if ( !myPrefs )
- return;
-
- myPrefs->reparent( 0, QPoint( 0, 0 ), false );
- myPrefs = 0;
-}
-
-/*!Show dialog.*/
-void SalomeApp_PreferencesDlg::show()
-{
- myPrefs->retrieve();
- myPrefs->toBackup();
-
- QtxDialog::show();
-}
-
-/*!Store preferences on accept.*/
-void SalomeApp_PreferencesDlg::accept()
-{
- QtxDialog::accept();
-
- myPrefs->store();
-}
-
-/*!Reject. Restore preferences from backup.*/
-void SalomeApp_PreferencesDlg::reject()
-{
- QtxDialog::reject();
-
- myPrefs->fromBackup();
-}
-
-/*!Do nothing.*/
-void SalomeApp_PreferencesDlg::onHelp()
-{
-}
-
-/*!Store preferences on apply.*/
-void SalomeApp_PreferencesDlg::onApply()
-{
- myPrefs->store();
-}
+++ /dev/null
-// File: SalomeApp_PreferencesDlg.h
-// Author: Sergey TELKOV
-
-#ifndef SALOMEAPP_PREFERENCESDLG_H
-#define SALOMEAPP_PREFERENCESDLG_H
-
-#include <SalomeApp.h>
-
-#include <QtxDialog.h>
-
-class SalomeApp_Preferences;
-
-/*!Preferences dialog.*/
-class SALOMEAPP_EXPORT SalomeApp_PreferencesDlg : public QtxDialog
-{
- Q_OBJECT
-
-public:
- SalomeApp_PreferencesDlg( SalomeApp_Preferences*, QWidget* = 0 );
- virtual ~SalomeApp_PreferencesDlg();
-
- virtual void show();
- virtual void accept();
- virtual void reject();
-
-private slots:
- void onHelp();
- void onApply();
-
-private:
- SalomeApp_Preferences* myPrefs;
-};
-
-#endif
+++ /dev/null
-#ifndef SALOMEAPP_ROOTOBJECT_H
-#define SALOMEAPP_ROOTOBJECT_H
-
-#include "SalomeApp.h"
-#include "SUIT_DataObject.h"
-
-class SalomeApp_Study;
-
-/*!
- SalomeApp_RootObject - class to be instanciated by only one object -
- root object of SalomeApp 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 SalomeApp_Study object from SalomeApp_DataObject instances.
-*/
-class SALOMEAPP_EXPORT SalomeApp_RootObject : public SUIT_DataObject
-{
-public:
- SalomeApp_RootObject( SalomeApp_Study* study )
- : myStudy( study ) {}
-
- virtual ~SalomeApp_RootObject() {}
-
- void setStudy( SalomeApp_Study* study ) { myStudy = study; }
- SalomeApp_Study* study() const { return myStudy; }
-
-private:
- SalomeApp_Study* myStudy;
-
-};
-
-#endif
+++ /dev/null
-
-#include "SalomeApp_Selection.h"
-
-#include "SalomeApp_SelectionMgr.h"
-#include "SalomeApp_DataOwner.h"
-#include "SalomeApp_Study.h"
-#include "SalomeApp_Application.h"
-
-#include "SUIT_Session.h"
-#include "SUIT_ViewWindow.h"
-
-/*!
- Constructor
-*/
-SalomeApp_Selection::SalomeApp_Selection()
-: myStudy( 0 )
-{
-}
-
-/*!
- Destructor.
-*/
-SalomeApp_Selection::~SalomeApp_Selection()
-{
-}
-
-/*!
- Initializetion.
-*/
-void SalomeApp_Selection::init( const QString& client, SalomeApp_SelectionMgr* mgr)
-{
- myPopupClient = client;
-
- if( mgr )
- {
- if ( mgr->application() )
- myStudy = dynamic_cast<SalomeApp_Study*>( mgr->application()->activeStudy() );
-
- SUIT_DataOwnerPtrList sel;
- mgr->selected( sel, client );
- SUIT_DataOwnerPtrList::const_iterator anIt = sel.begin(), aLast = sel.end();
- for( ; anIt!=aLast; anIt++ )
- {
- SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() );
- SalomeApp_DataOwner* sowner = dynamic_cast<SalomeApp_DataOwner*>( owner );
- if( sowner ) {
- myEntries.append( sowner->entry() );
- processOwner( sowner );
- }
- }
- }
-}
-
-/*!
- Gets count of entries.
-*/
-int SalomeApp_Selection::count() const
-{
- return myEntries.count();
-}
-
-/*!
- Gets QtxValue();
-*/
-QtxValue SalomeApp_Selection::param( const int, const QString& p ) const
-{
- return QtxValue();
-}
-
-/*!
- Gets global parameters. client, isActiveView, activeView etc.
-*/
-QtxValue SalomeApp_Selection::globalParam( const QString& p ) const
-{
- if ( p == "client" ) return QtxValue( myPopupClient );
- 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 SalomeApp_Selection::processOwner( const SalomeApp_DataOwner* )
-{
-}
-
-/*!
- Gets entry with index \a index.
-*/
-QString SalomeApp_Selection::entry( const int index ) const
-{
- if ( index >= 0 && index < count() )
- return myEntries[ index ];
- return QString();
-}
-
-/*!
- Gets type of active view manager.
-*/
-QString SalomeApp_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* SalomeApp_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
-// SalomeApp_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 : SalomeApp_Selection.h
-// Author : Alexander SOLOVYOV
-// Module : GUI
-// $Header$
-
-#ifndef SalomeApp_SELECTION_HeaderFile
-#define SalomeApp_SELECTION_HeaderFile
-
-#include <QtxPopupMgr.h>
-
-#include <SalomeApp.h>
-
-class SalomeApp_SelectionMgr;
-class SalomeApp_DataOwner;
-class SalomeApp_Study;
-class SALOMEDSClient_Study;
-class SUIT_ViewWindow;
-
-
-class SALOMEAPP_EXPORT SalomeApp_Selection : public QtxPopupMgr::Selection
-{
-public:
- SalomeApp_Selection();
- virtual ~SalomeApp_Selection();
-
- virtual void init( const QString&, SalomeApp_SelectionMgr* );
- virtual void processOwner( const SalomeApp_DataOwner* );
-
- virtual int count() const;
- virtual QtxValue param( const int, const QString& ) const;
- virtual QtxValue globalParam( const QString& ) const;
-
-protected:
- QString entry( const int ) const;
- /*!Gets study.*/
- SalomeApp_Study* study() const { return myStudy; }
- QString activeViewType() const;
- SUIT_ViewWindow* activeVW() const;
-
-private:
- QString myPopupClient;
- QStringList myEntries; // entries of selected objects
- SalomeApp_Study* myStudy;
-};
-
-#endif
+++ /dev/null
-#include "SalomeApp_SelectionMgr.h"
-
-#include "SalomeApp_Study.h"
-#include "SalomeApp_DataOwner.h"
-#include "SalomeApp_DataSubOwner.h"
-#include "SalomeApp_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>
-
-#include "SALOMEDSClient.hxx"
-
-/*!
- Constructor.
-*/
-SalomeApp_SelectionMgr::SalomeApp_SelectionMgr( SalomeApp_Application* app, const bool fb )
-: SUIT_SelectionMgr( fb ),
-myApp( app )
-{
-}
-
-/*!
- Destructor.
-*/
-SalomeApp_SelectionMgr::~SalomeApp_SelectionMgr()
-{
-}
-
-/*!
- Gets application.
-*/
-SalomeApp_Application* SalomeApp_SelectionMgr::application() const
-{
- return myApp;
-}
-
-/*!
- Get all selected objects from selection manager
-*/
-void SalomeApp_SelectionMgr::selectedObjects( SALOME_ListIO& theList, const QString& theType ) const
-{
- theList.Clear();
-
- SUIT_DataOwnerPtrList aList;
- selected( aList, theType );
-
- QMap<QString,int> entryMap;
-
- for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr )
- {
- const SalomeApp_DataOwner* owner = dynamic_cast<const SalomeApp_DataOwner*>( (*itr).operator->() );
- if( !owner ) continue;
-
- if ( !entryMap.contains(owner->entry()) )
- theList.Append( owner->IO() );
- entryMap.insert(owner->entry(), 1);
- }
-}
-
-/*!
- Append selected objects.
-*/
-void SalomeApp_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 SalomeApp_DataOwner( it.Value() ) );
- }
-
- setSelected( owners, append );
-}
-
-/*!
- Emit current selection changed.
-*/
-void SalomeApp_SelectionMgr::selectionChanged( SUIT_Selector* theSel )
-{
- SUIT_SelectionMgr::selectionChanged( theSel );
-
- emit currentSelectionChanged();
-}
-
-/*!
- get map of indexes for the given SALOME_InteractiveObject
-*/
-void SalomeApp_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 SalomeApp_DataSubOwner* subOwner = dynamic_cast<const SalomeApp_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 SalomeApp_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 SalomeApp_DataSubOwner* subOwner = dynamic_cast<const SalomeApp_DataSubOwner*>( (*itr).operator->() );
- if ( subOwner )
- if ( subOwner->entry() == theEntry )
- theIndex.Add( subOwner->index() );
- }
-
-}
-
-/*!
- Add or remove interactive objects from selection manager.
-*/
-bool SalomeApp_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 SalomeApp_DataOwner* owner = dynamic_cast<const SalomeApp_DataOwner*>( (*itr).operator->() );
- if ( owner )
- {
- if ( owner->entry() != QString(IObject->getEntry()) )
- {
- const SalomeApp_DataSubOwner* subOwner = dynamic_cast<const SalomeApp_DataSubOwner*>( owner );
- if ( subOwner )
- remainsOwners.append( new SalomeApp_DataSubOwner( subOwner->entry(), subOwner->index() ) );
- else
- remainsOwners.append( new SalomeApp_DataOwner( owner->entry() ) );
- }
- }
- }
- }
- else
- remainsOwners = aList;
-
- TColStd_MapIteratorOfMapOfInteger It;
- It.Initialize(theIndexes);
- for(;It.More();It.Next())
- remainsOwners.append( new SalomeApp_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 SalomeApp_SelectionMgr::selectObjects( const Handle(SALOME_InteractiveObject)& IObject,
- TColStd_IndexedMapOfInteger theIndex, bool append )
-{
- SUIT_DataOwnerPtrList aList;
-
- if ( theIndex.IsEmpty() )
- aList.append( new SalomeApp_DataOwner( QString(IObject->getEntry()) ) );
- else
- {
- int i;
- for ( i = 1; i <= theIndex.Extent(); i++ )
- aList.append( new SalomeApp_DataSubOwner( QString(IObject->getEntry()), theIndex( i ) ) );
- }
-
- setSelected( aList, append );
-
-}
-
-/*!
- select 'subobjects' with given indexes
-*/
-void SalomeApp_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 SalomeApp_DataOwner( QString(it.key()->getEntry()) ) );
- else
- {
- int i;
- for ( i = 1; i <= it.data().Extent(); i++ )
- aList.append( new SalomeApp_DataSubOwner( QString(it.key()->getEntry()), it.data()( i ) ) );
- }
- }
-
- setSelected( aList, append );
-
-}
-
-/*!
- get map of selected subowners : object's entry <-> map of indexes
-*/
-void SalomeApp_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 SalomeApp_DataSubOwner* subOwner = dynamic_cast<const SalomeApp_DataSubOwner*>( (*itr).operator->() );
- if ( subOwner )
- {
- if ( !theMap.contains( subOwner->entry() ) )
- {
- anIndexes.Clear();
- GetIndexes( subOwner->entry(), anIndexes );
- theMap.insert( subOwner->entry(), anIndexes );
- }
- }
- }
-}
+++ /dev/null
-#ifndef SALOMEAPP_SELECTIONMGR_H
-#define SALOMEAPP_SELECTIONMGR_H
-
-#include "SalomeApp.h"
-
-#include <SUIT_SelectionMgr.h>
-#include <SALOME_InteractiveObject.hxx>
-
-#include <qmap.h>
-
-class SALOME_ListIO;
-class SalomeApp_Application;
-class TColStd_IndexedMapOfInteger;
-class TColStd_MapOfInteger;
-
-class SALOMEAPP_EXPORT SalomeApp_SelectionMgr : public SUIT_SelectionMgr
-{
- Q_OBJECT
-
-public:
- SalomeApp_SelectionMgr( SalomeApp_Application*, const bool = true );
- virtual ~SalomeApp_SelectionMgr();
-
- typedef QMap< Handle(SALOME_InteractiveObject), TColStd_IndexedMapOfInteger > MapIOOfMapOfInteger;
- typedef QMap< QString, TColStd_IndexedMapOfInteger > MapEntryOfMapOfInteger;
-
- SalomeApp_Application* application() const;
-
- void selectedObjects( SALOME_ListIO&, const QString& = QString::null ) 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:
- SalomeApp_Application* myApp;
-};
-
-#endif
+++ /dev/null
-#include "SalomeApp_VTKSelector.h"
-#include "SalomeApp_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>
-
-#include "utilities.h"
-
-#ifdef _DEBUG_
-static int MYDEBUG = 1;
-#else
-static int MYDEBUG = 0;
-#endif
-
-/*!
- Constructor.
-*/
-SalomeApp_SVTKDataOwner
-::SalomeApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO,
- const TColStd_IndexedMapOfInteger& theIds,
- Selection_Mode theMode,
- SALOME_Actor* theActor):
- SalomeApp_DataOwner( theIO ),
- mySelectionMode(theMode),
- myActor(theActor)
-{
- myIds = theIds; // workaround - there is no constructor copy for the container
-}
-
-/*!
- Destuctor.
-*/
-SalomeApp_SVTKDataOwner
-::~SalomeApp_SVTKDataOwner()
-{
-}
-
-/*!
- Gets actor pointer.
-*/
-SALOME_Actor*
-SalomeApp_SVTKDataOwner
-::GetActor() const
-{
- return myActor.GetPointer();
-}
-
-/*!
- Constructor.
-*/
-SalomeApp_VTKSelector
-::SalomeApp_VTKSelector( SVTK_Viewer* viewer,
- SUIT_SelectionMgr* mgr ):
- SUIT_Selector( mgr, viewer ),
- myViewer( viewer )
-{
- if ( myViewer )
- connect( myViewer, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
-}
-
-/*!
- Destructor.
-*/
-SalomeApp_VTKSelector
-::~SalomeApp_VTKSelector()
-{
-}
-
-/*!
- Gets viewer.
-*/
-SVTK_Viewer*
-SalomeApp_VTKSelector
-::viewer() const
-{
- return myViewer;
-}
-
-/*!
- Gets type of salome vtk viewer.
-*/
-QString
-SalomeApp_VTKSelector
-::type() const
-{
- return SVTK_Viewer::Type();
-}
-
-/*!
- On selection changed.
-*/
-void
-SalomeApp_VTKSelector
-::onSelectionChanged()
-{
- selectionChanged();
-}
-
-/*!
- Gets list of selected data owners.(output \a aList).
-*/
-void
-SalomeApp_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 SalomeApp_SVTKDataOwner(anIO,anIds,aMode,anActor));
- if(MYDEBUG) MESSAGE("VTKSelector::getSelection - "<<anIO->getEntry());
- }
- }
- }
- }
- }
- }
-}
-
-/*!
- Sets selection to selector from data owner list \a theList.
-*/
-void
-SalomeApp_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 SalomeApp_SVTKDataOwner* anOwner = dynamic_cast<const SalomeApp_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);
- if(MYDEBUG) MESSAGE("VTKSelector::setSelection - SVTKDataOwner - "<<anIO->getEntry());
- }else if(const SalomeApp_DataOwner* anOwner = dynamic_cast<const SalomeApp_DataOwner*>(aDataOwner)){
- Handle(SALOME_InteractiveObject) anIO =
- new SALOME_InteractiveObject(anOwner->entry().latin1(),"");
- aSelector->AddIObject(anIO);
- anAppendList.Append(anIO);
- if(MYDEBUG) MESSAGE("VTKSelector::setSelection - DataOwner - "<<anIO->getEntry());
- }
- }
- // 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 SALOMEAPP_VTKSELECTOR_H
-#define SALOMEAPP_VTKSELECTOR_H
-
-#include <vtkSmartPointer.h>
-
-#include <TColStd_IndexedMapOfInteger.hxx>
-
-#include "SUIT_Selector.h"
-
-#include "SalomeApp.h"
-#include "SalomeApp_DataOwner.h"
-
-#include "SVTK_Selection.h"
-#include "SALOME_InteractiveObject.hxx"
-
-class SALOME_Actor;
-class SVTK_Viewer;
-
-/*!
- Provide salome vtk data owner list.
-*/
-class SalomeApp_SVTKDataOwner : public SalomeApp_DataOwner
-{
- public:
- SalomeApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO,
- const TColStd_IndexedMapOfInteger& theIds,
- Selection_Mode theMode = ActorSelection,
- SALOME_Actor* theActor = NULL);
- virtual ~SalomeApp_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 salome vtk selection of data owners.
-*/
-class SALOMEAPP_EXPORT SalomeApp_VTKSelector : public SUIT_Selector
-{
- Q_OBJECT;
-
-public:
- SalomeApp_VTKSelector( SVTK_Viewer*, SUIT_SelectionMgr* );
- virtual ~SalomeApp_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 "SalomeApp_WidgetContainer.h"
-
-#include <qobjectlist.h>
-#include <qwidgetstack.h>
-
-/*!
- Constructor.
-*/
-SalomeApp_WidgetContainer::SalomeApp_WidgetContainer( const int type, QWidget* parent )
-: QDockWindow( QDockWindow::InDock, parent ),
-myType( type )
-{
- setWidget( myStack = new QWidgetStack( this ) );
- myStack->show();
-}
-
-/*!
- Destructor.
-*/
-SalomeApp_WidgetContainer::~SalomeApp_WidgetContainer()
-{
-}
-
-/*!
- Checks: is widget container is empty?
-*/
-bool SalomeApp_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 SalomeApp_WidgetContainer::type() const
-{
- return myType;
-}
-
-/*!
- Checks: is container contains widget with id \a id.
-*/
-bool SalomeApp_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 SalomeApp_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 from stack by widget \a id.
-*/
-void SalomeApp_WidgetContainer::remove( const int id )
-{
- remove( myStack->widget( id ) );
-
- setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
-}
-
-/*!
- Remove widget(\a wid) from stack.
-*/
-void SalomeApp_WidgetContainer::remove( QWidget* wid )
-{
- myStack->removeWidget( wid );
-
- setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
-}
-
-/*!
- Raise widget with id = \a id.
-*/
-void SalomeApp_WidgetContainer::activate( const int id )
-{
- myStack->raiseWidget( id );
-
- setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
-}
-
-/*!
- Raise widget (\a wid).
-*/
-void SalomeApp_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* SalomeApp_WidgetContainer::widget( const int id ) const
-{
- return myStack->widget( id );
-}
-
-/*!
- Gets visible widget.
-*/
-QWidget* SalomeApp_WidgetContainer::active() const
-{
- return myStack->visibleWidget();
-}
+++ /dev/null
-#ifndef SALOMEAPP_WIDGETCONTAINER_H
-#define SALOMEAPP_WIDGETCONTAINER_H
-
-#include "SalomeApp.h"
-
-#include <qdockwindow.h>
-
-class QWidget;
-class QWidgetStack;
-
-/*!
- Class which privade widget container.
-*/
-class SALOMEAPP_EXPORT SalomeApp_WidgetContainer : public QDockWindow
-{
- Q_OBJECT
-
-public:
- SalomeApp_WidgetContainer( const int, QWidget* = 0 );
- virtual ~SalomeApp_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