[TD]respect AutoDistribute on load
This commit is contained in:
committed by
WandererFan
parent
2c19c29d3c
commit
80d5e9a0b8
@@ -171,28 +171,19 @@ App::DocumentObjectExecReturn *DrawProjGroup::execute()
|
||||
return App::DocumentObject::StdReturn;
|
||||
|
||||
//if group hasn't been added to page yet, can't scale or distribute projItems
|
||||
TechDraw::DrawPage *page = getPage();
|
||||
if (!page)
|
||||
if (!getPage())
|
||||
return DrawViewCollection::execute();
|
||||
|
||||
std::vector<App::DocumentObject*> docObjs = getAllSources();
|
||||
if (docObjs.empty())
|
||||
return DrawViewCollection::execute();
|
||||
|
||||
App::DocumentObject* docObj = Anchor.getValue();
|
||||
if (!docObj)
|
||||
if (!Anchor.getValue())
|
||||
//no anchor yet. nothing to do.
|
||||
return DrawViewCollection::execute();
|
||||
|
||||
if (ScaleType.isValue("Automatic")) {
|
||||
if (!checkFit()) {
|
||||
double newScale = autoScale();
|
||||
m_lockScale = true;
|
||||
Scale.setValue(newScale);
|
||||
Scale.purgeTouched();
|
||||
updateChildrenScale();
|
||||
m_lockScale = false;
|
||||
}
|
||||
if (ScaleType.isValue("Automatic") && !checkFit()) {
|
||||
m_lockScale = true;
|
||||
Scale.setValue(autoScale());
|
||||
Scale.purgeTouched();
|
||||
updateChildrenScale();
|
||||
m_lockScale = false;
|
||||
}
|
||||
|
||||
autoPositionChildren();
|
||||
@@ -942,21 +933,25 @@ void DrawProjGroup::recomputeChildren()
|
||||
// Base::Console().Message("DPG::recomputeChildren()\n");
|
||||
for( const auto it : Views.getValues() ) {
|
||||
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
|
||||
if (!view)
|
||||
if (!view) {
|
||||
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
|
||||
else
|
||||
} else {
|
||||
view->recomputeFeature();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawProjGroup::autoPositionChildren()
|
||||
{
|
||||
// Base::Console().Message("DPG::autoPositionChildren() - %s\n", getNameInDocument());
|
||||
for( const auto it : Views.getValues() ) {
|
||||
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
|
||||
if (!view)
|
||||
if (!view) {
|
||||
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
|
||||
else
|
||||
} else {
|
||||
view->autoPosition();
|
||||
view->requestPaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -135,9 +135,13 @@ bool DrawProjGroupItem::showLock(void) const
|
||||
|
||||
App::DocumentObjectExecReturn *DrawProjGroupItem::execute(void)
|
||||
{
|
||||
// Base::Console().Message("DPGI::execute(%s)\n",Label.getValue());
|
||||
// Base::Console().Message("DPGI::execute() - %s / %s\n", getNameInDocument(), Label.getValue());
|
||||
if (!keepUpdated()) {
|
||||
return App::DocumentObject::StdReturn;
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
if (waitingForHlr()) {
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
bool haveX = checkXDirection();
|
||||
@@ -155,26 +159,36 @@ App::DocumentObjectExecReturn *DrawProjGroupItem::execute(void)
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn* ret = DrawViewPart::execute();
|
||||
//autoPosition needs to run after the geometry has been created
|
||||
autoPosition();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void DrawProjGroupItem::postHlrTasks(void)
|
||||
{
|
||||
// Base::Console().Message("DPGI::postHlrTasks() - %s\n", getNameInDocument());
|
||||
//DPGI has no geometry until HLR has finished, and the DPG can not properly
|
||||
//AutoDistibute until all its items have geometry. autoPositionChildren is
|
||||
//relatively cheap so we can do it after every geometry update
|
||||
if (getPGroup() && getPGroup()->AutoDistribute.getValue()) {
|
||||
getPGroup()->autoPositionChildren();
|
||||
}
|
||||
DrawViewPart::postHlrTasks();
|
||||
}
|
||||
|
||||
void DrawProjGroupItem::autoPosition()
|
||||
{
|
||||
// Base::Console().Message("DPGI::autoPosition(%s)\n",Label.getValue());
|
||||
if (LockPosition.getValue()) {
|
||||
return;
|
||||
}
|
||||
auto pgroup = getPGroup();
|
||||
Base::Vector3d newPos;
|
||||
if (pgroup) {
|
||||
if (pgroup->AutoDistribute.getValue()) {
|
||||
newPos = pgroup->getXYPosition(Type.getValueAsString());
|
||||
if (getPGroup() && getPGroup()->AutoDistribute.getValue()) {
|
||||
newPos = getPGroup()->getXYPosition(Type.getValueAsString());
|
||||
X.setValue(newPos.x);
|
||||
Y.setValue(newPos.y);
|
||||
requestPaint();
|
||||
purgeTouched(); //prevents "still touched after recompute" message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,15 +217,10 @@ DrawProjGroup* DrawProjGroupItem::getPGroup() const
|
||||
|
||||
bool DrawProjGroupItem::isAnchor(void) const
|
||||
{
|
||||
bool result = false;
|
||||
auto group = getPGroup();
|
||||
if (group) {
|
||||
DrawProjGroupItem* anchor = group->getAnchor();
|
||||
if (anchor == this) {
|
||||
result = true;
|
||||
}
|
||||
if (getPGroup() && (getPGroup()->getAnchor() == this) ) {
|
||||
return true;
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// get a coord system aligned with Direction and Rotation Vector
|
||||
|
||||
@@ -64,24 +64,26 @@ public:
|
||||
void onDocumentRestored() override;
|
||||
void unsetupObject() override;
|
||||
|
||||
void postHlrTasks(void) override;
|
||||
|
||||
DrawProjGroup* getPGroup() const;
|
||||
double getRotateAngle();
|
||||
Base::Vector3d getXDirection() const override;
|
||||
Base::Vector3d getLegacyX(const Base::Vector3d& pt,
|
||||
const Base::Vector3d& axis,
|
||||
const bool flip = true) const override;
|
||||
const Base::Vector3d& axis,
|
||||
const bool flip = true) const override;
|
||||
|
||||
App::DocumentObjectExecReturn *execute() override;
|
||||
|
||||
const char* getViewProviderName() const override {
|
||||
return "TechDrawGui::ViewProviderProjGroupItem";
|
||||
}
|
||||
//return PyObject as DrawProjGroupItemPy
|
||||
PyObject *getPyObject() override;
|
||||
|
||||
//this doesn't override for dvp pointer??
|
||||
gp_Ax2 getViewAxis(const Base::Vector3d& pt,
|
||||
const Base::Vector3d& direction,
|
||||
const bool flip=true) const override;
|
||||
const Base::Vector3d& direction,
|
||||
const bool flip=true) const override;
|
||||
|
||||
double getScale() const override;
|
||||
void autoPosition();
|
||||
|
||||
@@ -278,6 +278,10 @@ void DrawViewDetail::detailExec(TopoDS_Shape& shape,
|
||||
// Base::Console().Message("DVD::detailExec - waiting for result\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (waitingForDetail()) {
|
||||
return;
|
||||
}
|
||||
QObject::connect(&m_detailWatcher, SIGNAL(finished()), this, SLOT(onMakeDetailFinished()));
|
||||
m_detailFuture = QtConcurrent::run(this, &DrawViewDetail::makeDetailShape, shape, dvp, dvs);
|
||||
m_detailWatcher.setFuture(m_detailFuture);
|
||||
@@ -288,10 +292,6 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape,
|
||||
DrawViewPart* dvp,
|
||||
DrawViewSection* dvs)
|
||||
{
|
||||
if (waitingForDetail()) {
|
||||
// Base::Console().Message("DVD::makeDetailShape - already in progress. returning\n");
|
||||
return;
|
||||
}
|
||||
waitingForDetail(true);
|
||||
showProgressMessage(getNameInDocument(), "is making detail shape");
|
||||
|
||||
|
||||
@@ -376,9 +376,9 @@ void DrawViewPart::onChanged(const App::Property* prop)
|
||||
void DrawViewPart::partExec(TopoDS_Shape& shape)
|
||||
{
|
||||
// Base::Console().Message("DVP::partExec()\n");
|
||||
if (waitingForResult()) {
|
||||
if (waitingForHlr()) {
|
||||
//finish what we are already doing before starting over
|
||||
// Base::Console().Message("DVP::partExec - %s - waiting for result\n", getNameInDocument());
|
||||
// Base::Console().Message("DVP::partExec - %s - waiting for HLR\n", getNameInDocument());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -386,7 +386,6 @@ void DrawViewPart::partExec(TopoDS_Shape& shape)
|
||||
delete geometryObject;
|
||||
geometryObject = nullptr;
|
||||
}
|
||||
showProgressMessage(getNameInDocument(), "is finding hidden lines");
|
||||
geometryObject = makeGeometryForShape(shape);
|
||||
}
|
||||
|
||||
@@ -424,7 +423,8 @@ GeometryObject* DrawViewPart::makeGeometryForShape(TopoDS_Shape& shape)
|
||||
//note: slightly different than routine with same name in DrawProjectSplit
|
||||
TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape& shape, gp_Ax2& viewAxis)
|
||||
{
|
||||
// Base::Console().Message("DVP::buildGeometryObject()\n");
|
||||
// Base::Console().Message("DVP::buildGeometryObject() - %s\n", getNameInDocument());
|
||||
showProgressMessage(getNameInDocument(), "is finding hidden lines");
|
||||
TechDraw::GeometryObject* go = new TechDraw::GeometryObject(getNameInDocument(), this);
|
||||
go->setIsoCount(IsoCount.getValue());
|
||||
go->isPerspective(Perspective.getValue());
|
||||
@@ -437,7 +437,6 @@ TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape& shape,
|
||||
onHlrFinished(); //poly algo does not run in separate thread, so we need to invoke
|
||||
//the post hlr processing manually
|
||||
} else {
|
||||
// Base::Console().Message("DVP::buildGeometryObject - starting projectShape\n");
|
||||
//project shape runs in a separate thread since if can take a long time
|
||||
QObject::connect(&m_hlrWatcher, SIGNAL(finished()), this, SLOT(onHlrFinished()));
|
||||
m_hlrFuture = QtConcurrent::run(go, &GeometryObject::projectShape, shape, viewAxis);
|
||||
@@ -450,8 +449,7 @@ TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape& shape,
|
||||
//continue processing after hlr thread completes
|
||||
void DrawViewPart::onHlrFinished(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::onHlrFinished()\n");
|
||||
|
||||
// Base::Console().Message("DVP::onHlrFinished() - %s\n", getNameInDocument());
|
||||
//the last hlr task is to make a bbox of the results
|
||||
bbox = geometryObject->calcBoundingBox();
|
||||
|
||||
@@ -462,9 +460,8 @@ void DrawViewPart::onHlrFinished(void)
|
||||
postHlrTasks();
|
||||
|
||||
//start face finding in a separate thread
|
||||
if (handleFaces() && !CoarseView.getValue()) {
|
||||
if (handleFaces() && !CoarseView.getValue() && !waitingForFaces()) {
|
||||
try {
|
||||
// Base::Console().Message("DVP::onHlrFinished - starting extractFaces\n");
|
||||
QObject::connect(&m_faceWatcher, SIGNAL(finished()), this, SLOT(onFacesFinished()));
|
||||
m_faceFuture = QtConcurrent::run(this, &DrawViewPart::extractFaces);
|
||||
m_faceWatcher.setFuture(m_faceFuture);
|
||||
@@ -480,6 +477,7 @@ void DrawViewPart::onHlrFinished(void)
|
||||
//run any tasks that need to been done after geometry is available
|
||||
void DrawViewPart::postHlrTasks(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::postHlrTasks() - %s\n", getNameInDocument());
|
||||
//add geometry that doesn't come from HLR
|
||||
addCosmeticVertexesToGeom();
|
||||
addCosmeticEdgesToGeom();
|
||||
@@ -505,16 +503,11 @@ void DrawViewPart::extractFaces()
|
||||
{
|
||||
// Base::Console().Message("DVP::extractFaces()\n");
|
||||
|
||||
if (geometryObject == nullptr) {
|
||||
if (!geometryObject) {
|
||||
//no geometry yet so don't bother
|
||||
// Base::Console().Message("DVP::extractFaces - GO is null\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// if (waitingForFaces()) {
|
||||
// Base::Console().Message("DVP::extractFaces - already extracting faces\n");
|
||||
// }
|
||||
|
||||
waitingForFaces(true);
|
||||
showProgressMessage(getNameInDocument(), "is extracting faces");
|
||||
|
||||
|
||||
@@ -180,10 +180,6 @@ short DrawViewSection::mustExecute() const
|
||||
void DrawViewSection::onChanged(const App::Property* prop)
|
||||
{
|
||||
App::Document* doc = getDocument();
|
||||
// bool docRestoring = getDocument()->testStatus(App::Document::Status::Restoring);
|
||||
// Base::Console().Message("DVS::onChanged(%s) - obj restoring: %d\n",
|
||||
// prop->getName(), isRestoring());
|
||||
|
||||
if (!isRestoring()) {
|
||||
if (prop == &SectionSymbol) {
|
||||
std::string lblText = "Section " +
|
||||
@@ -353,9 +349,11 @@ App::DocumentObjectExecReturn *DrawViewSection::execute()
|
||||
|
||||
void DrawViewSection::sectionExec(TopoDS_Shape& baseShape)
|
||||
{
|
||||
// Base::Console().Message("DVS::sectionExec() - %s\n", getNameInDocument());
|
||||
if (waitingForResult()) {
|
||||
// Base::Console().Message("DVS::sectionExec - waiting for result\n");
|
||||
// Base::Console().Message("DVS::sectionExec() - %s baseShape.IsNull: %d\n",
|
||||
// getNameInDocument(), baseShape.IsNull());
|
||||
|
||||
if (waitingForCut()) {
|
||||
// Base::Console().Message("DVS::sectionExec - %s - waiting for cut\n", getNameInDocument());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -371,11 +369,12 @@ void DrawViewSection::sectionExec(TopoDS_Shape& baseShape)
|
||||
|
||||
void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape)
|
||||
{
|
||||
// Base::Console().Message("DVS::makeSectionCut()\n");
|
||||
if (waitingForCut()) {
|
||||
// Base::Console().Message("DVS::makeSectionCut - waiting for cut - returning\n");
|
||||
return;
|
||||
}
|
||||
// Base::Console().Message("DVS::makeSectionCut() - %s - baseShape.IsNull: %d\n",
|
||||
// getNameInDocument(), baseShape.IsNull());
|
||||
// if (waitingForCut()) {
|
||||
// Base::Console().Message("DVS::makeSectionCut - %s - waiting for cut - returning\n", getNameInDocument());
|
||||
// return;
|
||||
// }
|
||||
|
||||
waitingForCut(true);
|
||||
showProgressMessage(getNameInDocument(), "is making section cut");
|
||||
@@ -430,8 +429,10 @@ void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape)
|
||||
builder.Add(pieces, cut);
|
||||
outdb++;
|
||||
}
|
||||
// pieces contains result of cutting each subshape in baseShape with tool
|
||||
|
||||
// pieces contains result of cutting each subshape in baseShape with tool
|
||||
TopoDS_Shape rawShape = pieces;
|
||||
|
||||
if (debugSection()) {
|
||||
BRepTools::Write(myShape, "DVSCopy.brep"); //debug
|
||||
BRepTools::Write(aProjFace, "DVSFace.brep"); //debug
|
||||
@@ -480,7 +481,7 @@ void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape)
|
||||
// DrawUtil::dumpCS("DVS::makeSectionCut - CS to GO", viewAxis);
|
||||
}
|
||||
|
||||
m_rawShape = rawShape; //save for postHlrTasks
|
||||
m_rawShape = rawShape; //save for section face finding
|
||||
|
||||
}
|
||||
catch (Standard_Failure& e1) {
|
||||
@@ -493,11 +494,19 @@ void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape)
|
||||
// auto diff = end - start;
|
||||
// double diffOut = chrono::duration <double, milli>(diff).count();
|
||||
// Base::Console().Message("DVS::makeSectionCut - %s spent: %.3f millisecs making section cut\n", getNameInDocument(), diffOut);
|
||||
waitingForCut(false);
|
||||
}
|
||||
|
||||
void DrawViewSection::onSectionCutFinished()
|
||||
{
|
||||
waitingForCut(false);
|
||||
// Base::Console().Message("DVS::onSectionCutFinished() - %s\n", getNameInDocument());
|
||||
// if (waitingForCut()) {
|
||||
//this should never happen since sectionExec only starts makeSectionCut if
|
||||
//a cut is not already in progress
|
||||
// Base::Console().Message("DVS::onSectionCutFinished - %s - cut not completed yet\n",
|
||||
// getNameInDocument());
|
||||
// return;
|
||||
// }
|
||||
QObject::disconnect(&m_cutWatcher, SIGNAL(finished()), this, SLOT(onSectionCutFinished()));
|
||||
|
||||
//display geometry for cut shape is in geometryObject as in DVP
|
||||
@@ -511,6 +520,13 @@ void DrawViewSection::postHlrTasks(void)
|
||||
|
||||
// build section face geometry
|
||||
TopoDS_Compound faceIntersections = findSectionPlaneIntersections(m_rawShape);
|
||||
if (faceIntersections.IsNull()) {
|
||||
// Base::Console().Message("DVS::postHlrTasks - no face intersections found\n");
|
||||
requestPaint();
|
||||
DrawViewPart::postHlrTasks();
|
||||
return;
|
||||
}
|
||||
|
||||
TopoDS_Shape centeredShapeF = TechDraw::moveShape(faceIntersections,
|
||||
m_saveCentroid * -1.0);
|
||||
|
||||
@@ -602,9 +618,11 @@ gp_Pln DrawViewSection::getSectionPlane() const
|
||||
//! tries to find the intersection of the section plane with the shape giving a collection of planar faces
|
||||
TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shape& shape)
|
||||
{
|
||||
// Base::Console().Message("DVS::findSectionPlaneIntersections()\n");
|
||||
// Base::Console().Message("DVS::findSectionPlaneIntersections() - %s\n", getNameInDocument());
|
||||
if(shape.IsNull()){
|
||||
Base::Console().Warning("DrawViewSection::getSectionSurface - Sectional View shape is Empty\n");
|
||||
//a) this shouldn't happen
|
||||
//b) if it does, we should throw something
|
||||
Base::Console().Warning("DrawViewSection::findSectionPlaneInter - %s - input shape is Null\n", getNameInDocument());
|
||||
return TopoDS_Compound();
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
void makeSectionCut(TopoDS_Shape &baseShape);
|
||||
void postHlrTasks(void) override;
|
||||
void waitingForCut(bool s) { m_waitingForCut = s; }
|
||||
bool waitingForCut(void) { return m_waitingForCut; }
|
||||
bool waitingForCut(void) const { return m_waitingForCut; }
|
||||
|
||||
std::vector<TechDraw::FacePtr> getTDFaceGeometry() {return tdSectionFaces;}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user