From d4f8c8352b15051ed112c64a20fbd93d302dc94c Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 7 Nov 2019 16:50:53 +0300 Subject: [PATCH] Task 5.2.5 Add some warnings (tooltips) to critical places --- src/PartSet/PartSet_WidgetSketchLabel.cpp | 37 +++++++++++++++++++++++ src/PartSet/PartSet_WidgetSketchLabel.h | 7 +++++ 2 files changed, 44 insertions(+) diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 0dde98c1c..f4514b927 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -78,6 +78,7 @@ #include #include #include +#include #ifndef DBL_MAX #define DBL_MAX 1.7976931348623158e+308 @@ -112,6 +113,23 @@ myIsSelection(false) mySizeOfView->setValidator(aValidator); aSizeLayout->addWidget(mySizeOfView); + myPartSetMessage = new QDialog(this, Qt::ToolTip); + myPartSetMessage->setModal(false); + myPartSetMessage->setStyleSheet("background-color:lightyellow;"); + QVBoxLayout* aMsgLay = new QVBoxLayout(myPartSetMessage); + QString aMsg = tr("The Sketch is created in PartSet.\n" + "It will be necessary to create a Part in order to use this sketch for body creation"); + aMsgLay->addWidget(new QLabel(aMsg, myPartSetMessage)); + myPartSetMessage->hide(); + + mySizeMessage = new QDialog(mySizeOfView, Qt::ToolTip); + mySizeMessage->setModal(false); + mySizeMessage->setStyleSheet("background-color:lightyellow;"); + aMsgLay = new QVBoxLayout(mySizeMessage); + aMsg = tr("A size of Sketch view can be defined here."); + aMsgLay->addWidget(new QLabel(aMsg, mySizeMessage)); + mySizeMessage->hide(); + QString aText = translate(theData->getProperty("title")); QLabel* aLabel = new QLabel(aText, aFirstWgt); aLabel->setWordWrap(true); @@ -309,6 +327,10 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs GeomPlanePtr aPlane = plane(); if (!aPlane.get()) return; + + myPartSetMessage->hide(); + mySizeMessage->hide(); + // 1. hide main planes if they have been displayed and display sketch preview plane myPreviewPlanes->erasePreviewPlanes(myWorkshop); @@ -548,6 +570,21 @@ void PartSet_WidgetSketchLabel::activateCustom() mySizeOfViewWidget->setVisible(false); } +void PartSet_WidgetSketchLabel::showEvent(QShowEvent* theEvent) +{ + if (mySizeOfViewWidget->isVisible()) { + DocumentPtr aDoc = feature()->document(); + DocumentPtr aModDoc = ModelAPI_Session::get()->moduleDocument(); + if (aModDoc == aDoc) { + myPartSetMessage->move(mapToGlobal(geometry().bottomLeft())); + myPartSetMessage->show(); + } + mySizeMessage->move(mySizeOfView->mapToGlobal(mySizeOfView->geometry().center())); + mySizeMessage->show(); + } +} + + void PartSet_WidgetSketchLabel::deactivate() { ModuleBase_WidgetValidated::deactivate(); diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index fe9c14716..fbc339502 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -41,6 +41,7 @@ class XGUI_Workshop; class QCheckBox; class QStackedWidget; class QLineEdit; +class QDialog; /** * \ingroup Modules @@ -193,6 +194,9 @@ protected: /// \param thePrs a presentation bool fillSketchPlaneBySelection(const std::shared_ptr& thePrs); + + virtual void showEvent(QShowEvent* theEvent); + private slots: /// A slot called on set sketch plane view void onSetPlaneView(); @@ -238,6 +242,9 @@ private: bool myOpenTransaction; bool myIsSelection; + + QDialog* myPartSetMessage; + QDialog* mySizeMessage; }; #endif -- 2.39.2