1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Coding - Apply .clang-format formatting #286

Update empty method guards to new style with regex (see PR).
Used clang-format 18.1.8.
New actions to validate code formatting is added.
Update .clang-format with disabling of include sorting.
  It is temporary changes, then include will be sorted.
Apply formatting for /src and /tools folder.
The files with .hxx,.cxx,.lxx,.h,.pxx,.hpp,*.cpp extensions.
This commit is contained in:
dpasukhi
2025-01-25 20:15:22 +00:00
parent dbba6f1289
commit a5a7b3185b
14005 changed files with 1273539 additions and 1195567 deletions

View File

@@ -11,7 +11,7 @@
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// commercial license or contractual agreement.
#include <inspector/ShapeView_Window.hxx>
#include <inspector/ShapeView_ItemRoot.hxx>
@@ -62,100 +62,106 @@
#include <QVBoxLayout>
#include <Standard_WarningsRestore.hxx>
static const int DEFAULT_SHAPE_VIEW_WIDTH = 900;
static const int DEFAULT_SHAPE_VIEW_HEIGHT = 450;
static const int DEFAULT_SHAPE_VIEW_WIDTH = 900;
static const int DEFAULT_SHAPE_VIEW_HEIGHT = 450;
static const int DEFAULT_SHAPE_VIEW_POSITION_X = 60;
static const int DEFAULT_SHAPE_VIEW_POSITION_Y = 60;
static const int SHAPEVIEW_DEFAULT_TREE_VIEW_WIDTH = 600;
static const int SHAPEVIEW_DEFAULT_TREE_VIEW_WIDTH = 600;
static const int SHAPEVIEW_DEFAULT_TREE_VIEW_HEIGHT = 500;
static const int SHAPEVIEW_DEFAULT_VIEW_WIDTH = 300;
static const int SHAPEVIEW_DEFAULT_VIEW_WIDTH = 300;
static const int SHAPEVIEW_DEFAULT_VIEW_HEIGHT = 1000;
// =======================================================================
// function : Constructor
// purpose :
// =======================================================================
ShapeView_Window::ShapeView_Window (QWidget* theParent)
: QObject (theParent)
ShapeView_Window::ShapeView_Window(QWidget* theParent)
: QObject(theParent)
{
myMainWindow = new QMainWindow (theParent);
myMainWindow = new QMainWindow(theParent);
myTreeView = new ViewControl_TreeView (myMainWindow);
((ViewControl_TreeView*)myTreeView)->SetPredefinedSize (QSize (SHAPEVIEW_DEFAULT_TREE_VIEW_WIDTH,
SHAPEVIEW_DEFAULT_TREE_VIEW_HEIGHT));
myTreeView->setContextMenuPolicy (Qt::CustomContextMenu);
connect (myTreeView, SIGNAL (customContextMenuRequested (const QPoint&)),
this, SLOT (onTreeViewContextMenuRequested (const QPoint&)));
new TreeModel_ContextMenu (myTreeView);
ShapeView_TreeModel* aModel = new ShapeView_TreeModel (myTreeView);
myTreeView = new ViewControl_TreeView(myMainWindow);
((ViewControl_TreeView*)myTreeView)
->SetPredefinedSize(
QSize(SHAPEVIEW_DEFAULT_TREE_VIEW_WIDTH, SHAPEVIEW_DEFAULT_TREE_VIEW_HEIGHT));
myTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
connect(myTreeView,
SIGNAL(customContextMenuRequested(const QPoint&)),
this,
SLOT(onTreeViewContextMenuRequested(const QPoint&)));
new TreeModel_ContextMenu(myTreeView);
ShapeView_TreeModel* aModel = new ShapeView_TreeModel(myTreeView);
aModel->InitColumns();
myTreeView->setModel (aModel);
ShapeView_VisibilityState* aVisibilityState = new ShapeView_VisibilityState (aModel);
aModel->SetVisibilityState (aVisibilityState);
TreeModel_Tools::UseVisibilityColumn (myTreeView);
QObject::connect (myTreeView, SIGNAL (clicked (const QModelIndex&)),
aVisibilityState, SLOT (OnClicked(const QModelIndex&)));
myTreeView->setModel(aModel);
ShapeView_VisibilityState* aVisibilityState = new ShapeView_VisibilityState(aModel);
aModel->SetVisibilityState(aVisibilityState);
TreeModel_Tools::UseVisibilityColumn(myTreeView);
QObject::connect(myTreeView,
SIGNAL(clicked(const QModelIndex&)),
aVisibilityState,
SLOT(OnClicked(const QModelIndex&)));
QItemSelectionModel* aSelModel = new QItemSelectionModel (myTreeView->model(), myTreeView);
myTreeView->setSelectionModel (aSelModel);
connect (aSelModel, SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
this, SLOT (onTreeViewSelectionChanged (const QItemSelection&, const QItemSelection&)));
QItemSelectionModel* aSelModel = new QItemSelectionModel(myTreeView->model(), myTreeView);
myTreeView->setSelectionModel(aSelModel);
connect(aSelModel,
SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
this,
SLOT(onTreeViewSelectionChanged(const QItemSelection&, const QItemSelection&)));
QModelIndex aParentIndex = myTreeView->model()->index (0, 0);
myTreeView->setExpanded (aParentIndex, true);
myMainWindow->setCentralWidget (myTreeView);
QModelIndex aParentIndex = myTreeView->model()->index(0, 0);
myTreeView->setExpanded(aParentIndex, true);
myMainWindow->setCentralWidget(myTreeView);
// property view
myPropertyView = new ViewControl_PropertyView (myMainWindow,
myPropertyView = new ViewControl_PropertyView(
myMainWindow,
QSize(SHAPEVIEW_DEFAULT_VIEW_WIDTH, SHAPEVIEW_DEFAULT_VIEW_HEIGHT));
myPropertyPanelWidget = new QDockWidget (tr ("PropertyPanel"), myMainWindow);
myPropertyPanelWidget->setObjectName (myPropertyPanelWidget->windowTitle());
myPropertyPanelWidget->setTitleBarWidget (new QWidget(myMainWindow));
myPropertyPanelWidget->setWidget (myPropertyView->GetControl());
myMainWindow->addDockWidget (Qt::RightDockWidgetArea, myPropertyPanelWidget);
myPropertyPanelWidget = new QDockWidget(tr("PropertyPanel"), myMainWindow);
myPropertyPanelWidget->setObjectName(myPropertyPanelWidget->windowTitle());
myPropertyPanelWidget->setTitleBarWidget(new QWidget(myMainWindow));
myPropertyPanelWidget->setWidget(myPropertyView->GetControl());
myMainWindow->addDockWidget(Qt::RightDockWidgetArea, myPropertyPanelWidget);
// view
myViewWindow = new View_Window (myMainWindow, NULL, false);
connect (myViewWindow, SIGNAL(eraseAllPerformed()), this, SLOT(onEraseAllPerformed()));
aVisibilityState->SetDisplayer (myViewWindow->Displayer());
aVisibilityState->SetPresentationType (View_PresentationType_Main);
myViewWindow->SetPredefinedSize (SHAPEVIEW_DEFAULT_VIEW_WIDTH, SHAPEVIEW_DEFAULT_VIEW_HEIGHT);
myViewWindow = new View_Window(myMainWindow, NULL, false);
connect(myViewWindow, SIGNAL(eraseAllPerformed()), this, SLOT(onEraseAllPerformed()));
aVisibilityState->SetDisplayer(myViewWindow->Displayer());
aVisibilityState->SetPresentationType(View_PresentationType_Main);
myViewWindow->SetPredefinedSize(SHAPEVIEW_DEFAULT_VIEW_WIDTH, SHAPEVIEW_DEFAULT_VIEW_HEIGHT);
QDockWidget* aViewDockWidget = new QDockWidget (tr ("View"), myMainWindow);
aViewDockWidget->setObjectName (aViewDockWidget->windowTitle());
aViewDockWidget->setWidget (myViewWindow);
aViewDockWidget->setTitleBarWidget (myViewWindow->ViewToolBar()->GetControl());
myMainWindow->addDockWidget (Qt::RightDockWidgetArea, aViewDockWidget);
QDockWidget* aViewDockWidget = new QDockWidget(tr("View"), myMainWindow);
aViewDockWidget->setObjectName(aViewDockWidget->windowTitle());
aViewDockWidget->setWidget(myViewWindow);
aViewDockWidget->setTitleBarWidget(myViewWindow->ViewToolBar()->GetControl());
myMainWindow->addDockWidget(Qt::RightDockWidgetArea, aViewDockWidget);
myMainWindow->splitDockWidget(myPropertyPanelWidget, aViewDockWidget, Qt::Vertical);
myMainWindow->resize (DEFAULT_SHAPE_VIEW_WIDTH, DEFAULT_SHAPE_VIEW_HEIGHT);
myMainWindow->move (DEFAULT_SHAPE_VIEW_POSITION_X, DEFAULT_SHAPE_VIEW_POSITION_Y);
myMainWindow->resize(DEFAULT_SHAPE_VIEW_WIDTH, DEFAULT_SHAPE_VIEW_HEIGHT);
myMainWindow->move(DEFAULT_SHAPE_VIEW_POSITION_X, DEFAULT_SHAPE_VIEW_POSITION_Y);
}
// =======================================================================
// function : Destructor
// purpose :
// =======================================================================
ShapeView_Window::~ShapeView_Window()
{
}
ShapeView_Window::~ShapeView_Window() {}
// =======================================================================
// function : SetParent
// purpose :
// =======================================================================
void ShapeView_Window::SetParent (void* theParent)
void ShapeView_Window::SetParent(void* theParent)
{
QWidget* aParent = (QWidget*)theParent;
if (aParent)
{
QLayout* aLayout = aParent->layout();
if (aLayout)
aLayout->addWidget (GetMainWindow());
aLayout->addWidget(GetMainWindow());
}
}
@@ -163,15 +169,15 @@ void ShapeView_Window::SetParent (void* theParent)
// function : FillActionsMenu
// purpose :
// =======================================================================
void ShapeView_Window::FillActionsMenu (void* theMenu)
void ShapeView_Window::FillActionsMenu(void* theMenu)
{
QMenu* aMenu = (QMenu*)theMenu;
QMenu* aMenu = (QMenu*)theMenu;
QList<QDockWidget*> aDockwidgets = myMainWindow->findChildren<QDockWidget*>();
for (QList<QDockWidget*>::iterator it = aDockwidgets.begin(); it != aDockwidgets.end(); ++it)
{
QDockWidget* aDockWidget = *it;
if (aDockWidget->parentWidget() == myMainWindow)
aMenu->addAction (aDockWidget->toggleViewAction());
aMenu->addAction(aDockWidget->toggleViewAction());
}
}
@@ -179,36 +185,44 @@ void ShapeView_Window::FillActionsMenu (void* theMenu)
// function : GetPreferences
// purpose :
// =======================================================================
void ShapeView_Window::GetPreferences (TInspectorAPI_PreferencesDataMap& theItem)
void ShapeView_Window::GetPreferences(TInspectorAPI_PreferencesDataMap& theItem)
{
theItem.Bind ("geometry", TreeModel_Tools::ToString (myMainWindow->saveState()).toStdString().c_str());
theItem.Bind("geometry",
TreeModel_Tools::ToString(myMainWindow->saveState()).toStdString().c_str());
QMap<QString, QString> anItems;
TreeModel_Tools::SaveState (myTreeView, anItems);
TreeModel_Tools::SaveState(myTreeView, anItems);
View_Window::SaveState(myViewWindow, anItems);
for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin(); anItemsIt != anItems.end(); anItemsIt++)
theItem.Bind (anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
for (QMap<QString, QString>::const_iterator anItemsIt = anItems.begin();
anItemsIt != anItems.end();
anItemsIt++)
theItem.Bind(anItemsIt.key().toStdString().c_str(), anItemsIt.value().toStdString().c_str());
}
// =======================================================================
// function : SetPreferences
// purpose :
// =======================================================================
void ShapeView_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& theItem)
void ShapeView_Window::SetPreferences(const TInspectorAPI_PreferencesDataMap& theItem)
{
if (theItem.IsEmpty())
{
TreeModel_Tools::SetDefaultHeaderSections (myTreeView);
TreeModel_Tools::SetDefaultHeaderSections(myTreeView);
return;
}
for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt (theItem); anItemIt.More(); anItemIt.Next())
for (TInspectorAPI_IteratorOfPreferencesDataMap anItemIt(theItem); anItemIt.More();
anItemIt.Next())
{
if (anItemIt.Key().IsEqual ("geometry"))
myMainWindow->restoreState (TreeModel_Tools::ToByteArray (anItemIt.Value().ToCString()));
else if (TreeModel_Tools::RestoreState (myTreeView, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
if (anItemIt.Key().IsEqual("geometry"))
myMainWindow->restoreState(TreeModel_Tools::ToByteArray(anItemIt.Value().ToCString()));
else if (TreeModel_Tools::RestoreState(myTreeView,
anItemIt.Key().ToCString(),
anItemIt.Value().ToCString()))
continue;
else if (View_Window::RestoreState(myViewWindow, anItemIt.Key().ToCString(), anItemIt.Value().ToCString()))
else if (View_Window::RestoreState(myViewWindow,
anItemIt.Key().ToCString(),
anItemIt.Value().ToCString()))
continue;
}
}
@@ -220,47 +234,50 @@ void ShapeView_Window::SetPreferences (const TInspectorAPI_PreferencesDataMap& t
void ShapeView_Window::UpdateContent()
{
TCollection_AsciiString aName = "TKShapeView";
if (myParameters->FindParameters (aName))
if (myParameters->FindParameters(aName))
{
NCollection_List<Handle(Standard_Transient)> aParameters = myParameters->Parameters (aName);
NCollection_List<Handle(Standard_Transient)> aParameters = myParameters->Parameters(aName);
// Init will remove from parameters those, that are processed only one time (TShape)
Init(aParameters);
myParameters->SetParameters (aName, aParameters);
myParameters->SetParameters(aName, aParameters);
}
if (myParameters->FindFileNames(aName))
{
for (NCollection_List<TCollection_AsciiString>::Iterator aFilesIt(myParameters->FileNames(aName));
aFilesIt.More(); aFilesIt.Next())
OpenFile (aFilesIt.Value());
for (NCollection_List<TCollection_AsciiString>::Iterator aFilesIt(
myParameters->FileNames(aName));
aFilesIt.More();
aFilesIt.Next())
OpenFile(aFilesIt.Value());
NCollection_List<TCollection_AsciiString> aNames;
myParameters->SetFileNames (aName, 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());
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())
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);
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);
aShape.TShape(aShapePointer);
QModelIndex aShapeIndex = aModel->FindIndex (aShape);
QModelIndex aShapeIndex = aModel->FindIndex(aShape);
if (!aShapeIndex.isValid())
continue;
aSelectionModel->select (aShapeIndex, QItemSelectionModel::Select);
myTreeView->scrollTo (aShapeIndex);
aSelectionModel->select(aShapeIndex, QItemSelectionModel::Select);
myTreeView->scrollTo(aShapeIndex);
}
myParameters->SetSelected (aName, NCollection_List<Handle(Standard_Transient)>());
myParameters->SetSelected(aName, NCollection_List<Handle(Standard_Transient)>());
}
}
@@ -268,46 +285,47 @@ void ShapeView_Window::UpdateContent()
// function : Init
// purpose :
// =======================================================================
void ShapeView_Window::Init (NCollection_List<Handle(Standard_Transient)>& theParameters)
void ShapeView_Window::Init(NCollection_List<Handle(Standard_Transient)>& theParameters)
{
Handle(AIS_InteractiveContext) aContext;
Handle(AIS_InteractiveContext) aContext;
NCollection_List<Handle(Standard_Transient)> aParameters;
TCollection_AsciiString aPluginName ("TKShapeView");
TCollection_AsciiString aPluginName("TKShapeView");
NCollection_List<TCollection_AsciiString> aSelectedParameters;
if (myParameters->FindSelectedNames (aPluginName)) // selected names have TShape parameters
aSelectedParameters = myParameters->GetSelectedNames (aPluginName);
if (myParameters->FindSelectedNames(aPluginName)) // selected names have TShape parameters
aSelectedParameters = myParameters->GetSelectedNames(aPluginName);
NCollection_List<TCollection_AsciiString>::Iterator aParamsIt (aSelectedParameters);
for (NCollection_List<Handle(Standard_Transient)>::Iterator anObjectsIt (theParameters);
anObjectsIt.More(); anObjectsIt.Next())
NCollection_List<TCollection_AsciiString>::Iterator aParamsIt(aSelectedParameters);
for (NCollection_List<Handle(Standard_Transient)>::Iterator anObjectsIt(theParameters);
anObjectsIt.More();
anObjectsIt.Next())
{
Handle(Standard_Transient) anObject = anObjectsIt.Value();
Handle(TopoDS_TShape) aShapePointer = Handle(TopoDS_TShape)::DownCast (anObject);
Handle(Standard_Transient) anObject = anObjectsIt.Value();
Handle(TopoDS_TShape) aShapePointer = Handle(TopoDS_TShape)::DownCast(anObject);
if (!aShapePointer.IsNull())
{
TopoDS_Shape aShape;
aShape.TShape (aShapePointer);
aShape.TShape(aShapePointer);
if (aParamsIt.More())
{
// each Transient object has own location/orientation description
TInspectorAPI_PluginParameters::ParametersToShape (aParamsIt.Value(), aShape);
TInspectorAPI_PluginParameters::ParametersToShape(aParamsIt.Value(), aShape);
aParamsIt.Next();
}
addShape (aShape);
addShape(aShape);
}
else
{
aParameters.Append (anObject);
aParameters.Append(anObject);
if (aContext.IsNull())
aContext = Handle(AIS_InteractiveContext)::DownCast (anObject);
aContext = Handle(AIS_InteractiveContext)::DownCast(anObject);
}
}
if (!aContext.IsNull())
myViewWindow->SetContext (View_ContextType_External, aContext);
myViewWindow->SetContext(View_ContextType_External, aContext);
theParameters = aParameters;
myParameters->SetSelectedNames (aPluginName, NCollection_List<TCollection_AsciiString>());
myParameters->SetSelectedNames(aPluginName, NCollection_List<TCollection_AsciiString>());
}
// =======================================================================
@@ -316,7 +334,7 @@ void ShapeView_Window::Init (NCollection_List<Handle(Standard_Transient)>& thePa
// =======================================================================
void ShapeView_Window::OpenFile(const TCollection_AsciiString& theFileName)
{
TopoDS_Shape aShape = Convert_Tools::ReadShape (theFileName);
TopoDS_Shape aShape = Convert_Tools::ReadShape(theFileName);
if (!aShape.IsNull())
addShape(aShape);
}
@@ -327,7 +345,7 @@ void ShapeView_Window::OpenFile(const TCollection_AsciiString& theFileName)
// =======================================================================
void ShapeView_Window::RemoveAllShapes()
{
ShapeView_TreeModel* aModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
ShapeView_TreeModel* aModel = dynamic_cast<ShapeView_TreeModel*>(myTreeView->model());
aModel->RemoveAllShapes();
}
@@ -335,76 +353,89 @@ void ShapeView_Window::RemoveAllShapes()
// function : addShape
// purpose :
// =======================================================================
void ShapeView_Window::addShape (const TopoDS_Shape& theShape)
void ShapeView_Window::addShape(const TopoDS_Shape& theShape)
{
ShapeView_TreeModel* aModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
aModel->AddShape (theShape);
ShapeView_TreeModel* aModel = dynamic_cast<ShapeView_TreeModel*>(myTreeView->model());
aModel->AddShape(theShape);
}
// =======================================================================
// function : onTreeViewContextMenuRequested
// purpose :
// =======================================================================
void ShapeView_Window::onTreeViewContextMenuRequested (const QPoint& thePosition)
void ShapeView_Window::onTreeViewContextMenuRequested(const QPoint& thePosition)
{
QItemSelectionModel* aModel = myTreeView->selectionModel();
if (!aModel)
return;
QModelIndex anIndex = TreeModel_ModelBase::SingleSelected (aModel->selectedIndexes(), 0);
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (anIndex);
QModelIndex anIndex = TreeModel_ModelBase::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 (ViewControl_Tools::CreateAction ("Load BREP file", SLOT (onLoadFile()), myMainWindow, this));
aMenu->addAction (ViewControl_Tools::CreateAction ("Remove all shape items", SLOT (onClearView()), myMainWindow, this));
QMenu* aMenu = new QMenu(myMainWindow);
ShapeView_ItemRootPtr aRootItem = itemDynamicCast<ShapeView_ItemRoot>(anItemBase);
if (aRootItem)
{
aMenu->addAction(
ViewControl_Tools::CreateAction("Load BREP file", SLOT(onLoadFile()), myMainWindow, this));
aMenu->addAction(ViewControl_Tools::CreateAction("Remove all shape items",
SLOT(onClearView()),
myMainWindow,
this));
}
else {
aMenu->addAction (ViewControl_Tools::CreateAction ("Export to BREP", SLOT (onExportToBREP()), myMainWindow, this));
ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
const TopoDS_Shape& aShape = aShapeItem->GetItemShape();
TopAbs_ShapeEnum anExplodeType = aShapeItem->ExplodeType();
else
{
aMenu->addAction(ViewControl_Tools::CreateAction("Export to BREP",
SLOT(onExportToBREP()),
myMainWindow,
this));
ShapeView_ItemShapePtr aShapeItem = itemDynamicCast<ShapeView_ItemShape>(anItemBase);
const TopoDS_Shape& aShape = aShapeItem->GetItemShape();
TopAbs_ShapeEnum anExplodeType = aShapeItem->ExplodeType();
NCollection_List<TopAbs_ShapeEnum> anExplodeTypes;
ShapeView_Tools::IsPossibleToExplode (aShape, anExplodeTypes);
ShapeView_Tools::IsPossibleToExplode(aShape, anExplodeTypes);
if (anExplodeTypes.Size() > 0)
{
QMenu* anExplodeMenu = aMenu->addMenu ("Explode");
for (NCollection_List<TopAbs_ShapeEnum>::Iterator anExpIterator (anExplodeTypes); anExpIterator.More();
anExpIterator.Next())
QMenu* anExplodeMenu = aMenu->addMenu("Explode");
for (NCollection_List<TopAbs_ShapeEnum>::Iterator anExpIterator(anExplodeTypes);
anExpIterator.More();
anExpIterator.Next())
{
TopAbs_ShapeEnum aType = anExpIterator.Value();
QAction* anAction = ViewControl_Tools::CreateAction (TopAbs::ShapeTypeToString (aType), SLOT (onExplode()), myMainWindow, this);
anExplodeMenu->addAction (anAction);
QAction* anAction = ViewControl_Tools::CreateAction(TopAbs::ShapeTypeToString(aType),
SLOT(onExplode()),
myMainWindow,
this);
anExplodeMenu->addAction(anAction);
if (anExplodeType == aType)
{
anAction->setCheckable (true);
anAction->setChecked (true);
anAction->setCheckable(true);
anAction->setChecked(true);
}
}
QAction* anAction = ViewControl_Tools::CreateAction ("NONE", SLOT (onExplode()), myMainWindow, this);
QAction* anAction =
ViewControl_Tools::CreateAction("NONE", SLOT(onExplode()), myMainWindow, this);
anExplodeMenu->addSeparator();
anExplodeMenu->addAction (anAction);
anExplodeMenu->addAction(anAction);
}
}
QPoint aPoint = myTreeView->mapToGlobal (thePosition);
aMenu->exec (aPoint);
QPoint aPoint = myTreeView->mapToGlobal(thePosition);
aMenu->exec(aPoint);
}
// =======================================================================
// function : onTreeViewSelectionChanged
// purpose :
// =======================================================================
void ShapeView_Window::onTreeViewSelectionChanged (const QItemSelection&,
const QItemSelection&)
void ShapeView_Window::onTreeViewSelectionChanged(const QItemSelection&, const QItemSelection&)
{
QApplication::setOverrideCursor (Qt::WaitCursor);
QApplication::setOverrideCursor(Qt::WaitCursor);
if (myPropertyPanelWidget->toggleViewAction()->isChecked())
myPropertyView->Init (ViewControl_Tools::CreateTableModelValues (myTreeView->selectionModel()));
myPropertyView->Init(ViewControl_Tools::CreateTableModelValues(myTreeView->selectionModel()));
QApplication::restoreOverrideCursor();
}
@@ -415,9 +446,10 @@ void ShapeView_Window::onTreeViewSelectionChanged (const QItemSelection&,
// =======================================================================
void ShapeView_Window::onEraseAllPerformed()
{
ShapeView_TreeModel* aTreeModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
ShapeView_TreeModel* aTreeModel = dynamic_cast<ShapeView_TreeModel*>(myTreeView->model());
// TODO: provide update for only visibility state for better performance TopoDS_Shape myCustomShape;
// TODO: provide update for only visibility state for better performance TopoDS_Shape
// myCustomShape;
aTreeModel->Reset();
aTreeModel->EmitLayoutChanged();
@@ -433,7 +465,7 @@ void ShapeView_Window::onExplode()
if (!aModel)
return;
QModelIndex anIndex = TreeModel_ModelBase::SingleSelected(aModel->selectedIndexes(), 0);
QModelIndex anIndex = TreeModel_ModelBase::SingleSelected(aModel->selectedIndexes(), 0);
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex(anIndex);
if (!anItemBase)
return;
@@ -446,7 +478,7 @@ void ShapeView_Window::onExplode()
if (!anAction)
return;
QApplication::setOverrideCursor (Qt::WaitCursor);
QApplication::setOverrideCursor(Qt::WaitCursor);
TopAbs_ShapeEnum aShapeType;
if (anAction->text() == "NONE")
aShapeType = TopAbs_SHAPE;
@@ -456,8 +488,8 @@ void ShapeView_Window::onExplode()
myViewWindow->Displayer()->EraseAllPresentations();
aShapeItem->SetExplodeType(aShapeType);
//anItemBase->Parent()->Reset(); - TODO (update only modified sub-tree)
ShapeView_TreeModel* aTreeModel = dynamic_cast<ShapeView_TreeModel*> (myTreeView->model());
// anItemBase->Parent()->Reset(); - TODO (update only modified sub-tree)
ShapeView_TreeModel* aTreeModel = dynamic_cast<ShapeView_TreeModel*>(myTreeView->model());
aTreeModel->Reset();
aTreeModel->EmitLayoutChanged();
QApplication::restoreOverrideCursor();
@@ -472,11 +504,11 @@ void ShapeView_Window::onLoadFile()
QString aDataDirName = QDir::currentPath();
QString aFileName = ShapeView_OpenFileDialog::OpenFile(0, aDataDirName);
aFileName = QDir().toNativeSeparators (aFileName);
aFileName = QDir().toNativeSeparators(aFileName);
if (aFileName.isEmpty())
return;
QApplication::setOverrideCursor (Qt::WaitCursor);
QApplication::setOverrideCursor(Qt::WaitCursor);
onOpenFile(aFileName);
QApplication::restoreOverrideCursor();
}
@@ -487,9 +519,13 @@ void ShapeView_Window::onLoadFile()
// =======================================================================
void ShapeView_Window::onExportToBREP()
{
QString aFilter (tr ("Boundary representation file (*.brep *)"));
QString aFilter(tr("Boundary representation file (*.brep *)"));
QString aSelectedFilter;
QString aFileName = QFileDialog::getSaveFileName (0, tr ("Export shape to file"), QString(), aFilter, &aSelectedFilter);
QString aFileName = QFileDialog::getSaveFileName(0,
tr("Export shape to file"),
QString(),
aFilter,
&aSelectedFilter);
QItemSelectionModel* aModel = myTreeView->selectionModel();
if (!aModel)
@@ -499,8 +535,8 @@ void ShapeView_Window::onExportToBREP()
if (aSelectedRows.size() == 0)
return;
QModelIndex aSelectedIndex = aSelectedRows.at (0);
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex (aSelectedIndex);
QModelIndex aSelectedIndex = aSelectedRows.at(0);
TreeModel_ItemBasePtr anItemBase = TreeModel_ModelBase::GetItemByIndex(aSelectedIndex);
if (!anItemBase)
return;
@@ -509,8 +545,8 @@ void ShapeView_Window::onExportToBREP()
return;
TCollection_AsciiString aFileNameIndiced = aFileName.toStdString().c_str();
const TopoDS_Shape& aShape = anItem->GetItemShape();
BRepTools::Write (aShape, aFileNameIndiced.ToCString());
anItem->SetFileName (aFileNameIndiced.ToCString());
const TopoDS_Shape& aShape = anItem->GetItemShape();
BRepTools::Write(aShape, aFileNameIndiced.ToCString());
anItem->SetFileName(aFileNameIndiced.ToCString());
aFileName = aFileNameIndiced.ToCString();
}