]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_WidgetSketchLabel.cpp
Salome HOME
b6f18fb7f365b654ec02be44ad573d818f7f9d93
[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("", theParent);
22   myLabel->setWordWrap(true);
23   myTooltip = QString::fromStdString(theData->getProperty("tooltip"));
24   myLabel->setToolTip("");
25   myLabel->setIndent(5);
26 }
27
28 QList<QWidget*> PartSet_WidgetSketchLabel::getControls() const
29 {
30   return QList<QWidget*>();
31 }
32
33 QWidget* PartSet_WidgetSketchLabel::getControl() const
34 {
35   return myLabel;
36 }
37
38 void PartSet_WidgetSketchLabel::setOperationsMgr(XGUI_OperationMgr* theMgr)
39 {
40   ModuleBase_Operation* aOperation = theMgr->currentOperation();
41   if (aOperation->inherits("PartSet_OperationSketch")) {
42     PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(aOperation);
43     updateLabel(aSketchOpe);
44     connect(aSketchOpe, SIGNAL(updatePropPanel()), this,
45             SLOT(onPlaneSelected()));
46   }
47 }
48
49 void PartSet_WidgetSketchLabel::onPlaneSelected()
50 {
51   PartSet_OperationSketch* aSketchOpe = static_cast<PartSet_OperationSketch*>(sender());
52   updateLabel(aSketchOpe);
53 }
54
55 void PartSet_WidgetSketchLabel::updateLabel(PartSet_OperationSketch* theSketchOpe)
56 {
57   if (theSketchOpe->hasSketchPlane()) {
58     myLabel->setText("");
59     myLabel->setToolTip("");
60   } else {
61     myLabel->setText(myText);
62     myLabel->setToolTip(myTooltip);
63   }
64 }