Salome HOME
Create selection validator and selection object
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchLabel.cpp
1 // File:        PartSet_WidgetSketchLabel.cpp
2 // Created:     07 July 2014
3 // Author:      Vitaly SMETANNIKOV
4
5 #include "PartSet_WidgetSketchLabel.h"
6 #include "PartSet_OperationSketch.h"
7
8 #include <ModuleBase_Operation.h>
9 #include <XGUI_OperationMgr.h>
10
11 #include <Config_WidgetAPI.h>
12
13 #include <QLabel>
14
15 PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent, 
16                                                      const Config_WidgetAPI* theData)
17 : ModuleBase_ModelWidget(theParent, theData)
18 {
19   myText = QString::fromStdString(theData->getProperty("title"));
20   myLabel = new QLabel(myText, theParent);
21   myLabel->setWordWrap(true);
22   myTooltip = QString::fromStdString(theData->getProperty("tooltip"));
23   myLabel->setToolTip(myTooltip);
24 }
25
26 QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
27 {
28   QList<QWidget*> aLst;
29   aLst<<myLabel;
30   return aLst;
31 }
32
33 QWidget* PartSet_WidgetSketchLabel::getControl() const
34 {
35   return myLabel;
36 }
37
38
39
40 void PartSet_WidgetSketchLabel::setOperationsMgr(XGUI_OperationMgr* theMgr)
41 {
42   ModuleBase_Operation* aOperation = theMgr->currentOperation();
43   if (aOperation->inherits("PartSet_OperationSketch")) {
44     PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(aOperation);
45     updateLabel(aSketchOpe);
46     connect(aSketchOpe, SIGNAL(planeSelected(double, double, double)), 
47             this, SLOT(onPlaneSelected()));
48   }
49 }
50
51 void PartSet_WidgetSketchLabel::onPlaneSelected()
52 {
53   PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(sender());
54   updateLabel(aSketchOpe);
55 }
56
57 void PartSet_WidgetSketchLabel::updateLabel(PartSet_OperationSketch* theSketchOpe)
58 {
59   if (theSketchOpe->hasSketchPlane()) {
60     myLabel->setText("");
61     myLabel->setToolTip("");
62   } else {
63     myLabel->setText(myText);
64     myLabel->setToolTip(myTooltip);
65   }
66 }