Salome HOME
Correction of icon
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchLabel.cpp
index f3001c881b3325eeb4f240d2d84406c932a83ccd..96435f627a95826200c5ed20017793ba04989e46 100644 (file)
@@ -7,6 +7,8 @@
 #include "PartSet_WidgetSketchLabel.h"
 #include "PartSet_Tools.h"
 
+#include "SketchPlugin_SketchEntity.h"
+
 #include <XGUI_Workshop.h>
 #include <XGUI_Displayer.h>
 #include <XGUI_SelectionMgr.h>
@@ -16,6 +18,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>
+#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);
@@ -54,6 +60,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()
@@ -63,12 +74,9 @@ PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel()
 
 QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
 {
-  return QList<QWidget*>();
-}
-
-QWidget* PartSet_WidgetSketchLabel::getControl() const
-{
-  return myLabel;
+  QList<QWidget*> aResult;
+  aResult << myLabel;
+  return aResult;
 }
 
 void PartSet_WidgetSketchLabel::onPlaneSelected()
@@ -87,7 +95,7 @@ void PartSet_WidgetSketchLabel::onPlaneSelected()
           DataPtr aData = feature()->data();
           AttributeSelectionPtr aSelAttr = 
             std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
-            (aData->attribute(SketchPlugin_Feature::EXTERNAL_ID()));
+            (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
           if (aSelAttr) {
             ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs.object());
             if (aRes) {
@@ -128,6 +136,17 @@ std::shared_ptr<GeomAPI_Pln> PartSet_WidgetSketchLabel::plane() const
 
 }
 
+bool PartSet_WidgetSketchLabel::focusTo()
+{
+  myLabel->setFocus();
+  return true;
+}
+
+void PartSet_WidgetSketchLabel::enableFocusProcessing()
+{
+  myLabel->installEventFilter(this);
+}
+
 void PartSet_WidgetSketchLabel::activateCustom()
 {
   std::shared_ptr<GeomAPI_Pln> aPlane = plane();