Salome HOME
Merge branch 'master' of newgeom:newgeom
[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   const std::string& theParentId)
18 : ModuleBase_ModelWidget(theParent, theData, theParentId)
19 {
20   myText = QString::fromStdString(theData->getProperty("title"));
21   myLabel = new QLabel(myText, theParent);
22   myLabel->setWordWrap(true);
23   myTooltip = QString::fromStdString(theData->getProperty("tooltip"));
24   myLabel->setToolTip(myTooltip);
25 }
26
27 QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
28 {
29   QList<QWidget*> aLst;
30   aLst<<myLabel;
31   return aLst;
32 }
33
34 QWidget* PartSet_WidgetSketchLabel::getControl() const
35 {
36   return myLabel;
37 }
38
39
40
41 void PartSet_WidgetSketchLabel::setOperationsMgr(XGUI_OperationMgr* theMgr)
42 {
43   ModuleBase_Operation* aOperation = theMgr->currentOperation();
44   if (aOperation->inherits("PartSet_OperationSketch")) {
45     PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(aOperation);
46     updateLabel(aSketchOpe);
47     connect(aSketchOpe, SIGNAL(planeSelected(double, double, double)), 
48             this, SLOT(onPlaneSelected()));
49   }
50 }
51
52 void PartSet_WidgetSketchLabel::onPlaneSelected()
53 {
54   PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(sender());
55   updateLabel(aSketchOpe);
56 }
57
58 void PartSet_WidgetSketchLabel::updateLabel(PartSet_OperationSketch* theSketchOpe)
59 {
60   if (theSketchOpe->hasSketchPlane()) {
61     myLabel->setText("");
62     myLabel->setToolTip("");
63   } else {
64     myLabel->setText(myText);
65     myLabel->setToolTip(myTooltip);
66   }
67 }