Part/Import: [skip ci] disable use of Message_ProgressIndicator for OCC >= 7.5 due to major API changes

This commit is contained in:
wmayer
2020-10-08 14:48:35 +02:00
parent f129f3f097
commit fd9cdb9de9
9 changed files with 81 additions and 5 deletions

View File

@@ -174,12 +174,16 @@ private:
throw Py::Exception(PyExc_IOError, "cannot read STEP file");
}
#if OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) pi = new Part::ProgressIndicator(100);
aReader.Reader().WS()->MapReader()->SetProgress(pi);
pi->NewScope(100, "Reading STEP file...");
pi->Show();
#endif
aReader.Transfer(hDoc);
#if OCC_VERSION_HEX < 0x070500
pi->EndScope();
#endif
}
catch (OSD_Exception& e) {
Base::Console().Error("%s\n", e.GetMessageString());
@@ -206,12 +210,16 @@ private:
throw Py::Exception(PyExc_IOError, "cannot read IGES file");
}
#if OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) pi = new Part::ProgressIndicator(100);
aReader.WS()->MapReader()->SetProgress(pi);
pi->NewScope(100, "Reading IGES file...");
pi->Show();
#endif
aReader.Transfer(hDoc);
#if OCC_VERSION_HEX < 0x070500
pi->EndScope();
#endif
// http://opencascade.blogspot.de/2009/03/unnoticeable-memory-leaks-part-2.html
Handle(IGESToBRep_Actor)::DownCast(aReader.WS()->TransferReader()->Actor())
->SetModel(new IGESData_IGESModel);

View File

@@ -459,12 +459,17 @@ private:
if (aReader.ReadFile((const char*)name8bit.c_str()) != IFSelect_RetDone) {
throw Py::Exception(PyExc_IOError, "cannot read STEP file");
}
#if OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) pi = new Part::ProgressIndicator(100);
aReader.Reader().WS()->MapReader()->SetProgress(pi);
pi->NewScope(100, "Reading STEP file...");
pi->Show();
#endif
aReader.Transfer(hDoc);
#if OCC_VERSION_HEX < 0x070500
pi->EndScope();
#endif
}
catch (OSD_Exception& e) {
Base::Console().Error("%s\n", e.GetMessageString());
@@ -491,12 +496,16 @@ private:
throw Py::Exception(Base::BaseExceptionFreeCADError, "cannot read IGES file");
}
#if OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) pi = new Part::ProgressIndicator(100);
aReader.WS()->MapReader()->SetProgress(pi);
pi->NewScope(100, "Reading IGES file...");
pi->Show();
#endif
aReader.Transfer(hDoc);
#if OCC_VERSION_HEX < 0x070500
pi->EndScope();
#endif
// http://opencascade.blogspot.de/2009/03/unnoticeable-memory-leaks-part-2.html
Handle(IGESToBRep_Actor)::DownCast(aReader.WS()->TransferReader()->Actor())
->SetModel(new IGESData_IGESModel);
@@ -710,12 +719,16 @@ private:
throw Py::Exception(PyExc_IOError, "cannot read STEP file");
}
#if OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) pi = new Part::ProgressIndicator(100);
aReader.Reader().WS()->MapReader()->SetProgress(pi);
pi->NewScope(100, "Reading STEP file...");
pi->Show();
#endif
aReader.Transfer(hDoc);
#if OCC_VERSION_HEX < 0x070500
pi->EndScope();
#endif
}
else if (file.hasExtension("igs") || file.hasExtension("iges")) {
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
@@ -732,12 +745,16 @@ private:
throw Py::Exception(PyExc_IOError, "cannot read IGES file");
}
#if OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) pi = new Part::ProgressIndicator(100);
aReader.WS()->MapReader()->SetProgress(pi);
pi->NewScope(100, "Reading IGES file...");
pi->Show();
#endif
aReader.Transfer(hDoc);
#if OCC_VERSION_HEX < 0x070500
pi->EndScope();
#endif
// http://opencascade.blogspot.de/2009/03/unnoticeable-memory-leaks-part-2.html
Handle(IGESToBRep_Actor)::DownCast(aReader.WS()->TransferReader()->Actor())
->SetModel(new IGESData_IGESModel);

View File

@@ -47,6 +47,7 @@
# include <Interface_EntityIterator.hxx>
# include <Quantity_Color.hxx>
# include <TCollection_ExtendedString.hxx>
# include <Standard_Version.hxx>
#endif
#include <Base/Console.h>
@@ -86,16 +87,20 @@ int Part::ImportIgesParts(App::Document *pcDoc, const char* FileName)
#if 1
std::string aName = fi.fileNamePure();
#if OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
pi->NewScope(100, "Reading IGES file...");
pi->Show();
aReader.WS()->MapReader()->SetProgress(pi);
#endif
// make model
aReader.ClearShapes();
//Standard_Integer nbRootsForTransfer = aReader.NbRootsForTransfer();
aReader.TransferRoots();
#if OCC_VERSION_HEX < 0x070500
pi->EndScope();
#endif
// put all other free-flying shapes into a single compound
Standard_Boolean emptyComp = Standard_True;

View File

@@ -103,10 +103,12 @@ int Part::ImportStepParts(App::Document *pcDoc, const char* Name)
throw Base::FileException("Cannot open STEP file");
}
#if OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
aReader.WS()->MapReader()->SetProgress(pi);
pi->NewScope(100, "Reading STEP file...");
pi->Show();
#endif
// Root transfers
Standard_Integer nbr = aReader.NbRootsForTransfer();
@@ -115,7 +117,9 @@ int Part::ImportStepParts(App::Document *pcDoc, const char* Name)
Base::Console().Log("STEP: Transferring Root %d\n",n);
aReader.TransferRoot(n);
}
#if OCC_VERSION_HEX < 0x070500
pi->EndScope();
#endif
// Collecting resulting entities
Standard_Integer nbs = aReader.NbShapes();

View File

@@ -54,6 +54,7 @@ using namespace Part;
\endcode
*/
#if OCC_VERSION_HEX < 0x070500
ProgressIndicator::ProgressIndicator (int theMaxVal)
: myProgress(new Base::SequencerLauncher("", theMaxVal))
{
@@ -83,3 +84,4 @@ Standard_Boolean ProgressIndicator::UserBreak()
{
return myProgress->wasCanceled();
}
#endif

View File

@@ -25,11 +25,13 @@
#define PART_PROGRESSINDICATOR_H
#include <Message_ProgressIndicator.hxx>
#include <Standard_Version.hxx>
#include <Base/Sequencer.h>
#include <memory>
namespace Part {
#if OCC_VERSION_HEX < 0x070500
class PartExport ProgressIndicator : public Message_ProgressIndicator
{
public:
@@ -42,6 +44,7 @@ public:
private:
std::unique_ptr<Base::SequencerLauncher> myProgress;
};
#endif
}

View File

@@ -739,17 +739,21 @@ void TopoShape::importIges(const char *FileName)
if (aReader.ReadFile(encodeFilename(FileName).c_str()) != IFSelect_RetDone)
throw Base::FileException("Error in reading IGES");
#if OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
pi->NewScope(100, "Reading IGES file...");
pi->Show();
aReader.WS()->MapReader()->SetProgress(pi);
#endif
// make brep
aReader.ClearShapes();
aReader.TransferRoots();
// one shape that contains all subshapes
this->_Shape = aReader.OneShape();
#if OCC_VERSION_HEX < 0x070500
pi->EndScope();
#endif
}
catch (Standard_Failure& e) {
throw Base::CADKernelError(e.GetMessageString());
@@ -763,16 +767,20 @@ void TopoShape::importStep(const char *FileName)
if (aReader.ReadFile(encodeFilename(FileName).c_str()) != IFSelect_RetDone)
throw Base::FileException("Error in reading STEP");
#if OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
aReader.WS()->MapReader()->SetProgress(pi);
pi->NewScope(100, "Reading STEP file...");
pi->Show();
#endif
// Root transfers
aReader.TransferRoots();
// one shape that contains all subshapes
this->_Shape = aReader.OneShape();
#if OCC_VERSION_HEX < 0x070500
pi->EndScope();
#endif
}
catch (Standard_Failure& e) {
throw Base::CADKernelError(e.GetMessageString());
@@ -785,7 +793,7 @@ void TopoShape::importBrep(const char *FileName)
// read brep-file
BRep_Builder aBuilder;
TopoDS_Shape aShape;
#if OCC_VERSION_HEX >= 0x060300
#if OCC_VERSION_HEX >= 0x060300 && OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
pi->NewScope(100, "Reading BREP file...");
pi->Show();
@@ -807,16 +815,19 @@ void TopoShape::importBrep(std::istream& str, int indicator)
// read brep-file
BRep_Builder aBuilder;
TopoDS_Shape aShape;
#if OCC_VERSION_HEX >= 0x060300
#if OCC_VERSION_HEX >= 0x060300 && OCC_VERSION_HEX < 0x070500
if (indicator) {
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
pi->NewScope(100, "Reading BREP file...");
pi->Show();
BRepTools::Read(aShape,str,aBuilder,pi);
pi->EndScope();
} else
}
else {
BRepTools::Read(aShape,str,aBuilder);
}
#else
(void)indicator;
BRepTools::Read(aShape,str,aBuilder);
#endif
this->_Shape = aShape;
@@ -905,10 +916,13 @@ void TopoShape::exportStep(const char *filename) const
const Handle(XSControl_TransferWriter)& hTransferWriter = aWriter.WS()->TransferWriter();
Handle(Transfer_FinderProcess) hFinder = hTransferWriter->FinderProcess();
#if OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
hFinder->SetProgress(pi);
pi->NewScope(100, "Writing STEP file...");
pi->Show();
#endif
if (aWriter.Transfer(this->_Shape, STEPControl_AsIs) != IFSelect_RetDone)
throw Base::FileException("Error in transferring STEP");
@@ -922,7 +936,9 @@ void TopoShape::exportStep(const char *filename) const
if (aWriter.Write(encodeFilename(filename).c_str()) != IFSelect_RetDone)
throw Base::FileException("Writing of STEP failed");
#if OCC_VERSION_HEX < 0x070500
pi->EndScope();
#endif
}
catch (Standard_Failure& e) {
throw Base::CADKernelError(e.GetMessageString());
@@ -3455,13 +3471,20 @@ void TopoShape::setFaces(const std::vector<Base::Vector3d> &Points,
aSewingTool.Load(aComp);
#if OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
pi->NewScope(100, "Sewing Faces...");
pi->Show();
aSewingTool.Perform(pi);
#else
aSewingTool.Perform();
#endif
_Shape = aSewingTool.SewedShape();
#if OCC_VERSION_HEX < 0x070500
pi->EndScope();
#endif
if (_Shape.IsNull())
_Shape = aComp;
}

View File

@@ -419,10 +419,13 @@ void TaskCheckGeometryResults::goCheck()
Gui::WaitCursor wc;
int selectedCount(0), checkedCount(0), invalidShapes(0);
ResultEntry *theRoot = new ResultEntry();
#if OCC_VERSION_HEX < 0x070500
Handle(Message_ProgressIndicator) theProgress = new BOPProgressIndicator(tr("Check geometry"), Gui::getMainWindow());
theProgress->NewScope("BOP check...");
#if OCC_VERSION_HEX >= 0x060900
theProgress->Show();
#endif
#endif
for(const auto &sel : Gui::Selection().getSelection()) {
@@ -473,11 +476,18 @@ void TaskCheckGeometryResults::goCheck()
std::string label = "Checking ";
label += sel.pObject->Label.getStrValue();
label += "...";
#if OCC_VERSION_HEX < 0x070500
theProgress->NewScope(label.c_str());
invalidShapes += goBOPSingleCheck(shape, theRoot, baseName, theProgress);
#else
invalidShapes += goBOPSingleCheck(shape, theRoot, baseName, nullptr);
#endif
#if OCC_VERSION_HEX < 0x070500
theProgress->EndScope();
if (theProgress->UserBreak())
break;
#endif
}
}
}
@@ -684,7 +694,7 @@ int TaskCheckGeometryResults::goBOPSingleCheck(const TopoDS_Shape& shapeIn, Resu
//this is left for another time.
TopoDS_Shape BOPCopy = BRepBuilderAPI_Copy(shapeIn).Shape();
BOPAlgo_ArgumentAnalyzer BOPCheck;
#if OCC_VERSION_HEX >= 0x060900
#if OCC_VERSION_HEX >= 0x060900 && OCC_VERSION_HEX < 0x070500
BOPCheck.SetProgressIndicator(theProgress);
#else
Q_UNUSED(theProgress);
@@ -1370,6 +1380,7 @@ TaskCheckGeometryDialog::~TaskCheckGeometryDialog()
////////////////////////////////////////////////////////////////////////////////////////////////
#if OCC_VERSION_HEX < 0x070500
BOPProgressIndicator::BOPProgressIndicator (const QString& title, QWidget* parent)
{
steps = 0;
@@ -1432,5 +1443,6 @@ Standard_Boolean BOPProgressIndicator::UserBreak()
return Standard_False;
}
#endif
#include "moc_TaskCheckGeometry.cpp"

View File

@@ -27,6 +27,7 @@
#include <BRepCheck_Analyzer.hxx>
#include <BRepCheck_Status.hxx>
#include <Message_ProgressIndicator.hxx>
#include <Standard_Version.hxx>
#include <TopTools_MapOfShape.hxx>
#include <Gui/TaskView/TaskDialog.h>
#include <Gui/TaskView/TaskView.h>
@@ -190,6 +191,7 @@ private:
QPushButton *resultsBtn;
};
#if OCC_VERSION_HEX < 0x070500
class BOPProgressIndicator : public Message_ProgressIndicator
{
public:
@@ -205,7 +207,7 @@ private:
QElapsedTimer time;
QProgressDialog* myProgress;
};
#endif
}
#endif // TASKCHECKGEOMETRY_H