From 0dc7b23a7d737e6281d20e002860286392b3e1c9 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 14 Sep 2010 14:43:42 +0000 Subject: [PATCH] Color management for sub-windows of OCCViewer --- src/LightApp/LightApp_Application.cxx | 32 ++++++++++++++++++----- src/LightApp/resources/LightApp.xml | 5 +++- src/LightApp/resources/LightApp_msg_en.ts | 16 ++++++++++++ src/OCCViewer/OCCViewer_ViewFrame.cxx | 4 +-- src/OCCViewer/OCCViewer_ViewModel.cxx | 25 +++++++++++++----- src/OCCViewer/OCCViewer_ViewModel.h | 10 +++++-- src/SalomeApp/resources/SalomeApp.xml | 5 +++- 7 files changed, 79 insertions(+), 18 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index b1b027d92..c5e27ec21 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -110,6 +110,7 @@ #ifndef DISABLE_OCCVIEWER #include + #include #ifndef DISABLE_SALOMEOBJECT #include #else @@ -1343,7 +1344,16 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType #else vm = new OCCViewer_Viewer( true, resMgr->booleanValue( "OCCViewer", "static_trihedron", true ) ); #endif - vm->setBackgroundColor( resMgr->colorValue( "OCCViewer", "background", vm->backgroundColor() ) ); + vm->setBackgroundColor( OCCViewer_ViewFrame::TOP_LEFT, + resMgr->colorValue( "OCCViewer", "xz_background", vm->backgroundColor() ) ); + vm->setBackgroundColor( OCCViewer_ViewFrame::TOP_RIGHT, + resMgr->colorValue( "OCCViewer", "yz_background", vm->backgroundColor() ) ); + + vm->setBackgroundColor( OCCViewer_ViewFrame::BOTTOM_LEFT, + resMgr->colorValue( "OCCViewer", "xy_background", vm->backgroundColor() ) ); + vm->setBackgroundColor( OCCViewer_ViewFrame::BOTTOM_RIGHT, + resMgr->colorValue( "OCCViewer", "3d_background", vm->backgroundColor() ) ); + vm->setTrihedronSize( resMgr->doubleValue( "OCCViewer", "trihedron_size", vm->trihedronSize() ) ); int u( 1 ), v( 1 ); vm->isos( u, v ); @@ -1902,22 +1912,32 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->setItemProperty( "min", 1.0E-06, occTS ); pref->setItemProperty( "max", 1000, occTS ); + int occStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), occGroup, + LightApp_Preferences::Selector, "OCCViewer", "navigation_mode" ); + int isoU = pref->addPreference( tr( "PREF_ISOS_U" ), occGroup, LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_u" ); pref->setItemProperty( "min", 0, isoU ); pref->setItemProperty( "max", 100000, isoU ); - pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup, - LightApp_Preferences::Color, "OCCViewer", "background" ); - int isoV = pref->addPreference( tr( "PREF_ISOS_V" ), occGroup, LightApp_Preferences::IntSpin, "OCCViewer", "iso_number_v" ); pref->setItemProperty( "min", 0, isoV ); pref->setItemProperty( "max", 100000, isoV ); - int occStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), occGroup, - LightApp_Preferences::Selector, "OCCViewer", "navigation_mode" ); + //pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup, + // LightApp_Preferences::Color, "OCCViewer", "background" ); + pref->addPreference( tr( "PREF_XZVIEWER_BACKGROUND" ), occGroup, + LightApp_Preferences::Color, "OCCViewer", "xz_background" ); + pref->addPreference( tr( "PREF_YZVIEWER_BACKGROUND" ), occGroup, + LightApp_Preferences::Color, "OCCViewer", "yz_background" ); + + pref->addPreference( tr( "PREF_XYVIEWER_BACKGROUND" ), occGroup, + LightApp_Preferences::Color, "OCCViewer", "xy_background" ); + pref->addPreference( tr( "PREF_3DVIEWER_BACKGROUND" ), occGroup, + LightApp_Preferences::Color, "OCCViewer", "3d_background" ); + QStringList aStyleModeList; aStyleModeList.append( tr("PREF_STANDARD_STYLE") ); aStyleModeList.append( tr("PREF_KEYFREE_STYLE") ); diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index eceb49113..d367186c1 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -114,7 +114,10 @@
- + + + + diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 2c9178de5..9e799934b 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -434,6 +434,22 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASPREF_VIEWER_BACKGROUND Background color + + PREF_XYVIEWER_BACKGROUND + XY View background color + + + PREF_XZVIEWER_BACKGROUND + XZ View background color + + + PREF_YZVIEWER_BACKGROUND + YZ View background color + + + PREF_3DVIEWER_BACKGROUND + 3D View background color + PREF_FONT Font diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index 1fa170d5e..28d368be1 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -73,7 +73,7 @@ void OCCViewer_ViewFrame::onMaximizedView( OCCViewer_ViewWindow* theView, bool i int i = 0; if (myViews.count() == 1) { - QColor aColor = myViews.at( MAIN_VIEW )->backgroundColor(); + //QColor aColor = myViews.at( MAIN_VIEW )->backgroundColor(); OCCViewer_ViewWindow* view = 0; for ( i = BOTTOM_LEFT; i <= TOP_RIGHT; i++) { view = aModel->createSubWindow(); @@ -84,7 +84,7 @@ void OCCViewer_ViewFrame::onMaximizedView( OCCViewer_ViewWindow* theView, bool i aModel->initView(view); view->setMaximized(false, false); connectViewSignals(view); - view->setBackgroundColor(aColor); + view->setBackgroundColor(aModel->backgroundColor(i)); } myLayout->addWidget( myViews.at(BOTTOM_LEFT), 1, 0 ); myLayout->addWidget( myViews.at(TOP_LEFT), 0, 0 ); diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index e84dd4fb0..38b380dbe 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -62,8 +62,8 @@ */ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron, bool DisplayStaticTrihedron ) : SUIT_ViewModel(), - myBgColor( Qt::black ), - myShowStaticTrihedron( DisplayStaticTrihedron ) + myShowStaticTrihedron( DisplayStaticTrihedron ), + myColors(4, Qt::black) { // init CasCade viewers myV3dViewer = OCCViewer_VService::Viewer3d( "", (short*) "Viewer3d", "", 1000., @@ -137,7 +137,7 @@ OCCViewer_Viewer::~OCCViewer_Viewer() */ QColor OCCViewer_Viewer::backgroundColor() const { - return myBgColor; + return myColors[0]; } /*! @@ -147,7 +147,7 @@ QColor OCCViewer_Viewer::backgroundColor() const void OCCViewer_Viewer::setBackgroundColor( const QColor& c ) { if ( c.isValid() ) - myBgColor = c; + myColors[0] = c; } /*! @@ -163,7 +163,7 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) OCCViewer_ViewPort3d* vp3d = view->getViewPort(); if ( vp3d ) - vp3d->setBackgroundColor( myBgColor ); + vp3d->setBackgroundColor( myColors[0] ); } } @@ -408,7 +408,7 @@ void OCCViewer_Viewer::onDumpView() */ void OCCViewer_Viewer::onChangeBgColor() { - OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView()); + OCCViewer_ViewWindow* aView = dynamic_cast(myViewManager->getActiveView()); if( !aView ) return; QColor aColorActive = aView->backgroundColor(); @@ -718,3 +718,16 @@ OCCViewer_ViewWindow* OCCViewer_Viewer::createSubWindow() { return new OCCViewer_ViewWindow( 0, this); } + +QColor OCCViewer_Viewer::backgroundColor(int theViewId) const +{ + if (theViewId < myColors.count()) + return myColors[theViewId]; + return Qt::black; +} + +void OCCViewer_Viewer::setBackgroundColor( int theViewId, const QColor& theColor) +{ + if (theViewId < myColors.count()) + myColors[theViewId] = theColor; +} diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 251095a65..b0c2b758e 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -25,6 +25,7 @@ #include #include +#include #include "OCCViewer.h" @@ -105,7 +106,10 @@ public: virtual void clearViewAspects(); QColor backgroundColor() const; - void setBackgroundColor( const QColor& ); + void setBackgroundColor( const QColor& ); + + QColor backgroundColor(int theViewId) const; + void setBackgroundColor( int theViewId, const QColor& ); //! returns true if 3d Trihedron in viewer was created bool trihedronActivated() const { return !myTrihedron.IsNull(); } @@ -183,10 +187,12 @@ private: bool mySelectionEnabled; bool myMultiSelectionEnabled; - QColor myBgColor; + //QColor myBgColor; QPoint myStartPnt, myEndPnt; bool myShowStaticTrihedron; + + QVector myColors; }; #ifdef WIN32 diff --git a/src/SalomeApp/resources/SalomeApp.xml b/src/SalomeApp/resources/SalomeApp.xml index 1500aedaf..a068e6e81 100644 --- a/src/SalomeApp/resources/SalomeApp.xml +++ b/src/SalomeApp/resources/SalomeApp.xml @@ -121,7 +121,10 @@
- + + + + -- 2.39.2