#include <QRadioButton>
#include <QToolButton>
+const QString AStyle = "QToolButton:checked {border: 1px solid black; background-color:#C0DCF3}";
+
+
ModuleBase_ChoiceCtrl::ModuleBase_ChoiceCtrl(QWidget* theParent,
const QStringList& theChoiceList,
const QStringList& theIconsList,
QPixmap aIcon = ModuleBase_IconFactory::loadPixmap(theIconsList.at(aId));
aBtn->setIcon(aIcon);
aBtn->setIconSize(aIcon.size());
+ aBtn->setStyleSheet(AStyle);
aBtnLayout->addWidget(aBtn);
myButtons->addButton(aBtn, aId++);
/// Have an opportunity to create widgets for the current operation
/// instead of standard creation in workshop
- /// \param theOperation a started operation
+ /// \param theFeature a feature of the started operation
+ /// \param theXmlRepr an XML representation of the operation
/// \param theWidgets a list of created widgets
/// \return boolean result, false by default
- virtual bool createWidgets(ModuleBase_Operation* theOperation,
+ virtual bool createWidgets(const FeaturePtr& theFeature, const QString& theXmlRepr,
QList<ModuleBase_ModelWidget*>& theWidgets) const { return false; }
//! Returns True if there are available Undos and there is not an active operation
//**************************************************************
bool ModuleBase_ModelWidget::restoreValue()
{
+ if (!isEnabled()) {
+ // This code works in inspection panel
+ ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
+ if (!aValidators->isCase(myFeature, attributeID()))
+ return false; // if it is not an active case for the widget
+ }
emit beforeValuesRestored();
bool isDone = restoreValueCustom();
emit afterValuesRestored();
/// By default this slot does nothing
virtual void onFeatureAccepted() {}
+ /// Returns True in case if the widget contains useful information for inspection tool
+ virtual bool isInformative() const { return true; }
+
+ /// If widgets has several panels then this method has to show a page which contains information
+ /// for current feature. By default does nothing
+ virtual void showInformativePage() {}
+
signals:
/// The signal about widget values are to be changed
void beforeValuesChanged();
#include <ModuleBase_PagedContainer.h>
+const QString AStyle = "QToolButton:checked {border: 1px solid black; background-color:#C0DCF3}";
+
+
ModuleBase_ToolBox::ModuleBase_ToolBox(QWidget* theParent, const bool theUseFrameStyleBox)
: QFrame(theParent)
{
QToolButton* aButton = new QToolButton(myButtonsFrame);
aButton->setFocusPolicy(Qt::StrongFocus);
aButton->setCheckable(true);
+ aButton->setStyleSheet(AStyle);
if (theIcon.isNull())
aButton->setText(theName);
else {
std::string aTextRepr = aRef->text();
if (!aTextRepr.empty()) {
QString aText = QString::fromStdString(aTextRepr);
- //if (aText.endsWith('=')) {
- // if (!myParameter.get()) {
- // QString aName = aText.left(aText.indexOf('=')).trimmed();
- // myParameter = ModuleBase_Tools::findParameter(aName);
- // }
- // /// If myParameter is empty then it was not created because of an error
- // if (!myParameter.get())
- // return false;
-
- // AttributeStringPtr aExprAttr = myParameter->string("expression");
- // aText += aExprAttr->value().c_str();
- //}
ModuleBase_Tools::setSpinText(mySpinBox, aText);
}
else {
}
//******************************************************
-bool PartSet_Module::createWidgets(ModuleBase_Operation* theOperation,
+bool PartSet_Module::createWidgets(const FeaturePtr& theFeature, const QString& theXmlRepr,
QList<ModuleBase_ModelWidget*>& theWidgets) const
{
bool aProcessed = false;
- ModuleBase_OperationFeature* aFOperation =
- dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
XGUI_Workshop* aWorkshop = getWorkshop();
XGUI_PropertyPanel* aPropertyPanel = aWorkshop->propertyPanel();
- if (mySketchMgr->activeSketch().get() && aFOperation && aPropertyPanel) {
+ if (mySketchMgr->activeSketch().get() && aPropertyPanel) {
ModuleBase_ISelection* aSelection = workshop()->selection();
// click on a point in sketch leads here with the point is highlighted, not yet selected
QList<ModuleBase_ViewerPrsPtr> aPreselection = aSelection->getHighlighted();
ObjectPtr anObject = aSelectedPrs->object();
FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
- FeaturePtr anOpFeature = aFOperation->feature();
GeomShapePtr aShape = aSelectedPrs->shape();
// click on the digit of dimension constrain comes here
// with an empty shape, so we need the check
- if (aFeature == anOpFeature && aShape.get() && !aShape->isNull()) {
+ if (aFeature == theFeature && aShape.get() && !aShape->isNull()) {
// if feature has only one result and shape of result is equal to selected shape
// this attribute is not processed. It is a case of Sketch Point.
if (aFeature->results().size() == 1) {
AttributePtr anAttribute = PartSet_Tools::findAttributeBy2dPoint(anObject, aTDShape,
mySketchMgr->activeSketch());
if (anAttribute.get()) {
- QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
- ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), workshop());
+ ModuleBase_WidgetFactory aFactory(theXmlRepr.toStdString(), workshop());
const std::string anAttributeId = anAttribute->id();
aFactory.createWidget(aPropertyPanel->contentWidget(), anAttributeId);
/// If there is found selected attribute, widgets are created and contains
/// only a widget for the attribute
/// It is important for Property Panel filling by sketch point attribute
- /// \param theOperation a started operation
+ /// \param theFeature a feature of the started operation
+ /// \param theXmlRepr an XML representation of the operation
/// \param theWidgets a list of created widgets
/// \return boolean result, false by default
- virtual bool createWidgets(ModuleBase_Operation* theOperation,
+ virtual bool createWidgets(const FeaturePtr& theFeature, const QString& theXmlRepr,
QList<ModuleBase_ModelWidget*>& theWidgets) const;
/// Launching of a edit operation on the feature
/// \return a boolean value
virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
+ /// Returns True in case if the widget contains useful information for inspection tool
+ virtual bool isInformative() const { return false; }
+
protected:
/// If there is no operation in current session, start operation for modify parameters
/// \return true if the operation was not opened
#include <QCheckBox>
#include <QGroupBox>
#include <QPushButton>
-#include <QStackedWidget>
#include <QLineEdit>
#include <QDoubleValidator>
#include <QDialog>
#include <TopoDS_Shape.hxx>
+#include <QStackedWidget>
#include <QMap>
class PartSet_PreviewPlanes;
/// \param thePrs a presentation
static bool canFillSketch(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
+ /// If widgets has several panels then this method has to show a page which contains information
+ /// for current feature. By default does nothing
+ virtual void showInformativePage() {
+ if (myStackWidget) myStackWidget->setCurrentIndex(1);
+ }
+
signals:
/// Signal on plane selection
void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
//
#include "XGUI_InspectionPanel.h"
+#include "XGUI_Workshop.h"
#include "XGUI_SelectionMgr.h"
#include "XGUI_Selection.h"
#include "XGUI_Tools.h"
+#include "XGUI_ModuleConnector.h"
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_Tools.h>
+#include <ModuleBase_OperationDescription.h>
+#include <ModuleBase_WidgetFactory.h>
+#include <ModuleBase_IModule.h>
+#include <ModuleBase_PageWidget.h>
+
#include <ModelAPI_ResultField.h>
#include <ModelAPI_Result.h>
#include <QTextBrowser>
#include <QResizeEvent>
#include <QSplitter>
+#include <QStackedWidget>
#include <BRepBndLib.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_ListOfShape.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic
+
// ================ Auxiliary functions ================
#define TITLE(val) ("<b>" + (val) + "</b>")
// ================ XGUI_InspectionPanel ================
-XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr* theMgr)
+XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_Workshop* theWorkshop)
: QDockWidget(theParent),
- mySelectionMgr(theMgr)
+ myWorkshop(theWorkshop)
{
setWindowTitle(tr("Inspection Panel"));
setObjectName(INSPECTION_PANEL);
setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
- QSplitter* aSplitter = new QSplitter(Qt::Vertical, this);
+ myStackWgt = new QStackedWidget(this);
+
+ // Create shape selection page
+ QSplitter* aSplitter = new QSplitter(Qt::Vertical, myStackWgt);
// Create an internal widget
QWidget* aNameWgt = new QWidget(aSplitter);
aSizes << 10 << 140 << 10;
aSplitter->setSizes(aSizes);
- setWidget(aSplitter);
+ myShapePanelId = myStackWgt->addWidget(aSplitter);
+
+ // Create feature selection page
+ QScrollArea* aScroll = new QScrollArea(myStackWgt);
+ aScroll->setWidgetResizable(true);
+ aScroll->setFrameStyle(QFrame::NoFrame);
+
+ myFeaturePane = new ModuleBase_PageWidget(aScroll);
+ myFeatureLayout = new QGridLayout(myFeaturePane);
+ myFeatureLayout->setContentsMargins(3, 3, 3, 3);
+ aScroll->setWidget(myFeaturePane);
+ //myFeaturePane->setEnabled(false);
- connect(mySelectionMgr, SIGNAL(selectionChanged()), SLOT(onSelectionChanged()));
+ myFeaturePanelId = myStackWgt->addWidget(aScroll);
+
+ setWidget(myStackWgt);
+ connect(myWorkshop->selector(), SIGNAL(selectionChanged()), SLOT(onSelectionChanged()));
}
//********************************************************************
}
myTypeLbl->setText("");
setParamsText("");
+
+ myFeaturePane->clearPage();
}
//********************************************************************
void XGUI_InspectionPanel::onSelectionChanged()
{
+ if (!isVisible())
+ return;
+
clearContent();
- XGUI_Selection* aSelection = mySelectionMgr->selection();
- QList<ModuleBase_ViewerPrsPtr> aSelectedList =
- aSelection->getSelected(ModuleBase_ISelection::Viewer);
- QList<ModuleBase_ViewerPrsPtr> anOBSelected =
- aSelection->getSelected(ModuleBase_ISelection::Browser);
- if (!anOBSelected.isEmpty())
- ModuleBase_ISelection::appendSelected(anOBSelected, aSelectedList);
+ XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+ QList<ModuleBase_ViewerPrsPtr> aSelectedList =
+ aSelection->getSelected(myWorkshop->selector()->placeOfSelection());
if (aSelectedList.count() > 0) {
ModuleBase_ViewerPrsPtr aPrs = aSelectedList.first();
std::dynamic_pointer_cast<ModelAPI_ResultField::ModelAPI_FieldStep>(aPrs->object());
if (aStep)
return;
- TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(aPrs);
- if (aShape.IsNull()) {
- ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs->object());
- if (aRes.get()) {
- GeomShapePtr aShpPtr = aRes->shape();
- if (aShpPtr.get()) {
- aShape = aShpPtr->impl<TopoDS_Shape>();
+ FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aPrs->object());
+ if (aFeature.get()) {
+ myStackWgt->setCurrentIndex(myFeaturePanelId);
+ buildFeaturePane(aFeature);
+ }
+ else {
+ myStackWgt->setCurrentIndex(myShapePanelId);
+ TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(aPrs);
+ if (aShape.IsNull()) {
+ ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs->object());
+ if (aRes.get()) {
+ GeomShapePtr aShpPtr = aRes->shape();
+ if (aShpPtr.get()) {
+ aShape = aShpPtr->impl<TopoDS_Shape>();
+ }
}
}
+ if (aShape.IsNull())
+ return;
+ GeomShapePtr aShapePtr(new GeomAPI_Shape());
+ aShapePtr->setImpl(new TopoDS_Shape(aShape));
+
+ ModuleBase_ViewerPrsPtr aPrsCopy(new ModuleBase_ViewerPrs(aPrs->object(), aShapePtr));
+ setName(XGUI_Tools::generateName(aPrsCopy));
+ setShapeContent(aShape);
+ setShapeParams(aShape);
}
- if (aShape.IsNull())
- return;
- GeomShapePtr aShapePtr(new GeomAPI_Shape());
- aShapePtr->setImpl(new TopoDS_Shape(aShape));
-
- ModuleBase_ViewerPrsPtr aPrsCopy(new ModuleBase_ViewerPrs(aPrs->object(), aShapePtr));
- setName(XGUI_Tools::generateName(aPrsCopy));
- setShapeContent(aShape);
- setShapeParams(aShape);
}
}
appendPointToParameters(tr("Maximal corner"), aMaxPoint, aParams);
}
+//********************************************************************
void XGUI_InspectionPanel::setPlaneType(const QString& theTitle,
const std::shared_ptr<GeomAPI_Pln>& thePlane)
{
setParamsText(aParams);
}
+//********************************************************************
void XGUI_InspectionPanel::setSphereType(const QString& theTitle,
const std::shared_ptr<GeomAPI_Sphere>& theSphere)
{
setParamsText(aParams);
}
+//********************************************************************
void XGUI_InspectionPanel::setCylinderType(const QString& theTitle,
const std::shared_ptr<GeomAPI_Cylinder>& theCyl)
{
setParamsText(aParams);
}
+//********************************************************************
void XGUI_InspectionPanel::setConeType(const QString& theTitle,
const std::shared_ptr<GeomAPI_Cone>& theCone)
{
setParamsText(aParams);
}
+//********************************************************************
void XGUI_InspectionPanel::setTorusType(const QString& theTitle,
const std::shared_ptr<GeomAPI_Torus>& theTorus)
{
setParamsText(aParams);
}
+//********************************************************************
void XGUI_InspectionPanel::setBoxType(const QString& theTitle,
const std::shared_ptr<GeomAPI_Box>& theBox)
{
setParamsText(aParams);
}
+//********************************************************************
void XGUI_InspectionPanel::setRotatedBoxType(const QString& theTitle,
const std::shared_ptr<GeomAPI_Box>& theBox)
{
}
+//********************************************************************
void XGUI_InspectionPanel::setParamsText(const QString& theText)
{
myTypeParams->setText(theText);
}
+
+//********************************************************************
+void XGUI_InspectionPanel::buildFeaturePane(const FeaturePtr& theFeature)
+{
+ std::string aXmlCfg, aDescription;
+ myWorkshop->module()->getXMLRepresentation(theFeature->getKind(), aXmlCfg, aDescription);
+ if (!aXmlCfg.empty()) {
+ QList<ModuleBase_ModelWidget*> aWidgets;
+ if (!myWorkshop->module()->createWidgets(theFeature, aXmlCfg.c_str(), aWidgets)) {
+ ModuleBase_WidgetFactory aFactory(aXmlCfg, myWorkshop->moduleConnector());
+ aFactory.createWidget(myFeaturePane);
+ aWidgets = aFactory.getModelWidgets();
+ }
+ foreach(ModuleBase_ModelWidget* aWgt, aWidgets) {
+ if (aWgt->isInformative()) {
+ aWgt->setEnabled(false);
+ aWgt->setFeature(theFeature, false, false);
+ aWgt->setEditingMode(true);
+ aWgt->restoreValue();
+ aWgt->showInformativePage();
+ }
+ else {
+ aWgt->setFeature(theFeature, false, false);
+ aWgt->setEditingMode(true);
+ aWgt->hide();
+ }
+ }
+ }
+}
+
+void XGUI_InspectionPanel::showEvent(QShowEvent* theEvent)
+{
+ QDockWidget::showEvent(theEvent);
+ onSelectionChanged();
+}
#include "XGUI.h"
+#include <ModelAPI_Feature.h>
+
#include <QDockWidget>
#include <memory>
-class XGUI_SelectionMgr;
+class XGUI_Workshop;
class QLineEdit;
class QTableWidget;
class QLabel;
class QTextBrowser;
class QVBoxLayout;
class QResizeEvent;
+class QStackedWidget;
+class QGridLayout;
class TopoDS_Shape;
class GeomAPI_Cone;
class GeomAPI_Torus;
class GeomAPI_Box;
+class ModuleBase_PageWidget;
/// Internal name of property panel widget
const static char* INSPECTION_PANEL = "inspection_panel_dock";
/// Constructor
/// \param theParent is a parent of the property panel
/// \param theMgr operation manager
- XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr* theMgr);
+ XGUI_InspectionPanel(QWidget* theParent, XGUI_Workshop* theWorkshop);
// Destructor
virtual ~XGUI_InspectionPanel();
+protected:
+ virtual void showEvent(QShowEvent* theEvent);
private slots:
/// A slot to react on selection changed
/// \param theBox the box
void setRotatedBoxType(const QString& theTitle, const std::shared_ptr<GeomAPI_Box>& theBox);
-
/// Set text into parameters area
/// \param theText the text
void setParamsText(const QString& theText);
+ /// Fills Feature panel with controls specific to the given feature
+ /// \param theFeature the selected feature
+ void buildFeaturePane(const FeaturePtr& theFeature);
+
private:
- XGUI_SelectionMgr* mySelectionMgr; //> selection manager
-
- QLineEdit* myNameEdt; //> Name field
- QTableWidget* mySubShapesTab; //> table of sub-shapes
- QLabel* myTypeLbl; //> label of a type
- QTextBrowser* myTypeParams; //> parameters area
- QVBoxLayout* myMainLayout; //> main layout
- //QWidget* myMainWidget; //> main widget
+ XGUI_Workshop* myWorkshop; //> selection manager
+
+ QLineEdit* myNameEdt; ///> Name field
+ QTableWidget* mySubShapesTab; ///> table of sub-shapes
+ QLabel* myTypeLbl; ///> label of a type
+ QTextBrowser* myTypeParams; ///> parameters area
+ QVBoxLayout* myMainLayout; ///> main layout
+ ModuleBase_PageWidget* myFeaturePane; ///> Content of feature property panel
+ QGridLayout* myFeatureLayout; ///> Layout of feature panel
+ QStackedWidget* myStackWgt; ///> base widget of the panel
+ int myShapePanelId;
+ int myFeaturePanelId;
};
#endif
\ No newline at end of file
//**************************************************************
void XGUI_SelectionMgr::onObjectBrowserSelection()
{
+ myLastSelectionPlace = ModuleBase_ISelection::Browser;
QList<ModuleBase_ViewerPrsPtr> aSelectedPrs =
myWorkshop->selector()->selection()->getSelected(ModuleBase_ISelection::Browser);
XGUI_Displayer* aDisplayer = myWorkshop->displayer();
//**************************************************************
void XGUI_SelectionMgr::onViewerSelection()
{
+ myLastSelectionPlace = ModuleBase_ISelection::Viewer;
QList<ModuleBase_ViewerPrsPtr> aValues;
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
if (!aContext.IsNull())
return mySelection;
}
+ ModuleBase_ISelection::SelectionPlace placeOfSelection() const {
+ return myLastSelectionPlace;
+ }
+
//! Connects the manager to all viewers accessible by Workshop
void connectViewers();
/// Current selection object
XGUI_Selection* mySelection;
+
+ ModuleBase_ISelection::SelectionPlace myLastSelectionPlace;
};
#endif
myPropertyPanel->cleanContent();
QList<ModuleBase_ModelWidget*> aWidgets;
- if (!module()->createWidgets(theOperation, aWidgets)) {
- QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+ QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+ if (!module()->createWidgets(aFOperation->feature(), aXmlRepr, aWidgets)) {
ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myModuleConnector);
aFactory.createWidget(myPropertyPanel->contentWidget());
aWidgets = aFactory.getModelWidgets();
Qt::BottomDockWidgetArea);
connect(myFacesPanel, SIGNAL(closed()), myFacesPanel, SLOT(onClosed()));
- myInspectionPanel = new XGUI_InspectionPanel(aDesktop, mySelector);
+ myInspectionPanel = new XGUI_InspectionPanel(aDesktop, this);
myInspectionPanel->setAllowedAreas(Qt::LeftDockWidgetArea |
Qt::RightDockWidgetArea);
aDesktop->addDockWidget(Qt::RightDockWidgetArea, myInspectionPanel);