#include <SALOME_Event.h>
+#ifdef USE_SALOME_STYLE
#include <Style_Salome.h>
#include <Style_PrefDlg.h>
+#endif // USE_SALOME_STYLE
#include <CAM_Module.h>
#include <CAM_DataModel.h>
#include <SUIT_ViewWindow.h>
#include <Qtx.h>
+#include <QtxFontEdit.h>
#include <QtxToolBar.h>
#include <QtxTreeView.h>
#include <QtxMRUAction.h>
#include <QTreeView>
#include <QMimeData>
#include <QShortcut>
+#include <QRegExp>
#include <utilities.h>
//since the 'toolbar marker' is not unique, find index of first occurrence of the
//'toolbar marker' in the array and check that next string is name of the toolbar
-int getToolbarMarkerIndex(QByteArray input, const QStringList& aFlags) {
- int aResult = -1,tmp = 0;
- int inputLen = input.length();
- QDataStream anInputData(&input, QIODevice::ReadOnly);
- while(tmp < inputLen) {
- tmp = input.indexOf(QToolBarMarker, tmp + 1);
- if(tmp < 0 )
- break;
- anInputData.device()->seek(tmp);
+void LightAppCleanUpAppResources()
+{
+ if ( LightApp_Application::_prefs_ ) {
+ delete LightApp_Application::_prefs_;
+ LightApp_Application::_prefs_ = 0;
+ }
+}
+
+namespace
+{
+ int getToolbarMarkerIndex( QByteArray input, const QStringList& aFlags ) {
+ int aResult = -1,tmp = 0;
+ int inputLen = input.length();
+ QDataStream anInputData( &input, QIODevice::ReadOnly );
+ while ( tmp < inputLen ) {
+ tmp = input.indexOf( QToolBarMarker, tmp + 1 );
+ if ( tmp < 0 )
+ break;
+ anInputData.device()->seek( tmp );
uchar mark;
- anInputData>>mark;
+ anInputData >> mark;
int lines;
anInputData >> lines;
- if(lines == 0 && anInputData.atEnd()){
- //Case then array doesn't contain information about toolbars,
- aResult = tmp;
- break;
+ if ( lines == 0 && anInputData.atEnd() ) {
+ //Case then array doesn't contain information about toolbars,
+ aResult = tmp;
+ break;
}
int pos;
int cnt;
anInputData >> cnt;
QString str;
- anInputData>>str;
- if(aFlags.contains(str)) {
- aResult = tmp;
- break;
+ anInputData >> str;
+ if ( aFlags.contains( str ) ) {
+ aResult = tmp;
+ break;
}
- }
- return aResult;
+ }
+ return aResult;
+ }
+
+ QString langToName( const QString& lang )
+ {
+ // special processing for English language to avoid such result as "American English"
+ // as Qt cannot just say "English"
+ QString result;
+ if ( lang == "en" )
+ result = "English";
+ else
+ result = QLocale( lang ).nativeLanguageName();
+ return result;
+ }
}
/*!
*/
LightApp_Application::~LightApp_Application()
{
+ savePreferences();
delete mySelMgr;
delete myScreenHelper;
+ myPrefs = 0;
}
/*!Start application.*/
/*!Closeapplication.*/
void LightApp_Application::closeApplication()
{
+#ifndef DISABLE_QTXWEBBROWSER
QProcess::startDetached( "HelpBrowser",
QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) );
-
+#endif
CAM_Application::closeApplication();
}
// Preferences
createAction( PreferencesId, tr( "TOT_DESK_PREFERENCES" ), QIcon(),
tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
- Qt::CTRL+Qt::Key_R, desk, false, this, SLOT( onPreferences() ) );
-
- // Help menu:
+ Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onPreferences() ) );
- // - Help for modules
+ // Help menu
int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
- createMenu( separator(), helpMenu, -1, 10 );
+
+ int id = LightApp_Application::UserID + FIRST_HELP_ID;
+
+ // a) Link to web site
+ QString url = resMgr->stringValue("GUI", "site_url");
+ if ( !url.isEmpty() ) {
+ QString title = tr ( "SALOME_SITE" );
+ QAction* as = createAction( id, title,
+ resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
+ title, title,
+ 0, desk, false, this, SLOT( onHelpOnline() ) );
+ as->setData( url );
+ createMenu( as, helpMenu, -1, 0 );
+ id++;
+ }
+
+ // b) Link to Forum
+ url = resMgr->stringValue("GUI", "forum_url");
+ if ( !url.isEmpty() ) {
+ QString title = tr ( "SALOME_FORUM" );
+ QAction* af = createAction( helpMenu, title,
+ resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
+ title, title,
+ 0, desk, false, this, SLOT( onHelpOnline() ) );
+ af->setData( url );
+ createMenu( af, helpMenu, -1, 0 );
+ id++;
+ }
+
+ // c) Link to YouTube channel
+ url = resMgr->stringValue("GUI", "channel_url");
+ if ( !url.isEmpty() ) {
+ createMenu( separator(), helpMenu, -1, 0 );
+ QString title = tr ( "SALOME_VIDEO_TUTORIALS" );
+ QAction* av = createAction( helpMenu, title,
+ resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ),
+ title, title,
+ 0, desk, false, this, SLOT( onHelpOnline() ) );
+ av->setData( url );
+ createMenu( av, helpMenu, -1, 0 );
+ id++;
+ }
+
+ // d) Help for modules
+
+ // - First create top-level menus to preserve correct order
+ QString userGuide = "User's Guide";
+ QString devGuide = "Developer's Guide";
+ createMenu( userGuide, helpMenu, -1, 5 );
+ createMenu( devGuide, helpMenu, -1, 5 );
+
QStringList aModuleList;
modules( aModuleList, false );
aModuleList.prepend( "GUI" );
aModuleList.prepend( "KERNEL" );
- int id = LightApp_Application::UserID + FIRST_HELP_ID;
-
QString aModule;
foreach( aModule, aModuleList ) {
if ( aModule.isEmpty() ) // module title (user name)
QString helpSubMenu; // help submenu name (empty if not needed)
QString modName = moduleName( aModule ); // module name
if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
- QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
- QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
+ QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir env variable
+ QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir path
QString docSection;
if (resMgr->hasValue( modName, "documentation" ) )
docSection = resMgr->stringValue(modName, "documentation");
helpFileName.replace( "//", "" );
// obtain submenus hierarchy if given
QStringList smenus = helpFileName.split( "/" );
- helpFileName = smenus.last();
- smenus.removeLast();
+ helpFileName = smenus.takeLast();
+ // workaround for User's Guide and Developer's Guide to avoid having single item in module's submenu.
+ if ( helpFileName == userGuide || helpFileName == devGuide ) {
+ QString menuPath = smenus.join( "/" );
+ QStringList allKeys = helpData.keys();
+ QStringList total = allKeys.filter( QRegExp( QString( "^%1" ).arg( menuPath ) ) );
+ if ( total.count() == 1 && smenus.count() > 0 )
+ helpFileName = smenus.takeLast();
+ }
QAction* a = createAction( id, helpFileName,
resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
helpFileName, helpFileName,
}
// create sub-menus hierarchy
int menuId = helpMenu;
- foreach ( QString subMenu, smenus ) {
- menuId = createMenu( subMenu, menuId, -1, 0 );
- }
- createMenu( a, menuId, -1, 0 );
+ foreach ( QString subMenu, smenus )
+ menuId = createMenu( subMenu, menuId, -1, 5 );
+ createMenu( a, menuId, -1, ( menuId != helpMenu && (helpFileName == userGuide || helpFileName == devGuide) ) ? 0 : 5 );
id++;
}
}
// - Additional help items
- createMenu( separator(), helpMenu, -1, 5 );
+ createMenu( separator(), helpMenu, -1, 10 );
QStringList addHelpItems = resMgr->parameters( "add_help" );
foreach ( QString addHelpItem, addHelpItems ) {
addHelpItem, addHelpItem,
0, desk, false, this, SLOT( onHelpContentsModule() ) );
a->setData( valueStr );
- createMenu( a, helpMenu, -1, 5 );
+ createMenu( a, helpMenu, -1, 10 );
id++;
}
}
QStringList::Iterator it;
for ( it = modList.begin(); it != modList.end(); ++it )
{
- if ( !isLibExists( *it ) )
+ if ( !isModuleAccessible( *it ) )
continue;
QString modName = moduleName( *it );
- if ( !isModuleAccessible( *it ) )
- continue;
-
QString iconName;
if ( iconMap.contains( *it ) )
iconName = iconMap[*it];
if ( icon.isNull() )
{
icon = modIcon;
- INFOS ( "\n****************************************************************" << std::endl
- << "* Icon for " << (*it).toLatin1().constData()
- << " not found. Using the default one." << std::endl
- << "****************************************************************" << std::endl );
+ INFOS( std::endl <<
+ "****************************************************************" << std::endl <<
+ " Warning: icon for " << qPrintable(*it) << " is not found!" << std::endl <<
+ " Using the default icon." << std::endl <<
+ "****************************************************************" << std::endl);
}
-
icon = Qtx::scaleIcon( icon, iconSize );
moduleAction->insertModule( *it, icon );
createMenu( MRUId, fileMenu, 100, -1 );
createMenu( separator(), fileMenu, -1, 100, -1 );
+#ifdef USE_SALOME_STYLE
createAction( StyleId, tr( "TOT_THEME" ), QIcon(), tr( "MEN_DESK_THEME" ), tr( "PRP_THEME" ),
0, desk, false, this, SLOT( onStylePreferences() ) );
+#endif // USE_SALOME_STYLE
createAction( FullScreenId, tr( "TOT_FULLSCREEN" ), QIcon(), tr( "MEN_DESK_FULLSCREEN" ), tr( "PRP_FULLSCREEN" ),
Qt::Key_F11, desk, false, this, SLOT( onFullScreen() ) );
int viewMenu = createMenu( tr( "MEN_DESK_VIEW" ), -1 );
createMenu( separator(), viewMenu, -1, 20, -1 );
+#ifdef USE_SALOME_STYLE
createMenu( StyleId, viewMenu, 20, -1 );
+#endif // USE_SALOME_STYLE
createMenu( FullScreenId, viewMenu, 20, -1 );
int modTBar = createTool( tr( "INF_TOOLBAR_MODULES" ), // title (language-dependant)
- QString( "SalomeModules" ) ); // name (language-independant)
+ QString( "SalomeModules" ) ); // name (language-independant)
createTool( ModulesListId, modTBar );
}
*/
void LightApp_Application::onSelection()
{
+ //MESSAGE("onSelection")
onSelectionChanged();
if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) )
const QString& theApp,
const QString& theParams,
const QString& theHelpFile,
- const QString& theContext = QString() )
+ const QString& theContext = QString(),
+ //For the external browser always specify 'file://' protocol,
+ //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
+ const QString& theProtocol = QString("file://"),
+ const bool isFile = true)
: myApp( theApp ),
myParams( theParams ),
myContext( theContext ),
myStatus(0),
myLApp( app )
{
- //For the external browser always specify 'file://' protocol,
- //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
- myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
+ QString path_begin = theProtocol+"%1";
+ QString path_end = theHelpFile;
+ if( isFile ) {
+ path_end = QFileInfo( theHelpFile ).canonicalFilePath();
+ }
+ myHelpFile = path_begin.arg( path_end );
}
virtual void run()
anApp.append( quote );
#endif
QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
+#if DISABLE_QTXWEBBROWSER
+ bool useExtBrowser = true;
+#else
bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
-
+#endif
+
if( useExtBrowser ) {
if ( !anApp.isEmpty() ) {
RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile );
anApp.append( quote );
#endif
+#if DISABLE_QTXWEBBROWSER
+ bool useExtBrowser = true;
+#else
bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
+#endif
if(useExtBrowser) {
QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
}
}
+/*!
+ SLOT: Displays help contents for choosen module
+*/
+void LightApp_Application::onHelpOnline()
+{
+ const QAction* a = (QAction*) sender();
+ QString url = a->data().toString();
+ if ( url.isEmpty() ) return;
+
+ SUIT_ResourceMgr* resMgr = resourceMgr();
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ QString anApp = resMgr->stringValue("ExternalBrowser", platform);
+#ifdef WIN32
+ QString quote("\"");
+ anApp.prepend( quote );
+ anApp.append( quote );
+#endif
+ QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
+#if DISABLE_QTXWEBBROWSER
+ bool useExtBrowser = true;
+#else
+ bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
+#endif
+
+ if( useExtBrowser ) {
+ if ( !anApp.isEmpty() ) {
+ RunBrowser* rs = new RunBrowser( this, anApp, aParams, url, "", "http://", false );
+ rs->start();
+ }
+ else {
+ if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
+
+ showPreferences( tr( "PREF_APP" ) );
+ }
+ }
+ else {
+ QStringList parameters;
+ parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
+ parameters << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
+ parameters << "http://" + url;
+ QProcess::startDetached( "HelpBrowser", parameters );
+ }
+}
+
/*!
Sets enable or disable some actions on selection changed.
*/
connect( dock, SIGNAL( destroyed( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) );
dock->setFeatures( QDockWidget::AllDockWidgetFeatures );
- dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) :
- QString( "%1Dock" ).arg( wid->objectName() ) );
+ dock->setObjectName( wid->objectName().isEmpty() ? QString( "window_%1" ).arg( id ) :
+ QString( "%1Dock" ).arg( wid->objectName() ) );
dock->setWidget( wid );
dock->toggleViewAction()->setData( QVariant( wid->objectName() ) );
connect( dock->toggleViewAction(), SIGNAL( triggered( bool ) ),
{
SUIT_ViewManager* aVM = viewManager( vmType );
SUIT_ViewManager* anActiveVM = CAM_Application::activeViewManager();
-
+ MESSAGE("vmType: " << vmType.toStdString() << " aVM: " << aVM << " anActiveVM: " << anActiveVM );
if ( anActiveVM && anActiveVM->getType() == vmType )
- aVM = anActiveVM;
+ {
+ MESSAGE("aVM = anActiveVM");
+ aVM = anActiveVM;
+ }
- if ( aVM && create )
+ if ( aVM && !aVM->getDetached() && create )
{
if ( !aVM->getActiveView() )
- aVM->createView();
+ {
+ MESSAGE("aVM->createView()");
+ aVM->createView();
+ }
else
- desktop()->setActiveWindow( aVM->getActiveView() );
+ {
+ MESSAGE("desktop()->setActiveWindow: " << aVM->getActiveView());
+ desktop()->setActiveWindow( aVM->getActiveView() );
+ }
}
else if ( create )
- aVM = createViewManager( vmType );
+ {
+ MESSAGE("aVM = createViewManager( vmType )");
+ aVM = createViewManager( vmType );
+ }
return aVM;
}
Creates view manager of some type
\param vmType - type of view manager
*/
-SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType )
+SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType, bool detached )
{
SUIT_ResourceMgr* resMgr = resourceMgr();
#ifndef DISABLE_PVVIEWER
if( vmType == PVViewer_Viewer::Type() )
{
- if ( viewMgr = dynamic_cast<PVViewer_ViewManager*>( getViewManager( vmType, false ) ) ) {
+ if (( viewMgr = dynamic_cast<PVViewer_ViewManager*>( getViewManager( vmType, false )))) {
viewMgr->getActiveView()->setFocus();
return 0;
} else {
resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ));
vm->setInteractionStyle( resMgr->integerValue( "3DViewer", "navigation_mode", vm->interactionStyle() ) );
vm->setProjectionType( resMgr->integerValue( "OCCViewer", "projection_mode", vm->projectionType() ) );
- #if OCC_VERSION_LARGE > 0x06090000
vm->setStereoType( resMgr->integerValue( "OCCViewer", "stereo_type", vm->stereoType() ) );
vm->setAnaglyphFilter( resMgr->integerValue( "OCCViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
vm->setStereographicFocus( resMgr->integerValue( "OCCViewer", "focus_type", vm->stereographicFocusType() ),
vm->setReverseStereo( resMgr->booleanValue( "OCCViewer", "reverse_stereo", vm->isReverseStereo() ) );
vm->setVSync( resMgr->booleanValue( "OCCViewer", "enable_vsync", vm->isVSync() ) );
vm->setQuadBufferSupport( resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) );
- #endif
vm->setZoomingStyle( resMgr->integerValue( "3DViewer", "zooming_mode", vm->zoomingStyle() ) );
vm->enablePreselection( resMgr->booleanValue( "OCCViewer", "enable_preselection", vm->isPreselectionEnabled() ) );
vm->enableSelection( resMgr->booleanValue( "OCCViewer", "enable_selection", vm->isSelectionEnabled() ) );
if ( !viewMgr )
return 0;
+ viewMgr->setDetached(detached);
addViewManager( viewMgr );
SUIT_ViewWindow* viewWin = viewMgr->createViewWindow();
{
QtxMRUAction* mru = ::qobject_cast<QtxMRUAction*>( action( MRUId ) );
if ( mru && s )
- mru->insert( s->studyName() );
+ mru->insert( s->studyName() );
emit studySaved();
}
{
/*
disconnect( this, SIGNAL( viewManagerRemoved( SUIT_ViewManager* ) ),
- this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
+ this, SLOT( onViewManagerRemoved( SUIT_ViewManager* ) ) );
*/
// stop auto-save timer
}
/*!Gets file filter.
- *\retval QString "(*.bin)"
+ *\retval QString "(*.hdf)"
*/
-QString LightApp_Application::getFileFilter() const
+QString LightApp_Application::getFileFilter( bool /*open*/) const
{
- //return "(*.bin)";
- // HDF persistence
return "(*.hdf)";
}
// Create OBSelector
new LightApp_OBSelector( ob, mySelMgr );
-
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
+#else
+ ob->treeView()->header()->setSectionResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
+#endif
ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
{
_prefs_ = new LightApp_Preferences( resourceMgr() );
that->createPreferences( _prefs_ );
+ qAddPostRoutine( LightAppCleanUpAppResources );
}
that->myPrefs = _prefs_;
for ( QStringList::const_iterator it = modNameList.begin(); it != modNameList.end(); ++it )
{
- if ( !app->isLibExists( *it ) || _prefs_->hasModule( *it ) )
+ if ( !app->isModuleAccessible( *it ) || _prefs_->hasModule( *it ) )
continue;
int modId = _prefs_->addPreference( *it );
LightApp_Preferences::Selector, "language", "language" );
QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," );
QList<QVariant> aIcons;
+ QList<QVariant> aNumbers;
+ QStringList aTitles;
foreach ( QString aLang, aLangs ) {
aIcons << QPixmap( QString( ":/images/%1" ).arg( aLang ) );
+ aNumbers << aLang;
+ aTitles << langToName( aLang );
}
- pref->setItemProperty( "strings", aLangs, curLang );
+ pref->setItemProperty( "strings", aTitles, curLang );
+ pref->setItemProperty( "ids", aNumbers, curLang );
pref->setItemProperty( "icons", aIcons, curLang );
pref->setItemProperty( "restart", true, curLang );
// ... "Study properties" group <<end>>
// ... "Help browser" group <<start>>
+#ifndef DISABLE_QTXWEBBROWSER
int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab, LightApp_Preferences::Auto, "ExternalBrowser", "use_external_browser");
+#else
+ int extgroup = pref->addPreference( tr( "PREF_GROUP_EXT_BROWSER" ), genTab );
+#endif
+
#ifdef WIN32
QString platform = "winapplication";
#else
pref->setItemProperty( "columns", 2, fullScreenGroup );
// .... -> automatic hiding toolbars
pref->addPreference( tr( "PREF_FULL_SCREEN_AUTO" ), fullScreenGroup,
- LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" );
+ LightApp_Preferences::Bool, "OCCViewer", "automatic_hiding" );
// ... "Full-screen" group <<end>>
// .. "General" preferences tab <<end>>
anIndicesList << 0 << 1;
pref->setItemProperty( "strings", aValuesList, occProjMode );
pref->setItemProperty( "indexes", anIndicesList, occProjMode );
-#if OCC_VERSION_LARGE > 0x06090000
+
// .... -> Stereo group
int stereoGroup = pref->addPreference( tr( "PREF_GROUP_STEREO" ), occGroup);
pref->setItemProperty( "columns", 2, stereoGroup );
// .... -> Reverse stereo
pref->addPreference( tr( "PREF_REVERSE_STEREO" ), stereoGroup,
- LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" );
+ LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" );
// .... -> Enable V-Sync
pref->addPreference( tr( "PREF_ENABLE_VSYNC" ), stereoGroup,
- LightApp_Preferences::Bool, "OCCViewer", "enable_vsync" );
+ LightApp_Preferences::Bool, "OCCViewer", "enable_vsync" );
// .... -> Enable quad-buffer support
pref->addPreference( tr( "PREF_ENABLE_QUAD_BUFFER_SUPPORT" ), stereoGroup,
- LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" );
-#endif
+ LightApp_Preferences::Bool, "OCCViewer", "enable_quad_buffer_support" );
+
// ... "Background" group <<start>>
int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup );
// pref->setItemProperty( "columns", 2, bgGroup );
int occSelectionGroup = pref->addPreference( tr( "PREF_GROUP_SELECTION" ), occGroup );
pref->setItemProperty( "columns", 2, occSelectionGroup );
// .... -> enable preselection
- pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
- LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
+ pref->addPreference( tr( "PREF_ENABLE_PRESELECTION" ), occSelectionGroup,
+ LightApp_Preferences::Bool, "OCCViewer", "enable_preselection" );
// .... -> enable selection
- pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
- LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
+ pref->addPreference( tr( "PREF_ENABLE_SELECTION" ), occSelectionGroup,
+ LightApp_Preferences::Bool, "OCCViewer", "enable_selection" );
// ... "Selection" group <<end>>
// ... "Clipping" group <<start>>
int occClippingGroup = pref->addPreference( tr( "PREF_GROUP_CLIPPING" ), occGroup );
// .... -> clipping color
pref->addPreference( tr( "PREF_CLIPPING_COLOR" ), occClippingGroup,
- LightApp_Preferences::Color, "OCCViewer", "clipping_color" );
+ LightApp_Preferences::Color, "OCCViewer", "clipping_color" );
int texturePref = pref->addPreference( "", occClippingGroup, LightApp_Preferences::Frame );
pref->setItemProperty( "columns", 2, texturePref );
// .... -> use default texture
int pyeditTab = pref->addPreference( tr( "PREF_TAB_PYEDITOR" ), salomeCat );
// ... "Font settings" group <<start>>
int pyFontGroup = pref->addPreference( tr( "PREF_GROUP_PY_FONT" ), pyeditTab );
- pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup,
- LightApp_Preferences::Font, "PyEditor", "Font" );
+ int pyFont = pref->addPreference( tr( "PREF_PY_FONT" ), pyFontGroup,
+ LightApp_Preferences::Font, "PyEditor", "Font" );
+ pref->setItemProperty( "features", QtxFontEdit::Family | QtxFontEdit::Size | QtxFontEdit::UserSize, pyFont );
// ... "Font settings" group <<end>>
// ... "Display settings" group <<start>>
int pyDispGroup = pref->addPreference( tr( "PREF_GROUP_PY_DISPLAY" ), pyeditTab );
pref->addPreference( tr( "PREF_PY_LINE_NUMBS_AREA" ), pyDispGroup,
LightApp_Preferences::Bool, "PyEditor", "LineNumberArea" );
// ... "Display settings" group <<end>>
+
+ // ... "Editor settings" group <<start>>
+ int pyEditGroup = pref->addPreference( tr( "PREF_GROUP_PY_EDITOR" ), pyeditTab );
+ // ... -> navigation mode
+ int pyCompletion = pref->addPreference( tr( "PREF_PY_COMPLETION_MODE" ), pyEditGroup,
+ LightApp_Preferences::Selector, "PyEditor", "CompletionPolicy" );
+ aValuesList.clear();
+ anIndicesList.clear();
+ aValuesList << tr("PREF_PY_NONE") << tr("PREF_PY_AUTO") << tr("PREF_PY_MANUAL") << tr("PREF_PY_ALWAYS");
+ anIndicesList << 0 << 1 << 2 << 3 ;
+ pref->setItemProperty( "strings", aValuesList, pyCompletion );
+ pref->setItemProperty( "indexes", anIndicesList, pyCompletion );
+ // ... "Editor settings" group <<end>>
+
// ... "Tab settings" group <<start>>
int pyTabGroup = pref->addPreference( tr( "PREF_GROUP_PY_TAB" ), pyeditTab );
pref->setItemProperty( "columns", 2, pyTabGroup );
}
}
#endif
-#if OCC_VERSION_LARGE > 0x06090000
+
#ifndef DISABLE_OCCVIEWER
if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) )
{
}
}
#endif
-#endif
+
if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) )
{
int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 );
}
if ( sec == "desktop" && param == "opaque_resize" ) {
bool opaqueResize = resMgr->booleanValue( "desktop", "opaque_resize", false );
- QMainWindow::DockOptions dopts = desktop()->dockOptions();
- if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
- else dopts &= ~QMainWindow::AnimatedDocks;
- desktop()->setDockOptions( dopts );
+ // RNV: This code has been commented, because clearing of the QMainWindow::AnimatedDocks option
+ // leads to strange behaviour of the dockable windows (at least at qt-5.6.1):
+ // any dockable window can't be docked to the another area, except initial area.
+ // It is possible to move window to another area, but it always returns to the initial area.
+ //
+ // QMainWindow::DockOptions dopts = desktop()->dockOptions();
+ // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
+ // else dopts &= ~QMainWindow::AnimatedDocks;
+ // desktop()->setDockOptions( dopts );
desktop()->setOpaqueResize( opaqueResize );
if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
if ( !vm || !vm->inherits( "Plot2d_Viewer" ) )
continue;
- Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
+ //Plot2d_Viewer* Plot2dVM = dynamic_cast<Plot2d_Viewer*>( vm );
viewMgr->setViewModel( vm );
Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( viewMgr->getActiveView() );
}
}
#endif
-
-#ifndef DISABLE_PYVIEWER
- if ( sec == QString( "PyViewer" ) && ( param == QString( "HighlightCurrentLine" ) ||
- param == QString( "LineNumberArea" ) ||
- param == QString( "TextWrapping" ) ||
- param == QString( "CenterCursorOnScroll" ) ||
- param == QString( "TabSpaceVisible" ) ||
- param == QString( "TabSize" ) ||
- param == QString( "VerticalEdge" ) ||
- param == QString( "NumberColumns" ) ||
- param == QString( "Font" ) ) )
- {
- QList<SUIT_ViewManager*> lst;
- viewManagers( PyViewer_Viewer::Type(), lst );
- QListIterator<SUIT_ViewManager*> itPy( lst );
- while ( itPy.hasNext() )
- {
- SUIT_ViewManager* viewMgr = itPy.next();
- SUIT_ViewModel* vm = viewMgr->getViewModel();
- if ( !vm || !vm->inherits( "PyViewer_Viewer" ) )
- continue;
-
- PyViewer_Viewer* pyEditVM = dynamic_cast<PyViewer_Viewer*>( vm );
-
- viewMgr->setViewModel( vm );
- PyViewer_ViewWindow* pyView = dynamic_cast<PyViewer_ViewWindow*>( viewMgr->getActiveView() );
- if( pyView )
- {
- pyView->setPreferences();
- }
- }
- }
-#endif
}
/*!
if ( desktop() ) {
desktop()->retrieveGeometry( aResMgr->stringValue( "desktop", "geometry" ) );
bool opaqueResize = aResMgr->booleanValue( "desktop", "opaque_resize", false );
- QMainWindow::DockOptions dopts = desktop()->dockOptions();
- if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
- else dopts &= ~QMainWindow::AnimatedDocks;
- desktop()->setDockOptions( dopts );
+ // QMainWindow::DockOptions dopts = desktop()->dockOptions();
+ // if ( opaqueResize ) dopts |= QMainWindow::AnimatedDocks;
+ // else dopts &= ~QMainWindow::AnimatedDocks;
+ // desktop()->setDockOptions( dopts );
desktop()->setOpaqueResize( opaqueResize );
if ( dynamic_cast<STD_TabDesktop*>( desktop() ) )
dynamic_cast<STD_TabDesktop*>( desktop() )->workstack()->setOpaqueResize( opaqueResize );
moduleAction->removeModule( modName );
}
+bool LightApp_Application::checkModule( const QString& title )
+{
+ if ( title.isEmpty() )
+ return false;
+
+ QString library = moduleLibrary( title, true );
+ if ( library.isEmpty() )
+ return false;
+
+ QString name = moduleName( title );
+
+ bool isPyModule = library.contains( "SalomePyQtGUI" ) || library.contains( "SalomePyQtGUILight" );
+
+ QStringList paths;
+#if defined(WIN32)
+ paths = QString( ::getenv( "PATH" ) ).split( ";", QString::SkipEmptyParts );
+#elif defined(__APPLE__)
+ paths = QString( ::getenv( "DYLD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
+#else
+ paths = QString( ::getenv( "LD_LIBRARY_PATH" ) ).split( ":", QString::SkipEmptyParts );
+#endif
+
+ bool isFound = false;
+ QStringList::const_iterator it;
+ for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
+ {
+ isFound = QFileInfo( Qtx::addSlash( *it ) + library ).exists();
+ }
+
+ if ( !isFound )
+ {
+ INFOS( std::endl <<
+ "****************************************************************" << std::endl <<
+ " Warning: library " << qPrintable( library ) << " is not found!" << std::endl <<
+ " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
+ "****************************************************************" << std::endl);
+ return false;
+ }
+
+ if ( isPyModule )
+ {
+ QString pyModule = QString( "%1GUI.py" ).arg( name );
+ paths = QString( ::getenv( "PYTHONPATH" ) ).split( ":", QString::SkipEmptyParts );
+
+ isFound = false;
+ for ( it = paths.begin(); it != paths.end() && !isFound; ++it )
+ {
+ isFound = QFileInfo( Qtx::addSlash( *it ) + pyModule ).exists();
+ }
+
+ if ( !isFound )
+ {
+ INFOS( std::endl <<
+ "****************************************************************" << std::endl <<
+ " Warning: Python module " << qPrintable( pyModule ) << " is not found!" << std::endl <<
+ " Module " << qPrintable( title ) << " will not be available in GUI mode!" << std::endl <<
+ "****************************************************************" << std::endl);
+ return false;
+ }
+ }
+
+ return true;
+}
+
/*!
Gets current windows.
\param winMap - output current windows map.
if(tbMap) {
QList<QToolBar*> tbList = findToolBars();
for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit )
- {
- QToolBar* tb = *tit;
- if ( tbMap->contains( tb->objectName() ) ) {
- tb->setVisible( (*tbMap)[tb->objectName()] );
- }
+ {
+ QToolBar* tb = *tit;
+ if ( tbMap->contains( tb->objectName() ) ) {
+ tb->setVisible( (*tbMap)[tb->objectName()] );
+ }
}
}
QList<QDockWidget*> dwList = desktop()->findChildren<QDockWidget*>();
for ( QList<QDockWidget*>::iterator dit = dwList.begin(); dit != dwList.end(); ++dit )
{
- QDockWidget* dw = *dit;
-
- QObject* po = Qtx::findParent( dw, "QMainWindow" );
- if ( po != desktop() )
- continue;
-
- if ( dwMap->contains( dw->objectName() ) )
- dw->setVisible( (*dwMap)[dw->objectName()] );
+ QDockWidget* dw = *dit;
+
+ QObject* po = Qtx::findParent( dw, "QMainWindow" );
+ if ( po != desktop() )
+ continue;
+
+ if ( dwMap->contains( dw->objectName() ) )
+ dw->setVisible( (*dwMap)[dw->objectName()] );
}
}
*/
void LightApp_Application::onStylePreferences()
{
+#ifdef USE_SALOME_STYLE
Style_PrefDlg dlg( desktop() );
dlg.exec();
resourceMgr()->setValue( "Style", "use_salome_style", Style_Salome::isActive() );
+#endif // USE_SALOME_STYLE
}
void LightApp_Application::onFullScreen(){
wgStack->stack();
}
-/*!
- \return if the library of module exists
- \param moduleTitle - title of module
-*/
-bool LightApp_Application::isLibExists( const QString& moduleTitle ) const
-{
- if( moduleTitle.isEmpty() )
- return false;
-
- QString lib = moduleLibrary( moduleTitle );
-
- //abd: changed libSalomePyQtGUI to SalomePyQtGUI for WIN32
- bool isPythonModule = lib.contains("SalomePyQtGUI");
- bool isPythonLightModule = lib.contains("SalomePyQtGUILight");
-
- QStringList paths;
-#ifdef WIN32
- paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
-#else
- paths = QString(::getenv( "LD_LIBRARY_PATH" )).split( ":", QString::SkipEmptyParts );
-#endif
-
- bool isLibFound = false;
- QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
- for( ; anIt!=aLast; anIt++ )
- {
- QFileInfo inf( Qtx::addSlash( *anIt ) + lib );
-
- if( inf.exists() )
- {
- isLibFound = true;
- break;
- }
- }
-
- if ( !isLibFound )
- {
- INFOS( "\n****************************************************************" << std::endl
- << "* Warning: library " << lib.toLatin1().constData() << " cannot be found" << std::endl
- << "* Module " << moduleTitle.toLatin1().constData() << " will not be available in GUI mode" << std::endl
- << "****************************************************************" << std::endl );
- }
- else if ( !isPythonModule && !isPythonLightModule)
- return true;
-
- if ( isPythonModule || isPythonLightModule)
- {
- QString pylib = moduleName( moduleTitle ) + QString(".py");
- QString pylibgui = moduleName( moduleTitle ) + QString("GUI.py");
-
- // Check the python library
-// #ifdef WIN32
-// paths = QString(::getenv( "PATH" )).split( ";", QString::SkipEmptyParts );
-// #else
- paths = QString(::getenv( "PYTHONPATH" )).split( ":", QString::SkipEmptyParts );
-// #endif
- bool isPyLib = false, isPyGuiLib = false;
- QStringList::const_iterator anIt = paths.begin(), aLast = paths.end();
- for( ; anIt!=aLast; anIt++ )
- {
- QFileInfo inf( Qtx::addSlash( *anIt ) + pylib );
- QFileInfo infgui( Qtx::addSlash( *anIt ) + pylibgui );
-
- if(!isPythonLightModule)
- if( !isPyLib && inf.exists() )
- isPyLib = true;
-
- if( !isPyGuiLib && infgui.exists() )
- isPyGuiLib = true;
-
- if ((isPyLib || isPythonLightModule ) && isPyGuiLib && isLibFound)
- return true;
- }
-
- printf( "\n****************************************************************\n" );
- printf( "* Warning: python library for %s cannot be found:\n", moduleTitle.toLatin1().constData() );
- if (!isPyLib)
- printf( "* No module named %s\n", moduleName( moduleTitle ).toLatin1().constData() );
- if (!isPyGuiLib)
- printf( "* No module named %s\n", (moduleName( moduleTitle ) + QString("GUI")).toLatin1().constData() );
- printf( "****************************************************************\n" );
- return true;
- }
- return false;
-}
-
/*!
\return default name for an active study
*/
QList<QToolBar*> aResult;
QList<QToolBar*> tbList = desktop()->findChildren<QToolBar*>();
for ( QList<QToolBar*>::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) {
- QToolBar* tb = *tit;
+ QToolBar* tb = *tit;
QObject* po = Qtx::findParent( tb, "QMainWindow" );
if ( po != desktop() )
- continue;
+ continue;
if ( names.isEmpty() || names.contains( tb->objectName() ) )
aResult.append(tb);
}
/*!
Internal method to parse toolbars and dockable windows state.
- */
-QByteArray LightApp_Application::processState(QByteArray& input,
- const bool processWin,
- const bool processTb,
- const bool isRestoring,
- QByteArray defaultState) {
+*/
+QByteArray LightApp_Application::processState(QByteArray& input,
+ const bool processWin,
+ const bool processTb,
+ const bool isRestoring,
+ QByteArray defaultState) {
QByteArray aRes;
bool hasDefaultState = !defaultState.isEmpty();
tmpInputData >> version;
tmpInputData >> dockmarker;
tmpInputData >> nbDocWin;
- }
+ }
if(processWin && processTb && !isRestoring) {
aRes = input;
} else if(!processWin && !processTb ) {
QList<QToolBar*> aToolBars = findToolBars();
QStringList aNames;
- for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
+ for ( QList<QToolBar*>::iterator tit = aToolBars.begin(); tit != aToolBars.end(); ++tit ) {
QToolBar* tb = *tit;
aNames.append(tb->objectName());
}
if(hasDefaultState) {
toolBarMarkerIndexDef = getToolbarMarkerIndex(defaultState, aNames);
if(toolBarMarkerIndexDef < 0)
- return aRes;
+ return aRes;
}
QDataStream anInputDataDef(&defaultState, QIODevice::ReadOnly);
} else {
//Write date from default settings
if(hasDefaultState) {
- aTargetData = &anInputDataDef;
- aTargetIndex = toolBarMarkerIndexDef;
+ aTargetData = &anInputDataDef;
+ aTargetIndex = toolBarMarkerIndexDef;
} else {
- //If no default state, write current snapshot of the dockable windows
- if(isRestoring) {
- aTargetData = &anInputDataCur;
- int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
- aTargetIndex = toolBarMarkerIndexCur;
- }
+ //If no default state, write current snapshot of the dockable windows
+ if(isRestoring) {
+ aTargetData = &anInputDataCur;
+ int toolBarMarkerIndexCur = getToolbarMarkerIndex(currentArr, aNames);
+ aTargetIndex = toolBarMarkerIndexCur;
+ }
}
}
if(aTargetData && aTargetIndex >= 0 ) {
aTargetData->device()->seek(0);
while( aTargetData->device()->pos() < aTargetIndex ) {
- uchar ch;
- *aTargetData >> ch;
- aData<<ch;
+ uchar ch;
+ *aTargetData >> ch;
+ aData<<ch;
}
isDockWinWriten = true;
}
-
+
aTargetData = 0;
aTargetIndex = -1;
aTargetIndex = toolBarMarkerIndex;
} else {
if(hasDefaultState) {
- aTargetData = &anInputDataDef;
- aTargetIndex = toolBarMarkerIndexDef;
- }
+ aTargetData = &anInputDataDef;
+ aTargetIndex = toolBarMarkerIndexDef;
+ }
}
if(aTargetData && aTargetIndex >= 0) {
int index;
if(!isDockWinWriten ) {
- //Write version marker
- int marker, version;
- aTargetData->device()->seek(0);
- *aTargetData >> marker;
- *aTargetData >> version;
- aData << marker;
- aData << version;
- aData << (uchar) QDockWidgetMarker;
- aData << (int) 0;
- int shift = 4*sizeof(int) + sizeof(QSize);
- index = aTargetIndex - shift;
+ //Write version marker
+ int marker, version;
+ aTargetData->device()->seek(0);
+ *aTargetData >> marker;
+ *aTargetData >> version;
+ aData << marker;
+ aData << version;
+ aData << (uchar) QDockWidgetMarker;
+ aData << (int) 0;
+ int shift = 4*sizeof(int) + sizeof(QSize);
+ index = aTargetIndex - shift;
} else {
- index = aTargetIndex;
+ index = aTargetIndex;
}
-
+
aTargetData->device()->seek(index);
while(!aTargetData->atEnd()) {
- uchar ch;
- *aTargetData >> ch;
- aData << ch;
+ uchar ch;
+ *aTargetData >> ch;
+ aData << ch;
}
} else { // Not treat toolbars
aData << (uchar) QToolBarMarker;
Update visibility state of given objects
*/
void LightApp_Application::updateVisibilityState( DataObjectList& theList,
- SUIT_ViewModel* theViewModel )
+ SUIT_ViewModel* theViewModel )
{
if ( !theViewModel || theList.isEmpty() ) return;
if ( anObjModule ) {
LightApp_Displayer* aDisplayer = anObjModule->displayer();
if ( aDisplayer ) {
- Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
+ Qtx::VisibilityState anObjState = Qtx::UnpresentableState;
if ( aDisplayer->canBeDisplayed( obj->entry(), theViewModel->getType() ) ) {
if ( aView && aDisplayer->IsDisplayed( obj->entry(), aView ) )
anObjState = Qtx::ShownState;
else
anObjState = Qtx::HiddenState;
}
- aStudy->setVisibilityState( obj->entry(), anObjState );
+ aStudy->setVisibilityState( obj->entry(), anObjState );
}
}
}
{
bool result = true;
if( activeStudy() ) {
- int answer = SUIT_MessageBox::question( desktop(),
- tr( "APPCLOSE_CAPTION" ),
- tr( "STUDYCLOSE_DESCRIPTION" ),
- tr( "APPCLOSE_SAVE" ),
- tr( "APPCLOSE_CLOSE" ),
- tr( "APPCLOSE_CANCEL" ), 0 );
+ int answer = SUIT_MessageBox::question( desktop(),
+ tr( "APPCLOSE_CAPTION" ),
+ tr( "STUDYCLOSE_DESCRIPTION" ),
+ tr( "APPCLOSE_SAVE" ),
+ tr( "APPCLOSE_CLOSE" ),
+ tr( "APPCLOSE_CANCEL" ), 0 );
if(answer == 0) {
if ( activeStudy()->isSaved() ) {
- onSaveDoc();
- closeDoc( false );
+ onSaveDoc();
+ closeDoc( false );
} else if ( onSaveAsDoc() ) {
- if( !closeDoc( false ) ) {
- result = false;
- }
+ if( !closeDoc( false ) ) {
+ result = false;
+ }
} else {
- result = false;
- }
+ result = false;
+ }
}
else if( answer == 1 ) {
closeDoc( false );