Allow DrawPage updates to be suspended

This commit is contained in:
WandererFan
2017-07-20 18:29:56 -04:00
committed by wmayer
parent f981cf6572
commit ddbbae9956
28 changed files with 844 additions and 69 deletions

View File

@@ -74,15 +74,19 @@ DrawPage::DrawPage(void)
{
static const char *group = "Page";
nowDeleting = false;
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
bool autoUpdate = hGrp->GetBool("KeepPagesUpToDate", 1l);
ADD_PROPERTY_TYPE(KeepUpdated, (autoUpdate), group, (App::PropertyType)(App::Prop_None), "Keep page in sync with model");
ADD_PROPERTY_TYPE(Template, (0), group, (App::PropertyType)(App::Prop_None), "Attached Template");
ADD_PROPERTY_TYPE(Views, (0), group, (App::PropertyType)(App::Prop_None), "Attached Views");
// Projection Properties
ProjectionType.setEnums(ProjectionTypeEnums);
Base::Reference<ParameterGrp> hGrp =
App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
// In preferences, 0 -> First Angle 1 -> Third Angle
int projType = hGrp->GetInt("ProjectionAngle", -1);
@@ -108,24 +112,29 @@ void DrawPage::onBeforeChange(const App::Property* prop)
void DrawPage::onChanged(const App::Property* prop)
{
if (prop == &Template) {
if ((prop == &KeepUpdated) &&
KeepUpdated.getValue()) {
if (!isRestoring() &&
!isDeleting()) {
//TODO: reload if Template prop changes (ie different Template)
auto views(Views.getValues());
for (auto& v: views) {
v->touch(); //get all views up to date
}
}
} else if (prop == &Views) {
} else if (prop == &Template) {
if (!isRestoring() &&
!isDeleting() ) {
//TODO: reload if Views prop changes (ie adds/deletes)
!isDeleting()) {
Template.getValue()->touch();
}
} else if(prop == &Scale) {
// touch all views in the Page as they may be dependent on this scale
const std::vector<App::DocumentObject*> &vals = Views.getValues();
for(std::vector<App::DocumentObject *>::const_iterator it = vals.begin(); it < vals.end(); ++it) {
TechDraw::DrawView *view = dynamic_cast<TechDraw::DrawView *>(*it);
if (view != NULL && view->ScaleType.isValue("Page")) {
view->Scale.touch();
}
// but the views know how to get their own Scale correctly.
const std::vector<App::DocumentObject*> &vals = Views.getValues();
for(std::vector<App::DocumentObject *>::const_iterator it = vals.begin(); it < vals.end(); ++it) {
TechDraw::DrawView *view = dynamic_cast<TechDraw::DrawView *>(*it);
if (view != NULL && view->ScaleType.isValue("Page")) {
view->Scale.touch();
}
}
} else if (prop == &ProjectionType) {
// touch all ortho views in the Page as they may be dependent on Projection Type
@@ -140,37 +149,18 @@ void DrawPage::onChanged(const App::Property* prop)
// TODO: Also update Template graphic.
}
App::DocumentObject::onChanged(prop); //<<<<
App::DocumentObject::onChanged(prop);
}
//Page is just a container. It doesn't "do" anything.
App::DocumentObjectExecReturn *DrawPage::execute(void)
{
//Page is just a property storage area? no real logic involved?
//all this does is trigger onChanged in this and ViewProviderPage
Template.touch();
Views.touch();
return App::DocumentObject::StdReturn;
}
// this is now irrelevant, b/c DP::execute doesn't do anything.
short DrawPage::mustExecute() const
{
if(Scale.isTouched())
return 1;
// Check the value of template if this has been modified
App::DocumentObject* tmpl = Template.getValue();
if(tmpl && tmpl->isTouched())
return 1;
// Check if within this Page, any Views have been touched
// Why does Page have to execute if a View changes?
const std::vector<App::DocumentObject*> &vals = Views.getValues();
for(std::vector<App::DocumentObject *>::const_iterator it = vals.begin(); it < vals.end(); ++it) {
if((*it)->isTouched()) {
return 1;
}
}
return App::DocumentObject::mustExecute();
}
@@ -248,6 +238,8 @@ int DrawPage::addView(App::DocumentObject *docObj)
if(!docObj->isDerivedFrom(TechDraw::DrawView::getClassTypeId()))
return -1;
DrawView* view = static_cast<DrawView*>(docObj);
//TODO: replace list of views with PropertyLink to Page in subordinate DrawView
// view->Page.setValue(this);
//position all new views in center of Page (exceptDVDimension)
if (!docObj->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {

View File

@@ -42,6 +42,7 @@ public:
App::PropertyLinkList Views;
App::PropertyLink Template;
App::PropertyBool KeepUpdated;
App::PropertyFloatConstraint Scale;
App::PropertyEnumeration ProjectionType; // First or Third Angle

View File

@@ -144,6 +144,10 @@ void DrawProjGroup::setCubeFromProps(void)
}
App::DocumentObjectExecReturn *DrawProjGroup::execute(void)
{
if (!keepUpdated()) {
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) {

View File

@@ -57,14 +57,14 @@ PROPERTY_SOURCE(TechDraw::DrawSVGTemplate, TechDraw::DrawTemplate)
DrawSVGTemplate::DrawSVGTemplate()
{
static const char *group = "Drawing view";
static const char *group = "Template";
//TODO: Do we need PageResult anymore? -wf Yes!
// PageResult points to a temporary file in tmp/FreeCAD-AB-CD-EF-.../myTemplate.svg
// which is really copy of original Template with EditableFields replaced
// When restoring saved document, Template is redundant/incorrect/not present - PageResult is the correct info. -wf-
ADD_PROPERTY_TYPE(PageResult, (0), group, App::Prop_Output, "Resulting SVG document of that page");
ADD_PROPERTY_TYPE(Template, (""), group, App::Prop_Transient, "Template for the page");
ADD_PROPERTY_TYPE(PageResult, (0), group, App::Prop_Output, "Current SVG code for template");
ADD_PROPERTY_TYPE(Template, (""), group, App::Prop_Transient, "Template for the page"); //sb TemplateFileName???
// Width and Height properties shouldn't be set by the user
Height.setStatus(App::Property::ReadOnly,true);
@@ -105,7 +105,7 @@ void DrawSVGTemplate::onChanged(const App::Property* prop)
//original template has been stored in fcstd file
Template.setValue(PageResult.getValue());
}
} else if (prop == &Template) {
} else if (prop == &Template) { //fileName has changed
if (!isRestoring()) {
EditableTexts.setValues(getEditableTextsFromTemplate());
updatePage = true;
@@ -118,11 +118,6 @@ void DrawSVGTemplate::onChanged(const App::Property* prop)
if (updatePage) {
execute();
// Update the parent page if exists
TechDraw::DrawPage *page = getParentPage();
if (page)
page->touch();
}
TechDraw::DrawTemplate::onChanged(prop);
@@ -253,11 +248,6 @@ App::DocumentObjectExecReturn * DrawSVGTemplate::execute(void)
Orientation.setValue(isLandscape ? 1 : 0);
// Housekeeping close the file
//resultFile.close();
touch();
return TechDraw::DrawTemplate::execute();
}

View File

@@ -120,7 +120,7 @@ App::DocumentObjectExecReturn *DrawTemplate::execute(void)
}
if(page) {
page->Template.touch();
page->Template.touch(); //if you are on a page, execute yourself???
}
return App::DocumentObject::execute();

View File

@@ -95,7 +95,8 @@ DrawView::~DrawView()
App::DocumentObjectExecReturn *DrawView::execute(void)
{
TechDraw::DrawPage *page = findParentPage();
if(page) {
if(page &&
keepUpdated()) {
if (ScaleType.isValue("Page")) {
if(std::abs(page->Scale.getValue() - Scale.getValue()) > FLT_EPSILON) {
Scale.setValue(page->Scale.getValue());
@@ -116,6 +117,7 @@ App::DocumentObjectExecReturn *DrawView::execute(void)
} else if (ScaleType.isValue("Custom")) {
//Base::Console().Message("TRACE - DV::execute - custom %s Scale: %.3f\n",getNameInDocument(),Scale.getValue());
}
requestPaint();
}
return App::DocumentObject::StdReturn; //DO::execute returns 0
}
@@ -306,6 +308,20 @@ void DrawView::Restore(Base::XMLReader &reader)
reader.readEndElement("Properties");
}
bool DrawView::keepUpdated(void)
{
bool result = false;
TechDraw::DrawPage *page = findParentPage();
if(page) {
result = page->KeepUpdated.getValue();
}
return result;
}
void DrawView::requestPaint(void)
{
signalGuiPaint(this);
}
PyObject *DrawView::getPyObject(void)
{

View File

@@ -23,6 +23,8 @@
#ifndef _DrawView_h_
#define _DrawView_h_
#include <boost/signals.hpp>
#include <QRectF>
#include <App/DocumentObject.h>
@@ -82,12 +84,15 @@ public:
virtual double autoScale(double w, double h) const;
virtual bool checkFit(DrawPage*) const;
virtual void setPosition(double x, double y);
bool keepUpdated(void);
boost::signal<void (const DrawView*)> signalGuiPaint;
protected:
void onChanged(const App::Property* prop);
std::string pageFeatName;
bool autoPos;
bool mouseMove;
void requestPaint(void);
private:
static const char* ScaleTypeEnums[];

View File

@@ -92,6 +92,10 @@ void DrawViewArch::onChanged(const App::Property* prop)
App::DocumentObjectExecReturn *DrawViewArch::execute(void)
{
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
App::DocumentObject* sourceObj = Source.getValue();
if (sourceObj) {
std::string svgFrag;

View File

@@ -103,6 +103,10 @@ void DrawViewClip::removeView(DrawView *view)
App::DocumentObjectExecReturn *DrawViewClip::execute(void)
{
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
touch();
std::vector<App::DocumentObject*> children = Views.getValues();

View File

@@ -190,6 +190,10 @@ void DrawViewCollection::unsetupObject()
App::DocumentObjectExecReturn *DrawViewCollection::execute(void)
{
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
if (ScaleType.isValue("Page")) {
const std::vector<App::DocumentObject *> &views = Views.getValues();
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {

View File

@@ -146,6 +146,10 @@ void DrawViewDetail::onChanged(const App::Property* prop)
App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
{
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
App::DocumentObject* link = Source.getValue();
App::DocumentObject* base = BaseView.getValue();
if (!link || !base) {

View File

@@ -177,6 +177,10 @@ short DrawViewDimension::mustExecute() const
App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
{
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
if (!has2DReferences()) { //too soon
return App::DocumentObject::StdReturn;
}

View File

@@ -88,6 +88,10 @@ void DrawViewDraft::onChanged(const App::Property* prop)
App::DocumentObjectExecReturn *DrawViewDraft::execute(void)
{
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
App::DocumentObject* sourceObj = Source.getValue();
if (sourceObj) {
std::string svgFrag;

View File

@@ -118,6 +118,10 @@ void DrawViewMulti::onChanged(const App::Property* prop)
App::DocumentObjectExecReturn *DrawViewMulti::execute(void)
{
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
const std::vector<App::DocumentObject*>& links = Sources.getValues();
if (links.empty()) {
Base::Console().Log("INFO - DVM::execute - No Sources - creation?\n");

View File

@@ -155,6 +155,9 @@ DrawViewPart::~DrawViewPart()
App::DocumentObjectExecReturn *DrawViewPart::execute(void)
{
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
App::DocumentObject *link = Source.getValue();
if (!link) {
return new App::DocumentObjectExecReturn("DVP - No Source object linked");
@@ -201,7 +204,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
// Base::Console().Message("TRACE _ DVP::exec - %s/%s u: %s v: %s w: %s\n",getNameInDocument(),Label.getValue(),
// DrawUtil::formatVector(getUDir()).c_str(), DrawUtil::formatVector(getVDir()).c_str(),DrawUtil::formatVector(getWDir()).c_str());
requestPaint();
return App::DocumentObject::StdReturn;
}

View File

@@ -191,6 +191,10 @@ void DrawViewSection::onChanged(const App::Property* prop)
App::DocumentObjectExecReturn *DrawViewSection::execute(void)
{
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
App::DocumentObject* link = Source.getValue();
App::DocumentObject* base = BaseView.getValue();
if (!link || !base) {

View File

@@ -89,6 +89,10 @@ void DrawViewSymbol::onChanged(const App::Property* prop)
App::DocumentObjectExecReturn *DrawViewSymbol::execute(void)
{
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
std::string svg = Symbol.getValue();
const std::vector<std::string>& editText = EditableTexts.getValues();

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>558</width>
<height>648</height>
<height>709</height>
</rect>
</property>
<property name="windowTitle">
@@ -131,6 +131,22 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="Gui::PrefCheckBox" name="cb_PageUpdate">
<property name="text">
<string>Keep Pages Up to Date</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>KeepPagesUpToDate</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/General</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@@ -349,7 +349,6 @@ void QGIViewPart::updateView(bool update)
void QGIViewPart::draw() {
drawViewPart();
drawMatting();
// drawBorder();
QGIView::draw();
}

View File

@@ -3,6 +3,7 @@
<file>icons/TechDraw_Tree_Annotation.svg</file>
<file>icons/TechDraw_Tree_Hatch.svg</file>
<file>icons/TechDraw_Tree_Page.svg</file>
<file>icons/TechDraw_Tree_Page_Unsync.svg</file>
<file>icons/TechDraw_Tree_PageTemplate.svg</file>
<file>icons/TechDraw_Tree_ProjGroup.svg</file>
<file>icons/TechDraw_Tree_Section.svg</file>

View File

@@ -0,0 +1,664 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
inkscape:export-ydpi="90.000000"
inkscape:export-xdpi="90.000000"
inkscape:export-filename="/home/jimmac/Desktop/wi-fi.png"
width="64"
height="64"
id="svg11300"
sodipodi:version="0.32"
inkscape:version="0.91 r"
sodipodi:docname="View-unsynced.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1">
<defs
id="defs3">
<linearGradient
id="linearGradient3063">
<stop
id="stop3065"
offset="0"
style="stop-color:#729fcf;stop-opacity:1" />
<stop
id="stop3067"
offset="1"
style="stop-color:#204a87;stop-opacity:1" />
</linearGradient>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 24 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="48 : 24 : 1"
inkscape:persp3d-origin="24 : 16 : 1"
id="perspective58" />
<linearGradient
inkscape:collect="always"
id="linearGradient2690">
<stop
style="stop-color:#c4d7eb;stop-opacity:1;"
offset="0"
id="stop2692" />
<stop
style="stop-color:#c4d7eb;stop-opacity:0;"
offset="1"
id="stop2694" />
</linearGradient>
<linearGradient
id="linearGradient2682">
<stop
style="stop-color:#3977c3;stop-opacity:1;"
offset="0"
id="stop2684" />
<stop
style="stop-color:#89aedc;stop-opacity:0;"
offset="1"
id="stop2686" />
</linearGradient>
<linearGradient
id="linearGradient2402">
<stop
style="stop-color:#729fcf;stop-opacity:1;"
offset="0"
id="stop2404" />
<stop
style="stop-color:#528ac5;stop-opacity:1;"
offset="1"
id="stop2406" />
</linearGradient>
<linearGradient
id="linearGradient2380">
<stop
style="stop-color:#729fcf;stop-opacity:1"
offset="0"
id="stop2382" />
<stop
style="stop-color:#3465a4;stop-opacity:1"
offset="1"
id="stop2384" />
</linearGradient>
<linearGradient
inkscape:collect="always"
id="linearGradient2871">
<stop
style="stop-color:#3465a4;stop-opacity:1;"
offset="0"
id="stop2873" />
<stop
style="stop-color:#3465a4;stop-opacity:1"
offset="1"
id="stop2875" />
</linearGradient>
<linearGradient
id="linearGradient2831">
<stop
style="stop-color:#3465a4;stop-opacity:1;"
offset="0"
id="stop2833" />
<stop
id="stop2855"
offset="0.33333334"
style="stop-color:#5b86be;stop-opacity:1;" />
<stop
style="stop-color:#83a8d8;stop-opacity:0;"
offset="1"
id="stop2835" />
</linearGradient>
<linearGradient
inkscape:collect="always"
id="linearGradient2797">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop2799" />
<stop
style="stop-color:#ffffff;stop-opacity:0;"
offset="1"
id="stop2801" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2797"
id="linearGradient1491"
gradientUnits="userSpaceOnUse"
x1="5.9649177"
y1="26.048164"
x2="52.854095"
y2="26.048164" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2797"
id="linearGradient1493"
gradientUnits="userSpaceOnUse"
x1="5.9649177"
y1="26.048164"
x2="52.854095"
y2="26.048164" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2871"
id="linearGradient1501"
gradientUnits="userSpaceOnUse"
x1="46.834816"
y1="45.264122"
x2="45.380436"
y2="50.939667" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3063"
id="linearGradient2386"
x1="42.703487"
y1="20.547306"
x2="26.605606"
y2="33.634254"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2402"
id="linearGradient2408"
x1="18.935766"
y1="23.667896"
x2="53.588623"
y2="26.649363"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2682"
id="linearGradient2688"
x1="36.713837"
y1="31.455952"
x2="37.124462"
y2="24.842253"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.370336,0,0,1.3589114,-0.33380651,-16.948724)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2690"
id="linearGradient2696"
x1="32.647972"
y1="30.748846"
x2="37.124462"
y2="24.842253"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.370336,0,0,1.3589114,-0.33380651,-16.948724)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2871"
id="linearGradient3036"
gradientUnits="userSpaceOnUse"
x1="46.834816"
y1="45.264122"
x2="45.380436"
y2="50.939667" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2402"
id="linearGradient3038"
gradientUnits="userSpaceOnUse"
x1="18.935766"
y1="23.667896"
x2="53.588623"
y2="26.649363" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2871"
id="linearGradient3040"
gradientUnits="userSpaceOnUse"
x1="46.834816"
y1="45.264122"
x2="45.380436"
y2="50.939667" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2831-7"
id="linearGradient1486-1"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.370336,0,0,1.3589114,0.30396568,-17.325948)"
x1="13.478554"
y1="10.612206"
x2="15.419417"
y2="19.115122" />
<linearGradient
id="linearGradient2831-7">
<stop
style="stop-color:#3465a4;stop-opacity:1;"
offset="0"
id="stop2833-4" />
<stop
id="stop2855-0"
offset="0.33333334"
style="stop-color:#5b86be;stop-opacity:1;" />
<stop
style="stop-color:#83a8d8;stop-opacity:0;"
offset="1"
id="stop2835-9" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2847-8"
id="linearGradient1488-4"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-1.370336,0,0,-1.3589114,64.7954,45.353844)"
x1="37.128052"
y1="29.729605"
x2="37.065414"
y2="26.194071" />
<linearGradient
inkscape:collect="always"
id="linearGradient2847-8">
<stop
style="stop-color:#3465a4;stop-opacity:1;"
offset="0"
id="stop2849-8" />
<stop
style="stop-color:#3465a4;stop-opacity:0;"
offset="1"
id="stop2851-2" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2380-5"
id="linearGradient2386-4"
x1="62.513836"
y1="36.061237"
x2="15.984863"
y2="20.60858"
gradientUnits="userSpaceOnUse" />
<linearGradient
id="linearGradient2380-5">
<stop
style="stop-color:#b9cfe7;stop-opacity:1"
offset="0"
id="stop2382-5" />
<stop
style="stop-color:#729fcf;stop-opacity:1"
offset="1"
id="stop2384-1" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2380-5"
id="linearGradient3034-7"
gradientUnits="userSpaceOnUse"
x1="62.513836"
y1="36.061237"
x2="15.984863"
y2="20.60858" />
<linearGradient
id="linearGradient3895">
<stop
style="stop-color:#b9cfe7;stop-opacity:1"
offset="0"
id="stop3897" />
<stop
style="stop-color:#729fcf;stop-opacity:1"
offset="1"
id="stop3899" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient2797-1"
id="linearGradient3861-1"
gradientUnits="userSpaceOnUse"
x1="5.9649177"
y1="26.048164"
x2="52.854095"
y2="26.048164" />
<linearGradient
inkscape:collect="always"
id="linearGradient2797-1">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop2799-5" />
<stop
style="stop-color:#ffffff;stop-opacity:0;"
offset="1"
id="stop2801-2" />
</linearGradient>
<linearGradient
id="linearGradient2831-2">
<stop
style="stop-color:#3465a4;stop-opacity:1;"
offset="0"
id="stop2833-3" />
<stop
id="stop2855-1"
offset="0.33333334"
style="stop-color:#5b86be;stop-opacity:1;" />
<stop
style="stop-color:#83a8d8;stop-opacity:0;"
offset="1"
id="stop2835-6" />
</linearGradient>
<linearGradient
id="linearGradient3063-2">
<stop
id="stop3065-6"
offset="0"
style="stop-color:#729fcf;stop-opacity:1" />
<stop
id="stop3067-0"
offset="1"
style="stop-color:#204a87;stop-opacity:1" />
</linearGradient>
<linearGradient
id="linearGradient2380-9">
<stop
style="stop-color:#729fcf;stop-opacity:1"
offset="0"
id="stop2382-4" />
<stop
style="stop-color:#3465a4;stop-opacity:1"
offset="1"
id="stop2384-6" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient8662"
id="radialGradient4371"
cx="-70.66935"
cy="-0.79587156"
fx="-70.66935"
fy="-0.79587156"
r="31.937773"
gradientTransform="matrix(1,0,0,0.35772441,38.669348,-37.504601)"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
id="linearGradient8662">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop8664" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop8666" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4253"
id="linearGradient5203"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.370336,0,0,1.3589114,0.454453,-1.682154)"
x1="13.478554"
y1="10.612206"
x2="15.419417"
y2="19.115122" />
<linearGradient
inkscape:collect="always"
id="linearGradient4253">
<stop
style="stop-color:#cc0000;stop-opacity:1;"
offset="0"
id="stop4255" />
<stop
style="stop-color:#cc0000;stop-opacity:0;"
offset="1"
id="stop4257" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4263"
id="linearGradient5205"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-1.370336,0,0,-1.3589114,64.945884,60.997638)"
x1="37.128052"
y1="29.729605"
x2="37.065414"
y2="26.194071" />
<linearGradient
inkscape:collect="always"
id="linearGradient4263">
<stop
style="stop-color:#cc0000;stop-opacity:1"
offset="0"
id="stop4265" />
<stop
id="stop4271"
offset="0.4255361"
style="stop-color:#ef2929;stop-opacity:1" />
<stop
style="stop-color:#a40000;stop-opacity:0;"
offset="1"
id="stop4267" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4347"
id="linearGradient5209"
gradientUnits="userSpaceOnUse"
x1="5.8964558"
y1="24.75346"
x2="54.864159"
y2="24.75346" />
<linearGradient
inkscape:collect="always"
id="linearGradient4347">
<stop
style="stop-color:#ef2929;stop-opacity:1"
offset="0"
id="stop4335" />
<stop
style="stop-color:#cc0000;stop-opacity:1"
offset="1"
id="stop4337" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4253"
id="linearGradient4389"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.370336,0,0,1.3589114,43.633579,-55.898687)"
x1="13.478554"
y1="10.612206"
x2="15.419417"
y2="19.115122" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4263"
id="linearGradient4391"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-1.370336,0,0,-1.3589114,108.12501,6.7811049)"
x1="37.128052"
y1="29.729605"
x2="37.065414"
y2="26.194071" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4347"
id="linearGradient5626"
gradientUnits="userSpaceOnUse"
x1="5.8964558"
y1="24.75346"
x2="54.864159"
y2="24.75346" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4347"
id="linearGradient5628"
gradientUnits="userSpaceOnUse"
x1="5.8964558"
y1="24.75346"
x2="54.864159"
y2="24.75346" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4347"
id="linearGradient5630"
gradientUnits="userSpaceOnUse"
x1="5.8964558"
y1="24.75346"
x2="54.864159"
y2="24.75346" />
</defs>
<sodipodi:namedview
stroke="#3465a4"
fill="#729fcf"
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="0.25490196"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1"
inkscape:cx="32"
inkscape:cy="32"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:showpageshadow="false"
inkscape:window-width="1366"
inkscape:window-height="694"
inkscape:window-x="0"
inkscape:window-y="25"
inkscape:snap-bbox="true"
inkscape:snap-nodes="false"
inkscape:snap-global="true"
inkscape:window-maximized="1">
<inkscape:grid
empspacing="2"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true"
type="xygrid"
id="grid3042" />
</sodipodi:namedview>
<metadata
id="metadata4">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:creator>
<cc:Agent>
<dc:title>Jakub Steiner</dc:title>
</cc:Agent>
</dc:creator>
<dc:source>http://jimmac.musichall.cz</dc:source>
<cc:license
rdf:resource="http://creativecommons.org/licenses/publicdomain/" />
<dc:title></dc:title>
<dc:subject>
<rdf:Bag>
<rdf:li>reload</rdf:li>
<rdf:li>refresh</rdf:li>
<rdf:li>view</rdf:li>
</rdf:Bag>
</dc:subject>
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/publicdomain/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
</cc:License>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer"
transform="translate(0,16)"
style="display:inline">
<g
id="g6457">
<ellipse
ry="11.424921"
rx="31.937773"
cy="-37.789307"
cx="-32"
inkscape:r_cy="true"
inkscape:r_cx="true"
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.38333333;fill:url(#radialGradient4371);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;marker:none"
id="path8660-9"
transform="scale(-1,-1)" />
<g
transform="translate(-2.0309525,-14.682363)"
id="g5281">
<path
style="color:#000000;display:block;overflow:visible;visibility:visible;fill:url(#linearGradient5203);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient5205);stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none"
d="m 27.432943,12.841207 c 0,0 -12.247378,-0.84932 -8.478954,13.41925 l -10.534457,0 c 0,0 0.685168,-16.137073 19.013411,-13.41925 z"
id="path2865-8"
inkscape:r_cx="true"
inkscape:r_cy="true"
sodipodi:nodetypes="cccc"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
inkscape:r_cy="true"
inkscape:r_cx="true"
style="color:#000000;display:block;overflow:visible;visibility:visible;fill:#ef2929;fill-opacity:1;fill-rule:nonzero;stroke:#a40000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none"
d="M 8.649397,26.725762 C 3.619195,3.077272 29.081037,-5.807504 51.2786,11.55773 l 6.542274,-7.122518 -0.13116,23.281319 -20.502868,-0.02094 c 0,0 6.824331,-7.607846 6.824331,-7.607846 C 28.400147,8.355465 8.406659,9.233731 8.649397,26.725758 Z"
id="path1880-5"
sodipodi:nodetypes="ccccccc" />
<g
style="fill:url(#linearGradient5628);fill-opacity:1;stroke:#ef2929;stroke-width:0.73280919;stroke-opacity:1"
inkscape:r_cy="true"
inkscape:r_cx="true"
transform="matrix(-0.69686517,-0.58385766,-0.58876622,0.69105539,72.481944,16.500722)"
id="g2805-0">
<path
inkscape:r_cy="true"
inkscape:r_cx="true"
style="color:#000000;display:block;overflow:visible;visibility:visible;fill:url(#linearGradient5626);fill-opacity:1;stroke:#ef2929;stroke-width:2.20148993;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:21;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none"
d="M 52.368857,42.344789 C 57.336994,33.465615 49.176003,12.601866 19.05552,12.672851 L 18.677956,5.6633463 7.4378077,19.282655 19.129354,29.167094 18.807724,20.554957 c 18.244937,0.381972 33.804002,9.457851 33.561133,21.789832 z"
id="path2807-3"
sodipodi:nodetypes="ccccccc"
inkscape:connector-curvature="0" />
</g>
</g>
<g
transform="matrix(-1,0,0,-1,107.30581,-7.894457)"
id="g4379">
<path
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccc"
inkscape:r_cy="true"
inkscape:r_cx="true"
id="path4381"
d="m 70.612069,-41.375326 c 0,0 -12.247378,-0.84932 -8.478954,13.41925 l -10.534457,0 c 0,0 0.685168,-16.137073 19.013411,-13.41925 z"
style="color:#000000;display:block;overflow:visible;visibility:visible;fill:url(#linearGradient4389);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient4391);stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" />
<path
sodipodi:nodetypes="ccccccc"
id="path4383"
d="m 51.828523,-27.490771 c -5.030202,-23.64849 20.43164,-32.533266 42.629203,-15.168032 L 101,-49.781321 l -0.13116,23.281319 -20.502868,-0.02094 c 0,0 6.824331,-7.607846 6.824331,-7.607846 -15.61103,-11.73228 -35.604518,-10.854014 -35.36178,6.638013 z"
style="color:#000000;display:block;overflow:visible;visibility:visible;fill:#ef2929;fill-opacity:1;fill-rule:nonzero;stroke:#a40000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none"
inkscape:r_cx="true"
inkscape:r_cy="true"
inkscape:connector-curvature="0" />
<g
id="g4385"
transform="matrix(-0.69686517,-0.58385766,-0.58876622,0.69105539,115.66107,-37.715811)"
inkscape:r_cx="true"
inkscape:r_cy="true"
style="fill:url(#linearGradient5209);fill-opacity:1;stroke:#ef2929;stroke-width:0.73280919;stroke-opacity:1">
<path
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccc"
id="path4387"
d="M 52.368857,42.344789 C 57.336994,33.465615 49.176003,12.601866 19.05552,12.672851 L 18.677956,5.6633463 7.4378077,19.282655 19.129354,29.167094 18.807724,20.554957 c 18.244937,0.381972 33.804002,9.457851 33.561133,21.789832 z"
style="color:#000000;display:block;overflow:visible;visibility:visible;fill:url(#linearGradient5630);fill-opacity:1;stroke:#ef2929;stroke-width:2.20148993;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:21;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none"
inkscape:r_cx="true"
inkscape:r_cy="true" />
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -77,7 +77,6 @@ std::vector<std::string> ViewProviderAnnotation::getDisplayModes(void) const
void ViewProviderAnnotation::updateData(const App::Property* prop)
{
Base::Console().Log("ViewProviderViewSection::updateData - Update View: %s\n",prop->getName());
if (prop == &(getViewObject()->Text) ||
prop == &(getViewObject()->Font) ||
prop == &(getViewObject()->TextColor) ||
@@ -90,7 +89,7 @@ void ViewProviderAnnotation::updateData(const App::Property* prop)
if (qgiv) {
qgiv->updateView(true);
}
}
}
ViewProviderDrawingView::updateData(prop);
}

View File

@@ -25,6 +25,9 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <boost/signal.hpp>
#include <boost/bind.hpp>
#endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
@@ -43,6 +46,7 @@
#include <Mod/TechDraw/App/DrawViewClip.h>
#include <Mod/TechDraw/App/DrawPage.h>
#include <Mod/TechDraw/App/DrawView.h>
#include "ViewProviderPage.h"
#include "QGIView.h"
@@ -61,6 +65,7 @@ ViewProviderDrawingView::ViewProviderDrawingView()
// Do not show in property editor why? wf
DisplayMode.setStatus(App::Property::ReadOnly,true);
m_docReady = true;
}
ViewProviderDrawingView::~ViewProviderDrawingView()
@@ -70,6 +75,14 @@ ViewProviderDrawingView::~ViewProviderDrawingView()
void ViewProviderDrawingView::attach(App::DocumentObject *pcFeat)
{
ViewProviderDocumentObject::attach(pcFeat);
auto bnd = boost::bind(&ViewProviderDrawingView::onGuiRepaint, this, _1);
auto feature = getViewObject();
if (feature != nullptr) {
connectGuiRepaint = feature->signalGuiPaint.connect(bnd);
} else {
Base::Console().Log("VPDV::attach has no Feature!\n");
}
}
void ViewProviderDrawingView::setDisplayMode(const char* ModeName)
@@ -137,10 +150,6 @@ void ViewProviderDrawingView::hide(void)
QGIView* ViewProviderDrawingView::getQView(void)
{
//TODO: vp can get its MDIView with 1 call getActiveView()?
// instead of going back to App side an up tree and back to Gui?
//MDIVPage* mdivp = static_cast<MDIVPage*>(getActiveView());
//qView = mdivp->getQGVPage()->findQViewForDocObj(getViewObject());
QGIView *qView = nullptr;
if (m_docReady){
TechDraw::DrawView* dv = getViewObject();
@@ -185,12 +194,12 @@ void ViewProviderDrawingView::finishRestoring()
void ViewProviderDrawingView::updateData(const App::Property* prop)
{
if (prop == &(getViewObject()->Rotation) ) {
// redraw QGIVP
QGIView* qgiv = getQView();
if (qgiv) {
qgiv->updateView(true);
}
}
}
Gui::ViewProviderDocumentObject::updateData(prop);
}
@@ -216,6 +225,23 @@ MDIViewPage* ViewProviderDrawingView::getMDIViewPage() const
return result;
}
void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv)
{
if (dv == getViewObject()) {
QGIView* qgiv = getQView();
if (qgiv) {
qgiv->updateView(true);
}
// } else {
// auto vo = getViewObject();
// auto page = vo->findParentPage();
// if (page != nullptr) {
// page->requestPaint() ;
// }
}
}
TechDraw::DrawView* ViewProviderDrawingView::getViewObject() const
{
return dynamic_cast<TechDraw::DrawView*>(pcObject);

View File

@@ -31,6 +31,10 @@
#include <Mod/TechDraw/App/DrawView.h>
#include "QGIView.h"
namespace TechDraw {
class DrawView;
}
namespace TechDrawGui {
class QGIView;
class MDIViewPage;
@@ -71,6 +75,11 @@ public:
//@}
virtual TechDraw::DrawView* getViewObject() const;
void onGuiRepaint(const TechDraw::DrawView* dv);
typedef boost::signals::connection Connection;
Connection connectGuiRepaint;
private:
bool m_docReady; //sb MDI + QGraphicsScene ready

View File

@@ -126,6 +126,18 @@ void ViewProviderPage::hide(void)
void ViewProviderPage::updateData(const App::Property* prop)
{
if (prop == &(getDrawPage()->KeepUpdated)) {
if (getDrawPage()->KeepUpdated.getValue()) {
sPixmap = "TechDraw_Tree_Page";
if (!m_mdiView.isNull() &&
!getDrawPage()->isDeleting()) {
m_mdiView->updateDrawing();
}
} else {
sPixmap = "TechDraw_Tree_Page_Unsync";
}
}
if (prop == &(getDrawPage()->Views)) {
if(!m_mdiView.isNull() &&
!getDrawPage()->isDeleting()) {
@@ -310,11 +322,7 @@ void ViewProviderPage::onSelectionChanged(const Gui::SelectionChanges& msg)
void ViewProviderPage::onChanged(const App::Property *prop)
{
if (prop == &(getDrawPage()->Views)) {
if(m_mdiView) {
m_mdiView->updateDrawing();
}
} else if (prop == &(getDrawPage()->Template)) {
if (prop == &(getDrawPage()->Template)) {
if(m_mdiView) {
m_mdiView->updateTemplate();
}
@@ -336,6 +344,10 @@ void ViewProviderPage::finishRestoring()
Gui::ViewProviderDocumentObject::finishRestoring();
}
bool ViewProviderPage::isShow(void) const
{
return Visibility.getValue();
}
TechDraw::DrawPage* ViewProviderPage::getDrawPage() const
{

View File

@@ -62,6 +62,7 @@ public:
virtual void hide(void);
/// Shows the view provider
virtual void show(void);
virtual bool isShow(void) const;
void onSelectionChanged(const Gui::SelectionChanges& msg);

View File

@@ -86,7 +86,6 @@ std::vector<std::string> ViewProviderTemplate::getDisplayModes(void) const
void ViewProviderTemplate::updateData(const App::Property* prop)
{
//Base::Console().Log("ViewProviderTemplate::updateData(%s)/n",prop->getName());
Gui::ViewProviderDocumentObject::updateData(prop);
}
@@ -105,6 +104,7 @@ void ViewProviderTemplate::onChanged(const App::Property *prop)
hide();
}
}
Gui::ViewProviderDocumentObject::onChanged(prop);
}

View File

@@ -95,7 +95,8 @@ void ViewProviderViewPart::attach(App::DocumentObject *pcFeat)
}
// call parent attach method
ViewProviderDocumentObject::attach(pcFeat);
// ViewProviderDocumentObject::attach(pcFeat);
ViewProviderDrawingView::attach(pcFeat);
}
void ViewProviderViewPart::setDisplayMode(const char* ModeName)