]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Preferences created
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 8 Aug 2014 15:40:13 +0000 (19:40 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 8 Aug 2014 15:40:13 +0000 (19:40 +0400)
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_Constants.h
src/XGUI/XGUI_Preferences.cpp [new file with mode: 0644]
src/XGUI/XGUI_Preferences.h [new file with mode: 0644]
src/XGUI/XGUI_ViewPort.cpp
src/XGUI/XGUI_Viewer.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h
src/XGUI/XGUI_pictures.qrc
src/XGUI/pictures/preferences.png [new file with mode: 0644]
src/XGUI/pictures/view_prefs.png [new file with mode: 0644]

index a5a31330139a65f38fd5fbf4b66b6fd33b3fd5d4..eca046d10873a0841c3b6ada09da6d91085059ac 100644 (file)
@@ -31,6 +31,7 @@ SET(PROJECT_HEADERS
     XGUI_ContextMenuMgr.h
     XGUI_ModuleConnector.h
        XGUI_Selection.h
+       XGUI_Preferences.h
 )
 
 SET(PROJECT_AUTOMOC 
@@ -62,6 +63,7 @@ SET(PROJECT_SOURCES
     XGUI_ContextMenuMgr.cpp
     XGUI_ModuleConnector.cpp
        XGUI_Selection.cpp
+       XGUI_Preferences.cpp
 )
 
 SET(PROJECT_RESOURCES 
index 6058ba3b44cc76a8e9be4f3c1afde0eeb7a38934..5cd0f25238dabfdf7b9c8df2cf1ee99c580bc73b 100644 (file)
@@ -51,13 +51,13 @@ enum Mode2dType
 };
 
 //! Types of background in view window
-enum BackgroundMode
-{
-  NoBackground,              // no (invalid) background data
-  ColorBackground,           // single color
-  SimpleGradientBackground,  // simple two-color gradient
-  CustomGradientBackground   // custom (complex) gradient
-};
+//enum BackgroundMode
+//{
+//  NoBackground,              // no (invalid) background data
+//  ColorBackground,           // single color
+//  SimpleGradientBackground,  // simple two-color gradient
+//  CustomGradientBackground   // custom (complex) gradient
+//};
 
 //! Texture mode
 enum TextureMode
diff --git a/src/XGUI/XGUI_Preferences.cpp b/src/XGUI/XGUI_Preferences.cpp
new file mode 100644 (file)
index 0000000..12a21be
--- /dev/null
@@ -0,0 +1,113 @@
+// File:        XGUI_Preferences.cpp
+// Created:     07 Aug 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "XGUI_Preferences.h"
+#include "XGUI_Constants.h"
+
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_PreferenceMgr.h>
+
+#include <QLayout>
+#include <QApplication>
+#include <QDialogButtonBox>
+
+SUIT_ResourceMgr* XGUI_Preferences::myResourceMgr = 0;
+
+
+SUIT_ResourceMgr* XGUI_Preferences::resourceMgr()
+{
+  if (!myResourceMgr) {
+    myResourceMgr = new SUIT_ResourceMgr("NewGeom");
+    myResourceMgr->setCurrentFormat("xml");
+  }
+  return myResourceMgr;
+}
+
+void XGUI_Preferences::editPreferences()
+{
+  XGUI_PreferencesDlg aDlg(resourceMgr(), QApplication::activeWindow());
+  aDlg.exec();
+}
+
+
+
+//**********************************************************
+//**********************************************************
+//**********************************************************
+XGUI_PreferencesDlg::XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent)
+  : QDialog(theParent)
+{
+  setWindowTitle( tr("Edit preferences") );
+
+  QVBoxLayout* main = new QVBoxLayout(this);
+  main->setMargin( 5 );
+  main->setSpacing( 5 );
+
+  myPreferences = new SUIT_PreferenceMgr(theResurces, this);
+  main->addWidget( myPreferences );
+
+  setFocusProxy( myPreferences );
+  myPreferences->setFrameStyle( QFrame::Box | QFrame::Sunken );
+  //myPreferences->show();
+
+  QDialogButtonBox* aBtnBox = new QDialogButtonBox(
+    QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
+  main->addWidget(aBtnBox);
+  connect(aBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
+  connect(aBtnBox, SIGNAL(rejected()), this, SLOT(reject()));  
+
+  myPreferences->retrieve();
+  createEditors();
+}
+
+XGUI_PreferencesDlg::~XGUI_PreferencesDlg()
+{
+}
+
+void XGUI_PreferencesDlg::createEditors()
+{
+  int aLFpage = myPreferences->addItem("Look&Feel");
+  myPreferences->setItemIcon(aLFpage, QIcon(":pictures/view_prefs.png"));
+
+  int viewTab = myPreferences->addItem( tr("Viewer"), aLFpage );
+
+  QStringList gradList;
+  gradList << tr("Horizontal gradient")     << tr("Vertical gradient")        <<
+              tr("First diagonal gradient") << tr("Second diagonal gradient") <<
+              tr("First corner gradient")   << tr("Second corner gradient")   <<
+              tr("Third corner gradient")   << tr("Fourth corner gradient");
+  
+  QList<QVariant> anIndicesList;
+  QIntList idList;
+  idList   << XGUI::HorizontalGradient << XGUI::VerticalGradient <<
+              XGUI::Diagonal1Gradient  << XGUI::Diagonal2Gradient <<
+              XGUI::Corner1Gradient    << XGUI::Corner2Gradient   <<
+              XGUI::Corner3Gradient    << XGUI::Corner4Gradient;
+
+  foreach(int gid, idList ) anIndicesList << gid;
+
+  int bgGroup = myPreferences->addItem( tr( "Background" ), viewTab );
+
+  //QIntList txtList;
+  //txtList  << Qtx::CenterTexture << Qtx::TileTexture << Qtx::StretchTexture;
+
+  QString aImgFiles("Image files (*.bmp *.gif *.pix *.xwd *.rgb *.rs)");
+
+  int bgId = myPreferences->addItem( tr("Viewer 3d" ), bgGroup,
+                                  SUIT_PreferenceMgr::Background, "Viewer", "background" );
+  myPreferences->setItemProperty( "gradient_names", gradList, bgId );
+  //myPreferences->setItemProperty( "gradient_ids", anIndicesList, bgId );
+  myPreferences->setItemProperty( "texture_enabled", true, bgId );
+  myPreferences->setItemProperty( "texture_center_enabled", true, bgId );
+  myPreferences->setItemProperty( "texture_tile_enabled", true, bgId );
+  myPreferences->setItemProperty( "texture_stretch_enabled", true, bgId );
+  myPreferences->setItemProperty( "custom_enabled", false, bgId );
+  myPreferences->setItemProperty( "image_formats", aImgFiles, bgId );
+
+}
+
+
+
+
+
diff --git a/src/XGUI/XGUI_Preferences.h b/src/XGUI/XGUI_Preferences.h
new file mode 100644 (file)
index 0000000..5453ec5
--- /dev/null
@@ -0,0 +1,42 @@
+// File:        XGUI_Preferences.h
+// Created:     07 Aug 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef XGUI_Preferences_H
+#define XGUI_Preferences_H
+
+#include "XGUI.h"
+#include <QDialog>
+
+class SUIT_ResourceMgr;
+class SUIT_PreferenceMgr;
+class QWidget;
+
+class XGUI_EXPORT XGUI_Preferences
+{
+public:
+
+  static void editPreferences();
+
+  static SUIT_ResourceMgr* resourceMgr();
+
+private:
+  static SUIT_ResourceMgr* myResourceMgr;
+};
+
+
+class XGUI_PreferencesDlg: public QDialog
+{
+  Q_OBJECT
+public:
+  XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent = 0);
+  virtual ~XGUI_PreferencesDlg();
+
+private:
+  void createEditors();
+
+  SUIT_PreferenceMgr* myPreferences;
+};
+
+
+#endif
\ No newline at end of file
index 609db462fa7eb2248208512245eaeb10d3fc1344..f59055beb2b1b3605d1c779025f853aa856226c0 100644 (file)
@@ -156,7 +156,7 @@ void XGUI_ViewPort::updateBackground()
   // In OCCT 6.5.3 all above mentioned problems are fixed; so, above comment should be removed as soon
   // as SALOME is migrated to OCCT 6.5.3. The same concerns #ifdef statements in the below code
   switch(myBackground.mode()) {
-  case XGUI::ColorBackground: {
+  case Qtx::ColorBackground: {
     QColor c = myBackground.color();
     if (c.isValid()) {
       // Unset texture should be done here
@@ -171,7 +171,7 @@ void XGUI_ViewPort::updateBackground()
     }
     break;
   }
-  case XGUI::SimpleGradientBackground: {
+  case Qtx::SimpleGradientBackground: {
     QColor c1, c2;
     int type = myBackground.gradient(c1, c2);
     if (c1.isValid() && type >= XGUI::HorizontalGradient && type <= XGUI::LastGradient) {
@@ -222,7 +222,7 @@ void XGUI_ViewPort::updateBackground()
     }
     break;
   }
-  case XGUI::CustomGradientBackground:
+  case Qtx::CustomGradientBackground:
     // NOT IMPLEMENTED YET
     break;
   default:
index c0048f2fad54430451e33e24e6f1c95d0862f5c8..4f445729ba88db177162bd5052644fcd9c49cbd4 100644 (file)
@@ -2,7 +2,7 @@
 #include "XGUI_MainWindow.h"
 #include "XGUI_ViewWindow.h"
 #include "XGUI_ViewPort.h"
-#include "XGUI_Workshop.h"
+#include "XGUI_Preferences.h"
 
 #include <SUIT_ResourceMgr.h>
 
@@ -184,7 +184,7 @@ QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType)
   if (myViews.size() == 0) 
     setTrihedronShown(true);
 
-  Qtx::BackgroundData aBk = XGUI_Workshop::resourceMgr()->backgroundValue("Viewer", "background");
+  Qtx::BackgroundData aBk = XGUI_Preferences::resourceMgr()->backgroundValue("Viewer", "background");
   view->setBackground(aBk);
   view->updateEnabledDrawMode();
 
index a18688e229ec8ecf090e2a8f4aab979cc9952291..25e6166790f957fc9ba1116ad7096fb97538b35e 100644 (file)
@@ -8,7 +8,6 @@
 #include "XGUI_Workbench.h"
 #include "XGUI_Workshop.h"
 #include "XGUI_Viewer.h"
-#include "ModuleBase_WidgetFactory.h"
 #include "XGUI_SelectionMgr.h"
 #include "XGUI_Selection.h"
 #include "XGUI_ObjectsBrowser.h"
@@ -22,6 +21,7 @@
 #include "XGUI_PropertyPanel.h"
 #include "XGUI_ContextMenuMgr.h"
 #include "XGUI_ModuleConnector.h"
+#include "XGUI_Preferences.h"
 
 #include <ModelAPI_Events.h>
 #include <ModelAPI_PluginManager.h>
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_SelectionValidator.h>
 #include <ModuleBase_ResultValidators.h>
+#include "ModuleBase_WidgetFactory.h"
 
 #include <Config_Common.h>
 #include <Config_FeatureMessage.h>
 #include <Config_PointerMessage.h>
 #include <Config_ModuleReader.h>
 
-#include <SUIT_ResourceMgr.h>
-
 #include <QApplication>
 #include <QFileDialog>
 #include <QMessageBox>
@@ -71,8 +70,6 @@
 #include <dlfcn.h>
 #endif
 
-SUIT_ResourceMgr* XGUI_Workshop::myResourceMgr = 0;
-
 QMap<QString, QString> XGUI_Workshop::myIcons;
 
 QString XGUI_Workshop::featureIcon(const std::string& theId)
@@ -92,10 +89,6 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   myObjectBrowser(0),
   myDisplayer(0)
 {
-  if (!myResourceMgr) {
-    myResourceMgr = new SUIT_ResourceMgr("NewGeom");
-    myResourceMgr->setCurrentFormat("xml");
-  }
   myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
 
   myDisplayer = new XGUI_Displayer(this);
@@ -211,6 +204,10 @@ void XGUI_Workshop::initMenu()
   //                              QIcon(":pictures/new.png"), QKeySequence::New);
   //aCommand->connectTo(this, SLOT(onNew()));
 
+  aCommand = aGroup->addFeature("PREF_CMD", tr("Preferences"), tr("Edit preferences"),
+                                QIcon(":pictures/preferences.png"), QKeySequence::Preferences);
+  aCommand->connectTo(this, SLOT(onPreferences()));
+
   aCommand = aGroup->addFeature("EXIT_CMD", tr("Exit"), tr("Exit application"),
                                 QIcon(":pictures/close.png"), QKeySequence::Close);
   aCommand->connectTo(this, SLOT(onExit()));
@@ -667,6 +664,12 @@ void XGUI_Workshop::onRedo()
   updateCommandStatus();
 }
 
+//******************************************************
+void XGUI_Workshop::onPreferences()
+{
+  XGUI_Preferences::editPreferences();
+}
+
 //******************************************************
 ModuleBase_IModule* XGUI_Workshop::loadModule(const QString& theModule)
 {
index c83583cc0f8094bbcf973eaeb5d381776d156a41..be2d9a032f7525841ad5f0960b6a2769bf898bc3 100644 (file)
@@ -43,8 +43,6 @@ class ModelAPI_ObjectUpdatedMessage;
 class ModelAPI_ObjectDeletedMessage;
 class QAction;
 
-class SUIT_ResourceMgr;
-
 /**\class XGUI_Workshop
  * \ingroup GUI
  * \brief Class which defines a configuration of the application (Workshop) and launches it.
@@ -113,8 +111,6 @@ public:
   //! Returns icon name according to feature Id
   static QString featureIcon(const std::string& theId);
 
-  static SUIT_ResourceMgr* resourceMgr() { return myResourceMgr; }
-
   //! Activates or deactivates a part
   //! If PartPtr is Null pointer then PartSet will be activated
   void activatePart(ResultPartPtr theFeature);
@@ -142,6 +138,7 @@ public slots:
   void onExit();
   void onUndo();
   void onRedo();
+  void onPreferences();
 
   void showPropertyPanel();
   void hidePropertyPanel();
@@ -216,9 +213,6 @@ private:
 
   QString myCurrentDir;
   static QMap<QString, QString> myIcons;
-
-  static SUIT_ResourceMgr* myResourceMgr;
-
 };
 
 #endif
index efd946fcb86823b56fba8584e79c39bf0c2edbd9..8a616c63812fefec59f886119648174f323043b7 100644 (file)
@@ -7,6 +7,7 @@
      <file>pictures/redo.png</file>
      <file>pictures/undo.png</file>
      <file>pictures/rebuild.png</file>
+     <file>pictures/preferences.png</file>
 
      <file>pictures/occ_view_back.png</file>
      <file>pictures/occ_view_bottom.png</file>
@@ -59,5 +60,7 @@
      <file>pictures/rename_edit.png</file>
      <file>pictures/eye_pencil.png</file>
      <file>pictures/eye_pencil_closed.png</file>
+   
+     <file>pictures/view_prefs.png</file>
  </qresource>
  </RCC>
diff --git a/src/XGUI/pictures/preferences.png b/src/XGUI/pictures/preferences.png
new file mode 100644 (file)
index 0000000..a5f3308
Binary files /dev/null and b/src/XGUI/pictures/preferences.png differ
diff --git a/src/XGUI/pictures/view_prefs.png b/src/XGUI/pictures/view_prefs.png
new file mode 100644 (file)
index 0000000..9c11769
Binary files /dev/null and b/src/XGUI/pictures/view_prefs.png differ