From f46eb9fea23baef3447a51979b6e2a43c7017b58 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 18 Jan 2012 12:20:47 +0000 Subject: [PATCH] 0000550: No correct name of parts after import of STEP file containing assemblies embed tree widget in dialog git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5415 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Mod/Import/Gui/AppImportGuiPy.cpp | 46 ++++++++++++++++++++------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index 0c0a30360..8edbcada5 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -176,9 +177,9 @@ void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc, if (aShapeTool->IsSimpleShape(label) && (isRef || aShapeTool->IsFree(label))) { if (isRef) - createShape( label, loc, defaultname ); + createShape(label, loc, part_name); else - createShape( label, part_loc, part_name ); + createShape(label, part_loc, part_name); } else { for (TDF_ChildIterator it(label); it.More(); it.Next()) { @@ -691,10 +692,15 @@ static PyObject * exporter(PyObject *self, PyObject *args) #include #include #include +#include +#include +#include #include #include #include #include +#include +#include class OCAFBrowser { @@ -703,8 +709,6 @@ public: : pDoc(h) { myGroupIcon = QApplication::style()->standardIcon(QStyle::SP_DirIcon); - myTree = new QTreeWidget(); - myTree->setHeaderLabel(QString::fromAscii("OCAF Browser")); TDataStd::IDList(myList); myList.Append(TDataStd_TreeNode::GetDefaultTreeID()); @@ -720,7 +724,7 @@ public: myList.Append(XCAFDoc_Location::GetID()); } - void load(); + void load(QTreeWidget*); private: void load(const TDF_Label& label, QTreeWidgetItem* item, const QString&); @@ -735,22 +739,20 @@ private: private: QIcon myGroupIcon; - QTreeWidget* myTree; TDF_IDList myList; Handle_TDocStd_Document pDoc; }; -void OCAFBrowser::load() +void OCAFBrowser::load(QTreeWidget* theTree) { - myTree->clear(); + theTree->clear(); QTreeWidgetItem* root = new QTreeWidgetItem(); root->setText(0, QLatin1String("0")); root->setIcon(0, myGroupIcon); - myTree->addTopLevelItem(root); + theTree->addTopLevelItem(root); load(pDoc->GetData()->Root(), root, QString::fromAscii("0")); - myTree->show(); } void OCAFBrowser::load(const TDF_Label& label, QTreeWidgetItem* item, const QString& s) @@ -907,8 +909,30 @@ static PyObject * ocaf(PyObject *self, PyObject *args) return 0; } + static QPointer dlg = 0; + if (!dlg) { + dlg = new QDialog(Gui::getMainWindow()); + QTreeWidget* tree = new QTreeWidget(); + tree->setHeaderLabel(QString::fromAscii("OCAF Browser")); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(tree); + dlg->setLayout(layout); + + QDialogButtonBox* btn = new QDialogButtonBox(dlg); + btn->setStandardButtons(QDialogButtonBox::Close); + QObject::connect(btn, SIGNAL(rejected()), dlg, SLOT(reject())); + QHBoxLayout *boxlayout = new QHBoxLayout; + boxlayout->addWidget(btn); + layout->addLayout(boxlayout); + } + + dlg->setWindowTitle(QString::fromUtf8(file.fileName().c_str())); + dlg->setAttribute(Qt::WA_DeleteOnClose); + dlg->show(); + OCAFBrowser browse(hDoc); - browse.load(); + browse.load(dlg->findChild()); } catch (Standard_Failure) { Handle_Standard_Failure e = Standard_Failure::Caught();