Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom.git into Dev_1.1.0
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchLabel.cpp
index 9fff4686996f5bad134648b16a32382df9218baf..5925437ed68ebcdf91fe921535220636c0141e50 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
 
 #include <GeomAlgoAPI_FaceBuilder.h>
 #include <GeomDataAPI_Point.h>
 #include <QLabel>
 #include <QTimer>
 #include <QApplication>
-
-#define PLANE_SIZE          "200"     
-#define SKETCH_WIDTH        "4"
+#include <QVBoxLayout>
 
 
 PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
                                                      const Config_WidgetAPI* theData,
                                                      const std::string& theParentId)
-    : ModuleBase_ModelWidget(theParent, theData, theParentId), myPreviewDisplayed(false)
+    : ModuleBase_ModelWidget(theParent, theData, theParentId),
+      myPreviewDisplayed(false),
+      myWorkshop(NULL)
 {
   myText = QString::fromStdString(theData->getProperty("title"));
   myLabel = new QLabel("", theParent);
@@ -57,6 +58,11 @@ PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
   mySelectionTimer = new QTimer(this);
   connect(mySelectionTimer, SIGNAL(timeout()), SLOT(setSketchingMode()));
   mySelectionTimer->setSingleShot(true);
+
+  QVBoxLayout* aLayout = new QVBoxLayout(this);
+  ModuleBase_Tools::zeroMargins(aLayout);
+  aLayout->addWidget(myLabel);
+  setLayout(aLayout);
 }
 
 PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel()
@@ -69,11 +75,6 @@ QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
   return QList<QWidget*>();
 }
 
-QWidget* PartSet_WidgetSketchLabel::getControl() const
-{
-  return myLabel;
-}
-
 void PartSet_WidgetSketchLabel::onPlaneSelected()
 {
   XGUI_Selection* aSelection = myWorkshop->selector()->selection();
@@ -131,7 +132,7 @@ std::shared_ptr<GeomAPI_Pln> PartSet_WidgetSketchLabel::plane() const
 
 }
 
-void PartSet_WidgetSketchLabel::activate()
+void PartSet_WidgetSketchLabel::activateCustom()
 {
   std::shared_ptr<GeomAPI_Pln> aPlane = plane();
   if (aPlane) {
@@ -194,9 +195,16 @@ void PartSet_WidgetSketchLabel::showPreviewPlanes()
     std::shared_ptr<GeomAPI_Dir> aXZDir(new GeomAPI_Dir(0, 1, 0));
     std::shared_ptr<GeomAPI_Dir> aXYDir(new GeomAPI_Dir(0, 0, 1));
 
-    int aR[] = {255, 0, 0};
-    int aG[] = {0, 255, 0};
-    int aB[] = {0, 0, 255};
+    std::vector<int> aYZRGB, aXZRGB, aXYRGB;
+    aYZRGB = Config_PropManager::color("Visualization", "yz_plane_color",
+                                                        YZ_PLANE_COLOR);
+    aXZRGB = Config_PropManager::color("Visualization", "xz_plane_color",
+                                                        XZ_PLANE_COLOR);
+    aXYRGB = Config_PropManager::color("Visualization", "xy_plane_color",
+                                                        XY_PLANE_COLOR);
+    int aR[] = {aYZRGB[0], aYZRGB[1], aYZRGB[2]};
+    int aG[] = {aXZRGB[0], aXZRGB[1], aXZRGB[2]};
+    int aB[] = {aXYRGB[0], aXYRGB[1], aXYRGB[2]};
 
     myYZPlane = createPreviewPlane(anOrigin, aYZDir, aR);
     myXZPlane = createPreviewPlane(anOrigin, aXZDir, aG);
@@ -214,7 +222,7 @@ AISObjectPtr PartSet_WidgetSketchLabel::createPreviewPlane(std::shared_ptr<GeomA
                                                            std::shared_ptr<GeomAPI_Dir> theNorm, 
                                                            const int theRGB[3])
 {
-  double aSize = Config_PropManager::integer("Sketch planes", "Size of planes", PLANE_SIZE);
+  double aSize = Config_PropManager::integer("Sketch planes", "planes_size", PLANE_SIZE);
   std::shared_ptr<GeomAPI_Shape> aFace = GeomAlgoAPI_FaceBuilder::square(theOrigin, theNorm, aSize);
   AISObjectPtr aAIS = AISObjectPtr(new GeomAPI_AISObject());
   aAIS->createShape(aFace);
@@ -274,8 +282,6 @@ std::shared_ptr<GeomAPI_Dir> PartSet_WidgetSketchLabel::setSketchPlane(const Top
 
 void PartSet_WidgetSketchLabel::setSketchingMode()
 {
-  qDebug("### Set sketching mode");
-
   XGUI_Displayer* aDisp = myWorkshop->displayer();
   // Clear standard selection modes if they are defined
   //aDisp->activateObjects(aModes);