[TD]prevent extra recompute on X,Y change
This commit is contained in:
@@ -461,10 +461,10 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
|
||||
} else { //Front
|
||||
Anchor.setValue(view);
|
||||
Anchor.purgeTouched();
|
||||
requestPaint(); //make sure the group object is on the Gui page
|
||||
view->LockPosition.setValue(true); //lock "Front" position within DPG (note not Page!).
|
||||
view->LockPosition.setStatus(App::Property::ReadOnly,true); //Front should stay locked.
|
||||
view->LockPosition.purgeTouched();
|
||||
requestPaint(); //make sure the group object is on the Gui page
|
||||
}
|
||||
// addView(view); //from DrawViewCollection
|
||||
// if (view != getAnchor()) { //anchor is done elsewhere
|
||||
@@ -1004,6 +1004,8 @@ void DrawProjGroup::updateChildrenLock(void)
|
||||
Base::Console().Log("PROBLEM - DPG::updateChildrenLock - non DPGI entry in Views! %s\n",
|
||||
getNameInDocument());
|
||||
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
|
||||
} else {
|
||||
view->requestPaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,16 +103,10 @@ void DrawProjGroupItem::onChanged(const App::Property *prop)
|
||||
|
||||
bool DrawProjGroupItem::isLocked(void) const
|
||||
{
|
||||
bool isLocked = DrawView::isLocked();
|
||||
|
||||
if (isAnchor()) { //Anchor view is always locked to DPG
|
||||
return true;
|
||||
}
|
||||
DrawProjGroup* parent = getPGroup();
|
||||
if (parent != nullptr) {
|
||||
isLocked = isLocked || parent->LockPosition.getValue();
|
||||
}
|
||||
return isLocked;
|
||||
return DrawView::isLocked();
|
||||
}
|
||||
|
||||
bool DrawProjGroupItem::showLock(void) const
|
||||
|
||||
@@ -76,17 +76,17 @@ DrawView::DrawView(void):
|
||||
mouseMove(false)
|
||||
{
|
||||
static const char *group = "Base";
|
||||
ADD_PROPERTY_TYPE(X, (0.0), group, App::Prop_None, "X position");
|
||||
ADD_PROPERTY_TYPE(Y, (0.0), group, App::Prop_None, "Y position");
|
||||
ADD_PROPERTY_TYPE(LockPosition, (false), group, App::Prop_None, "Lock View position to parent Page or Group");
|
||||
ADD_PROPERTY_TYPE(Rotation, (0.0), group, App::Prop_None, "Rotation in degrees counterclockwise");
|
||||
ADD_PROPERTY_TYPE(X, (0.0), group, (App::PropertyType)(App::Prop_Output | App::Prop_NoRecompute), "X position");
|
||||
ADD_PROPERTY_TYPE(Y, (0.0), group, (App::PropertyType)(App::Prop_Output | App::Prop_NoRecompute), "Y position");
|
||||
ADD_PROPERTY_TYPE(LockPosition, (false), group, App::Prop_Output, "Lock View position to parent Page or Group");
|
||||
ADD_PROPERTY_TYPE(Rotation, (0.0), group, App::Prop_Output, "Rotation in degrees counterclockwise");
|
||||
|
||||
ScaleType.setEnums(ScaleTypeEnums);
|
||||
ADD_PROPERTY_TYPE(ScaleType, (prefScaleType()), group, App::Prop_None, "Scale Type");
|
||||
ADD_PROPERTY_TYPE(Scale, (prefScale()), group, App::Prop_None, "Scale factor of the view");
|
||||
ADD_PROPERTY_TYPE(ScaleType, (prefScaleType()), group, App::Prop_Output, "Scale Type");
|
||||
ADD_PROPERTY_TYPE(Scale, (prefScale()), group, App::Prop_Output, "Scale factor of the view");
|
||||
Scale.setConstraints(&scaleRange);
|
||||
|
||||
ADD_PROPERTY_TYPE(Caption, (""), group, App::Prop_None, "Short text about the view");
|
||||
ADD_PROPERTY_TYPE(Caption, (""), group, App::Prop_Output, "Short text about the view");
|
||||
}
|
||||
|
||||
DrawView::~DrawView()
|
||||
@@ -95,10 +95,17 @@ DrawView::~DrawView()
|
||||
|
||||
App::DocumentObjectExecReturn *DrawView::execute(void)
|
||||
{
|
||||
// Base::Console().Message("DV::execute() - %s\n", getNameInDocument());
|
||||
// Base::Console().Message("DV::execute() - %s touched: %d\n", getNameInDocument(), isTouched());
|
||||
if (findParentPage() == nullptr) {
|
||||
return App::DocumentObject::execute();
|
||||
}
|
||||
handleXYLock();
|
||||
requestPaint();
|
||||
return App::DocumentObject::execute();
|
||||
//documentobject::execute doesn't do anything useful for us.
|
||||
//documentObject::recompute causes an infinite loop.
|
||||
//should not be neccessary to purgeTouched here, but it prevents a superflous feature recompute
|
||||
purgeTouched(); //this should not be necessary!
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
void DrawView::checkScale(void)
|
||||
@@ -146,11 +153,15 @@ void DrawView::onChanged(const App::Property* prop)
|
||||
}
|
||||
} else if (prop == &LockPosition) {
|
||||
handleXYLock();
|
||||
requestPaint(); //change lock icon
|
||||
LockPosition.purgeTouched();
|
||||
}
|
||||
if ((prop == &Caption) ||
|
||||
} else if ((prop == &Caption) ||
|
||||
(prop == &Label)) {
|
||||
requestPaint();
|
||||
} else if ((prop == &X) ||
|
||||
(prop == &Y)) {
|
||||
X.purgeTouched();
|
||||
Y.purgeTouched();
|
||||
}
|
||||
}
|
||||
App::DocumentObject::onChanged(prop);
|
||||
@@ -195,11 +206,7 @@ short DrawView::mustExecute() const
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (Scale.isTouched() ||
|
||||
ScaleType.isTouched() ||
|
||||
Caption.isTouched() ||
|
||||
X.isTouched() ||
|
||||
Y.isTouched() ||
|
||||
LockPosition.isTouched());
|
||||
ScaleType.isTouched());
|
||||
}
|
||||
if ((bool) result) {
|
||||
return result;
|
||||
|
||||
@@ -248,14 +248,10 @@ std::vector<App::DocumentObject*> DrawViewPart::getAllSources(void) const
|
||||
|
||||
App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
{
|
||||
// Base::Console().Message("DVP::execute() - %s\n", Label.getValue());
|
||||
if (!keepUpdated()) {
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
// Base::Console().Message("DVP::execute - Source: %d XSource: %d\n",
|
||||
// Source.getValues().size(), XSource.getValues().size());
|
||||
|
||||
App::Document* doc = getDocument();
|
||||
bool isRestoring = doc->testStatus(App::Document::Status::Restoring);
|
||||
const std::vector<App::DocumentObject*>& links = getAllSources();
|
||||
@@ -291,7 +287,6 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
XDirection.purgeTouched(); //don't trigger updates!
|
||||
//unblock
|
||||
}
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
m_saveShape = shape;
|
||||
partExec(shape);
|
||||
@@ -312,14 +307,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
}
|
||||
}
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
auto diff = end - start;
|
||||
double diffOut = std::chrono::duration <double, std::milli> (diff).count();
|
||||
Base::Console().Log("TIMING - %s DVP spent: %.3f millisecs handling Faces\n",
|
||||
getNameInDocument(),diffOut);
|
||||
|
||||
//#endif //#if MOD_TECHDRAW_HANDLE_FACES
|
||||
// Base::Console().Message("DVP::execute - exits\n");
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
@@ -366,7 +354,6 @@ void DrawViewPart::partExec(TopoDS_Shape shape)
|
||||
}
|
||||
|
||||
#if MOD_TECHDRAW_HANDLE_FACES
|
||||
// auto start = std::chrono::high_resolution_clock::now();
|
||||
if (handleFaces() && !geometryObject->usePolygonHLR()) {
|
||||
try {
|
||||
extractFaces();
|
||||
@@ -463,8 +450,6 @@ TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape,
|
||||
viewAxis);
|
||||
}
|
||||
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
go->extractGeometry(TechDraw::ecHARD, //always show the hard&outline visible lines
|
||||
true);
|
||||
go->extractGeometry(TechDraw::ecOUTLINE,
|
||||
@@ -499,10 +484,6 @@ TechDraw::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape,
|
||||
go->extractGeometry(TechDraw::ecUVISO,
|
||||
false);
|
||||
}
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
auto diff = end - start;
|
||||
double diffOut = std::chrono::duration <double, std::milli> (diff).count();
|
||||
Base::Console().Log("TIMING - %s DVP spent: %.3f millisecs in GO::extractGeometry\n",getNameInDocument(),diffOut);
|
||||
|
||||
const std::vector<TechDraw::BaseGeom *> & edges = go->getEdgeGeometry();
|
||||
if (edges.empty()) {
|
||||
@@ -533,34 +514,32 @@ void DrawViewPart::extractFaces()
|
||||
if (!DrawUtil::isZeroEdge(e)) {
|
||||
nonZero.push_back(e);
|
||||
} else {
|
||||
Base::Console().Message("INFO - DVP::extractFaces for %s found ZeroEdge!\n",getNameInDocument());
|
||||
Base::Console().Log("INFO - DVP::extractFaces for %s found ZeroEdge!\n",getNameInDocument());
|
||||
}
|
||||
}
|
||||
faceEdges = nonZero;
|
||||
origEdges = nonZero;
|
||||
|
||||
//HLR algo does not provide all edge intersections for edge endpoints.
|
||||
//need to split long edges touched by Vertex of another edge
|
||||
std::vector<splitPoint> splits;
|
||||
std::vector<TopoDS_Edge>::iterator itOuter = origEdges.begin();
|
||||
std::vector<TopoDS_Edge>::iterator itOuter = nonZero.begin();
|
||||
int iOuter = 0;
|
||||
for (; itOuter != origEdges.end(); ++itOuter, iOuter++) {
|
||||
for (; itOuter != nonZero.end(); ++itOuter, iOuter++) { //*** itOuter != nonZero.end() - 1
|
||||
TopoDS_Vertex v1 = TopExp::FirstVertex((*itOuter));
|
||||
TopoDS_Vertex v2 = TopExp::LastVertex((*itOuter));
|
||||
Bnd_Box sOuter;
|
||||
BRepBndLib::Add(*itOuter, sOuter);
|
||||
sOuter.SetGap(0.1);
|
||||
if (sOuter.IsVoid()) {
|
||||
Base::Console().Message("DVP::Extract Faces - outer Bnd_Box is void for %s\n",getNameInDocument());
|
||||
Base::Console().Log("DVP::Extract Faces - outer Bnd_Box is void for %s\n",getNameInDocument());
|
||||
continue;
|
||||
}
|
||||
if (DrawUtil::isZeroEdge(*itOuter)) {
|
||||
Base::Console().Message("DVP::extractFaces - outerEdge: %d is ZeroEdge\n",iOuter); //this is not finding ZeroEdges
|
||||
Base::Console().Log("DVP::extractFaces - outerEdge: %d is ZeroEdge\n",iOuter); //this is not finding ZeroEdges
|
||||
continue; //skip zero length edges. shouldn't happen ;)
|
||||
}
|
||||
int iInner = 0;
|
||||
std::vector<TopoDS_Edge>::iterator itInner = faceEdges.begin();
|
||||
for (; itInner != faceEdges.end(); ++itInner,iInner++) {
|
||||
std::vector<TopoDS_Edge>::iterator itInner = nonZero.begin(); //***sb itOuter + 1;
|
||||
for (; itInner != nonZero.end(); ++itInner,iInner++) {
|
||||
if (iInner == iOuter) {
|
||||
continue;
|
||||
}
|
||||
@@ -602,10 +581,10 @@ void DrawViewPart::extractFaces()
|
||||
std::vector<splitPoint> sorted = DrawProjectSplit::sortSplits(splits,true);
|
||||
auto last = std::unique(sorted.begin(), sorted.end(), DrawProjectSplit::splitEqual); //duplicates to back
|
||||
sorted.erase(last, sorted.end()); //remove dupl splits
|
||||
std::vector<TopoDS_Edge> newEdges = DrawProjectSplit::splitEdges(faceEdges,sorted);
|
||||
std::vector<TopoDS_Edge> newEdges = DrawProjectSplit::splitEdges(nonZero,sorted);
|
||||
|
||||
if (newEdges.empty()) {
|
||||
Base::Console().Log("LOG - DVP::extractFaces - no newEdges\n");
|
||||
Base::Console().Log("DVP::extractFaces - no newEdges\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1242,15 +1221,11 @@ int DrawViewPart::getCVIndex(std::string tag)
|
||||
// Base::Console().Message("DVP::getCVIndex(%s)\n", tag.c_str());
|
||||
int result = -1;
|
||||
std::vector<TechDraw::Vertex *> gVerts = getVertexGeometry();
|
||||
Base::Console().Message("DVP::getCVIndex - gVerts: %d\n", gVerts.size());
|
||||
std::vector<TechDraw::CosmeticVertex*> cVerts = CosmeticVertexes.getValues();
|
||||
Base::Console().Message("DVP::getCVIndex - cVerts: %d\n", cVerts.size());
|
||||
|
||||
int i = 0;
|
||||
bool found = false;
|
||||
for (auto& gv :gVerts) {
|
||||
Base::Console().Message("DVP::getCVIndex - gv cosmetic: %d ctag: %s\n",
|
||||
gv->cosmetic, gv->cosmeticTag.c_str());
|
||||
if (gv->cosmeticTag == tag) {
|
||||
result = i;
|
||||
found = true;
|
||||
|
||||
@@ -348,6 +348,8 @@ void CmdTechDrawView::activated(int iMsg)
|
||||
openCommand("Create view");
|
||||
std::string FeatName = getUniqueObjectName("View");
|
||||
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewPart','%s')",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||
|
||||
App::DocumentObject *docObj = getDocument()->getObject(FeatName.c_str());
|
||||
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart *>(docObj);
|
||||
if (!dvp) {
|
||||
@@ -355,7 +357,6 @@ void CmdTechDrawView::activated(int iMsg)
|
||||
}
|
||||
dvp->Source.setValues(shapes);
|
||||
dvp->XSource.setValues(xShapes);
|
||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||
if (faceName.size()) {
|
||||
std::pair<Base::Vector3d,Base::Vector3d> dirs = DrawGuiUtil::getProjDirFromFace(partObj,faceName);
|
||||
projDir = dirs.first;
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
using namespace std;
|
||||
|
||||
#define GEOMETRYEDGE 0
|
||||
#define COSMETICEDGE 1
|
||||
@@ -407,7 +408,6 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDraw::BaseGeom *baseGeom, double
|
||||
void QGIViewPart::updateView(bool update)
|
||||
{
|
||||
// Base::Console().Message("QGIVP::updateView()\n");
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
auto viewPart( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
|
||||
if( viewPart == nullptr ) {
|
||||
return;
|
||||
@@ -421,11 +421,6 @@ void QGIViewPart::updateView(bool update)
|
||||
draw();
|
||||
}
|
||||
QGIView::updateView(update);
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
auto diff = end - start;
|
||||
double diffOut = std::chrono::duration <double, std::milli> (diff).count();
|
||||
Base::Console().Log("TIMING - QGIVP::updateView - %s - total %.3f millisecs\n",getViewName(),diffOut);
|
||||
}
|
||||
|
||||
void QGIViewPart::draw() {
|
||||
@@ -459,7 +454,6 @@ void QGIViewPart::drawViewPart()
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
float lineWidth = vp->LineWidth.getValue() * lineScaleFactor;
|
||||
float lineWidthHid = vp->HiddenWidth.getValue() * lineScaleFactor;
|
||||
float lineWidthIso = vp->IsoWidth.getValue() * lineScaleFactor;
|
||||
|
||||
Reference in New Issue
Block a user