Salome HOME
Issue #2584: Adjust height of inspection panel to size of a desktop
authorvsv <vsv@opencascade.com>
Fri, 24 Aug 2018 14:58:51 +0000 (17:58 +0300)
committervsv <vsv@opencascade.com>
Fri, 24 Aug 2018 14:59:06 +0000 (17:59 +0300)
src/XGUI/XGUI_InspectionPanel.cpp
src/XGUI/XGUI_InspectionPanel.h

index 16ef5c1649512a63c08beee39240038da89ed397..2ef6cefebffca4a267c090762ef7ed27e753d0c5 100644 (file)
@@ -52,6 +52,7 @@
 #include <QTableWidget>
 #include <QHeaderView>
 #include <QTextBrowser>
+#include <QResizeEvent>
 
 #include <BRepBndLib.hxx>
 #include <TopoDS_Iterator.hxx>
@@ -118,12 +119,12 @@ XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr
   setWidget(aScrollArea);
 
   // Create an internal widget
-  QWidget* aMainWidget = new QWidget(aScrollArea);
+  myMainWidget = new QWidget(aScrollArea);
 
-  QVBoxLayout* aMainLayout = new QVBoxLayout(aMainWidget);
-  aMainLayout->setContentsMargins(5, 5, 5, 5);
+  myMainLayout = new QVBoxLayout(myMainWidget);
+  myMainLayout->setContentsMargins(5, 5, 5, 5);
 
-  QWidget* aNameWgt = new QWidget(aMainWidget);
+  QWidget* aNameWgt = new QWidget(myMainWidget);
   QHBoxLayout* aNameLayout = new QHBoxLayout(aNameWgt);
   aNameLayout->setContentsMargins(0, 0, 0, 0);
   aNameLayout->addWidget(new QLabel(tr("Object"), aNameWgt));
@@ -131,10 +132,10 @@ XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr
   myNameEdt->setReadOnly(true);
   aNameLayout->addWidget(myNameEdt);
 
-  aMainLayout->addWidget(aNameWgt);
+  myMainLayout->addWidget(aNameWgt);
 
   // Table with sub-shapes
-  mySubShapesTab = new QTableWidget(9, 2, aMainWidget);
+  mySubShapesTab = new QTableWidget(9, 2, myMainWidget);
   mySubShapesTab->setFocusPolicy(Qt::NoFocus);
   mySubShapesTab->verticalHeader()->hide();
   QStringList aTitles;
@@ -162,10 +163,10 @@ XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr
   mySubShapesTab->setMaximumWidth(170);
   mySubShapesTab->setMinimumHeight(300);
 
-  aMainLayout->addWidget(mySubShapesTab);
+  myMainLayout->addWidget(mySubShapesTab);
 
   // Type of object
-  QWidget* aTypeWgt = new QWidget(aMainWidget);
+  QWidget* aTypeWgt = new QWidget(myMainWidget);
   QHBoxLayout* aTypeLayout = new QHBoxLayout(aTypeWgt);
   aTypeLayout->setContentsMargins(0, 0, 0, 0);
 
@@ -173,19 +174,18 @@ XGUI_InspectionPanel::XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr
   myTypeLbl = new QLabel("", aTypeWgt);
   aTypeLayout->addWidget(myTypeLbl);
 
-  aMainLayout->addWidget(aTypeWgt);
+  myMainLayout->addWidget(aTypeWgt);
 
-  myTypeParams = new QTextBrowser(aMainWidget);
-  myTypeParams->setMaximumWidth(170);
-  myTypeParams->setMaximumHeight(160);
+  myTypeParams = new QTextBrowser(myMainWidget);
+  myTypeParams->setFixedWidth(170);
   myTypeParams->setReadOnly(true);
   myTypeParams->setFocusPolicy(Qt::NoFocus);
   myTypeParams->setFrameStyle(QFrame::NoFrame);
   myTypeParams->viewport()->setBackgroundRole(QPalette::Window);
 
-  aMainLayout->addWidget(myTypeParams);
+  myMainLayout->addWidget(myTypeParams, 1);
 
-  aScrollArea->setWidget(aMainWidget);
+  aScrollArea->setWidget(myMainWidget);
 
   connect(mySelectionMgr, SIGNAL(selectionChanged()), SLOT(onSelectionChanged()));
 }
@@ -209,7 +209,7 @@ void XGUI_InspectionPanel::clearContent()
     mySubShapesTab->item((SudShape)i, 1)->setText("");
   }
   myTypeLbl->setText("");
-  myTypeParams->setText("");
+  setParamsText("");
 }
 
 //********************************************************************
@@ -275,8 +275,6 @@ void XGUI_InspectionPanel::setShapeContent(const TopoDS_Shape& theShape)
     setSubShapeValue(ShapeId, aMapOfShape.Extent());
   }
   catch (Standard_Failure) {
-    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
-    //SetErrorCode(aFail->GetMessageString());
   }
 }
 
@@ -321,7 +319,7 @@ void XGUI_InspectionPanel::fillVertex(const GeomVertexPtr& theVertex)
 
   QString aParams;
   appendPointToParameters(tr("Coordinates"), aPoint, aParams);
-  myTypeParams->setText(aParams);
+  setParamsText(aParams);
 }
 
 //********************************************************************
@@ -378,7 +376,7 @@ void XGUI_InspectionPanel::fillEdge(const GeomEdgePtr& theEdge)
     appendPointToParameters(tr("Start point"), aStartPnt, aParams);
     appendPointToParameters(tr("End point"), aEndPnt, aParams);
   }
-  myTypeParams->setText(aParams);
+  setParamsText(aParams);
 }
 
 //********************************************************************
@@ -400,7 +398,7 @@ void XGUI_InspectionPanel::fillWire(const GeomWirePtr& theWire)
   else
     myTypeLbl->setText(tr("Wire"));
 
-  myTypeParams->setText(aParams);
+  setParamsText(aParams);
 }
 
 //********************************************************************
@@ -439,7 +437,7 @@ void XGUI_InspectionPanel::fillFace(const GeomFacePtr& theFace)
           appendGroupNameToParameters(tr("Dimensions"), aParams);
           appendNamedValueToParameters(tr("Width"), aWidth, aParams);
           appendNamedValueToParameters(tr("Height"), aHeight, aParams);
-          myTypeParams->setText(aParams);
+          setParamsText(aParams);
 
           isCommonCase = false;
         }
@@ -589,7 +587,7 @@ void XGUI_InspectionPanel::setPlaneType(const QString& theTitle,
   QString aParams;
   appendPointToParameters(tr("Origin"), thePlane->location(), aParams);
   appendDirToParameters(tr("Normal"), thePlane->direction(), aParams);
-  myTypeParams->setText(aParams);
+  setParamsText(aParams);
 }
 
 void XGUI_InspectionPanel::setSphereType(const QString& theTitle,
@@ -600,7 +598,7 @@ void XGUI_InspectionPanel::setSphereType(const QString& theTitle,
   appendPointToParameters(tr("Center"), theSphere->center(), aParams);
   appendGroupNameToParameters(tr("Dimensions"), aParams);
   appendNamedValueToParameters(tr("Radius"), theSphere->radius(), aParams);
-  myTypeParams->setText(aParams);
+  setParamsText(aParams);
 }
 
 void XGUI_InspectionPanel::setCylinderType(const QString& theTitle,
@@ -613,7 +611,7 @@ void XGUI_InspectionPanel::setCylinderType(const QString& theTitle,
   appendGroupNameToParameters(tr("Dimensions"), aParams);
   appendNamedValueToParameters(tr("Radius"), theCyl->radius(), aParams);
   appendNamedValueToParameters(tr("Height"), theCyl->height(), aParams);
-  myTypeParams->setText(aParams);
+  setParamsText(aParams);
 }
 
 void XGUI_InspectionPanel::setConeType(const QString& theTitle,
@@ -627,7 +625,7 @@ void XGUI_InspectionPanel::setConeType(const QString& theTitle,
   appendNamedValueToParameters(tr("Radius 1"), theCone->radius1(), aParams);
   appendNamedValueToParameters(tr("Radius 2"), theCone->radius2(), aParams);
   appendNamedValueToParameters(tr("Height"), theCone->height(), aParams);
-  myTypeParams->setText(aParams);
+  setParamsText(aParams);
 }
 
 void XGUI_InspectionPanel::setTorusType(const QString& theTitle,
@@ -640,7 +638,7 @@ void XGUI_InspectionPanel::setTorusType(const QString& theTitle,
   appendGroupNameToParameters(tr("Dimensions"), aParams);
   appendNamedValueToParameters(tr("Major radius"), theTorus->majorRadius(), aParams);
   appendNamedValueToParameters(tr("Minor radius"), theTorus->minorRadius(), aParams);
-  myTypeParams->setText(aParams);
+  setParamsText(aParams);
 }
 
 void XGUI_InspectionPanel::setBoxType(const QString& theTitle,
@@ -653,7 +651,7 @@ void XGUI_InspectionPanel::setBoxType(const QString& theTitle,
   appendNamedValueToParameters(tr("Width"), theBox->width(), aParams);
   appendNamedValueToParameters(tr("Depth"), theBox->depth(), aParams);
   appendNamedValueToParameters(tr("Height"), theBox->height(), aParams);
-  myTypeParams->setText(aParams);
+  setParamsText(aParams);
 }
 
 void XGUI_InspectionPanel::setRotatedBoxType(const QString& theTitle,
@@ -669,5 +667,21 @@ void XGUI_InspectionPanel::setRotatedBoxType(const QString& theTitle,
   appendNamedValueToParameters(tr("Width"), theBox->width(), aParams);
   appendNamedValueToParameters(tr("Depth"), theBox->depth(), aParams);
   appendNamedValueToParameters(tr("Height"), theBox->height(), aParams);
-  myTypeParams->setText(aParams);
+  setParamsText(aParams);
 }
+
+
+void XGUI_InspectionPanel::setParamsText(const QString& theText)
+{
+  myTypeParams->setText(theText);
+}
+
+void XGUI_InspectionPanel::resizeEvent(QResizeEvent* theEvent)
+{
+  QSize aSize = theEvent->size();
+
+  int aHeight = aSize.height();
+
+  if (aHeight > 450) // 450 is a a minimal height
+    myMainWidget->setFixedHeight(aHeight - 30);
+}
\ No newline at end of file
index b5d1a056f79837e484330ee08a64415b6906308a..552ce7774e399a2a934aa9e55477afe6307f9644 100644 (file)
@@ -32,6 +32,8 @@ class QLineEdit;
 class QTableWidget;
 class QLabel;
 class QTextBrowser;
+class QVBoxLayout;
+class QResizeEvent;
 
 class TopoDS_Shape;
 
@@ -53,10 +55,15 @@ class GeomAPI_Box;
 /// Internal name of property panel widget
 const static char* INSPECTION_PANEL = "inspection_panel_dock";
 
+/**
+* \ingroup GUI
+* A class which represents an inspection panel: to show content of currently selected objects
+*/
 class XGUI_EXPORT XGUI_InspectionPanel : public QDockWidget
 {
   Q_OBJECT
 public:
+  /// Type of selected objects
   enum SudShape {
     ShapeId,
     CompoundId,
@@ -74,59 +81,118 @@ public:
   /// \param theMgr operation manager
   XGUI_InspectionPanel(QWidget* theParent, XGUI_SelectionMgr* theMgr);
 
+  // Destructor
   virtual ~XGUI_InspectionPanel();
 
+
+protected:
+  /// Vitrual method is redefined in order to adjust size of internal wirdet to size of
+  /// the whole whindow
+  /// \param theEvent an event with resize parameters
+  virtual void resizeEvent(QResizeEvent* theEvent);
+
 private slots:
+  /// A slot to react on selection changed
   void onSelectionChanged();
 
 private:
+  /// Set counts of a sub-shapes
+  /// \param theId an id of sub-shape type
+  /// \param theVal a number of sub-shapes of corresponded type
   void setSubShapeValue(SudShape theId, int theVal);
 
+  /// Set name of current selection
+  /// \param theName the name
   void setName(const QString& theName);
 
+  /// Set content of selected shape into table
+  /// \param theShape the shape
   void setShapeContent(const TopoDS_Shape& theShape);
 
+  /// Set parameters of the selected shape
+  /// \param theShape the shape
   void setShapeParams(const TopoDS_Shape& theShape);
 
+  /// Clear content of the window
   void clearContent();
 
-
+  /// Show parameters of a vertex
+  /// \param theVertex the vertex
   void fillVertex(const std::shared_ptr<GeomAPI_Vertex>& theVertex);
 
+  /// Show parameters of a edge
+  /// \param theEdge the edge
   void fillEdge(const std::shared_ptr<GeomAPI_Edge>& theEdge);
 
+  /// Show parameters of a wire
+  /// \param theWire the wire
   void fillWire(const std::shared_ptr<GeomAPI_Wire>& theWire);
 
+  /// Show parameters of a face
+  /// \param theFace the face
   void fillFace(const std::shared_ptr<GeomAPI_Face>& theFace);
 
+  /// Show parameters of a shell
+  /// \param theShell the shell
   void fillShell(const std::shared_ptr<GeomAPI_Shell>& theShell);
 
+  /// Show parameters of a solid
+  /// \param theSolid the solid
   void fillSolid(const std::shared_ptr<GeomAPI_Solid>& theSolid);
 
+  /// Show parameters of a compound
+  /// \param theShape the compound
   void fillContainer(const std::shared_ptr<GeomAPI_Shape>& theShape);
 
-
+  /// Show parameters of a plane
+  /// \param theTitle a title of the object
+  /// \param thePlane the plane
   void setPlaneType(const QString& theTitle, const std::shared_ptr<GeomAPI_Pln>& thePlane);
 
+  /// Show parameters of a sphere
+  /// \param theTitle a title of the object
+  /// \param theSphere the sphere
   void setSphereType(const QString& theTitle, const std::shared_ptr<GeomAPI_Sphere>& theSphere);
 
+  /// Show parameters of a cylinder
+  /// \param theTitle a title of the object
+  /// \param theCyl the cylinder
   void setCylinderType(const QString& theTitle, const std::shared_ptr<GeomAPI_Cylinder>& theCyl);
 
+  /// Show parameters of a cone
+  /// \param theTitle a title of the object
+  /// \param theCone the cone
   void setConeType(const QString& theTitle, const std::shared_ptr<GeomAPI_Cone>& theCone);
 
+  /// Show parameters of a torus
+  /// \param theTitle a title of the object
+  /// \param theTorus the torus
   void setTorusType(const QString& theTitle, const std::shared_ptr<GeomAPI_Torus>& theTorus);
 
+  /// Show parameters of a box
+  /// \param theTitle a title of the object
+  /// \param theBox the box
   void setBoxType(const QString& theTitle, const std::shared_ptr<GeomAPI_Box>& theBox);
 
+  /// Show parameters of a rotated box
+  /// \param theTitle a title of the object
+  /// \param theBox the box
   void setRotatedBoxType(const QString& theTitle, const std::shared_ptr<GeomAPI_Box>& theBox);
 
-private:
-  XGUI_SelectionMgr* mySelectionMgr;
 
-  QLineEdit* myNameEdt;
-  QTableWidget* mySubShapesTab;
-  QLabel* myTypeLbl;
-  QTextBrowser* myTypeParams;
+  /// Set text into parameters area
+  /// \param theText the text
+  void setParamsText(const QString& theText);
+
+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
 };
 
 #endif
\ No newline at end of file