X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_InspectionPanel.cpp;h=d82af690252fb778b08f9540b02d167e7897cb51;hb=814a346c0ef4b2625779c5ef96be5ff87980acbb;hp=6d615ac06dbe53dce38181ce38f964017dc631b9;hpb=3c987a8d1b88765224e3ac1388afb91eae17e4d3;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_InspectionPanel.cpp b/src/XGUI/XGUI_InspectionPanel.cpp index 6d615ac06..d82af6902 100644 --- a/src/XGUI/XGUI_InspectionPanel.cpp +++ b/src/XGUI/XGUI_InspectionPanel.cpp @@ -18,12 +18,19 @@ // #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 #include +#include +#include +#include +#include + #include #include @@ -54,6 +61,7 @@ #include #include #include +#include #include #include @@ -61,6 +69,7 @@ #include #include // CAREFUL ! position of this file is critic + // ================ Auxiliary functions ================ #define TITLE(val) ("" + (val) + "") @@ -108,15 +117,18 @@ static void appendNamedValueToParameters(const QString& theName, // ================ 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); @@ -184,9 +196,23 @@ XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr 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())); } //******************************************************************** @@ -203,26 +229,28 @@ void XGUI_InspectionPanel::setSubShapeValue(SudShape theId, int theVal) //******************************************************************** void XGUI_InspectionPanel::clearContent() { + myStackWgt->setCurrentIndex(myFeaturePanelId); setName(""); for (int i = 0; i <= VertexId; i++) { mySubShapesTab->item((SudShape)i, 1)->setText(""); } myTypeLbl->setText(""); setParamsText(""); + + myFeaturePane->clearPage(); } //******************************************************************** void XGUI_InspectionPanel::onSelectionChanged() { + if (!isVisible()) + return; + clearContent(); - XGUI_Selection* aSelection = mySelectionMgr->selection(); - QList aSelectedList = - aSelection->getSelected(ModuleBase_ISelection::Viewer); - QList anOBSelected = - aSelection->getSelected(ModuleBase_ISelection::Browser); - if (!anOBSelected.isEmpty()) - ModuleBase_ISelection::appendSelected(anOBSelected, aSelectedList); + XGUI_Selection* aSelection = myWorkshop->selector()->selection(); + QList aSelectedList = + aSelection->getSelected(myWorkshop->selector()->placeOfSelection()); if (aSelectedList.count() > 0) { ModuleBase_ViewerPrsPtr aPrs = aSelectedList.first(); @@ -230,25 +258,35 @@ void XGUI_InspectionPanel::onSelectionChanged() std::dynamic_pointer_cast(aPrs->object()); if (aStep) return; - TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(aPrs); - if (aShape.IsNull()) { - ResultPtr aRes = std::dynamic_pointer_cast(aPrs->object()); - if (aRes.get()) { - GeomShapePtr aShpPtr = aRes->shape(); - if (aShpPtr.get()) { - aShape = aShpPtr->impl(); + FeaturePtr aFeature = std::dynamic_pointer_cast(aPrs->object()); + if (aFeature.get()) { + myStackWgt->setCurrentIndex(myFeaturePanelId); + buildFeaturePane(aFeature); + } + else { + TopoDS_Shape aShape = ModuleBase_Tools::getSelectedShape(aPrs); + if (aShape.IsNull()) { + ResultPtr aRes = std::dynamic_pointer_cast(aPrs->object()); + if (aRes.get()) { + GeomShapePtr aShpPtr = aRes->shape(); + if (aShpPtr.get()) { + aShape = aShpPtr->impl(); + } } } + if (aShape.IsNull()) { + myStackWgt->setCurrentIndex(myFeaturePanelId); + return; + } + myStackWgt->setCurrentIndex(myShapePanelId); + 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); } } @@ -606,6 +644,7 @@ void XGUI_InspectionPanel::fillContainer(const GeomShapePtr& theShape) appendPointToParameters(tr("Maximal corner"), aMaxPoint, aParams); } +//******************************************************************** void XGUI_InspectionPanel::setPlaneType(const QString& theTitle, const std::shared_ptr& thePlane) { @@ -616,6 +655,7 @@ void XGUI_InspectionPanel::setPlaneType(const QString& theTitle, setParamsText(aParams); } +//******************************************************************** void XGUI_InspectionPanel::setSphereType(const QString& theTitle, const std::shared_ptr& theSphere) { @@ -627,6 +667,7 @@ void XGUI_InspectionPanel::setSphereType(const QString& theTitle, setParamsText(aParams); } +//******************************************************************** void XGUI_InspectionPanel::setCylinderType(const QString& theTitle, const std::shared_ptr& theCyl) { @@ -640,6 +681,7 @@ void XGUI_InspectionPanel::setCylinderType(const QString& theTitle, setParamsText(aParams); } +//******************************************************************** void XGUI_InspectionPanel::setConeType(const QString& theTitle, const std::shared_ptr& theCone) { @@ -654,6 +696,7 @@ void XGUI_InspectionPanel::setConeType(const QString& theTitle, setParamsText(aParams); } +//******************************************************************** void XGUI_InspectionPanel::setTorusType(const QString& theTitle, const std::shared_ptr& theTorus) { @@ -667,6 +710,7 @@ void XGUI_InspectionPanel::setTorusType(const QString& theTitle, setParamsText(aParams); } +//******************************************************************** void XGUI_InspectionPanel::setBoxType(const QString& theTitle, const std::shared_ptr& theBox) { @@ -680,6 +724,7 @@ void XGUI_InspectionPanel::setBoxType(const QString& theTitle, setParamsText(aParams); } +//******************************************************************** void XGUI_InspectionPanel::setRotatedBoxType(const QString& theTitle, const std::shared_ptr& theBox) { @@ -697,7 +742,43 @@ void XGUI_InspectionPanel::setRotatedBoxType(const QString& theTitle, } +//******************************************************************** 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 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->setFeature(theFeature, false, false); + aWgt->setReadOnly(true); + 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(); +}