From 83df328d655f4fc01bedd7a4ebcfd410178e656f Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 3 Jul 2018 20:35:25 +0300 Subject: [PATCH] Task 2.1 "Functionality of inspection 'what is'" from CEA specification. Panel definition --- src/XGUI/CMakeLists.txt | 3 + src/XGUI/XGUI_InspectionPanel.cpp | 240 ++++++++++++++++++++++++++++++ src/XGUI/XGUI_InspectionPanel.h | 95 ++++++++++++ src/XGUI/XGUI_Workshop.cpp | 7 + src/XGUI/XGUI_Workshop.h | 9 +- 5 files changed, 350 insertions(+), 4 deletions(-) create mode 100644 src/XGUI/XGUI_InspectionPanel.cpp create mode 100644 src/XGUI/XGUI_InspectionPanel.h diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index 72be73b8f..9602b24c5 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -62,6 +62,7 @@ SET(PROJECT_HEADERS XGUI_ViewerProxy.h XGUI_Workshop.h XGUI_WorkshopListener.h + XGUI_InspectionPanel.h ) SET(PROJECT_MOC_HEADERS @@ -89,6 +90,7 @@ SET(PROJECT_MOC_HEADERS XGUI_ViewerProxy.h XGUI_Workshop.h XGUI_WorkshopListener.h + XGUI_InspectionPanel.h ) # sources / moc wrappings @@ -127,6 +129,7 @@ SET(PROJECT_SOURCES XGUI_ViewerProxy.cpp XGUI_Workshop.cpp XGUI_WorkshopListener.cpp + XGUI_InspectionPanel.cpp ) SET(PROJECT_RESOURCES diff --git a/src/XGUI/XGUI_InspectionPanel.cpp b/src/XGUI/XGUI_InspectionPanel.cpp new file mode 100644 index 000000000..b89334e9b --- /dev/null +++ b/src/XGUI/XGUI_InspectionPanel.cpp @@ -0,0 +1,240 @@ +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// + +#include "XGUI_InspectionPanel.h" +#include "XGUI_SelectionMgr.h" +#include "XGUI_Selection.h" + +#include +#include +#include +#include +#include +#include +#include + +XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr* theMgr) + : QDockWidget(theParent), + mySelectionMgr(theMgr) +{ + setWindowTitle(tr("Inspection Panel")); + setObjectName(INSPECTION_PANEL); + setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }"); + + QScrollArea* aScrollArea = new QScrollArea(this); + setWidget(aScrollArea); + + // Create an internal widget + QWidget* aMainWidget = new QWidget(aScrollArea); + + QVBoxLayout* aMainLayout = new QVBoxLayout(aMainWidget); + aMainLayout->setContentsMargins(5, 5, 5, 5); + + QWidget* aNameWgt = new QWidget(aMainWidget); + QHBoxLayout* aNameLayout = new QHBoxLayout(aNameWgt); + aNameLayout->setContentsMargins(0, 0, 0, 0); + aNameLayout->addWidget(new QLabel(tr("Object"), aNameWgt)); + myNameEdt = new QLineEdit(aNameWgt); + myNameEdt->setReadOnly(true); + aNameLayout->addWidget(myNameEdt); + + aMainLayout->addWidget(aNameWgt); + + // Table with sub-shapes + mySubShapesTab = new QTableWidget(9, 2, aMainWidget); + mySubShapesTab->setFocusPolicy(Qt::NoFocus); + mySubShapesTab->verticalHeader()->hide(); + QStringList aTitles; + aTitles << tr("Sub-shapes") << tr("Number"); + mySubShapesTab->setHorizontalHeaderLabels(aTitles); + + QStringList aSubShapes; + aSubShapes << "SHAPE" << "COMPOUND" << "COMPSOLID" << + "SOLID" << "SHELL" << "FACE" << "WIRE" << "EDGE" << "VERTEX"; + int i = 0; + foreach(QString aType, aSubShapes) { + QTableWidgetItem* aItem = new QTableWidgetItem(aType); + aItem->setFlags(Qt::ItemIsEnabled); + mySubShapesTab->setItem(i++, 0, aItem); + } + for (i = 0; i < 9; i++) { + QTableWidgetItem* aItem = new QTableWidgetItem("0"); + aItem->setFlags(Qt::ItemIsEnabled); + aItem->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + mySubShapesTab->setItem(i, 1, aItem); + } + mySubShapesTab->setColumnWidth(0, 90); + mySubShapesTab->setColumnWidth(1, 70); + + mySubShapesTab->setMaximumWidth(170); + mySubShapesTab->setMinimumHeight(300); + + aMainLayout->addWidget(mySubShapesTab); + + // Type of object + QWidget* aTypeWgt = new QWidget(aMainWidget); + QHBoxLayout* aTypeLayout = new QHBoxLayout(aTypeWgt); + aTypeLayout->setContentsMargins(0, 0, 0, 0); + + aTypeLayout->addWidget(new QLabel(tr("Type:"), aTypeWgt)); + myTypeLbl = new QLabel("No-type", aTypeWgt); + aTypeLayout->addWidget(myTypeLbl); + + aMainLayout->addWidget(aTypeWgt); + + myTypeParams = new QTextBrowser(aMainWidget); + myTypeParams->setMaximumWidth(170); + myTypeParams->setMaximumHeight(160); + myTypeParams->setReadOnly(true); + myTypeParams->setFocusPolicy(Qt::NoFocus); + myTypeParams->setFrameStyle(QFrame::NoFrame); + myTypeParams->viewport()->setBackgroundRole(QPalette::Window); + + aMainLayout->addWidget(myTypeParams); + + aScrollArea->setWidget(aMainWidget); + + connect(mySelectionMgr, SIGNAL(selectionChanged()), SLOT(onSelectionChanged())); + + // Test + setVertexType(0, 0, 0); +} + +XGUI_InspectionPanel::~XGUI_InspectionPanel() +{ +} + +void XGUI_InspectionPanel::setSubShapeValue(SudShape theId, int theVal) +{ + mySubShapesTab->item(theId, 1)->setText(QString::number(theVal)); +} + +void XGUI_InspectionPanel::onSelectionChanged() +{ + QObjectPtrList aObjects = mySelectionMgr->selection()->selectedObjects(); + if (aObjects.count() > 0) { + ObjectPtr aObj = aObjects.first(); + setName(aObj->data()->name().c_str()); + } +} + +void XGUI_InspectionPanel::setName(const QString& theName) +{ + myNameEdt->setText(theName); +} + +#define TITLE(val) ("" + val + "") + +void XGUI_InspectionPanel::setCylinderType(double theX, double theY, double theZ, + double theDX, double theDY, double theDZ, double theRadius, double theHeight) +{ + myTypeLbl->setText(tr("Cylinder")); + QString aParams = TITLE(tr("Center")) + + "
X: " + QString::number(theX) + + "
Y: " + QString::number(theY) + + "
Z: " + QString::number(theZ) + + "
" + TITLE(tr("Axis")) + + "
DX: " + QString::number(theDX) + + "
DY: " + QString::number(theDY) + + "
DZ: " + QString::number(theDZ) + + "
" + TITLE(tr("Dimensions")) + + "
" + tr("Radius:") + QString::number(theRadius) + + "
" + tr("Height") + QString::number(theHeight); + + myTypeParams->setText(aParams); +} + +void XGUI_InspectionPanel::setSphereType(double theX, double theY, double theZ, double theRadius) +{ + myTypeLbl->setText(tr("Sphere")); + QString aParams = TITLE(tr("Center")) + + "
X: " + QString::number(theX) + + "
Y: " + QString::number(theY) + + "
Z: " + QString::number(theZ) + + "
" + TITLE(tr("Dimensions")) + + "
" + tr("Radius:") + QString::number(theRadius); + myTypeParams->setText(aParams); +} + +void XGUI_InspectionPanel::setBoxType(double theX, double theY, double theZ, + double theXsize, double theYsize, double theZsize) +{ + myTypeLbl->setText(tr("Box")); + QString aParams = TITLE(tr("Position")) + + "
X: " + QString::number(theX) + + "
Y: " + QString::number(theY) + + "
Z: " + QString::number(theZ) + + "
" + TITLE(tr("Dimensions")) + + "
" + "Ax :" + QString::number(theXsize) + + "
" + "Ay :" + QString::number(theYsize) + + "
" + "Az :" + QString::number(theZsize); + myTypeParams->setText(aParams); +} + + +void XGUI_InspectionPanel::setRotatedBoxType(double theX, double theY, double theZ, + double theZaxisX, double theZaxisY, double theZaxisZ, + double theXaxisX, double theXaxisY, double theXaxisZ, + double theXsize, double theYsize, double theZsize) +{ + myTypeLbl->setText(tr("Box")); + QString aParams = TITLE(tr("Position")) + + "
X: " + QString::number(theX) + + "
Y: " + QString::number(theY) + + "
Z: " + QString::number(theZ) + + "
" + TITLE(tr("Z axis")) + + "
DX: " + QString::number(theZaxisX) + + "
DY: " + QString::number(theZaxisY) + + "
DZ: " + QString::number(theZaxisZ) + + "
" + TITLE(tr("X axis")) + + "
DX: " + QString::number(theXaxisX) + + "
DY: " + QString::number(theXaxisY) + + "
DZ: " + QString::number(theXaxisZ) + + "
" + TITLE(tr("Dimensions")) + + "
" + "Ax :" + QString::number(theXsize) + + "
" + "Ay :" + QString::number(theYsize) + + "
" + "Az :" + QString::number(theZsize); + myTypeParams->setText(aParams); +} + +void XGUI_InspectionPanel::setPlaneType(double theX, double theY, double theZ, + double theDX, double theDY, double theDZ) +{ + myTypeLbl->setText(tr("Plane")); + QString aParams = TITLE(tr("Center")) + + "
X: " + QString::number(theX) + + "
Y: " + QString::number(theY) + + "
Z: " + QString::number(theZ) + + "
" + TITLE(tr("Normal")) + + "
DX: " + QString::number(theDX) + + "
DY: " + QString::number(theDY) + + "
DZ: " + QString::number(theDZ); + myTypeParams->setText(aParams); +} + +void XGUI_InspectionPanel::setVertexType(double theX, double theY, double theZ) +{ + myTypeLbl->setText(tr("Vertex")); + QString aParams = TITLE(tr("Coordinates")) + + "
X: " + QString::number(theX) + + "
Y: " + QString::number(theY) + + "
Z: " + QString::number(theZ); + myTypeParams->setText(aParams); +} \ No newline at end of file diff --git a/src/XGUI/XGUI_InspectionPanel.h b/src/XGUI/XGUI_InspectionPanel.h new file mode 100644 index 000000000..27ea2a8b2 --- /dev/null +++ b/src/XGUI/XGUI_InspectionPanel.h @@ -0,0 +1,95 @@ +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// + +#ifndef XGUI_INSPECTIONPANEL_H_ +#define XGUI_INSPECTIONPANEL_H_ + +#include "XGUI.h" + +#include + +class XGUI_SelectionMgr; +class QLineEdit; +class QTableWidget; +class QLabel; +class QTextBrowser; + +/// Internal name of property panel widget +const static char* INSPECTION_PANEL = "inspection_panel_dock"; + +class XGUI_EXPORT XGUI_InspectionPanel : public QDockWidget +{ + Q_OBJECT +public: + enum SudShape { + ShapeId, + CompoundId, + CompsolidId, + SolidId, + ShellId, + FaceId, + WireId, + EdgeId, + VertexId + }; + + /// Constructor + /// \param theParent is a parent of the property panel + /// \param theMgr operation manager + XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr* theMgr); + + virtual ~XGUI_InspectionPanel(); + + void setSubShapeValue(SudShape theId, int theVal); + + void setName(const QString& theName); + + // Set of type parameters + void setCylinderType(double theX, double theY, double theZ, + double theDX, double theDY, double theDZ, double theRadius, double theHeight); + + void setSphereType(double theX, double theY, double theZ, double theRadius); + + void setBoxType(double theX, double theY, double theZ, + double theXsize, double theYsize, double theZsize); + + void setRotatedBoxType(double theX, double theY, double theZ, + double theZaxisX, double theZaxisY, double theZaxisZ, + double theXaxisX, double theXaxisY, double theXaxisZ, + double theXsize, double theYsize, double theZsize); + + void setPlaneType(double theX, double theY, double theZ, + double theDX, double theDY, double theDZ); + + void setVertexType(double theX, double theY, double theZ); + +private slots: + void onSelectionChanged(); + +private: + XGUI_SelectionMgr* mySelectionMgr; + + QLineEdit* myNameEdt; + QTableWidget* mySubShapesTab; + QLabel* myTypeLbl; + QTextBrowser* myTypeParams; +}; + +#endif \ No newline at end of file diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 9ca33837f..caf8e541b 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #ifndef HAVE_SALOME #include @@ -174,6 +175,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) myModule(NULL), mySalomeConnector(theConnector), myPropertyPanel(0), + myInspectionPanel(0), myFacesPanel(0), myObjectBrowser(0), myDisplayer(0) @@ -1341,6 +1343,11 @@ void XGUI_Workshop::createDockWidgets() Qt::BottomDockWidgetArea); connect(myFacesPanel, SIGNAL(closed()), myFacesPanel, SLOT(onClosed())); + myInspectionPanel = new XGUI_InspectionPanel(aDesktop, mySelector); + myInspectionPanel->setAllowedAreas(Qt::LeftDockWidgetArea | + Qt::RightDockWidgetArea); + aDesktop->addDockWidget(Qt::RightDockWidgetArea, myInspectionPanel); + aDesktop->addDockWidget( #ifdef HAVE_SALOME Qt::RightDockWidgetArea, diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 7495365b4..7af135fc8 100755 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -63,6 +63,7 @@ class XGUI_SelectionActivate; class XGUI_SelectionMgr; class XGUI_ViewerProxy; class XGUI_WorkshopListener; +class XGUI_InspectionPanel; class ModuleBase_IModule; class ModuleBase_IViewer; @@ -130,6 +131,9 @@ Q_OBJECT /// Returns property panel widget XGUI_PropertyPanel* propertyPanel() const { return myPropertyPanel; } + /// Returns property panel widget + XGUI_InspectionPanel* inspectionPanel() const { return myInspectionPanel; } + /// Returns panel for hide object faces XGUI_FacesPanel* facesPanel() const { return myFacesPanel; } @@ -480,10 +484,6 @@ private: /// \param theParent a parent of widget QDockWidget* createObjectBrowser(QWidget* theParent); - /// Create property panel widget - /// \param theParent a parent of widget - QDockWidget* createPropertyPanel(QWidget* theParent); - // Creates Dock widgets: Object browser and Property panel void createDockWidgets(); @@ -528,6 +528,7 @@ private: QString myCurrentDir; ///< cached the last open directory QIntList myViewerSelMode; ///< selection modes set in the viewer Config_DataModelReader* myDataModelXMLReader; ///< XML reader of data model + XGUI_InspectionPanel* myInspectionPanel; ///< container of feature attributes widgets }; #endif -- 2.39.2