-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 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
//
// 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "XGUI_InspectionPanel.h"
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_Tools.h>
+#include <ModelAPI_ResultField.h>
#include <ModelAPI_Result.h>
#include <QTableWidget>
#include <QHeaderView>
#include <QTextBrowser>
+#include <QResizeEvent>
+#include <QSplitter>
#include <BRepBndLib.hxx>
#include <TopoDS_Iterator.hxx>
setObjectName(INSPECTION_PANEL);
setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
- QScrollArea* aScrollArea = new QScrollArea(this);
- setWidget(aScrollArea);
+ QSplitter* aSplitter = new QSplitter(Qt::Vertical, this);
// 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);
+ QWidget* aNameWgt = new QWidget(aSplitter);
QHBoxLayout* aNameLayout = new QHBoxLayout(aNameWgt);
- aNameLayout->setContentsMargins(0, 0, 0, 0);
+ aNameLayout->setContentsMargins(3, 0, 3, 0);
aNameLayout->addWidget(new QLabel(tr("Object"), aNameWgt));
myNameEdt = new QLineEdit(aNameWgt);
myNameEdt->setReadOnly(true);
aNameLayout->addWidget(myNameEdt);
- aMainLayout->addWidget(aNameWgt);
+ aSplitter->addWidget(aNameWgt);
// Table with sub-shapes
- mySubShapesTab = new QTableWidget(9, 2, aMainWidget);
+ mySubShapesTab = new QTableWidget(9, 2, aSplitter);
mySubShapesTab->setFocusPolicy(Qt::NoFocus);
mySubShapesTab->verticalHeader()->hide();
QStringList aTitles;
mySubShapesTab->setHorizontalHeaderLabels(aTitles);
QStringList aSubShapes;
- aSubShapes << "SHAPE" << "COMPOUND" << "COMPSOLID" <<
- "SOLID" << "SHELL" << "FACE" << "WIRE" << "EDGE" << "VERTEX";
+ aSubShapes << tr("SHAPE") << tr("COMPOUND") << tr("COMPSOLID") <<
+ tr("SOLID") << tr("SHELL") << tr("FACE") << tr("WIRE") << tr("EDGE") << tr("VERTEX");
int i = 0;
foreach(QString aType, aSubShapes) {
QTableWidgetItem* aItem = new QTableWidgetItem(aType);
mySubShapesTab->setColumnWidth(0, 90);
mySubShapesTab->setColumnWidth(1, 70);
- mySubShapesTab->setMaximumWidth(170);
- mySubShapesTab->setMinimumHeight(300);
-
- aMainLayout->addWidget(mySubShapesTab);
+ aSplitter->addWidget(mySubShapesTab);
// Type of object
- QWidget* aTypeWgt = new QWidget(aMainWidget);
+ QWidget* aTypeWgt = new QWidget(aSplitter);
QHBoxLayout* aTypeLayout = new QHBoxLayout(aTypeWgt);
- aTypeLayout->setContentsMargins(0, 0, 0, 0);
+ aTypeLayout->setContentsMargins(3, 0, 3, 0);
aTypeLayout->addWidget(new QLabel(tr("Type:"), aTypeWgt));
myTypeLbl = new QLabel("", aTypeWgt);
aTypeLayout->addWidget(myTypeLbl);
- aMainLayout->addWidget(aTypeWgt);
+ aSplitter->addWidget(aTypeWgt);
- myTypeParams = new QTextBrowser(aMainWidget);
- myTypeParams->setMaximumWidth(170);
- myTypeParams->setMaximumHeight(160);
+ myTypeParams = new QTextBrowser(aSplitter);
myTypeParams->setReadOnly(true);
myTypeParams->setFocusPolicy(Qt::NoFocus);
- myTypeParams->setFrameStyle(QFrame::NoFrame);
myTypeParams->viewport()->setBackgroundRole(QPalette::Window);
- aMainLayout->addWidget(myTypeParams);
+ aSplitter->addWidget(myTypeParams);
+
+ aSplitter->setCollapsible(0, false);
+ aSplitter->setCollapsible(1, false);
+ aSplitter->setCollapsible(2, false);
+ aSplitter->setCollapsible(3, false);
+
+ QList<int> aSizes;
+ aSizes << 10 << 140 << 10;
+ aSplitter->setSizes(aSizes);
- aScrollArea->setWidget(aMainWidget);
+ setWidget(aSplitter);
connect(mySelectionMgr, SIGNAL(selectionChanged()), SLOT(onSelectionChanged()));
}
mySubShapesTab->item((SudShape)i, 1)->setText("");
}
myTypeLbl->setText("");
- myTypeParams->setText("");
+ setParamsText("");
}
//********************************************************************
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);
+
if (aSelectedList.count() > 0) {
ModuleBase_ViewerPrsPtr aPrs = aSelectedList.first();
+ FieldStepPtr aStep =
+ 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>();
+ }
+ }
+ }
if (aShape.IsNull())
return;
- setName(XGUI_Tools::generateName(aPrs));
+ 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);
}
setSubShapeValue(ShapeId, aMapOfShape.Extent());
}
catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- //SetErrorCode(aFail->GetMessageString());
}
}
QString aParams;
appendPointToParameters(tr("Coordinates"), aPoint, aParams);
- myTypeParams->setText(aParams);
+ setParamsText(aParams);
}
//********************************************************************
appendPointToParameters(tr("Start point"), aStartPnt, aParams);
appendPointToParameters(tr("End point"), aEndPnt, aParams);
}
- myTypeParams->setText(aParams);
+ setParamsText(aParams);
}
//********************************************************************
else
myTypeLbl->setText(tr("Wire"));
- myTypeParams->setText(aParams);
+ setParamsText(aParams);
}
//********************************************************************
appendGroupNameToParameters(tr("Dimensions"), aParams);
appendNamedValueToParameters(tr("Width"), aWidth, aParams);
appendNamedValueToParameters(tr("Height"), aHeight, aParams);
- myTypeParams->setText(aParams);
+ setParamsText(aParams);
isCommonCase = false;
}
myTypeLbl->setText("Compound");
// fill bounding box
+ TopoDS_Shape aShape = theShape->impl<TopoDS_Shape>();
Bnd_Box aBB;
- BRepBndLib::Add(theShape->impl<TopoDS_Shape>(), aBB);
+ BRepBndLib::Add(aShape, aBB);
+
+ if (aBB.IsVoid())
+ return;
gp_Pnt aMinPnt = aBB.CornerMin();
GeomPointPtr aMinPoint(new GeomAPI_Pnt(aMinPnt.X(), aMinPnt.Y(), aMinPnt.Z()));
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,
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,
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,
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,
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,
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,
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);
}