X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_WidgetSketchLabel.cpp;h=96435f627a95826200c5ed20017793ba04989e46;hb=0b503091623876eda1ae9214e32f8831ef03778b;hp=eeb38baaab46c3e49126cefcc72a37e82af383ec;hpb=d090d2a84b306232c2bfc888594339f0042c9040;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index eeb38baaa..96435f627 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -7,6 +7,8 @@ #include "PartSet_WidgetSketchLabel.h" #include "PartSet_Tools.h" +#include "SketchPlugin_SketchEntity.h" + #include #include #include @@ -16,6 +18,7 @@ #include #include +#include #include #include @@ -36,15 +39,16 @@ #include #include - -#define PLANE_SIZE "200" -#define SKETCH_WIDTH "4" +#include +#include 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); @@ -56,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() @@ -65,12 +74,9 @@ PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel() QList PartSet_WidgetSketchLabel::getControls() const { - return QList(); -} - -QWidget* PartSet_WidgetSketchLabel::getControl() const -{ - return myLabel; + QList aResult; + aResult << myLabel; + return aResult; } void PartSet_WidgetSketchLabel::onPlaneSelected() @@ -89,7 +95,7 @@ void PartSet_WidgetSketchLabel::onPlaneSelected() DataPtr aData = feature()->data(); AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast - (aData->attribute(SketchPlugin_Feature::EXTERNAL_ID())); + (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); if (aSelAttr) { ResultPtr aRes = std::dynamic_pointer_cast(aPrs.object()); if (aRes) { @@ -117,6 +123,7 @@ void PartSet_WidgetSketchLabel::onPlaneSelected() // Update sketcher actions XGUI_ActionsMgr* anActMgr = myWorkshop->actionsMgr(); anActMgr->update(); + myWorkshop->viewer()->update(); } } } @@ -129,7 +136,18 @@ std::shared_ptr PartSet_WidgetSketchLabel::plane() const } -void PartSet_WidgetSketchLabel::activate() +bool PartSet_WidgetSketchLabel::focusTo() +{ + myLabel->setFocus(); + return true; +} + +void PartSet_WidgetSketchLabel::enableFocusProcessing() +{ + myLabel->installEventFilter(this); +} + +void PartSet_WidgetSketchLabel::activateCustom() { std::shared_ptr aPlane = plane(); if (aPlane) { @@ -192,9 +210,16 @@ void PartSet_WidgetSketchLabel::showPreviewPlanes() std::shared_ptr aXZDir(new GeomAPI_Dir(0, 1, 0)); std::shared_ptr aXYDir(new GeomAPI_Dir(0, 0, 1)); - int aR[] = {255, 0, 0}; - int aG[] = {0, 255, 0}; - int aB[] = {0, 0, 255}; + std::vector aYZRGB, aXZRGB, aXYRGB; + aYZRGB = Config_PropManager::color("Visualization", "yz_plane_color", + YZ_PLANE_COLOR); + aXZRGB = Config_PropManager::color("Visualization", "xz_plane_color", + XZ_PLANE_COLOR); + aXYRGB = Config_PropManager::color("Visualization", "xy_plane_color", + XY_PLANE_COLOR); + int aR[] = {aYZRGB[0], aYZRGB[1], aYZRGB[2]}; + int aG[] = {aXZRGB[0], aXZRGB[1], aXZRGB[2]}; + int aB[] = {aXYRGB[0], aXYRGB[1], aXYRGB[2]}; myYZPlane = createPreviewPlane(anOrigin, aYZDir, aR); myXZPlane = createPreviewPlane(anOrigin, aXZDir, aG); @@ -212,7 +237,7 @@ AISObjectPtr PartSet_WidgetSketchLabel::createPreviewPlane(std::shared_ptr theNorm, const int theRGB[3]) { - double aSize = Config_PropManager::integer("Sketch planes", "Size of planes", PLANE_SIZE); + double aSize = Config_PropManager::integer("Sketch planes", "planes_size", PLANE_SIZE); std::shared_ptr aFace = GeomAlgoAPI_FaceBuilder::square(theOrigin, theNorm, aSize); AISObjectPtr aAIS = AISObjectPtr(new GeomAPI_AISObject()); aAIS->createShape(aFace); @@ -272,8 +297,6 @@ std::shared_ptr PartSet_WidgetSketchLabel::setSketchPlane(const Top void PartSet_WidgetSketchLabel::setSketchingMode() { - qDebug("### Set sketching mode"); - XGUI_Displayer* aDisp = myWorkshop->displayer(); // Clear standard selection modes if they are defined //aDisp->activateObjects(aModes);