]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_WidgetSketchLabel.cpp
Salome HOME
de9c411c1db1c02b3ec647871f88fb99f9493646
[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     connect(aSketchOpe, SIGNAL(planeSelected(double, double, double)), 
46             this, SLOT(onPlaneSelected()));
47   }
48 }
49
50 void PartSet_WidgetSketchLabel::onPlaneSelected()
51 {
52   PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(sender());
53   if (aSketchOpe->hasSketchPlane()) {
54     myLabel->setText("");
55     myLabel->setToolTip("");
56   } else {
57     myLabel->setText(myText);
58     myLabel->setToolTip(myTooltip);
59   }
60 }