]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Color management for sub-windows of OCCViewer
authorvsv <vsv@opencascade.com>
Tue, 14 Sep 2010 14:43:42 +0000 (14:43 +0000)
committervsv <vsv@opencascade.com>
Tue, 14 Sep 2010 14:43:42 +0000 (14:43 +0000)
src/LightApp/LightApp_Application.cxx
src/LightApp/resources/LightApp.xml
src/LightApp/resources/LightApp_msg_en.ts
src/OCCViewer/OCCViewer_ViewFrame.cxx
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/SalomeApp/resources/SalomeApp.xml

index b1b027d9292aa5191717bf432738cf63c00b5146..c5e27ec21e059dab63aa0caa5d76c37cc85acabc 100644 (file)
 
 #ifndef DISABLE_OCCVIEWER
   #include <OCCViewer_ViewManager.h>
+  #include <OCCViewer_ViewFrame.h>
 #ifndef DISABLE_SALOMEOBJECT
   #include <SOCC_ViewModel.h>
 #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") );
index eceb4911315bca79454fd3df6c938b26837f6d44..d367186c1aad7085f17906442739fe038bba3422 100644 (file)
   </section>
   <section name="OCCViewer" >
     <!-- OCC viewer preferences -->
-    <parameter name="background"     value="35, 136, 145" />
+    <parameter name="xz_background"     value="35, 136, 145" />
+    <parameter name="yz_background"     value="35, 136, 145" />
+    <parameter name="xy_background"     value="35, 136, 145" />
+    <parameter name="3d_background"     value="35, 136, 145" />
     <parameter name="iso_number_u"   value="1" />
     <parameter name="iso_number_v"   value="1" />
     <parameter name="trihedron_size" value="100" />
index 2c9178de5908dfb2535e3039a84b9b27abc746db..9e799934b25cd4192dbbae9dd5382aad3d30ccd5 100644 (file)
@@ -434,6 +434,22 @@ CEA/DEN, CEDRAT, EDF R&amp;D, LEG, PRINCIPIA R&amp;D, BUREAU VERITAS</translatio
         <source>PREF_VIEWER_BACKGROUND</source>
         <translation>Background color</translation>
     </message>
+    <message>
+        <source>PREF_XYVIEWER_BACKGROUND</source>
+        <translation>XY View background color</translation>
+    </message>
+    <message>
+        <source>PREF_XZVIEWER_BACKGROUND</source>
+        <translation>XZ View background color</translation>
+    </message>
+    <message>
+        <source>PREF_YZVIEWER_BACKGROUND</source>
+        <translation>YZ View background color</translation>
+    </message>
+    <message>
+        <source>PREF_3DVIEWER_BACKGROUND</source>
+        <translation>3D View background color</translation>
+    </message>
     <message>
         <source>PREF_FONT</source>
         <translation>Font</translation>
index 1fa170d5e12dcb27737c469fdce1f71f611d4547..28d368be12ff666d1f90595d0b0537907aeda6bb 100644 (file)
@@ -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 );
index e84dd4fb0f1386de5365cb4fb7f5309722935651..38b380dbe01cecea08ca478181d294c1849b9c6e 100755 (executable)
@@ -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<OCCViewer_ViewWindow*>(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;
+}
index 251095a65e2802e8c0853ce23b47494d5bf30c25..b0c2b758e1e3800975ceda8ee79d58367f7d6e91 100755 (executable)
@@ -25,6 +25,7 @@
 
 #include <QColor>
 #include <QPoint>
+#include <QVector>
 
 #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<QColor>     myColors;
 };
 
 #ifdef WIN32
index 1500aedaf036fcfc7cc6790ce648be47a8abf495..a068e6e811b4889fa7fae9bdb804e7d59f3e2557 100644 (file)
   </section>
   <section name="OCCViewer" >
     <!-- OCC viewer preferences -->
-    <parameter name="background"     value="35, 136, 145" />
+    <parameter name="xz_background"     value="35, 136, 145" />
+    <parameter name="yz_background"     value="35, 136, 145" />
+    <parameter name="xy_background"     value="35, 136, 145" />
+    <parameter name="3d_background"     value="35, 136, 145" />
     <parameter name="iso_number_u"   value="1" />
     <parameter name="iso_number_v"   value="1" />
     <parameter name="trihedron_size" value="100" />