X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FLightApp%2FLightApp_Application.cxx;h=b105560ba3304faa33aa51548da99897a29bae77;hb=45e0e6dbad804e64caa86f1e692e7c5fa849e071;hp=ed6e0e8e2d437a2e805d178155974e7d753b9afd;hpb=98f6f008de828f33e7b0b951e33fe3057ef5d8c1;p=modules%2Fgui.git diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index ed6e0e8e2..b105560ba 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -35,8 +35,9 @@ #endif #ifndef DISABLE_PYCONSOLE - #include "LightApp_PyInterp.h" // WARNING! This include must be the first! - #include + #include "PyConsole_Interp.h" + #include "LightApp_PyEditor.h" + #include "PyConsole_Console.h" #endif #include "LightApp_Application.h" @@ -62,8 +63,10 @@ #include +#ifdef USE_SALOME_STYLE #include #include +#endif // USE_SALOME_STYLE #include #include @@ -82,6 +85,7 @@ #include #include +#include #include #include #include @@ -116,6 +120,7 @@ #ifndef DISABLE_OCCVIEWER #include #include + #include #ifndef DISABLE_SALOMEOBJECT #include #else @@ -241,21 +246,23 @@ int LightApp_Application::lastStudyId = 0; //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 ) +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); + anInputData.device()->seek( tmp ); uchar mark; - anInputData>>mark; + anInputData >> mark; int lines; anInputData >> lines; - if(lines == 0 && anInputData.atEnd()){ + if ( lines == 0 && anInputData.atEnd() ) { //Case then array doesn't contain information about toolbars, aResult = tmp; break; @@ -266,13 +273,26 @@ int getToolbarMarkerIndex(QByteArray input, const QStringList& aFlags) { int cnt; anInputData >> cnt; QString str; - anInputData>>str; - if(aFlags.contains(str)) { + 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; + } } /*! @@ -317,6 +337,8 @@ LightApp_Application::LightApp_Application() myAutoSaveTimer->setSingleShot( true ); connect( myAutoSaveTimer, SIGNAL( timeout() ), this, SLOT( onSaveDoc() ) ); + //connect( this, SIGNAL( moving() ), this, SLOT( onMoved() ) ); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); QPixmap aLogo = aResMgr->loadPixmap( "LightApp", tr( "APP_DEFAULT_ICO" ), false ); @@ -414,6 +436,7 @@ LightApp_Application::LightApp_Application() */ LightApp_Application::~LightApp_Application() { + savePreferences(); delete mySelMgr; delete myScreenHelper; } @@ -436,9 +459,10 @@ void LightApp_Application::start() /*!Closeapplication.*/ void LightApp_Application::closeApplication() { +#ifndef DISABLE_QTXWEBBROWSER QProcess::startDetached( "HelpBrowser", QStringList() << QString( "--remove=%1" ).arg( QApplication::instance()->applicationPid() ) ); - +#endif CAM_Application::closeApplication(); } @@ -517,6 +541,9 @@ bool LightApp_Application::activateModule( const QString& modName ) objectBrowser()->setRoot( activeStudy()->root() ); updateObjectBrowser( true ); } + + if ( activeModule() ) activeModule()->updateModuleVisibilityState(); + return true; } @@ -755,10 +782,7 @@ void LightApp_Application::createActions() createActionForViewer( NewGraphicsViewId, newWinMenu, QString::number( 5 ), Qt::ALT+Qt::Key_C ); #endif #ifndef DISABLE_PVVIEWER - QStringList aModuleNames; - modules( aModuleNames, false ); - if ( aModuleNames.contains( "ParaViS", Qt::CaseInsensitive ) ) - createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ), Qt::ALT+Qt::Key_A ); + createActionForViewer( NewPVViewId, newWinMenu, QString::number( 6 ), Qt::ALT+Qt::Key_A ); #endif #ifndef DISABLE_PYVIEWER createActionForViewer( NewPyViewerId, newWinMenu, QString::number( 7 ), Qt::ALT+Qt::Key_Y ); @@ -776,8 +800,10 @@ void LightApp_Application::createActions() 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() ) ); @@ -785,7 +811,9 @@ void LightApp_Application::createActions() 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) @@ -979,6 +1007,7 @@ void LightApp_Application::onHelpAbout() */ void LightApp_Application::onSelection() { + //MESSAGE("onSelection") onSelectionChanged(); if ( activeModule() && activeModule()->inherits( "LightApp_Module" ) ) @@ -1123,8 +1152,12 @@ void LightApp_Application::onHelpContentsModule() 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 ); @@ -1193,7 +1226,11 @@ void LightApp_Application::onHelpContextModule( const QString& theComponentName, 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"); @@ -1425,19 +1462,31 @@ SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, c { 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->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; } @@ -1535,6 +1584,18 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType 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() ), + resMgr->doubleValue( "OCCViewer", "focus_value", vm->stereographicFocusValue() )); + vm->setInterocularDistance( resMgr->integerValue( "OCCViewer", "iod_type", vm->interocularDistanceType() ), + resMgr->doubleValue( "OCCViewer", "iod_value", vm->interocularDistanceValue() )); + + 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() ) ); @@ -1564,6 +1625,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) ); vm->setStereoType( resMgr->integerValue( "VTKViewer", "stereo_type", vm->stereoType() ) ); vm->setAnaglyphFilter( resMgr->integerValue( "VTKViewer", "anaglyph_filter", vm->anaglyphFilter() ) ); + vm->setQuadBufferSupport( resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", vm->isQuadBufferSupport() ) ); vm->setBackground( resMgr->backgroundValue( "VTKViewer", "background", vm->background() ) ); vm->setTrihedronSize( resMgr->doubleValue( "3DViewer", "trihedron_size", vm->trihedronSize() ), resMgr->booleanValue( "3DViewer", "relative_size", vm->trihedronRelative() ) ); @@ -1787,12 +1849,10 @@ void LightApp_Application::studyCreated( SUIT_Study* s ) } /*!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)"; } @@ -1839,6 +1899,22 @@ void LightApp_Application::onRenamed() updateActions(); } +// IMN 08.07.2015 : issue 002556: Some stereo outputs are affected by window position. +// To prevent reversion the window should be either aligned during movement and resize. +/*!Private SLOT. Update actions after rename object.*/ +/*void LightApp_Application::onMoved() +{ + OCCViewer_ViewManager* viewMgr = 0; + viewMgr = dynamic_cast( getViewManager( OCCViewer_Viewer::Type(), false ) ); + if (viewMgr) { + OCCViewer_ViewWindow* view = 0; + view = dynamic_cast( viewMgr->getActiveView() ); + if (view) { + view->getViewPort()->repaintViewAfterMove(); + } + } +} +*/ /*!Private SLOT. Support drag-and-drop operation.*/ void LightApp_Application::onDropped( const QList& objects, SUIT_DataObject* parent, int row, Qt::DropAction action ) { @@ -1983,8 +2059,11 @@ QWidget* LightApp_Application::createWindow( const int flag ) // 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" ) ); @@ -1994,15 +2073,14 @@ QWidget* LightApp_Application::createWindow( const int flag ) #ifndef DISABLE_PYCONSOLE else if ( flag == WT_PyConsole ) { - PyConsole_Console* pyCons = new PyConsole_EnhConsole( desktop(), getPyInterp() ); + PyConsole_Console* pyCons = new PyConsole_Console( desktop(), new LightApp_PyEditor( getPyInterp() ) ); pyCons->setObjectName( "pythonConsole" ); pyCons->setWindowTitle( tr( "PYTHON_CONSOLE" ) ); - pyCons->setFont(resourceMgr()->fontValue( "PyConsole", "font" )); - pyCons->setIsShowBanner(resourceMgr()->booleanValue( "PyConsole", "show_banner", true )); + pyCons->setFont( resMgr->fontValue( "PyConsole", "font" ) ); + pyCons->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) ); + pyCons->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) ); pyCons->setProperty( "shortcut", QKeySequence( "Alt+Shift+P" ) ); - wid = pyCons; - pyCons->connectPopupRequest( this, SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) ); } #endif else if ( flag == WT_LogWindow ) @@ -2178,10 +2256,15 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) LightApp_Preferences::Selector, "language", "language" ); QStringList aLangs = SUIT_Session::session()->resourceMgr()->stringValue( "language", "languages", "en" ).split( "," ); QList aIcons; + QList 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 ); @@ -2209,6 +2292,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) // .... -> ascii save mode pref->addPreference( tr( "PREF_ASCII_FILE" ), studyGroup, LightApp_Preferences::Bool, "Study", "ascii_file" ); // .... -> store windows geometry + pref->addPreference( tr( "PREF_LOAD_LIGHT" ), studyGroup, LightApp_Preferences::Bool, "Study", "autoload_light_modules" ); pref->addPreference( tr( "PREF_STORE_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_positions" ); pref->addPreference( "", studyGroup, LightApp_Preferences::Space ); pref->addPreference( tr( "PREF_STORE_TOOL_POS" ), studyGroup, LightApp_Preferences::Bool, "Study", "store_tool_positions" ); @@ -2221,7 +2305,12 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) // ... "Study properties" group <> // ... "Help browser" group <> +#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 @@ -2236,10 +2325,13 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) // ... "Python console properties" group <> int pythonConsoleGroup = pref->addPreference( tr( "PREF_GROUP_PY_CONSOLE" ), genTab ); + pref->setItemProperty( "columns", 2, pythonConsoleGroup ); // .... -> font pref->addPreference( tr( "PREF_FONT" ), pythonConsoleGroup, LightApp_Preferences::Font, "PyConsole", "font" ); // .... -> show banner pref->addPreference( tr( "PREF_SHOW_BANNER" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "show_banner" ); + // .... -> auto-completion + pref->addPreference( tr( "PREF_AUTO_COMPLETION" ), pythonConsoleGroup, LightApp_Preferences::Bool, "PyConsole", "auto_completion" ); // ... "Python console properties" group <> // ... "MRU" preferences group <> @@ -2260,13 +2352,15 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->setItemProperty( "strings", aValuesList, mruLinkType ); pref->setItemProperty( "indexes", anIndicesList, mruLinkType ); // ... "MRU" preferences group <> + // ... "Full-screen" group <> int fullScreenGroup = pref->addPreference( tr( "PREF_GROUP_FULL_SCREEN" ), genTab ); 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 <> + // .. "General" preferences tab <> // .. "3D viewer" group <> @@ -2310,7 +2404,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) // .. "OCC viewer" group <> int occGroup = pref->addPreference( tr( "PREF_GROUP_OCCVIEWER" ), salomeCat ); - // .... -> projection mode + // .... -> Projection mode int occProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), occGroup, LightApp_Preferences::Selector, "OCCViewer", "projection_mode" ); aValuesList.clear(); @@ -2319,12 +2413,85 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) 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 ); + // .... -> Stereo type + int stereoType = pref->addPreference( tr( "PREF_STEREO_TYPE" ), stereoGroup, + LightApp_Preferences::Selector, "OCCViewer", "stereo_type" ); + aValuesList.clear(); + anIndicesList.clear(); + idList.clear(); + OCCViewer_Viewer::stereoData( aValuesList, idList); + foreach( int gid, idList ) anIndicesList << gid; + pref->setItemProperty( "strings", aValuesList, stereoType ); + pref->setItemProperty( "indexes", anIndicesList, stereoType ); + + // .... -> Anaglyph filter + int anaglyphFilter = pref->addPreference( tr( "PREF_ANAGLYPH_FILTER" ), stereoGroup, + LightApp_Preferences::Selector, "OCCViewer", "anaglyph_filter" ); + aValuesList.clear(); + anIndicesList.clear(); + aValuesList << tr("PREF_ANAGLYPH_RED_CYAN") << tr("PREF_ANAGLYPH_YELLOW_BLUE") << tr("PREF_ANAGLYPH_GREEN_MAGENTA"); + anIndicesList << 0 << 1 << 2; + + pref->setItemProperty( "strings", aValuesList, anaglyphFilter ); + pref->setItemProperty( "indexes", anIndicesList, anaglyphFilter ); + + // .... -> Convergence distance type + int occFocusType = pref->addPreference( tr( "PREF_FOCUS_TYPE" ), stereoGroup, + LightApp_Preferences::Selector, "OCCViewer", "focus_type" ); + aValuesList.clear(); + anIndicesList.clear(); + aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE"); + anIndicesList << 0 << 1; + pref->setItemProperty( "strings", aValuesList, occFocusType ); + pref->setItemProperty( "indexes", anIndicesList, occFocusType ); + + // .... -> Stereographic focus value + int focusValue = pref->addPreference( tr( "PREF_FOCUS_VALUE" ), stereoGroup, + LightApp_Preferences::DblSpin, "OCCViewer", "focus_value" ); + pref->setItemProperty( "precision", 3, focusValue ); + pref->setItemProperty( "min", 1.0E-03, focusValue ); + pref->setItemProperty( "max", 1.0E03, focusValue ); + pref->setItemProperty( "step", 0.05, focusValue ); + + // .... -> IOD type + int occIODType = pref->addPreference( tr( "PREF_IOD_TYPE" ), stereoGroup, + LightApp_Preferences::Selector, "OCCViewer", "iod_type" ); + aValuesList.clear(); + anIndicesList.clear(); + aValuesList << tr("PREF_ABSOLUTE") << tr("PREF_RELATIVE"); + anIndicesList << 0 << 1; + pref->setItemProperty( "strings", aValuesList, occIODType ); + pref->setItemProperty( "indexes", anIndicesList, occIODType ); + + // .... -> Interocular distance (IOD) value + int IODValue = pref->addPreference( tr( "PREF_IOD_VALUE" ), stereoGroup, + LightApp_Preferences::DblSpin, "OCCViewer", "iod_value" ); + pref->setItemProperty( "precision", 3, IODValue ); + pref->setItemProperty( "min", 1.0E-03, IODValue ); + pref->setItemProperty( "max", 1.0E03, IODValue ); + pref->setItemProperty( "step", 0.05, IODValue ); + + // .... -> Reverse stereo + pref->addPreference( tr( "PREF_REVERSE_STEREO" ), stereoGroup, + LightApp_Preferences::Bool, "OCCViewer", "reverse_stereo" ); + // .... -> Enable V-Sync + pref->addPreference( tr( "PREF_ENABLE_VSYNC" ), stereoGroup, + 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 // ... "Background" group <> int bgGroup = pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup ); // pref->setItemProperty( "columns", 2, bgGroup ); aValuesList.clear(); anIndicesList.clear(); txtList.clear(); + idList.clear(); formats = OCCViewer_Viewer::backgroundData( aValuesList, idList, txtList ); foreach( int gid, idList ) anIndicesList << gid; // .... -> 3D viewer background @@ -2411,11 +2578,67 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->setItemProperty( "step", 0.1, scaleFactor ); // ... "Clipping" group <> + // ... "Ray tracing" group <> + int occRayTracingGroup = pref->addPreference( tr( "PREF_GROUP_RAY_TRACING" ), occGroup ); + int rtPref = pref->addPreference( "", occRayTracingGroup, LightApp_Preferences::Frame ); + pref->setItemProperty( "columns", 2, rtPref ); + // .... -> depth + int rt_depth = pref->addPreference( tr( "PREF_RAY_TRACING_DEPTH" ), rtPref, + LightApp_Preferences::IntSpin, "OCCViewer", "rt_depth" ); + pref->setItemProperty( "min", 1, rt_depth ); + pref->setItemProperty( "max", 10, rt_depth ); + pref->setItemProperty( "step", 1, rt_depth ); + pref->addPreference( "", rtPref, LightApp_Preferences::Frame ); + // .... -> specular reflections + pref->addPreference( tr( "PREF_RAY_TRACING_REFLECTION" ), rtPref, + LightApp_Preferences::Bool, "OCCViewer", "rt_reflection" ); + // .... -> adaptive anti-aliasing + pref->addPreference( tr( "PREF_RAY_TRACING_ANTIALIASING" ), rtPref, + LightApp_Preferences::Bool, "OCCViewer", "rt_antialiasing" ); + // .... -> shadows rendering + pref->addPreference( tr( "PREF_RAY_TRACING_SHADOW" ), rtPref, + LightApp_Preferences::Bool, "OCCViewer", "rt_shadow" ); + // .... -> transparent shadow + pref->addPreference( tr( "PREF_RAY_TRACING_TRANS_SHADOW" ), rtPref, + LightApp_Preferences::Bool, "OCCViewer", "rt_trans_shadow" ); + // ... "Ray tracing" group <> + + // ... "Light source" group <> + int occLightGroup = pref->addPreference( tr( "PREF_GROUP_LIGHT" ), occGroup ); + // .... -> light color + pref->addPreference( tr( "PREF_LIGHT_COLOR" ), occLightGroup, + LightApp_Preferences::Color, "OCCViewer", "light_color" ); + int directionPref = pref->addPreference( "", occLightGroup, LightApp_Preferences::Frame ); + pref->setItemProperty( "columns", 3, directionPref ); + // .... -> light direction (dx component) + int light_dx = pref->addPreference( tr( "Dx" ), directionPref, + LightApp_Preferences::DblSpin, "OCCViewer", "light_dx" ); + pref->setItemProperty( "precision", 2, light_dx ); + pref->setItemProperty( "min", -1.0E03, light_dx ); + pref->setItemProperty( "max", 1.0E03, light_dx ); + pref->setItemProperty( "step", 0.1, light_dx ); + // .... -> light direction (dy component) + int light_dy = pref->addPreference( tr( "Dy" ), directionPref, + LightApp_Preferences::DblSpin, "OCCViewer", "light_dy" ); + pref->setItemProperty( "precision", 2, light_dy ); + pref->setItemProperty( "min", -1.0E03, light_dy ); + pref->setItemProperty( "max", 1.0E03, light_dy ); + pref->setItemProperty( "step", 0.1, light_dy ); + // .... -> light direction (dz component) + int light_dz = pref->addPreference( tr( "Dz" ), directionPref, + LightApp_Preferences::DblSpin, "OCCViewer", "light_dz" ); + pref->setItemProperty( "precision", 2, light_dz ); + pref->setItemProperty( "min", -1.0E03, light_dz ); + pref->setItemProperty( "max", 1.0E03, light_dz ); + pref->setItemProperty( "step", 0.1, light_dz ); + // ... "Light source" group <> + // ... -> empty frame (for layout) <> int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame ); pref->setItemProperty( "margin", 0, occGen ); pref->setItemProperty( "columns", 2, occGen ); // ... -> empty frame (for layout) <> + // .. "OCC viewer" group <> #endif @@ -2688,8 +2911,9 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) int pyeditTab = pref->addPreference( tr( "PREF_TAB_PYEDITOR" ), salomeCat ); // ... "Font settings" group <> 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 <> // ... "Display settings" group <> int pyDispGroup = pref->addPreference( tr( "PREF_GROUP_PY_DISPLAY" ), pyeditTab ); @@ -3021,7 +3245,144 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } } #endif +#if OCC_VERSION_LARGE > 0x06090000 +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && param == QString( "stereo_type" ) ) + { + int mode = resMgr->integerValue( "OCCViewer", "stereo_type", 0 ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setStereoType( mode ); + } + } +#endif + +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && param == QString( "anaglyph_filter" ) ) + { + int mode = resMgr->integerValue( "OCCViewer", "anaglyph_filter", 0 ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setAnaglyphFilter( mode ); + } + } +#endif + +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && ( param == QString( "focus_type" ) || + param == QString( "focus_value" ) ) ) + { + int aType = resMgr->integerValue( "OCCViewer", "focus_type" ); + double aValue = resMgr->doubleValue( "OCCViewer", "focus_value" ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setStereographicFocus( aType, aValue ); + } + } +#endif + +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && ( param == QString( "iod_type" ) || + param == QString( "iod_value" ) ) ) + { + int aType = resMgr->integerValue( "OCCViewer", "iod_type" ); + double aValue = resMgr->doubleValue( "OCCViewer", "iod_value" ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setInterocularDistance( aType, aValue ); + } + } +#endif + +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && param == QString( "reverse_stereo" ) ) + { + bool reverse = resMgr->booleanValue( "OCCViewer", "reverse_stereo", false ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setReverseStereo( reverse ); + } + } +#endif + +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && param == QString( "enable_vsync" ) ) + { + bool enable = resMgr->booleanValue( "OCCViewer", "enable_vsync", true ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setVSync( enable ); + } + } +#endif + +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && param == QString( "enable_quad_buffer_support" ) ) + { + bool enable = resMgr->booleanValue( "OCCViewer", "enable_quad_buffer_support", false ); + QList lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) ) + continue; + + OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm; + occVM->setQuadBufferSupport( enable ); + } + } +#endif +#endif if ( sec == QString( "3DViewer" ) && param == QString( "zooming_mode" ) ) { int mode = resMgr->integerValue( "3DViewer", "zooming_mode", 0 ); @@ -3141,6 +3502,27 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } #endif +#ifndef DISABLE_VTKVIEWER + if ( sec == QString( "VTKViewer" ) && param == QString( "enable_quad_buffer_support" ) ) + { + int enable = resMgr->booleanValue( "VTKViewer", "enable_quad_buffer_support", false ); + QList lst; +#ifndef DISABLE_SALOMEOBJECT + viewManagers( SVTK_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "SVTK_Viewer" ) ) + continue; + + SVTK_Viewer* vtkVM = dynamic_cast( vm ); + if( vtkVM ) vtkVM->setQuadBufferSupport( enable ); + } +#endif + } +#endif + #ifndef DISABLE_VTKVIEWER if ( sec == QString( "VTKViewer" ) && param == QString( "preselection" ) ) { @@ -3253,6 +3635,9 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString else if ( param=="show_banner" ) { pythonConsole()->setIsShowBanner( resMgr->booleanValue( "PyConsole", "show_banner", true ) ); } + else if ( param=="auto_completion" ) { + pythonConsole()->setAutoCompletion( resMgr->booleanValue( "PyConsole", "auto_completion", true ) ); + } } #endif @@ -3315,39 +3700,6 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } } #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 lst; - viewManagers( PyViewer_Viewer::Type(), lst ); - QListIterator 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( vm ); - - viewMgr->setViewModel( vm ); - PyViewer_ViewWindow* pyView = dynamic_cast( viewMgr->getActiveView() ); - if( pyView ) - { - pyView->setPreferences(); - } - } - } -#endif } /*! @@ -3692,7 +4044,7 @@ void LightApp_Application::loadDockWindowsState() } if(dwMap) { - QList dwList = qFindChildren( desktop() ); + QList dwList = desktop()->findChildren(); for ( QList::iterator dit = dwList.begin(); dit != dwList.end(); ++dit ) { QDockWidget* dw = *dit; @@ -3745,14 +4097,14 @@ void LightApp_Application::saveDockWindowsState() QMap tbMap, dwMap; dockWindowsState( visArr, tbMap, dwMap ); - QList tbList = qFindChildren( desktop() ); + QList tbList = desktop()->findChildren(); for ( QList::iterator it = tbList.begin(); it != tbList.end(); ++it ) { QToolBar* tb = *it; tbMap.insert( tb->objectName(), tb->toggleViewAction()->isChecked() ); } - QList dwList = qFindChildren( desktop() ); + QList dwList = desktop()->findChildren(); for ( QList::iterator it = dwList.begin(); it != dwList.end(); ++it ) { QDockWidget* wid = *it; @@ -3929,6 +4281,8 @@ void LightApp_Application::setDesktop( SUIT_Desktop* desk ) this, SLOT( onDesktopMessage( const QString& ) ), Qt::UniqueConnection ); connect( desk, SIGNAL( windowActivated( SUIT_ViewWindow* ) ), this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); + /* connect( desk, SIGNAL( windowMoved( SUIT_ViewWindow* ) ), + this, SLOT( onWindowMoved( SUIT_ViewWindow* ) ), Qt::UniqueConnection ); */ } } @@ -3980,10 +4334,12 @@ void LightApp_Application::onMRUActivated( const QString& name ) 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(){ @@ -4113,8 +4469,10 @@ bool LightApp_Application::isLibExists( const QString& moduleTitle ) const bool isPythonLightModule = lib.contains("SalomePyQtGUILight"); QStringList paths; -#ifdef WIN32 +#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 @@ -4537,7 +4895,7 @@ void LightApp_Application::onDesktopMessage( const QString& message ) QList LightApp_Application::findToolBars( const QStringList& names ) { QList aResult; - QList tbList = qFindChildren( desktop() ); + QList tbList = desktop()->findChildren(); for ( QList::iterator tit = tbList.begin(); tit != tbList.end(); ++tit ) { QToolBar* tb = *tit; QObject* po = Qtx::findParent( tb, "QMainWindow" ); @@ -4801,14 +5159,16 @@ bool LightApp_Application::checkExistingDoc() PyConsole_Interp* LightApp_Application::getPyInterp() { static PyConsole_Interp* myInterp = 0; - if ( !myInterp ) + if ( !myInterp ) { myInterp = createPyInterp(); + myInterp->initialize(); + } return myInterp; } PyConsole_Interp* LightApp_Application::createPyInterp() { - return new LightApp_PyInterp(); + return new PyConsole_Interp(); } #endif // DISABLE_PYCONSOLE