[TD]Transition to on demand page updates ph1

This commit is contained in:
wandererfan
2019-10-21 08:36:50 -04:00
committed by WandererFan
parent 820ad876cb
commit 5bb659e7e2
18 changed files with 344 additions and 226 deletions

View File

@@ -130,6 +130,7 @@ void DrawPage::onChanged(const App::Property* prop)
//would be nice if this message was displayed immediately instead of after the recomputeFeature
Base::Console().Message("Rebuilding Views for: %s/%s\n",getNameInDocument(),Label.getValue());
updateAllViews();
purgeTouched();
}
} else if (prop == &Template) {
if (!isRestoring() &&
@@ -176,6 +177,16 @@ App::DocumentObjectExecReturn *DrawPage::execute(void)
// this is now irrelevant, b/c DP::execute doesn't do anything.
short DrawPage::mustExecute() const
{
short result = 0;
if (!isRestoring()) {
result = (Views.isTouched() ||
Scale.isTouched() ||
ProjectionType.isTouched() ||
Template.isTouched());
if (result) {
return result;
}
}
return App::DocumentObject::mustExecute();
}
@@ -331,17 +342,27 @@ void DrawPage::onDocumentRestored()
App::DocumentObject::onDocumentRestored();
}
void DrawPage::redrawCommand()
{
// Base::Console().Message("DP::redrawCommand()\n");
forceRedraw(true);
updateAllViews();
forceRedraw(false);
}
//should really be called "updateMostViews". can still be problems to due execution order.
void DrawPage::updateAllViews()
{
// Base::Console().Message("DP::updateAllViews()\n");
std::vector<App::DocumentObject*> featViews = getAllViews();
std::vector<App::DocumentObject*>::const_iterator it = featViews.begin();
std::vector<App::DocumentObject*>::iterator it = featViews.begin();
//first, make sure all the Parts have been executed so GeometryObjects exist
for(; it != featViews.end(); ++it) {
TechDraw::DrawViewPart *part = dynamic_cast<TechDraw::DrawViewPart *>(*it);
if (part != nullptr &&
!part->hasGeometry()) {
TechDraw::DrawViewCollection *collect = dynamic_cast<TechDraw::DrawViewCollection*>(*it);
if (part != nullptr) {
part->recomputeFeature();
} else if (collect != nullptr) {
collect->recomputeFeature();
}
}
//second, make sure all the Dimensions have been executed so Measurements have References
@@ -448,6 +469,7 @@ void DrawPage::handleChangedPropertyType(
}
}
//allow/prevent drawing updates for all Pages
bool DrawPage::GlobalUpdateDrawings(void)
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
@@ -456,6 +478,7 @@ bool DrawPage::GlobalUpdateDrawings(void)
return result;
}
//allow/prevent a single page to update despite GlobalUpdateDrawings setting
bool DrawPage::AllowPageOverride(void)
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()

View File

@@ -103,6 +103,7 @@ public:
static bool AllowPageOverride(void);
void forceRedraw(bool b) { m_forceRedraw = b; }
bool forceRedraw(void) { return m_forceRedraw; }
void redrawCommand();
protected:
void onBeforeChange(const App::Property* prop) override;

View File

@@ -74,9 +74,11 @@ DrawProjGroup::DrawProjGroup(void)
ProjectionType.setEnums(ProjectionTypeEnums);
ADD_PROPERTY(ProjectionType, ((long)getDefProjConv()));
ADD_PROPERTY_TYPE(ProjectionType, ((long)getDefProjConv()), group,
App::Prop_None, "First or Third Angle projection");
ADD_PROPERTY_TYPE(AutoDistribute ,(autoDist),agroup,App::Prop_None,"Distribute Views Automatically or Manually");
ADD_PROPERTY_TYPE(AutoDistribute ,(autoDist),agroup,
App::Prop_None,"Distribute Views Automatically or Manually");
ADD_PROPERTY_TYPE(spacingX, (15), agroup, App::Prop_None, "Horizontal spacing between views");
ADD_PROPERTY_TYPE(spacingY, (15), agroup, App::Prop_None, "Vertical spacing between views");
Rotation.setStatus(App::Property::Hidden,true); //DPG does not rotate
@@ -108,8 +110,13 @@ void DrawProjGroup::onChanged(const App::Property* prop)
// }
}
if (prop == &Scale) {
updateChildren();
updateChildrenScale();
}
if (prop == &ProjectionType) {
updateChildrenEnforce();
}
if (prop == &Source) {
updateChildrenSource();
}
@@ -168,17 +175,8 @@ App::DocumentObjectExecReturn *DrawProjGroup::execute(void)
//no anchor yet. nothing to do.
return DrawViewCollection::execute();
}
// for (auto& v: Views.getValues()) { //is this needed here? Up to DPGI to keep up to date.
// v->recomputeFeature();
// }
for (auto& item: getViewsAsDPGI()) {
bool touched = item->isTouched();
item->autoPosition();
if(!touched)
item->purgeTouched();
}
autoPositionChildren();
return DrawViewCollection::execute();
}
@@ -853,16 +851,42 @@ void DrawProjGroup::makeViewBbs(DrawProjGroupItem *viewPtrs[10],
}
}
/*!
* tell children DPGIs that parent DPG has changed Scale
*/
void DrawProjGroup::updateChildren(void)
void DrawProjGroup::recomputeChildren(void)
{
// Base::Console().Message("DPG::recomputeChildren()\n");
for( const auto it : Views.getValues() ) {
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
if (view == nullptr) {
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
} else {
view->recomputeFeature();
}
}
}
void DrawProjGroup::autoPositionChildren(void)
{
for( const auto it : Views.getValues() ) {
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
if (view == nullptr) {
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
} else {
view->autoPosition();
}
}
}
/*!
* tell children DPGIs that parent DPG has changed Scale
*/
void DrawProjGroup::updateChildrenScale(void)
{
// Base::Console().Message("DPG::updateChildrenScale\n");
for( const auto it : Views.getValues() ) {
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
if (view == nullptr) {
//if an element in Views is not a DPGI, something really bad has happened somewhere
Base::Console().Log("PROBLEM - DPG::updateChildren - non DPGI entry in Views! %s\n",
Base::Console().Log("PROBLEM - DPG::updateChildrenScale - non DPGI entry in Views! %s\n",
getNameInDocument());
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
} else if(view->Scale.getValue()!=Scale.getValue()) {
@@ -906,6 +930,21 @@ void DrawProjGroup::updateChildrenLock(void)
}
}
void DrawProjGroup::updateChildrenEnforce(void)
{
for( const auto it : Views.getValues() ) {
auto view( dynamic_cast<DrawProjGroupItem *>(it) );
if (view == nullptr) {
//if an element in Views is not a DPGI, something really bad has happened somewhere
Base::Console().Log("PROBLEM - DPG::updateChildrenEnforce - non DPGI entry in Views! %s\n",
getNameInDocument());
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
} else {
view->enforceRecompute();
}
}
}
/*!
* check if ProjectionGroup fits on Page
*/

View File

@@ -127,6 +127,11 @@ public:
void dumpISO(char * title);
std::vector<DrawProjGroupItem*> getViewsAsDPGI();
void recomputeChildren(void);
void updateChildrenScale(void);
void autoPositionChildren(void);
void updateChildrenEnforce(void);
protected:
void onChanged(const App::Property* prop) override;
@@ -158,7 +163,7 @@ protected:
/// Returns pointer to our page, or NULL if it couldn't be located
TechDraw::DrawPage * getPage(void) const;
void updateChildren(void);
void updateChildrenSource(void);
void updateChildrenLock(void);
int getViewIndex(const char *viewTypeCStr) const;

View File

@@ -133,24 +133,20 @@ bool DrawProjGroupItem::showLock(void) const
App::DocumentObjectExecReturn *DrawProjGroupItem::execute(void)
{
// Base::Console().Message("DPGI::execute(%s)\n",Label.getValue());
if (DrawUtil::checkParallel(Direction.getValue(),
RotationVector.getValue())) {
return new App::DocumentObjectExecReturn("DPGI: Direction and RotationVector are parallel");
}
App::DocumentObjectExecReturn * ret = DrawViewPart::execute();
if (ret != nullptr) {
return ret;
} else {
autoPosition();
delete ret;
}
return App::DocumentObject::StdReturn;
App::DocumentObjectExecReturn* ret = DrawViewPart::execute();
autoPosition();
return ret;
}
void DrawProjGroupItem::autoPosition()
{
// Base::Console().Message("DPGI::autoPosition(%s)\n",getNameInDocument());
// Base::Console().Message("DPGI::autoPosition(%s)\n",Label.getValue());
auto pgroup = getPGroup();
Base::Vector3d newPos;
if (pgroup != nullptr) {

View File

@@ -144,7 +144,8 @@ void DrawViewDetail::onChanged(const App::Property* prop)
if ((prop == &Reference) ||
(prop == &Radius) ||
(prop == &AnchorPoint)) {
BaseView.getValue()->touch(); //hack. sb "update graphics"
// BaseView.getValue()->touch(); //hack. sb "update graphics"
enforceRecompute();
}
}

View File

@@ -93,22 +93,22 @@ enum RefType{
DrawViewDimension::DrawViewDimension(void)
{
ADD_PROPERTY_TYPE(References2D,(0,0),"",(App::PropertyType)(App::Prop_None),"Projected Geometry References");
ADD_PROPERTY_TYPE(References2D,(0,0),"",(App::Prop_None),"Projected Geometry References");
References2D.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(References3D,(0,0),"",(App::PropertyType)(App::Prop_None),"3D Geometry References");
ADD_PROPERTY_TYPE(References3D,(0,0),"",(App::Prop_None),"3D Geometry References");
References3D.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(FormatSpec,("") , "Format",(App::PropertyType)(App::Prop_None),"Dimension Format");
ADD_PROPERTY_TYPE(Arbitrary,(false) ,"Format",(App::PropertyType)(App::Prop_None),"Value overridden by user");
ADD_PROPERTY_TYPE(FormatSpec,("") , "Format", App::Prop_Output,"Dimension Format");
ADD_PROPERTY_TYPE(Arbitrary,(false) ,"Format", App::Prop_Output,"Value overridden by user");
Type.setEnums(TypeEnums); //dimension type: length, radius etc
ADD_PROPERTY(Type,((long)0));
MeasureType.setEnums(MeasureTypeEnums);
ADD_PROPERTY(MeasureType, ((long)1)); //Projected (or True) measurement
ADD_PROPERTY_TYPE(TheoreticalExact,(false),"",(App::PropertyType)(App::Prop_None),"Set for theoretical exact (basic) dimension");
ADD_PROPERTY_TYPE(OverTolerance ,(0.0),"",App::Prop_None,"+ Tolerance value");
ADD_PROPERTY_TYPE(UnderTolerance ,(0.0),"",App::Prop_None,"- Tolerance value");
ADD_PROPERTY_TYPE(Inverted,(false),"",(App::PropertyType)(App::Prop_None),"The dimensional value is displayed inverted");
ADD_PROPERTY_TYPE(TheoreticalExact,(false),"", App::Prop_Output,"Set for theoretical exact (basic) dimension");
ADD_PROPERTY_TYPE(OverTolerance ,(0.0),"", App::Prop_Output,"+ Tolerance value");
ADD_PROPERTY_TYPE(UnderTolerance ,(0.0),"", App::Prop_Output,"- Tolerance value");
ADD_PROPERTY_TYPE(Inverted,(false),"", App::Prop_Output,"The dimensional value is displayed inverted");
//hide the properties the user can't edit in the property editor
// References2D.setStatus(App::Property::Hidden,true);
@@ -160,19 +160,25 @@ void DrawViewDimension::onChanged(const App::Property* prop)
Base::Console().Warning("%s has no 3D References but is Type: True\n", getNameInDocument());
MeasureType.setValue("Projected");
}
}
if (prop == &References3D) { //have to rebuild the Measurement object
} else if (prop == &References3D) { //have to rebuild the Measurement object
clear3DMeasurements(); //Measurement object
if (!(References3D.getValues()).empty()) {
setAll3DMeasurement();
} else {
if (MeasureType.isValue("True")) { //empty 3dRefs, but True
MeasureType.touch(); //run MeasureType logic for this case
if (MeasureType.isValue("True")) { //empty 3dRefs, but True
MeasureType.touch(); //run MeasureType logic for this case
}
}
}
if (prop == &Type) {
} else if (prop == &Type) { //why??
FormatSpec.setValue(getDefaultFormatSpec().c_str());
} else if ( (prop == &FormatSpec) ||
(prop == &Arbitrary) ||
(prop == &MeasureType) ||
(prop == &TheoreticalExact) ||
(prop == &OverTolerance) ||
(prop == &UnderTolerance) ||
(prop == &Inverted) ) {
// nothing in particular
}
}
@@ -191,18 +197,15 @@ short DrawViewDimension::mustExecute() const
{
bool result = 0;
if (!isRestoring()) {
result = (References2D.isTouched() ||
result = (References2D.isTouched() ||
Type.isTouched() ||
FormatSpec.isTouched() ||
MeasureType.isTouched());
}
if (result) {
return result;
}
auto dvp = getViewPart();
if (dvp != nullptr) {
result = dvp->isTouched();
Arbitrary.isTouched() ||
MeasureType.isTouched() ||
TheoreticalExact.isTouched() ||
OverTolerance.isTouched() ||
UnderTolerance.isTouched() ||
Inverted.isTouched() );
}
if (result) {
return result;
@@ -572,10 +575,10 @@ std::string DrawViewDimension::getFormatedValue(int partial)
}
} else {
//handle single value schemes
QRegExp rxUnits(QString::fromUtf8(" \\D*$")); //space + any non digits at end of string
QRegExp rxUnits(QString::fromUtf8(" \\D*$")); //space + any non digits at end of string
QString userVal = userStr;
userVal.remove(rxUnits); //getUserString(defaultDecimals) without units
userVal.remove(rxUnits); //getUserString(defaultDecimals) without units
QLocale loc;
double userValNum = loc.toDouble(userVal);
@@ -583,7 +586,7 @@ std::string DrawViewDimension::getFormatedValue(int partial)
// QString userUnits;
int pos = 0;
if ((pos = rxUnits.indexIn(userStr, 0)) != -1) {
userUnits = rxUnits.cap(0); //entire capture - non numerics at end of userString
userUnits = rxUnits.cap(0); //entire capture - non numerics at end of userString
}
//find the %x.y tag in FormatSpec

View File

@@ -133,7 +133,8 @@ DrawViewPart::DrawViewPart(void) :
Source.setScope(App::LinkScope::Global);
ADD_PROPERTY_TYPE(Direction ,(0.0,-1.0,0.0),
group,App::Prop_None,"Projection direction. The direction you are looking from.");
ADD_PROPERTY_TYPE(Perspective ,(false),group,App::Prop_None,"Perspective(true) or Orthographic(false) projection");
ADD_PROPERTY_TYPE(Perspective ,(false),group,App::Prop_None,
"Perspective(true) or Orthographic(false) projection");
ADD_PROPERTY_TYPE(Focus,(defDist),group,App::Prop_None,"Perspective view focus distance");
//properties that control HLR algoaffect Appearance
@@ -149,10 +150,10 @@ DrawViewPart::DrawViewPart(void) :
ADD_PROPERTY_TYPE(IsoHidden ,(false),sgroup,App::Prop_None,"Hidden Iso u,v lines on/off");
ADD_PROPERTY_TYPE(IsoCount ,(0),sgroup,App::Prop_None,"Number of isoparameters");
ADD_PROPERTY_TYPE(CosmeticVertexes ,(0),sgroup,App::Prop_None,"CosmeticVertex Save/Restore");
ADD_PROPERTY_TYPE(CosmeticEdges ,(0),sgroup,App::Prop_None,"CosmeticEdge Save/Restore");
ADD_PROPERTY_TYPE(CenterLines ,(0),sgroup,App::Prop_None,"Geometry format Save/Restore");
ADD_PROPERTY_TYPE(GeomFormats ,(0),sgroup,App::Prop_None,"Geometry format Save/Restore");
ADD_PROPERTY_TYPE(CosmeticVertexes ,(0),sgroup,App::Prop_Output,"CosmeticVertex Save/Restore");
ADD_PROPERTY_TYPE(CosmeticEdges ,(0),sgroup,App::Prop_Output,"CosmeticEdge Save/Restore");
ADD_PROPERTY_TYPE(CenterLines ,(0),sgroup,App::Prop_Output,"Geometry format Save/Restore");
ADD_PROPERTY_TYPE(GeomFormats ,(0),sgroup,App::Prop_Output,"Geometry format Save/Restore");
geometryObject = nullptr;
getRunControl();
@@ -283,7 +284,7 @@ TopoDS_Shape DrawViewPart::getSourceShapeFused(void) const
App::DocumentObjectExecReturn *DrawViewPart::execute(void)
{
// Base::Console().Message("DVP::execute()\n");
// Base::Console().Message("DVP::execute() - %s\n", Label.getValue());
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
@@ -323,8 +324,8 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
shapeCentroid = Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z());
TopoDS_Shape mirroredShape;
mirroredShape = TechDraw::mirrorShape(shape,
inputCenter,
getScale());
inputCenter,
getScale());
gp_Ax2 viewAxis = getViewAxis(shapeCentroid,Direction.getValue());
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
@@ -361,8 +362,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
#endif //#if MOD_TECHDRAW_HANDLE_FACES
requestPaint();
return App::DocumentObject::StdReturn;
return DrawView::execute();
}
short DrawViewPart::mustExecute() const
@@ -371,8 +371,6 @@ short DrawViewPart::mustExecute() const
if (!isRestoring()) {
result = (Direction.isTouched() ||
Source.isTouched() ||
Scale.isTouched() ||
ScaleType.isTouched() ||
Perspective.isTouched() ||
Focus.isTouched() ||
Rotation.isTouched() ||
@@ -646,9 +644,10 @@ std::vector<TechDraw::DrawViewBalloon*> DrawViewPart::getBalloons() const
return result;
}
const std::vector<TechDraw::Vertex *> & DrawViewPart::getVertexGeometry() const
const std::vector<TechDraw::Vertex *> DrawViewPart::getVertexGeometry() const
{
return geometryObject->getVertexGeometry();
std::vector<TechDraw::Vertex*> gVerts = geometryObject->getVertexGeometry();
return gVerts;
}
const std::vector<TechDraw::Face *> & DrawViewPart::getFaceGeometry() const
@@ -960,6 +959,13 @@ void DrawViewPart::clearCosmeticVertexes(void)
CosmeticVertexes.setValues(noVerts);
}
//CosmeticVertex x,y are stored as unscaled, but mirrored values.
//if you are creating a CV based on calculations of scaled geometry, you need to
//unscale x,y before creation.
//if you are creating a CV based on calculations of mirrored geometry, you need to
//mirror again before creation.
//returns CosmeticVertex index! not geomVertexNumber!
int DrawViewPart::addCosmeticVertex(Base::Vector3d pos)
{
std::vector<CosmeticVertex*> verts = CosmeticVertexes.getValues();
@@ -1000,6 +1006,7 @@ void DrawViewPart::removeCosmeticVertex(TechDraw::CosmeticVertex* cv)
}
}
//this is by CV index, not the index returned by selection
void DrawViewPart::removeCosmeticVertex(int idx)
{
std::vector<CosmeticVertex*> verts = CosmeticVertexes.getValues();
@@ -1048,7 +1055,8 @@ TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByIndex(int idx) const
return result;
}
//find the cosmetic vertex corresponding to geometry vertex idx
// find the cosmetic vertex corresponding to geometry vertex idx
// used when selecting
TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByGeom(int idx) const
{
CosmeticVertex* result = nullptr;

View File

@@ -127,7 +127,7 @@ public:
std::vector<TechDraw::DrawViewDimension*> getDimensions() const;
std::vector<TechDraw::DrawViewBalloon*> getBalloons() const;
const std::vector<TechDraw::Vertex *> & getVertexGeometry() const;
const std::vector<TechDraw::Vertex *> getVertexGeometry() const;
const std::vector<TechDraw::BaseGeom *> & getEdgeGeometry() const;
const std::vector<TechDraw::BaseGeom *> getVisibleFaceEdges() const;
const std::vector<TechDraw::Face *> & getFaceGeometry() const;
@@ -210,7 +210,7 @@ protected:
TechDraw::GeometryObject *geometryObject;
Base::BoundBox3d bbox;
void onChanged(const App::Property* prop) override;
virtual void onChanged(const App::Property* prop) override;
virtual void unsetupObject() override;
virtual TechDraw::GeometryObject* buildGeometryObject(TopoDS_Shape shape, gp_Ax2 viewAxis);

View File

@@ -342,8 +342,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
//add centerlines to geometry edges list
addCenterLinesToGeom();
requestPaint();
return App::DocumentObject::StdReturn;
return DrawView::execute();
}
gp_Pln DrawViewSection::getSectionPlane() const