mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-18 14:27:39 +03:00
0029025: TInspector include files are not installed to inc directory by CMake
TInspector headers are collected in 'inc/tools' directory. Extending DRAW Commands; Eliminating warnings; Improve Export to ShapeView dialog; Avoid crash with QML using;
This commit is contained in:
@@ -13,9 +13,9 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <ShapeView_Communicator.hxx>
|
||||
#include <inspector/ShapeView_Communicator.hxx>
|
||||
|
||||
#include <ShapeView_Window.hxx>
|
||||
#include <inspector/ShapeView_Window.hxx>
|
||||
#include <OSD_Directory.hxx>
|
||||
#include <OSD_Environment.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
|
@@ -16,8 +16,8 @@
|
||||
#ifndef ShapeView_Communicator_H
|
||||
#define ShapeView_Communicator_H
|
||||
|
||||
#include <ShapeView_Window.hxx>
|
||||
#include <TInspectorAPI_Communicator.hxx>
|
||||
#include <inspector/ShapeView_Window.hxx>
|
||||
#include <inspector/TInspectorAPI_Communicator.hxx>
|
||||
|
||||
//! \class ShapeView_Communicator.
|
||||
//! \brief This is a connector from TInspector application to ShapeView window
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TreeModel_ItemBase.hxx>
|
||||
#include <inspector/TreeModel_ItemBase.hxx>
|
||||
|
||||
class ShapeView_ItemBase;
|
||||
typedef QExplicitlySharedDataPointer<ShapeView_ItemBase> ShapeView_ItemBasePtr;
|
||||
|
@@ -14,8 +14,8 @@
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
|
||||
#include <ShapeView_ItemRoot.hxx>
|
||||
#include <ShapeView_ItemShape.hxx>
|
||||
#include <inspector/ShapeView_ItemRoot.hxx>
|
||||
#include <inspector/ShapeView_ItemShape.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : GetShape
|
||||
|
@@ -17,7 +17,7 @@
|
||||
#define ShapeView_ItemRoot_H
|
||||
|
||||
#include <NCollection_List.hxx>
|
||||
#include <ShapeView_ItemBase.hxx>
|
||||
#include <inspector/ShapeView_ItemBase.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <ShapeView_ItemShape.hxx>
|
||||
#include <inspector/ShapeView_ItemShape.hxx>
|
||||
|
||||
#include <Adaptor3d_Curve.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
@@ -23,8 +23,8 @@
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <GeomAdaptor_Curve.hxx>
|
||||
|
||||
#include <ShapeView_ItemRoot.hxx>
|
||||
#include <ShapeView_ItemShape.hxx>
|
||||
#include <inspector/ShapeView_ItemRoot.hxx>
|
||||
#include <inspector/ShapeView_ItemShape.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
|
@@ -16,7 +16,7 @@
|
||||
#ifndef ShapeView_ItemShape_H
|
||||
#define ShapeView_ItemShape_H
|
||||
|
||||
#include <ShapeView_ItemBase.hxx>
|
||||
#include <inspector/ShapeView_ItemBase.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
virtual ~ShapeView_ItemShape() Standard_OVERRIDE {};
|
||||
|
||||
//! Returns the current shape
|
||||
const TopoDS_Shape& GetItemShape() const { return myShape; }
|
||||
const TopoDS_Shape& GetItemShape() const { initItem(); return myShape; }
|
||||
|
||||
//! Returns child(extracted) shape for the current shape by the index
|
||||
//! \param theRowId an index of child shape
|
||||
|
@@ -13,8 +13,8 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <ShapeView_OpenFileDialog.hxx>
|
||||
#include <ShapeView_OpenFileViewModel.hxx>
|
||||
#include <inspector/ShapeView_OpenFileDialog.hxx>
|
||||
#include <inspector/ShapeView_OpenFileViewModel.hxx>
|
||||
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
@@ -208,7 +208,8 @@ void ShapeView_OpenFileDialog::onSelectClicked()
|
||||
anEnteredPath = aDirName;
|
||||
}
|
||||
|
||||
QString aFileName = QFileDialog::getOpenFileName (0, "Open document", anEnteredPath);
|
||||
QString aFilter (tr ("BREP file (*.brep*)"));
|
||||
QString aFileName = QFileDialog::getOpenFileName (0, "Open document", anEnteredPath, aFilter);
|
||||
|
||||
if (aFileName.isEmpty())
|
||||
return; // do nothing, left the previous value
|
||||
|
@@ -13,7 +13,7 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <ShapeView_OpenFileViewModel.hxx>
|
||||
#include <inspector/ShapeView_OpenFileViewModel.hxx>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFileInfo>
|
||||
|
@@ -13,7 +13,7 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <ShapeView_Tools.hxx>
|
||||
#include <inspector/ShapeView_Tools.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
|
@@ -13,8 +13,11 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <ShapeView_TreeModel.hxx>
|
||||
#include <ShapeView_ItemRoot.hxx>
|
||||
#include <inspector/ShapeView_TreeModel.hxx>
|
||||
#include <inspector/ShapeView_ItemRoot.hxx>
|
||||
#include <inspector/ShapeView_TreeModel.hxx>
|
||||
#include <inspector/ShapeView_ItemRoot.hxx>
|
||||
#include <inspector/ShapeView_ItemShape.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : Constructor
|
||||
@@ -84,3 +87,39 @@ QVariant ShapeView_TreeModel::headerData (int theSection, Qt::Orientation theOri
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : FindIndex
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QModelIndex ShapeView_TreeModel::FindIndex (const TopoDS_Shape& theShape) const
|
||||
{
|
||||
QModelIndex aParentIndex = index (0, 0);
|
||||
TreeModel_ItemBasePtr aParentItem = TreeModel_ModelBase::GetItemByIndex (aParentIndex); // application item
|
||||
for (int aChildId = 0, aCount = aParentItem->rowCount(); aChildId < aCount; aChildId++)
|
||||
{
|
||||
QModelIndex anIndex = index (aChildId, 0, aParentIndex);
|
||||
ShapeView_ItemShapePtr anItem = itemDynamicCast<ShapeView_ItemShape> (TreeModel_ModelBase::GetItemByIndex (anIndex));
|
||||
if (anItem && anItem->GetItemShape() == theShape)
|
||||
return anIndex;
|
||||
}
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : SingleSelected
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
QModelIndex ShapeView_TreeModel::SingleSelected (const QModelIndexList& theIndices, const int theCellId,
|
||||
const Qt::Orientation theOrientation)
|
||||
{
|
||||
QModelIndexList aFirstColumnSelectedIndices;
|
||||
for (QModelIndexList::const_iterator anIndicesIt = theIndices.begin(); anIndicesIt != theIndices.end(); anIndicesIt++)
|
||||
{
|
||||
QModelIndex anIndex = *anIndicesIt;
|
||||
if ((theOrientation == Qt::Horizontal && anIndex.column() == theCellId) ||
|
||||
(theOrientation == Qt::Vertical && anIndex.row() == theCellId))
|
||||
aFirstColumnSelectedIndices.append (anIndex);
|
||||
}
|
||||
return aFirstColumnSelectedIndices.size() == 1 ? aFirstColumnSelectedIndices.first() : QModelIndex();
|
||||
}
|
||||
|
@@ -16,10 +16,10 @@
|
||||
#ifndef ShapeView_TreeModel_H
|
||||
#define ShapeView_TreeModel_H
|
||||
|
||||
#include <ShapeView_ItemBase.hxx>
|
||||
#include <inspector/ShapeView_ItemBase.hxx>
|
||||
#include <Standard.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TreeModel_ModelBase.hxx>
|
||||
#include <inspector/TreeModel_ModelBase.hxx>
|
||||
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
@@ -64,6 +64,19 @@ public:
|
||||
//! \return the header data
|
||||
Standard_EXPORT virtual QVariant headerData (int theSection, Qt::Orientation theOrientation,
|
||||
int theRole = Qt::DisplayRole ) const Standard_OVERRIDE;
|
||||
//! Returns model index of the shape.
|
||||
//! \param theShape a shape object
|
||||
//! \return the model index
|
||||
QModelIndex FindIndex (const TopoDS_Shape& theShape) const;
|
||||
|
||||
//! Returns single selected item in the cell of given orientation. If the orientation is Horizontal,
|
||||
//! in the cell id colum, one row should be selected.
|
||||
//! \param theIndices a container of selected indices
|
||||
//! \param theCellId column index if orientation is horizontal, row index otherwise
|
||||
//! \param theOrientation an orientation to apply the cell index
|
||||
//! \return model index from the list
|
||||
Standard_EXPORT static QModelIndex SingleSelected (const QModelIndexList& theIndices, const int theCellId,
|
||||
const Qt::Orientation theOrientation = Qt::Horizontal);
|
||||
|
||||
private:
|
||||
QMap<int, TreeModel_ItemBasePtr> myRootItems; //!< container of root items, for each column own root item
|
||||
|
@@ -13,18 +13,22 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <ShapeView_Window.hxx>
|
||||
#include <ShapeView_ItemShape.hxx>
|
||||
#include <ShapeView_TreeModel.hxx>
|
||||
#include <inspector/ShapeView_Window.hxx>
|
||||
#include <inspector/ShapeView_ItemRoot.hxx>
|
||||
#include <inspector/ShapeView_ItemShape.hxx>
|
||||
#include <inspector/ShapeView_TreeModel.hxx>
|
||||
#include <inspector/View_Displayer.hxx>
|
||||
#include <inspector/View_ToolBar.hxx>
|
||||
#include <inspector/View_Widget.hxx>
|
||||
#include <inspector/View_Window.hxx>
|
||||
#include <inspector/View_Viewer.hxx>
|
||||
|
||||
#include <View_Displayer.hxx>
|
||||
#include <View_ToolBar.hxx>
|
||||
#include <View_Widget.hxx>
|
||||
#include <View_Window.hxx>
|
||||
#include <View_Viewer.hxx>
|
||||
|
||||
#include <ShapeView_OpenFileDialog.hxx>
|
||||
#include <ShapeView_Tools.hxx>
|
||||
#include <inspector/ShapeView_Window.hxx>
|
||||
#include <inspector/ShapeView_ItemRoot.hxx>
|
||||
#include <inspector/ShapeView_ItemShape.hxx>
|
||||
#include <inspector/ShapeView_TreeModel.hxx>
|
||||
#include <inspector/ShapeView_OpenFileDialog.hxx>
|
||||
#include <inspector/ShapeView_Tools.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
@@ -127,19 +131,9 @@ ShapeView_Window::ShapeView_Window (QWidget* theParent, const TCollection_AsciiS
|
||||
{
|
||||
myMainWindow = new QMainWindow (theParent);
|
||||
|
||||
QWidget* aCentralWidget = new QWidget (myMainWindow);
|
||||
QGridLayout* aParentLay = new QGridLayout (aCentralWidget);
|
||||
aParentLay->setContentsMargins (0, 0, 0, 0);
|
||||
myMainWindow->setCentralWidget (aCentralWidget);
|
||||
|
||||
ShapeView_OpenButton* aButton = new ShapeView_OpenButton (0);
|
||||
connect (aButton, SIGNAL (OpenFile (const QString&)), this, SLOT (onOpenFile (const QString&)));
|
||||
aButton->setObjectName ("TKShapeView");
|
||||
aParentLay->addWidget (aButton->StartButton(), 0, 2);
|
||||
|
||||
myTreeView = new ShapeView_TreeView (myMainWindow);
|
||||
((ShapeView_TreeView*)myTreeView)->SetPredefinedSize (SHAPEVIEW_DEFAULT_TREE_VIEW_WIDTH,
|
||||
SHAPEVIEW_DEFAULT_TREE_VIEW_HEIGHT);
|
||||
SHAPEVIEW_DEFAULT_TREE_VIEW_HEIGHT);
|
||||
myTreeView->setContextMenuPolicy (Qt::CustomContextMenu);
|
||||
connect (myTreeView, SIGNAL (customContextMenuRequested (const QPoint&)),
|
||||
this, SLOT (onTreeViewContextMenuRequested (const QPoint&)));
|
||||
@@ -161,11 +155,7 @@ ShapeView_Window::ShapeView_Window (QWidget* theParent, const TCollection_AsciiS
|
||||
myTreeView->setColumnWidth (4, LOCATION_COLUMN_WIDTH);
|
||||
myTreeView->setColumnWidth (5, FLAGS_COLUMN_WIDTH);
|
||||
|
||||
QDockWidget* aTreeViewWidget = new QDockWidget (tr ("ShapeView"), myMainWindow);
|
||||
aTreeViewWidget->setFeatures (QDockWidget::NoDockWidgetFeatures);
|
||||
aTreeViewWidget->setWidget (myTreeView);
|
||||
myMainWindow->addDockWidget (Qt::LeftDockWidgetArea, aTreeViewWidget);
|
||||
myMainWindow->setCorner (Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
||||
myMainWindow->setCentralWidget (myTreeView);
|
||||
|
||||
// view
|
||||
myViewWindow = new View_Window (myMainWindow);
|
||||
@@ -173,7 +163,7 @@ ShapeView_Window::ShapeView_Window (QWidget* theParent, const TCollection_AsciiS
|
||||
|
||||
QDockWidget* aViewDockWidget = new QDockWidget (tr ("View"), myMainWindow);
|
||||
aViewDockWidget->setWidget (myViewWindow);
|
||||
myMainWindow->addDockWidget (Qt::BottomDockWidgetArea, aViewDockWidget);
|
||||
myMainWindow->addDockWidget (Qt::RightDockWidgetArea, aViewDockWidget);
|
||||
|
||||
myMainWindow->resize (DEFAULT_SHAPE_VIEW_WIDTH, DEFAULT_SHAPE_VIEW_HEIGHT);
|
||||
myMainWindow->move (DEFAULT_SHAPE_VIEW_POSITION_X, DEFAULT_SHAPE_VIEW_POSITION_Y);
|
||||
@@ -226,6 +216,32 @@ void ShapeView_Window::UpdateContent()
|
||||
NCollection_List<TCollection_AsciiString> aNames;
|
||||
myParameters->SetFileNames (aName, aNames);
|
||||
}
|
||||
// make TopoDS_TShape selected if exist in select parameters
|
||||
NCollection_List<Handle(Standard_Transient)> anObjects;
|
||||
if (myParameters->GetSelectedObjects(aName, anObjects))
|
||||
{
|
||||
ShapeView_TreeModel* aModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
|
||||
QItemSelectionModel* aSelectionModel = myTreeView->selectionModel();
|
||||
aSelectionModel->clear();
|
||||
for (NCollection_List<Handle(Standard_Transient)>::Iterator aParamsIt (anObjects);
|
||||
aParamsIt.More(); aParamsIt.Next())
|
||||
{
|
||||
Handle(Standard_Transient) anObject = aParamsIt.Value();
|
||||
Handle(TopoDS_TShape) aShapePointer = Handle(TopoDS_TShape)::DownCast (anObject);
|
||||
if (aShapePointer.IsNull())
|
||||
continue;
|
||||
|
||||
TopoDS_Shape aShape;
|
||||
aShape.TShape (aShapePointer);
|
||||
|
||||
QModelIndex aShapeIndex = aModel->FindIndex (aShape);
|
||||
if (!aShapeIndex.isValid())
|
||||
continue;
|
||||
aSelectionModel->select (aShapeIndex, QItemSelectionModel::Select);
|
||||
myTreeView->scrollTo (aShapeIndex);
|
||||
}
|
||||
myParameters->SetSelected (aName, NCollection_List<Handle(Standard_Transient)>());
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
@@ -299,13 +315,27 @@ void ShapeView_Window::addShape (const TopoDS_Shape& theShape)
|
||||
// =======================================================================
|
||||
void ShapeView_Window::onTreeViewContextMenuRequested (const QPoint& thePosition)
|
||||
{
|
||||
QMenu* aMenu = new QMenu(myMainWindow);
|
||||
aMenu->addAction (createAction ("Clear view", SLOT (onClearView())));
|
||||
if (!myTemporaryDirectory.IsEmpty())
|
||||
aMenu->addAction (createAction ("BREP view", SLOT (onBREPView())));
|
||||
aMenu->addAction (createAction ("Close All BREP views", SLOT (onCloseAllBREPViews())));
|
||||
aMenu->addAction (createAction ("BREP directory", SLOT (onBREPDirectory())));
|
||||
QItemSelectionModel* aModel = myTreeView->selectionModel();
|
||||
if (!aModel)
|
||||
return;
|
||||
|
||||
QModelIndex anIndex = ShapeView_TreeModel::SingleSelected (aModel->selectedIndexes(), 0);
|
||||
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
|
||||
if (!anItemBase)
|
||||
return;
|
||||
|
||||
QMenu* aMenu = new QMenu(myMainWindow);
|
||||
ShapeView_ItemRootPtr aRootItem = itemDynamicCast<ShapeView_ItemRoot> (anItemBase);
|
||||
if (aRootItem) {
|
||||
aMenu->addAction (createAction("Load BREP file", SLOT (onLoadFile())));
|
||||
aMenu->addAction (createAction ("Remove all shape items", SLOT (onClearView())));
|
||||
}
|
||||
else {
|
||||
if (!myTemporaryDirectory.IsEmpty())
|
||||
aMenu->addAction (createAction ("BREP view", SLOT (onBREPView())));
|
||||
aMenu->addAction (createAction ("Close All BREP views", SLOT (onCloseAllBREPViews())));
|
||||
aMenu->addAction (createAction ("BREP directory", SLOT (onBREPDirectory())));
|
||||
}
|
||||
QPoint aPoint = myTreeView->mapToGlobal (thePosition);
|
||||
aMenu->exec (aPoint);
|
||||
}
|
||||
@@ -324,6 +354,20 @@ void ShapeView_Window::onBREPDirectory()
|
||||
viewFile (aFileName);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onLoadFile
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void ShapeView_Window::onLoadFile()
|
||||
{
|
||||
QString aDataDirName = QDir::currentPath();
|
||||
|
||||
QString aFileName = ShapeView_OpenFileDialog::OpenFile(0, aDataDirName);
|
||||
aFileName = QDir().toNativeSeparators (aFileName);
|
||||
if (!aFileName.isEmpty())
|
||||
onOpenFile(aFileName);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : onBREPView
|
||||
// purpose :
|
||||
|
@@ -18,7 +18,7 @@
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TInspectorAPI_PluginParameters.hxx>
|
||||
#include <inspector/TInspectorAPI_PluginParameters.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
@@ -110,6 +110,9 @@ protected slots:
|
||||
//! Removes all shapes in tree view
|
||||
void onClearView() { RemoveAllShapes(); }
|
||||
|
||||
//! Load BREP file and updates tree model to have shape of the file
|
||||
void onLoadFile();
|
||||
|
||||
//! View BREP files of selected items if exist
|
||||
void onBREPView();
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 794 B After Width: | Height: | Size: 1.9 KiB |
Reference in New Issue
Block a user