[TD]add light text on dark page mode
- some visually impaired users need white graphics on dark page. - revise Annotation dialog to respect dark style
This commit is contained in:
@@ -23,9 +23,9 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <iostream>
|
||||
# include <sstream>
|
||||
# include <Precision.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include "DrawPage.h"
|
||||
#include "DrawPagePy.h" // generated from DrawPagePy.xml
|
||||
#include "DrawPagePy.h"// generated from DrawPagePy.xml
|
||||
#include "DrawProjGroup.h"
|
||||
#include "DrawTemplate.h"
|
||||
#include "DrawView.h"
|
||||
@@ -50,49 +50,59 @@ using namespace TechDraw;
|
||||
// DrawPage
|
||||
//===========================================================================
|
||||
|
||||
App::PropertyFloatConstraint::Constraints DrawPage::scaleRange = {Precision::Confusion(),
|
||||
std::numeric_limits<double>::max(),
|
||||
(0.1)}; // increment by 0.1
|
||||
App::PropertyFloatConstraint::Constraints DrawPage::scaleRange = {
|
||||
Precision::Confusion(), std::numeric_limits<double>::max(), (0.1)};// increment by 0.1
|
||||
|
||||
PROPERTY_SOURCE(TechDraw::DrawPage, App::DocumentObject)
|
||||
|
||||
const char* DrawPage::ProjectionTypeEnums[] = { "First Angle",
|
||||
"Third Angle",
|
||||
nullptr };
|
||||
const char* DrawPage::ProjectionTypeEnums[] = {"First Angle", "Third Angle", nullptr};
|
||||
|
||||
DrawPage::DrawPage(void)
|
||||
{
|
||||
static const char *group = "Page";
|
||||
static const char* group = "Page";
|
||||
nowUnsetting = false;
|
||||
forceRedraw(false);
|
||||
|
||||
ADD_PROPERTY_TYPE(KeepUpdated, (Preferences::keepPagesUpToDate()),
|
||||
group, (App::PropertyType)(App::Prop_Output), "Keep page in sync with model");
|
||||
ADD_PROPERTY_TYPE(Template, (nullptr), group, (App::PropertyType)(App::Prop_None), "Attached Template");
|
||||
ADD_PROPERTY_TYPE(KeepUpdated,
|
||||
(Preferences::keepPagesUpToDate()),
|
||||
group,
|
||||
(App::PropertyType)(App::Prop_Output),
|
||||
"Keep page in sync with model");
|
||||
ADD_PROPERTY_TYPE(
|
||||
Template, (nullptr), group, (App::PropertyType)(App::Prop_None), "Attached Template");
|
||||
Template.setScope(App::LinkScope::Global);
|
||||
ADD_PROPERTY_TYPE(Views, (nullptr), group, (App::PropertyType)(App::Prop_None), "Attached Views");
|
||||
ADD_PROPERTY_TYPE(
|
||||
Views, (nullptr), group, (App::PropertyType)(App::Prop_None), "Attached Views");
|
||||
Views.setScope(App::LinkScope::Global);
|
||||
|
||||
// Projection Properties
|
||||
ProjectionType.setEnums(ProjectionTypeEnums);
|
||||
ADD_PROPERTY(ProjectionType, ((long)Preferences::projectionAngle()));
|
||||
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/General");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/General");
|
||||
double defScale = hGrp->GetFloat("DefaultScale", 1.0);
|
||||
ADD_PROPERTY_TYPE(Scale, (defScale), group, (App::PropertyType)(App::Prop_None), "Scale factor for this Page");
|
||||
ADD_PROPERTY_TYPE(Scale,
|
||||
(defScale),
|
||||
group,
|
||||
(App::PropertyType)(App::Prop_None),
|
||||
"Scale factor for this Page");
|
||||
|
||||
ADD_PROPERTY_TYPE(NextBalloonIndex, (1), group, (App::PropertyType)(App::Prop_None),
|
||||
"Auto-numbering for Balloons");
|
||||
ADD_PROPERTY_TYPE(NextBalloonIndex,
|
||||
(1),
|
||||
group,
|
||||
(App::PropertyType)(App::Prop_None),
|
||||
"Auto-numbering for Balloons");
|
||||
|
||||
Scale.setConstraints(&scaleRange);
|
||||
balloonParent = nullptr;
|
||||
}
|
||||
|
||||
DrawPage::~DrawPage()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void DrawPage::onBeforeChange(const App::Property* prop)
|
||||
{
|
||||
@@ -101,53 +111,56 @@ void DrawPage::onBeforeChange(const App::Property* prop)
|
||||
|
||||
void DrawPage::onChanged(const App::Property* prop)
|
||||
{
|
||||
if ((prop == &KeepUpdated) &&
|
||||
KeepUpdated.getValue()) {
|
||||
if (!isRestoring() &&
|
||||
!isUnsetting()) {
|
||||
if ((prop == &KeepUpdated) && KeepUpdated.getValue()) {
|
||||
if (!isRestoring() && !isUnsetting()) {
|
||||
//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());
|
||||
Base::Console().Message(
|
||||
"Rebuilding Views for: %s/%s\n", getNameInDocument(), Label.getValue());
|
||||
updateAllViews();
|
||||
purgeTouched();
|
||||
}
|
||||
} else if (prop == &Template) {
|
||||
if (!isRestoring() &&
|
||||
!isUnsetting()) {
|
||||
}
|
||||
else if (prop == &Template) {
|
||||
if (!isRestoring() && !isUnsetting()) {
|
||||
//nothing to page to do??
|
||||
}
|
||||
} else if(prop == &Scale) {
|
||||
}
|
||||
else if (prop == &Scale) {
|
||||
// touch all views in the Page as they may be dependent on this scale
|
||||
// WF: not sure this loop is required. Views figure out their scale as required. but maybe
|
||||
// this is needed just to mark the Views to recompute??
|
||||
if (!isRestoring()) {
|
||||
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);
|
||||
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 && view->ScaleType.isValue("Page")) {
|
||||
if(std::abs(view->Scale.getValue() - Scale.getValue()) > FLT_EPSILON) {
|
||||
view->Scale.setValue(Scale.getValue());
|
||||
if (std::abs(view->Scale.getValue() - Scale.getValue()) > FLT_EPSILON) {
|
||||
view->Scale.setValue(Scale.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (prop == &ProjectionType) {
|
||||
// touch all ortho views in the Page as they may be dependent on Projection Type //(is this true?)
|
||||
const std::vector<App::DocumentObject*> &vals = Views.getValues();
|
||||
for(std::vector<App::DocumentObject *>::const_iterator it = vals.begin(); it < vals.end(); ++it) {
|
||||
TechDraw::DrawProjGroup *view = dynamic_cast<TechDraw::DrawProjGroup *>(*it);
|
||||
if (view && view->ProjectionType.isValue("Default")) {
|
||||
view->ProjectionType.touch();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Also update Template graphic.
|
||||
}
|
||||
else if (prop == &ProjectionType) {
|
||||
// touch all ortho views in the Page as they may be dependent on Projection Type //(is this true?)
|
||||
const std::vector<App::DocumentObject*>& vals = Views.getValues();
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = vals.begin(); it < vals.end();
|
||||
++it) {
|
||||
TechDraw::DrawProjGroup* view = dynamic_cast<TechDraw::DrawProjGroup*>(*it);
|
||||
if (view && view->ProjectionType.isValue("Default")) {
|
||||
view->ProjectionType.touch();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Also update Template graphic.
|
||||
}
|
||||
App::DocumentObject::onChanged(prop);
|
||||
}
|
||||
|
||||
//Page is just a container. It doesn't "do" anything.
|
||||
App::DocumentObjectExecReturn *DrawPage::execute(void)
|
||||
App::DocumentObjectExecReturn* DrawPage::execute(void)
|
||||
{
|
||||
return App::DocumentObject::execute();
|
||||
}
|
||||
@@ -157,10 +170,8 @@ short DrawPage::mustExecute() const
|
||||
{
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (Views.isTouched() ||
|
||||
Scale.isTouched() ||
|
||||
ProjectionType.isTouched() ||
|
||||
Template.isTouched());
|
||||
result = (Views.isTouched() || Scale.isTouched() || ProjectionType.isTouched()
|
||||
|| Template.isTouched());
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@@ -168,9 +179,9 @@ short DrawPage::mustExecute() const
|
||||
return App::DocumentObject::mustExecute();
|
||||
}
|
||||
|
||||
PyObject *DrawPage::getPyObject(void)
|
||||
PyObject* DrawPage::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())){
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new DrawPagePy(this), true);
|
||||
}
|
||||
@@ -180,13 +191,12 @@ PyObject *DrawPage::getPyObject(void)
|
||||
|
||||
bool DrawPage::hasValidTemplate() const
|
||||
{
|
||||
App::DocumentObject *obj = nullptr;
|
||||
App::DocumentObject* obj = nullptr;
|
||||
obj = Template.getValue();
|
||||
|
||||
if(obj && obj->isDerivedFrom(TechDraw::DrawTemplate::getClassTypeId())) {
|
||||
TechDraw::DrawTemplate *templ = static_cast<TechDraw::DrawTemplate *>(obj);
|
||||
if (templ->getWidth() > 0. &&
|
||||
templ->getHeight() > 0.) {
|
||||
if (obj && obj->isDerivedFrom(TechDraw::DrawTemplate::getClassTypeId())) {
|
||||
TechDraw::DrawTemplate* templ = static_cast<TechDraw::DrawTemplate*>(obj);
|
||||
if (templ->getWidth() > 0. && templ->getHeight() > 0.) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -196,11 +206,11 @@ bool DrawPage::hasValidTemplate() const
|
||||
|
||||
double DrawPage::getPageWidth() const
|
||||
{
|
||||
App::DocumentObject *obj = nullptr;
|
||||
App::DocumentObject* obj = nullptr;
|
||||
obj = Template.getValue();
|
||||
|
||||
if( obj && obj->isDerivedFrom(TechDraw::DrawTemplate::getClassTypeId()) ) {
|
||||
TechDraw::DrawTemplate *templ = static_cast<TechDraw::DrawTemplate *>(obj);
|
||||
if (obj && obj->isDerivedFrom(TechDraw::DrawTemplate::getClassTypeId())) {
|
||||
TechDraw::DrawTemplate* templ = static_cast<TechDraw::DrawTemplate*>(obj);
|
||||
return templ->getWidth();
|
||||
}
|
||||
|
||||
@@ -209,12 +219,12 @@ double DrawPage::getPageWidth() const
|
||||
|
||||
double DrawPage::getPageHeight() const
|
||||
{
|
||||
App::DocumentObject *obj = nullptr;
|
||||
App::DocumentObject* obj = nullptr;
|
||||
obj = Template.getValue();
|
||||
|
||||
if(obj) {
|
||||
if(obj->isDerivedFrom(TechDraw::DrawTemplate::getClassTypeId())) {
|
||||
TechDraw::DrawTemplate *templ = static_cast<TechDraw::DrawTemplate *>(obj);
|
||||
if (obj) {
|
||||
if (obj->isDerivedFrom(TechDraw::DrawTemplate::getClassTypeId())) {
|
||||
TechDraw::DrawTemplate* templ = static_cast<TechDraw::DrawTemplate*>(obj);
|
||||
return templ->getHeight();
|
||||
}
|
||||
}
|
||||
@@ -223,16 +233,16 @@ double DrawPage::getPageHeight() const
|
||||
}
|
||||
|
||||
//orientation as text
|
||||
const char * DrawPage::getPageOrientation() const
|
||||
const char* DrawPage::getPageOrientation() const
|
||||
{
|
||||
App::DocumentObject *obj;
|
||||
App::DocumentObject* obj;
|
||||
obj = Template.getValue();
|
||||
|
||||
if(obj) {
|
||||
if(obj->isDerivedFrom(TechDraw::DrawTemplate::getClassTypeId())) {
|
||||
TechDraw::DrawTemplate *templ = static_cast<TechDraw::DrawTemplate *>(obj);
|
||||
if (obj) {
|
||||
if (obj->isDerivedFrom(TechDraw::DrawTemplate::getClassTypeId())) {
|
||||
TechDraw::DrawTemplate* templ = static_cast<TechDraw::DrawTemplate*>(obj);
|
||||
|
||||
return templ->Orientation.getValueAsString();
|
||||
return templ->Orientation.getValueAsString();
|
||||
}
|
||||
}
|
||||
throw Base::RuntimeError("Template not set for Page");
|
||||
@@ -241,41 +251,43 @@ const char * DrawPage::getPageOrientation() const
|
||||
//orientation as 0(Portrait) or 1(Landscape)
|
||||
int DrawPage::getOrientation() const
|
||||
{
|
||||
App::DocumentObject *obj;
|
||||
App::DocumentObject* obj;
|
||||
obj = Template.getValue();
|
||||
|
||||
if(obj) {
|
||||
if(obj->isDerivedFrom(TechDraw::DrawTemplate::getClassTypeId())) {
|
||||
TechDraw::DrawTemplate *templ = static_cast<TechDraw::DrawTemplate *>(obj);
|
||||
if (obj) {
|
||||
if (obj->isDerivedFrom(TechDraw::DrawTemplate::getClassTypeId())) {
|
||||
TechDraw::DrawTemplate* templ = static_cast<TechDraw::DrawTemplate*>(obj);
|
||||
|
||||
return templ->Orientation.getValue();
|
||||
return templ->Orientation.getValue();
|
||||
}
|
||||
}
|
||||
throw Base::RuntimeError("Template not set for Page");
|
||||
}
|
||||
|
||||
int DrawPage::addView(App::DocumentObject *docObj)
|
||||
int DrawPage::addView(App::DocumentObject* docObj)
|
||||
{
|
||||
if(!docObj->isDerivedFrom(TechDraw::DrawView::getClassTypeId()))
|
||||
if (!docObj->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
|
||||
return -1;
|
||||
}
|
||||
DrawView* view = static_cast<DrawView*>(docObj);
|
||||
|
||||
//position all new views in center of Page (exceptDVDimension)
|
||||
if (!docObj->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId()) &&
|
||||
!docObj->isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId())) {
|
||||
view->X.setValue(getPageWidth()/2.0);
|
||||
view->Y.setValue(getPageHeight()/2.0);
|
||||
//position all new views in center of Page (exceptDVDimension)
|
||||
if (!docObj->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())
|
||||
&& !docObj->isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId())) {
|
||||
view->X.setValue(getPageWidth() / 2.0);
|
||||
view->Y.setValue(getPageHeight() / 2.0);
|
||||
}
|
||||
|
||||
//add view to list
|
||||
const std::vector<App::DocumentObject *> currViews = Views.getValues();
|
||||
std::vector<App::DocumentObject *> newViews(currViews);
|
||||
const std::vector<App::DocumentObject*> currViews = Views.getValues();
|
||||
std::vector<App::DocumentObject*> newViews(currViews);
|
||||
newViews.push_back(docObj);
|
||||
Views.setValues(newViews);
|
||||
|
||||
//check if View fits on Page
|
||||
if ( !view->checkFit(this) ) {
|
||||
Base::Console().Warning("%s is larger than page. Will be scaled.\n", view->getNameInDocument());
|
||||
if (!view->checkFit(this)) {
|
||||
Base::Console().Warning("%s is larger than page. Will be scaled.\n",
|
||||
view->getNameInDocument());
|
||||
view->ScaleType.setValue("Automatic");
|
||||
}
|
||||
|
||||
@@ -285,10 +297,11 @@ int DrawPage::addView(App::DocumentObject *docObj)
|
||||
}
|
||||
|
||||
//Note Views might be removed from document elsewhere so need to check if a View is still in Document here
|
||||
int DrawPage::removeView(App::DocumentObject *docObj)
|
||||
int DrawPage::removeView(App::DocumentObject* docObj)
|
||||
{
|
||||
if(!docObj->isDerivedFrom(TechDraw::DrawView::getClassTypeId()))
|
||||
if (!docObj->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
App::Document* doc = docObj->getDocument();
|
||||
if (!doc) {
|
||||
@@ -297,7 +310,7 @@ int DrawPage::removeView(App::DocumentObject *docObj)
|
||||
|
||||
const char* name = docObj->getNameInDocument();
|
||||
if (!name) {
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
const std::vector<App::DocumentObject*> currViews = Views.getValues();
|
||||
std::vector<App::DocumentObject*> newViews;
|
||||
@@ -334,7 +347,7 @@ void DrawPage::onDocumentRestored()
|
||||
|
||||
void DrawPage::redrawCommand()
|
||||
{
|
||||
// Base::Console().Message("DP::redrawCommand()\n");
|
||||
// Base::Console().Message("DP::redrawCommand()\n");
|
||||
forceRedraw(true);
|
||||
updateAllViews();
|
||||
forceRedraw(false);
|
||||
@@ -342,12 +355,13 @@ void DrawPage::redrawCommand()
|
||||
|
||||
void DrawPage::updateAllViews()
|
||||
{
|
||||
// Base::Console().Message("DP::updateAllViews()\n");
|
||||
std::vector<App::DocumentObject*> featViews = getAllViews(); //unordered list of views within page
|
||||
// Base::Console().Message("DP::updateAllViews()\n");
|
||||
std::vector<App::DocumentObject*> featViews =
|
||||
getAllViews();//unordered list of views within page
|
||||
|
||||
//first, make sure all the Parts have been executed so GeometryObjects exist
|
||||
for(auto& v: featViews) {
|
||||
TechDraw::DrawViewPart *part = dynamic_cast<TechDraw::DrawViewPart *>(v);
|
||||
for (auto& v : featViews) {
|
||||
TechDraw::DrawViewPart* part = dynamic_cast<TechDraw::DrawViewPart*>(v);
|
||||
if (part) {
|
||||
//view, section, detail, dpgi
|
||||
part->recomputeFeature();
|
||||
@@ -355,8 +369,8 @@ void DrawPage::updateAllViews()
|
||||
}
|
||||
//second, do the rest of the views that may depend on a part view
|
||||
//TODO: check if we have 2 layers of dependency (ex. leader > weld > tile?)
|
||||
for(auto& v: featViews) {
|
||||
TechDraw::DrawViewPart *part = dynamic_cast<TechDraw::DrawViewPart *>(v);
|
||||
for (auto& v : featViews) {
|
||||
TechDraw::DrawViewPart* part = dynamic_cast<TechDraw::DrawViewPart*>(v);
|
||||
if (part) {
|
||||
continue;
|
||||
}
|
||||
@@ -371,15 +385,15 @@ void DrawPage::updateAllViews()
|
||||
|
||||
std::vector<App::DocumentObject*> DrawPage::getAllViews(void)
|
||||
{
|
||||
auto views = Views.getValues(); //list of docObjects
|
||||
auto views = Views.getValues();//list of docObjects
|
||||
std::vector<App::DocumentObject*> allViews;
|
||||
for (auto& v: views) {
|
||||
for (auto& v : views) {
|
||||
allViews.push_back(v);
|
||||
if (v->isDerivedFrom(TechDraw::DrawProjGroup::getClassTypeId())) {
|
||||
TechDraw::DrawProjGroup* dpg = static_cast<TechDraw::DrawProjGroup*>(v);
|
||||
if (dpg) { //can't really happen!
|
||||
std::vector<App::DocumentObject*> pgViews = dpg->Views.getValues();
|
||||
allViews.insert(allViews.end(), pgViews.begin(), pgViews.end());
|
||||
if (dpg) {//can't really happen!
|
||||
std::vector<App::DocumentObject*> pgViews = dpg->Views.getValues();
|
||||
allViews.insert(allViews.end(), pgViews.begin(), pgViews.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -397,31 +411,34 @@ void DrawPage::unsetupObject()
|
||||
|
||||
try {
|
||||
const std::vector<App::DocumentObject*> currViews = Views.getValues();
|
||||
for (auto& v: currViews) {
|
||||
for (auto& v : currViews) {
|
||||
//NOTE: the order of objects in Page.Views does not reflect the object hierarchy
|
||||
// this means that a ProjGroup could be deleted before it's child ProjGroupItems.
|
||||
// this causes problems when removing objects from document
|
||||
if (v->isAttachedToDocument()) {
|
||||
std::string viewName = v->getNameInDocument();
|
||||
Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")",
|
||||
docName.c_str(), viewName.c_str());
|
||||
} else {
|
||||
Base::Console().Log("DP::unsetupObject - v(%s) is not in document. skipping\n", pageName.c_str());
|
||||
docName.c_str(),
|
||||
viewName.c_str());
|
||||
}
|
||||
else {
|
||||
Base::Console().Log("DP::unsetupObject - v(%s) is not in document. skipping\n",
|
||||
pageName.c_str());
|
||||
}
|
||||
}
|
||||
std::vector<App::DocumentObject*> emptyViews; //probably superfluous
|
||||
std::vector<App::DocumentObject*> emptyViews;//probably superfluous
|
||||
Views.setValues(emptyViews);
|
||||
|
||||
}
|
||||
catch (...) {
|
||||
Base::Console().Warning("DP::unsetupObject - %s - error while deleting children\n", getNameInDocument());
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
Base::Console().Warning("DP::unsetupObject - %s - error while deleting children\n",
|
||||
getNameInDocument());
|
||||
}
|
||||
|
||||
App::DocumentObject* tmp = Template.getValue();
|
||||
if (tmp) {
|
||||
std::string templateName = Template.getValue()->getNameInDocument();
|
||||
Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")",
|
||||
docName.c_str(), templateName.c_str());
|
||||
Base::Interpreter().runStringArg(
|
||||
"App.getDocument(\"%s\").removeObject(\"%s\")", docName.c_str(), templateName.c_str());
|
||||
}
|
||||
Template.setValue(nullptr);
|
||||
}
|
||||
@@ -434,21 +451,23 @@ int DrawPage::getNextBalloonIndex(void)
|
||||
return result;
|
||||
}
|
||||
|
||||
void DrawPage::handleChangedPropertyType(
|
||||
Base::XMLReader &reader, const char * TypeName, App::Property * prop)
|
||||
void DrawPage::handleChangedPropertyType(Base::XMLReader& reader, const char* TypeName,
|
||||
App::Property* prop)
|
||||
{
|
||||
if (prop == &Scale) {
|
||||
App::PropertyFloat tmp;
|
||||
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { //property in file is Float
|
||||
if (strcmp(tmp.getTypeId().getName(), TypeName) == 0) {//property in file is Float
|
||||
tmp.setContainer(this);
|
||||
tmp.Restore(reader);
|
||||
double tmpValue = tmp.getValue();
|
||||
if (tmpValue > 0.0) {
|
||||
Scale.setValue(tmpValue);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Scale.setValue(1.0);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// has Scale prop that isn't Float!
|
||||
Base::Console().Log("DrawPage::Restore - old Document Scale is Not Float!\n");
|
||||
// no idea
|
||||
@@ -459,12 +478,10 @@ void DrawPage::handleChangedPropertyType(
|
||||
bool DrawPage::canUpdate() const
|
||||
{
|
||||
bool result = false;
|
||||
if (GlobalUpdateDrawings() &&
|
||||
KeepUpdated.getValue()) {
|
||||
if (GlobalUpdateDrawings() && KeepUpdated.getValue()) {
|
||||
result = true;
|
||||
} else if (!GlobalUpdateDrawings() &&
|
||||
AllowPageOverride() &&
|
||||
KeepUpdated.getValue()) {
|
||||
}
|
||||
else if (!GlobalUpdateDrawings() && AllowPageOverride() && KeepUpdated.getValue()) {
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
@@ -486,8 +503,11 @@ bool DrawPage::hasObject(App::DocumentObject* obj)
|
||||
//allow/prevent drawing updates for all Pages
|
||||
bool DrawPage::GlobalUpdateDrawings(void)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/General");
|
||||
bool result = hGrp->GetBool("GlobalUpdateDrawings", true);
|
||||
return result;
|
||||
}
|
||||
@@ -495,8 +515,11 @@ bool DrawPage::GlobalUpdateDrawings(void)
|
||||
//allow/prevent a single page to update despite GlobalUpdateDrawings setting
|
||||
bool DrawPage::AllowPageOverride(void)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/General");
|
||||
bool result = hGrp->GetBool("AllowPageOverride", true);
|
||||
return result;
|
||||
}
|
||||
@@ -504,14 +527,16 @@ bool DrawPage::AllowPageOverride(void)
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
namespace App
|
||||
{
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(TechDraw::DrawPagePython, TechDraw::DrawPage)
|
||||
template<> const char* TechDraw::DrawPagePython::getViewProviderName(void) const {
|
||||
template<> const char* TechDraw::DrawPagePython::getViewProviderName(void) const
|
||||
{
|
||||
return "TechDrawGui::ViewProviderPage";
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class TechDrawExport FeaturePythonT<TechDraw::DrawPage>;
|
||||
}
|
||||
}// namespace App
|
||||
|
||||
@@ -53,7 +53,7 @@ DrawViewAnnotation::DrawViewAnnotation()
|
||||
ADD_PROPERTY_TYPE(Text ,("Default Text"), vgroup, App::Prop_None, "Annotation text");
|
||||
ADD_PROPERTY_TYPE(Font ,(Preferences::labelFont().c_str()),
|
||||
vgroup, App::Prop_None, "Font name");
|
||||
ADD_PROPERTY_TYPE(TextColor, (0.0f, 0.0f, 0.0f), vgroup, App::Prop_None, "Text color");
|
||||
ADD_PROPERTY_TYPE(TextColor, (Preferences::normalColor()), vgroup, App::Prop_None, "Text color");
|
||||
ADD_PROPERTY_TYPE(TextSize, (Preferences::labelFontSizeMM()),
|
||||
vgroup, App::Prop_None, "Text size");
|
||||
ADD_PROPERTY_TYPE(MaxWidth, (-1.0), vgroup, App::Prop_None, "Maximum width of the annotation block.\n -1 means no maximum width.");
|
||||
|
||||
@@ -23,19 +23,19 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
# include <QDomDocument>
|
||||
# include "QDomNodeModel.h"
|
||||
# include <QXmlQuery>
|
||||
# include <QXmlResultItems>
|
||||
#include "QDomNodeModel.h"
|
||||
#include <QDomDocument>
|
||||
#include <QXmlQuery>
|
||||
#include <QXmlResultItems>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include "DrawViewSymbol.h"
|
||||
#include "DrawViewSymbolPy.h" // generated from DrawViewSymbolPy.xml
|
||||
#include "DrawPage.h"
|
||||
#include "DrawUtil.h"
|
||||
#include "DrawViewSymbol.h"
|
||||
#include "DrawViewSymbolPy.h"// generated from DrawViewSymbolPy.xml
|
||||
|
||||
|
||||
using namespace TechDraw;
|
||||
@@ -49,18 +49,17 @@ PROPERTY_SOURCE(TechDraw::DrawViewSymbol, TechDraw::DrawView)
|
||||
|
||||
DrawViewSymbol::DrawViewSymbol()
|
||||
{
|
||||
static const char *vgroup = "Drawing view";
|
||||
static const char* vgroup = "Drawing view";
|
||||
|
||||
ADD_PROPERTY_TYPE(Symbol, (""), vgroup, App::Prop_None, "The SVG code defining this symbol");
|
||||
ADD_PROPERTY_TYPE(EditableTexts, (""), vgroup, App::Prop_None, "Substitution values for the editable strings in this symbol");
|
||||
ADD_PROPERTY_TYPE(EditableTexts, (""), vgroup, App::Prop_None,
|
||||
"Substitution values for the editable strings in this symbol");
|
||||
ScaleType.setValue("Custom");
|
||||
Scale.setStatus(App::Property::ReadOnly, false);
|
||||
Symbol.setStatus(App::Property::Hidden, true);
|
||||
}
|
||||
|
||||
DrawViewSymbol::~DrawViewSymbol()
|
||||
{
|
||||
}
|
||||
DrawViewSymbol::~DrawViewSymbol() {}
|
||||
|
||||
void DrawViewSymbol::onChanged(const App::Property* prop)
|
||||
{
|
||||
@@ -69,7 +68,8 @@ void DrawViewSymbol::onChanged(const App::Property* prop)
|
||||
std::vector<std::string> editables = getEditableFields();
|
||||
EditableTexts.setValues(editables);
|
||||
}
|
||||
} else if (prop == &EditableTexts) {
|
||||
}
|
||||
else if (prop == &EditableTexts) {
|
||||
//this will change Symbol, which will call onChanged(Symbol),
|
||||
//which will change EditableTexts, but the loop stops after
|
||||
//1 cycle
|
||||
@@ -79,7 +79,7 @@ void DrawViewSymbol::onChanged(const App::Property* prop)
|
||||
TechDraw::DrawView::onChanged(prop);
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *DrawViewSymbol::execute()
|
||||
App::DocumentObjectExecReturn* DrawViewSymbol::execute()
|
||||
{
|
||||
//nothing to do. DVS is just a container for properties.
|
||||
//the action takes place on the Gui side.
|
||||
@@ -88,9 +88,9 @@ App::DocumentObjectExecReturn *DrawViewSymbol::execute()
|
||||
|
||||
QRectF DrawViewSymbol::getRect() const
|
||||
{
|
||||
double w = 64.0; //must default to something
|
||||
double h = 64.0;
|
||||
return (QRectF(0, 0,w, h));
|
||||
double w = 64.0;//must default to something
|
||||
double h = 64.0;
|
||||
return (QRectF(0, 0, w, h));
|
||||
}
|
||||
|
||||
//!Assume all svg files fit the page and/or the user will scale manually
|
||||
@@ -117,15 +117,15 @@ std::vector<std::string> DrawViewSymbol::getEditableFields()
|
||||
|
||||
// XPath query to select all <tspan> nodes whose <text> parent
|
||||
// has "freecad:editable" attribute
|
||||
query.setQuery(QString::fromUtf8(
|
||||
"declare default element namespace \"" SVG_NS_URI "\"; "
|
||||
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
|
||||
"//text[@freecad:editable]/tspan"));
|
||||
query.setQuery(QString::fromUtf8("declare default element namespace \"" SVG_NS_URI "\"; "
|
||||
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
|
||||
"//text[@freecad:editable]/tspan"));
|
||||
|
||||
query.evaluateTo(&queryResult);
|
||||
|
||||
while (!queryResult.next().isNull()) {
|
||||
QDomElement tspan = model.toDomNode(queryResult.current().toNodeModelIndex()).toElement();
|
||||
QDomElement tspan =
|
||||
model.toDomNode(queryResult.current().toNodeModelIndex()).toElement();
|
||||
QString editableValue = tspan.firstChild().nodeValue();
|
||||
editables.emplace_back(editableValue.toUtf8().constData());
|
||||
}
|
||||
@@ -153,19 +153,19 @@ void DrawViewSymbol::updateFieldsInSymbol()
|
||||
|
||||
// XPath query to select all <tspan> nodes whose <text> parent
|
||||
// has "freecad:editable" attribute
|
||||
query.setQuery(QString::fromUtf8(
|
||||
"declare default element namespace \"" SVG_NS_URI "\"; "
|
||||
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
|
||||
"//text[@freecad:editable]/tspan"));
|
||||
query.setQuery(QString::fromUtf8("declare default element namespace \"" SVG_NS_URI "\"; "
|
||||
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
|
||||
"//text[@freecad:editable]/tspan"));
|
||||
query.evaluateTo(&queryResult);
|
||||
|
||||
unsigned int count = 0;
|
||||
while (!queryResult.next().isNull())
|
||||
{
|
||||
QDomElement tspanElement = model.toDomNode(queryResult.current().toNodeModelIndex()).toElement();
|
||||
while (!queryResult.next().isNull()) {
|
||||
QDomElement tspanElement =
|
||||
model.toDomNode(queryResult.current().toNodeModelIndex()).toElement();
|
||||
|
||||
// Keep all spaces in the text node
|
||||
tspanElement.setAttribute(QString::fromUtf8("xml:space"), QString::fromUtf8("preserve"));
|
||||
tspanElement.setAttribute(QString::fromUtf8("xml:space"),
|
||||
QString::fromUtf8("preserve"));
|
||||
|
||||
// Remove all child nodes (if any)
|
||||
while (!tspanElement.lastChild().isNull()) {
|
||||
@@ -173,8 +173,8 @@ void DrawViewSymbol::updateFieldsInSymbol()
|
||||
}
|
||||
|
||||
// Finally append text node with editable replacement as the only <tspan> descendant
|
||||
tspanElement.appendChild(symbolDocument.createTextNode(
|
||||
QString::fromUtf8(editText[count].c_str())));
|
||||
tspanElement.appendChild(
|
||||
symbolDocument.createTextNode(QString::fromUtf8(editText[count].c_str())));
|
||||
++count;
|
||||
}
|
||||
Symbol.setValue(symbolDocument.toString(1).toStdString());
|
||||
@@ -186,6 +186,9 @@ bool DrawViewSymbol::loadQDomDocument(QDomDocument& symbolDocument)
|
||||
{
|
||||
const char* symbol = Symbol.getValue();
|
||||
QByteArray qba(symbol);
|
||||
if (qba.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
QString errorMsg;
|
||||
int errorLine;
|
||||
int errorCol;
|
||||
@@ -193,15 +196,16 @@ bool DrawViewSymbol::loadQDomDocument(QDomDocument& symbolDocument)
|
||||
bool rc = symbolDocument.setContent(qba, nsProcess, &errorMsg, &errorLine, &errorCol);
|
||||
if (!rc) {
|
||||
//invalid SVG message
|
||||
Base::Console().Warning("DrawViewSymbol - %s - SVG for Symbol is not valid. See log.\n");
|
||||
Base::Console().Warning("DrawViewSymbol - %s - SVG for Symbol is not valid. See log.\n",
|
||||
getNameInDocument());
|
||||
Base::Console().Log("DrawViewSymbol - %s - len: %d rc: %d error: %s line: %d col: %d\n",
|
||||
getNameInDocument(), strlen(symbol), rc,
|
||||
qPrintable(errorMsg), errorLine, errorCol);
|
||||
getNameInDocument(), strlen(symbol), rc, qPrintable(errorMsg),
|
||||
errorLine, errorCol);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
PyObject *DrawViewSymbol::getPyObject()
|
||||
PyObject* DrawViewSymbol::getPyObject()
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
@@ -212,14 +216,16 @@ PyObject *DrawViewSymbol::getPyObject()
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
namespace App
|
||||
{
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(TechDraw::DrawViewSymbolPython, TechDraw::DrawViewSymbol)
|
||||
template<> const char* TechDraw::DrawViewSymbolPython::getViewProviderName() const {
|
||||
template<> const char* TechDraw::DrawViewSymbolPython::getViewProviderName() const
|
||||
{
|
||||
return "TechDrawGui::ViewProviderSymbol";
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class TechDrawExport FeaturePythonT<TechDraw::DrawViewSymbol>;
|
||||
}
|
||||
}// namespace App
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <string>
|
||||
#include <QString>
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -45,9 +45,11 @@ const double Preferences::DefaultFontSizeInMM = 5.0;
|
||||
|
||||
std::string Preferences::labelFont()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Labels");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Labels");
|
||||
std::string fontName = hGrp->GetASCII("LabelFont", "osifont");
|
||||
return fontName;
|
||||
}
|
||||
@@ -60,40 +62,50 @@ QString Preferences::labelFontQString()
|
||||
|
||||
double Preferences::labelFontSizeMM()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Labels");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Labels");
|
||||
return hGrp->GetFloat("LabelSize", DefaultFontSizeInMM);
|
||||
}
|
||||
|
||||
double Preferences::dimFontSizeMM()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Dimensions");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Dimensions");
|
||||
return hGrp->GetFloat("FontSize", DefaultFontSizeInMM);
|
||||
}
|
||||
|
||||
App::Color Preferences::normalColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Colors");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x000000FF)); //#000000 black
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x000000FF));//#000000 black
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
App::Color Preferences::selectColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("View");
|
||||
unsigned int defColor = hGrp->GetUnsigned("SelectionColor", 0x00FF00FF); //#00FF00 lime
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("View");
|
||||
unsigned int defColor = hGrp->GetUnsigned("SelectionColor", 0x00FF00FF);//#00FF00 lime
|
||||
|
||||
hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Colors");
|
||||
hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("SelectColor", defColor));
|
||||
return fcColor;
|
||||
@@ -101,14 +113,18 @@ App::Color Preferences::selectColor()
|
||||
|
||||
App::Color Preferences::preselectColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("View");
|
||||
unsigned int defColor = hGrp->GetUnsigned("HighlightColor", 0xFFFF00FF); //#FFFF00 yellow
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("View");
|
||||
unsigned int defColor = hGrp->GetUnsigned("HighlightColor", 0xFFFF00FF);//#FFFF00 yellow
|
||||
|
||||
hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Colors");
|
||||
hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("PreSelectColor", defColor));
|
||||
return fcColor;
|
||||
@@ -116,26 +132,34 @@ App::Color Preferences::preselectColor()
|
||||
|
||||
App::Color Preferences::vertexColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Decorations");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Decorations");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("VertexColor", 0x000000FF)); //#000000 black
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("VertexColor", 0x000000FF));//#000000 black
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
double Preferences::vertexScale()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/General");
|
||||
double result = hGrp->GetFloat("VertexScale", 3.0);
|
||||
return result;
|
||||
}
|
||||
|
||||
int Preferences::scaleType()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/General");
|
||||
int result = hGrp->GetInt("DefaultScaleType", 0);
|
||||
return result;
|
||||
}
|
||||
@@ -143,25 +167,32 @@ int Preferences::scaleType()
|
||||
double Preferences::scale()
|
||||
{
|
||||
int prefScaleType = scaleType();
|
||||
if (prefScaleType == 0) { //page scale
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
if (prefScaleType == 0) {//page scale
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/General");
|
||||
return hGrp->GetFloat("DefaultPageScale", 1.0);
|
||||
} else if (prefScaleType == 1) { //custom scale
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
}
|
||||
else if (prefScaleType == 1) {//custom scale
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/General");
|
||||
return hGrp->GetFloat("DefaultViewScale", 1.0);
|
||||
}
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
//lightgray #D3D3D3
|
||||
|
||||
bool Preferences::keepPagesUpToDate()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/General");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/General");
|
||||
bool autoUpdate = hGrp->GetBool("KeepPagesUpToDate", true);
|
||||
return autoUpdate;
|
||||
}
|
||||
@@ -169,45 +200,55 @@ bool Preferences::keepPagesUpToDate()
|
||||
bool Preferences::useGlobalDecimals()
|
||||
{
|
||||
bool result = false;
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().
|
||||
GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Dimensions");
|
||||
result = hGrp->GetBool("UseGlobalDecimals", true);
|
||||
return result;
|
||||
}
|
||||
|
||||
int Preferences::projectionAngle()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/General");
|
||||
int projType = hGrp->GetInt("ProjectionAngle", 0); //First Angle
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/General");
|
||||
int projType = hGrp->GetInt("ProjectionAngle", 0);//First Angle
|
||||
return projType;
|
||||
}
|
||||
|
||||
int Preferences::lineGroup()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Decorations");
|
||||
int lgInt = hGrp->GetInt("LineGroup", 3); // FC 0.70mm
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Decorations");
|
||||
int lgInt = hGrp->GetInt("LineGroup", 3);// FC 0.70mm
|
||||
return lgInt;
|
||||
}
|
||||
|
||||
int Preferences::balloonArrow()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Decorations");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Decorations");
|
||||
int end = hGrp->GetInt("BalloonArrow", 0);
|
||||
return end;
|
||||
}
|
||||
|
||||
QString Preferences::defaultTemplate()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Files");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Files");
|
||||
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Templates/";
|
||||
std::string defaultFileName = defaultDir + "A4_LandscapeTD.svg";
|
||||
std::string prefFileName = hGrp->GetASCII("TemplateFile", defaultFileName.c_str());
|
||||
@@ -225,8 +266,11 @@ QString Preferences::defaultTemplate()
|
||||
|
||||
QString Preferences::defaultTemplateDir()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Files");
|
||||
|
||||
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Templates";
|
||||
std::string prefTemplateDir = hGrp->GetASCII("TemplateDir", defaultDir.c_str());
|
||||
@@ -236,17 +280,20 @@ QString Preferences::defaultTemplateDir()
|
||||
QString templateDir = QString::fromStdString(prefTemplateDir);
|
||||
Base::FileInfo fi(prefTemplateDir);
|
||||
if (!fi.isReadable()) {
|
||||
Base::Console().Warning("Template Directory: %s is not readable\n", prefTemplateDir.c_str());
|
||||
Base::Console().Warning("Template Directory: %s is not readable\n",
|
||||
prefTemplateDir.c_str());
|
||||
templateDir = QString::fromStdString(defaultDir);
|
||||
}
|
||||
}
|
||||
return templateDir;
|
||||
}
|
||||
|
||||
std::string Preferences::lineGroupFile()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().
|
||||
GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Files");
|
||||
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/LineGroup/";
|
||||
std::string defaultFileName = defaultDir + "LineGroup.csv";
|
||||
std::string lgFileName = hGrp->GetASCII("LineGroupFile", defaultFileName.c_str());
|
||||
@@ -263,31 +310,42 @@ std::string Preferences::lineGroupFile()
|
||||
|
||||
std::string Preferences::formatSpec()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Dimensions");
|
||||
return hGrp->GetASCII("formatSpec", "%.2w");
|
||||
}
|
||||
|
||||
int Preferences::altDecimals()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Dimensions");
|
||||
return hGrp->GetInt("AltDecimals", 2);
|
||||
}
|
||||
|
||||
int Preferences::mattingStyle()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Decorations");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Decorations");
|
||||
int style = hGrp->GetInt("MattingStyle", 0);
|
||||
return style;
|
||||
}
|
||||
|
||||
std::string Preferences::svgFile()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Files");
|
||||
|
||||
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Patterns/";
|
||||
std::string defaultFileName = defaultDir + "simple.svg";
|
||||
@@ -305,8 +363,11 @@ std::string Preferences::svgFile()
|
||||
|
||||
std::string Preferences::patFile()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/PAT");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/PAT");
|
||||
|
||||
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/PAT/";
|
||||
std::string defaultFileName = defaultDir + "FCPAT.pat";
|
||||
@@ -325,8 +386,11 @@ std::string Preferences::patFile()
|
||||
|
||||
std::string Preferences::bitmapFill()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Files");
|
||||
|
||||
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Patterns/";
|
||||
std::string defaultFileName = defaultDir + "default.png";
|
||||
@@ -344,27 +408,130 @@ std::string Preferences::bitmapFill()
|
||||
|
||||
double Preferences::GapISO()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Dimensions");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Dimensions");
|
||||
double factor = hGrp->GetFloat("GapISO", 8.0);
|
||||
return factor;
|
||||
}
|
||||
|
||||
double Preferences::GapASME()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Dimensions");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Dimensions");
|
||||
double factor = hGrp->GetFloat("GapASME", 6.0);
|
||||
return factor;
|
||||
}
|
||||
|
||||
bool Preferences::reportProgress()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/General");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/General");
|
||||
bool report = hGrp->GetBool("ReportProgress", false);
|
||||
return report;
|
||||
}
|
||||
|
||||
bool Preferences::lightOnDark()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Colors");
|
||||
bool light = hGrp->GetBool("LightOnDark", false);
|
||||
return light;
|
||||
}
|
||||
|
||||
void Preferences::lightOnDark(bool state)
|
||||
{
|
||||
Base::Console().Message("Pref::useLightText - set to %d\n", state);
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Colors");
|
||||
hGrp->SetBool("LightOnDark", state);
|
||||
}
|
||||
|
||||
bool Preferences::monochrome()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Colors");
|
||||
bool mono = hGrp->GetBool("Monochrome", false);
|
||||
return mono;
|
||||
}
|
||||
|
||||
void Preferences::monochrome(bool state)
|
||||
{
|
||||
Base::Console().Message("Pref::useLightText - set to %d\n", state);
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Colors");
|
||||
hGrp->SetBool("Monochrome", state);
|
||||
}
|
||||
|
||||
App::Color Preferences::lightTextColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color result;
|
||||
result.setPackedValue(hGrp->GetUnsigned("LightTextColor", 0xFFFFFFFF));//#FFFFFFFF white
|
||||
return result;
|
||||
}
|
||||
|
||||
App::Color Preferences::lightenColor(App::Color orig)
|
||||
{
|
||||
// get component colours on [0, 255]
|
||||
uchar red = orig.r * 255;
|
||||
uchar blue = orig.b * 255;
|
||||
uchar green = orig.g * 255;
|
||||
// uchar alpha = orig.a * 255;
|
||||
|
||||
// shift color values
|
||||
uchar m = std::min({red, blue, green});
|
||||
red -= m;
|
||||
blue -= m;
|
||||
green -= m;
|
||||
|
||||
// calculate chroma (colour range)
|
||||
uchar chroma = std::max({red, blue, green});
|
||||
|
||||
// calculate lightened colour value
|
||||
uchar newm = 255 - chroma - m;
|
||||
red += newm;
|
||||
green += newm;
|
||||
blue += newm;
|
||||
|
||||
double redF = (float)red / 255.0;
|
||||
double greenF = (float)green / 255.0;
|
||||
double blueF = (float)blue / 255.0;
|
||||
|
||||
return App::Color(redF, greenF, blueF, orig.a);
|
||||
}
|
||||
|
||||
App::Color Preferences::getAccessibleColor(App::Color orig)
|
||||
{
|
||||
if (Preferences::lightOnDark() && Preferences::monochrome()) {
|
||||
return lightTextColor();
|
||||
}
|
||||
if (Preferences::lightOnDark()) {
|
||||
return lightenColor(orig);
|
||||
}
|
||||
return orig;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
|
||||
class QString;
|
||||
class QColor;
|
||||
|
||||
namespace App
|
||||
{
|
||||
@@ -39,50 +40,59 @@ namespace TechDraw
|
||||
{
|
||||
|
||||
//getters for parameters used in multiple places.
|
||||
class TechDrawExport Preferences {
|
||||
class TechDrawExport Preferences
|
||||
{
|
||||
|
||||
public:
|
||||
static std::string labelFont();
|
||||
static QString labelFontQString();
|
||||
static double labelFontSizeMM();
|
||||
static double dimFontSizeMM();
|
||||
static std::string labelFont();
|
||||
static QString labelFontQString();
|
||||
static double labelFontSizeMM();
|
||||
static double dimFontSizeMM();
|
||||
|
||||
static App::Color normalColor();
|
||||
static App::Color selectColor();
|
||||
static App::Color preselectColor();
|
||||
static App::Color vertexColor();
|
||||
static double vertexScale();
|
||||
static int scaleType();
|
||||
static double scale();
|
||||
static bool useGlobalDecimals();
|
||||
static bool keepPagesUpToDate();
|
||||
static App::Color normalColor();
|
||||
static App::Color selectColor();
|
||||
static App::Color preselectColor();
|
||||
static App::Color vertexColor();
|
||||
static double vertexScale();
|
||||
static int scaleType();
|
||||
static double scale();
|
||||
static bool useGlobalDecimals();
|
||||
static bool keepPagesUpToDate();
|
||||
|
||||
static int projectionAngle();
|
||||
static int lineGroup();
|
||||
static int projectionAngle();
|
||||
static int lineGroup();
|
||||
|
||||
static int balloonArrow();
|
||||
static int balloonArrow();
|
||||
|
||||
static QString defaultTemplate();
|
||||
static QString defaultTemplateDir();
|
||||
static std::string lineGroupFile();
|
||||
static QString defaultTemplate();
|
||||
static QString defaultTemplateDir();
|
||||
static std::string lineGroupFile();
|
||||
|
||||
static const double DefaultFontSizeInMM;
|
||||
static const double DefaultFontSizeInMM;
|
||||
|
||||
static std::string formatSpec();
|
||||
static int altDecimals();
|
||||
static std::string formatSpec();
|
||||
static int altDecimals();
|
||||
|
||||
static int mattingStyle();
|
||||
static int mattingStyle();
|
||||
|
||||
static std::string svgFile();
|
||||
static std::string patFile();
|
||||
static std::string svgFile();
|
||||
static std::string patFile();
|
||||
|
||||
static std::string bitmapFill();
|
||||
static std::string bitmapFill();
|
||||
|
||||
static double GapISO();
|
||||
static double GapASME();
|
||||
static double GapISO();
|
||||
static double GapASME();
|
||||
|
||||
static bool reportProgress();
|
||||
static bool reportProgress();
|
||||
|
||||
static bool lightOnDark();
|
||||
static void lightOnDark(bool state);
|
||||
static bool monochrome();
|
||||
static void monochrome(bool state);
|
||||
static App::Color lightTextColor();
|
||||
static App::Color lightenColor(App::Color orig);
|
||||
static App::Color getAccessibleColor(App::Color orig);
|
||||
};
|
||||
|
||||
} //end namespace TechDraw
|
||||
}//end namespace TechDraw
|
||||
#endif
|
||||
|
||||
@@ -49,6 +49,7 @@ set(TechDrawGui_LIBS
|
||||
qt_add_resources(TechDrawGui_SRCS Resources/TechDraw.qrc)
|
||||
|
||||
set(TechDrawGui_UIC_SRCS
|
||||
DlgStringListEditor.ui
|
||||
DlgPageChooser.ui
|
||||
DlgPrefsTechDrawAdvanced.ui
|
||||
DlgPrefsTechDrawAnnotation.ui
|
||||
@@ -115,6 +116,9 @@ SET(TechDrawGui_SRCS
|
||||
TaskProjGroup.ui
|
||||
TaskProjGroup.cpp
|
||||
TaskProjGroup.h
|
||||
DlgStringListEditor.ui
|
||||
DlgStringListEditor.cpp
|
||||
DlgStringListEditor.h
|
||||
DlgPageChooser.ui
|
||||
DlgPageChooser.cpp
|
||||
DlgPageChooser.h
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>440</width>
|
||||
<height>368</height>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -49,63 +49,19 @@
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Normal">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Normal</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Normal">
|
||||
<item row="10" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcbLightTextColor">
|
||||
<property name="toolTip">
|
||||
<string>Normal line color</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
<string>Monochrome text color</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>NormalColor</cstring>
|
||||
<cstring>LightTextColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="lbl_Hidden">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hidden Line</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Hidden">
|
||||
<property name="toolTip">
|
||||
@@ -126,114 +82,8 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_PreSelect">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Preselected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_PreSelect">
|
||||
<property name="toolTip">
|
||||
<string>Preselection color</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>PreSelectColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Section Face</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Surface">
|
||||
<property name="toolTip">
|
||||
<string>Section face color</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>211</red>
|
||||
<green>211</green>
|
||||
<blue>211</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CutSurfaceColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_Select">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Select">
|
||||
<property name="toolTip">
|
||||
<string>Selected item color</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>255</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SelectColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Section Line</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcbSectionLine">
|
||||
<property name="toolTip">
|
||||
<string>Section line color</string>
|
||||
</property>
|
||||
<item row="6" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcbHighlight">
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
@@ -242,84 +92,13 @@
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SectionColor</cstring>
|
||||
<cstring>HighlightColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>/Mod/TechDraw/Decorations</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Background</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Background">
|
||||
<property name="toolTip">
|
||||
<string>Background color around pages</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>211</red>
|
||||
<green>211</green>
|
||||
<blue>211</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Background</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>/Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hatch</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Hatch">
|
||||
<property name="toolTip">
|
||||
<string>Hatch image color</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Hatch</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>/Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>Dimension</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcbDimColor">
|
||||
<property name="toolTip">
|
||||
@@ -340,6 +119,200 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Background</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_PreSelect">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Preselected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Grid Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Detail Highlight</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_Select">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Selected</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="pcbLightOnDark">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Check this to use light text and lines on dark backgrounds. Set Page Color to a dark color. Transparent or light color faces are recommended with this option.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Light on dark</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>LightOnDark</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>/Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Hatch">
|
||||
<property name="toolTip">
|
||||
<string>Hatch image color</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Hatch</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>/Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcbMarkup">
|
||||
<property name="toolTip">
|
||||
<string>Default color for leader lines</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Color</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/TechDraw/Markups</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="3">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Page Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Background">
|
||||
<property name="toolTip">
|
||||
<string>Background color around pages</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>211</red>
|
||||
<green>211</green>
|
||||
<blue>211</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Background</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>/Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Section Face</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Section Line</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Centerline</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Grid">
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>gridColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>/Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="font">
|
||||
@@ -352,10 +325,34 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_GeomHatch">
|
||||
<item row="6" column="3">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Leaderline</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hatch</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcbSectionLine">
|
||||
<property name="toolTip">
|
||||
<string>Geometric hatch pattern color</string>
|
||||
<string>Section line color</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
@@ -365,17 +362,102 @@
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>GeomHatch</cstring>
|
||||
<cstring>SectionColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>/Mod/TechDraw/Decorations</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Face">
|
||||
<property name="toolTip">
|
||||
<string>Face color (if not transparent)</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>FaceColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>/Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_PreSelect">
|
||||
<property name="toolTip">
|
||||
<string>Preselection color</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>PreSelectColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="lbl_Hidden">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Centerline</string>
|
||||
<string>Hidden Line</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcbPageColor">
|
||||
<property name="toolTip">
|
||||
<string>Use a light color for dark text and dark color for light text.</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>PageColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Select">
|
||||
<property name="toolTip">
|
||||
<string>Selected item color</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>255</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>SelectColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -406,6 +488,46 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Normal">
|
||||
<property name="toolTip">
|
||||
<string>Normal line color</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>NormalColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Surface">
|
||||
<property name="toolTip">
|
||||
<string>Section face color</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>211</red>
|
||||
<green>211</green>
|
||||
<blue>211</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>CutSurfaceColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcbVertexColor">
|
||||
<property name="toolTip">
|
||||
@@ -426,92 +548,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Detail Highlight</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcbHighlight">
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>HighlightColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>/Mod/TechDraw/Decorations</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="3">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Leaderline</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcbMarkup">
|
||||
<property name="toolTip">
|
||||
<string>Default color for leader lines</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Color</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/TechDraw/Markups</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Grid Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Grid">
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>gridColor</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>/Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="7" column="3">
|
||||
<widget class="Gui::PrefCheckBox" name="pcb_PaintFaces">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@@ -538,27 +575,69 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_Face">
|
||||
<item row="4" column="4">
|
||||
<widget class="Gui::PrefColorButton" name="pcb_GeomHatch">
|
||||
<property name="toolTip">
|
||||
<string>Face color (if not transparent)</string>
|
||||
<string>Geometric hatch pattern color</string>
|
||||
</property>
|
||||
<property name="color">
|
||||
<color>
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>FaceColor</cstring>
|
||||
<cstring>GeomHatch</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>/Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_Normal">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Normal</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>Dimension</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="pcbMonochrome">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>If checked FreeCAD will use a single colour for all text and lines. If unchecked FreeCAD will attempt to use lighter versions of preferred colours.</p><p><br/></p><p><br/></p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Monochrome</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>Monochrome</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>/Mod/TechDraw/Colors</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -572,7 +651,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><span style=" font-weight:600;">Note:</span> Items in <span style=" font-style:italic;">italics</span> are default values for new objects. They have no effect on existing objects.</p></body></html></string>
|
||||
<string><html><head/><body><p><span style=" font-weight:600;">Note:</span> Items in <span style=" font-style:italic;">italics</span> are default values for new objects. They have no effect on existing objects.</p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
|
||||
@@ -61,6 +61,10 @@ void DlgPrefsTechDrawColorsImp::saveSettings()
|
||||
ui->pcbMarkup->onSave();
|
||||
ui->pcbHighlight->onSave();
|
||||
ui->pcb_Grid->onSave();
|
||||
ui->pcbPageColor->onSave();
|
||||
ui->pcbLightOnDark->onSave();
|
||||
ui->pcbMonochrome->onSave();
|
||||
ui->pcbLightTextColor->onSave();
|
||||
}
|
||||
|
||||
void DlgPrefsTechDrawColorsImp::loadSettings()
|
||||
@@ -82,6 +86,10 @@ void DlgPrefsTechDrawColorsImp::loadSettings()
|
||||
ui->pcbMarkup->onRestore();
|
||||
ui->pcbHighlight->onRestore();
|
||||
ui->pcb_Grid->onRestore();
|
||||
ui->pcbPageColor->onRestore();
|
||||
ui->pcbLightOnDark->onRestore();
|
||||
ui->pcbMonochrome->onRestore();
|
||||
ui->pcbLightTextColor->onRestore();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
140
src/Mod/TechDraw/Gui/DlgStringListEditor.cpp
Normal file
140
src/Mod/TechDraw/Gui/DlgStringListEditor.cpp
Normal file
@@ -0,0 +1,140 @@
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
****************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <QList>
|
||||
#include <QListWidgetItem>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>// for FC_LOG_LEVEL_INIT
|
||||
#include <Base/Tools.h>
|
||||
|
||||
#include "DlgStringListEditor.h"
|
||||
#include "ui_DlgStringListEditor.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
/* TRANSLATOR Gui::DlgStringListEditor */
|
||||
|
||||
DlgStringListEditor::DlgStringListEditor(const std::vector<std::string> texts, QWidget* parent,
|
||||
Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl),
|
||||
ui(new Ui_DlgStringListEditor)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->lwTexts->setSortingEnabled(false);
|
||||
|
||||
fillList(texts);
|
||||
|
||||
connect(ui->lwTexts,
|
||||
SIGNAL(itemActivated(QListWidgetItem*)),
|
||||
this,
|
||||
SLOT(slotItemActivated(QListWidgetItem*)));
|
||||
connect(ui->pbAdd, SIGNAL(clicked()), this, SLOT(slotAddItem()));
|
||||
connect(ui->pbRemove, SIGNAL(clicked()), this, SLOT(slotRemoveItem()));
|
||||
connect(ui->bbButtons, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(ui->bbButtons, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
DlgStringListEditor::~DlgStringListEditor()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DlgStringListEditor::fillList(std::vector<std::string> texts)
|
||||
{
|
||||
QString qText;
|
||||
int textCount = texts.size();
|
||||
int i = 0;
|
||||
for (; i < textCount; i++) {
|
||||
qText = Base::Tools::fromStdString(texts[i]);
|
||||
QListWidgetItem* item = new QListWidgetItem(qText);
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
ui->lwTexts->addItem(item);
|
||||
}
|
||||
//add a blank line at the end to allow extending the list
|
||||
QListWidgetItem* item = new QListWidgetItem(QString::fromUtf8(""));
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
ui->lwTexts->addItem(item);
|
||||
}
|
||||
|
||||
void DlgStringListEditor::slotItemActivated(QListWidgetItem* item)
|
||||
{
|
||||
ui->lwTexts->editItem(item);
|
||||
}
|
||||
|
||||
void DlgStringListEditor::slotAddItem()
|
||||
{
|
||||
QString newText = ui->leNewItem->text();
|
||||
QListWidgetItem* item = new QListWidgetItem(newText);
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
int row = ui->lwTexts->currentRow();
|
||||
if (row < 0) {
|
||||
//no location set yet, add to end of list
|
||||
ui->lwTexts->addItem(item);
|
||||
}
|
||||
else {
|
||||
//insert item at current row and push the rest down 1 position
|
||||
ui->lwTexts->insertItem(row, item);
|
||||
}
|
||||
ui->leNewItem->clear();
|
||||
//TODO: how to append to end of list?
|
||||
}
|
||||
|
||||
void DlgStringListEditor::slotRemoveItem()
|
||||
{
|
||||
int row = ui->lwTexts->currentRow();
|
||||
if (row >= 0) {
|
||||
auto item = ui->lwTexts->takeItem(row);
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> DlgStringListEditor::getTexts() const
|
||||
{
|
||||
std::vector<std::string> outTexts;
|
||||
for (int iRow = 0; iRow < ui->lwTexts->count(); iRow++) {
|
||||
QString itemText = ui->lwTexts->item(iRow)->text();
|
||||
outTexts.push_back(Base::Tools::toStdString(itemText));
|
||||
}
|
||||
if (outTexts.back().empty()) {
|
||||
outTexts.pop_back();
|
||||
}
|
||||
return outTexts;
|
||||
}
|
||||
|
||||
void DlgStringListEditor::accept()
|
||||
{
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void DlgStringListEditor::reject()
|
||||
{
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
#include "moc_DlgStringListEditor.cpp"
|
||||
62
src/Mod/TechDraw/Gui/DlgStringListEditor.h
Normal file
62
src/Mod/TechDraw/Gui/DlgStringListEditor.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2022 Wanderer Fan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
****************************************************************************/
|
||||
#ifndef GUI_DLGEDITABLETEXT_H
|
||||
#define GUI_DLGEDITABLETEXT_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QListWidgetItem;
|
||||
|
||||
namespace TechDrawGui {
|
||||
|
||||
class Ui_DlgStringListEditor;
|
||||
class TechDrawGuiExport DlgStringListEditor : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgStringListEditor(const std::vector<std::string> texts,
|
||||
QWidget* parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags());
|
||||
~DlgStringListEditor();
|
||||
|
||||
std::vector<std::string> getTexts() const;
|
||||
void accept();
|
||||
void reject();
|
||||
|
||||
public Q_SLOTS:
|
||||
void slotItemActivated(QListWidgetItem* item);
|
||||
void slotAddItem();
|
||||
void slotRemoveItem();
|
||||
|
||||
private:
|
||||
void fillList(std::vector<std::string> texts);
|
||||
|
||||
Ui_DlgStringListEditor* ui;
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
|
||||
#endif // GUI_DLGEDITABLETEXT_H
|
||||
|
||||
140
src/Mod/TechDraw/Gui/DlgStringListEditor.ui
Normal file
140
src/Mod/TechDraw/Gui/DlgStringListEditor.ui
Normal file
@@ -0,0 +1,140 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TechDrawGui::DlgStringListEditor</class>
|
||||
<widget class="QDialog" name="TechDrawGui::DlgStringListEditor">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::WindowModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>360</width>
|
||||
<height>331</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>String List Editor</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="modal">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QListWidget" name="lwTexts">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Double click to edit a line. New lines are added at the current location in the list.</p></body></html></string>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed|QAbstractItemView::SelectedClicked</set>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbAdd">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/list-add.svg</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leNewItem"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbRemove">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../Gui/Icons/resource.qrc">
|
||||
<normaloff>:/icons/list-remove.svg</normaloff>:/icons/list-remove.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="bbButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="Resources/TechDraw.qrc"/>
|
||||
<include location="../../../Gui/Icons/resource.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>bbButtons</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>TechDrawGui::DlgStringListEditor</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>179</x>
|
||||
<y>228</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>179</x>
|
||||
<y>139</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>bbButtons</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>TechDrawGui::DlgStringListEditor</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>179</x>
|
||||
<y>228</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>179</x>
|
||||
<y>139</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -91,7 +91,12 @@ App::Color PreferencesGui::sectionLineColor()
|
||||
|
||||
QColor PreferencesGui::sectionLineQColor()
|
||||
{
|
||||
return sectionLineColor().asValue<QColor>();
|
||||
//if the App::Color version has already lightened the color, we don't want to do it agin
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("SectionColor", 0x000000FF));
|
||||
return fcColor.asValue<QColor>();
|
||||
}
|
||||
|
||||
App::Color PreferencesGui::centerColor()
|
||||
@@ -105,7 +110,11 @@ App::Color PreferencesGui::centerColor()
|
||||
|
||||
QColor PreferencesGui::centerQColor()
|
||||
{
|
||||
return centerColor().asValue<QColor>();
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Decorations");
|
||||
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("CenterColor", 0x000000FF));
|
||||
return fcColor.asValue<QColor>();
|
||||
}
|
||||
|
||||
QColor PreferencesGui::vertexQColor()
|
||||
@@ -118,30 +127,39 @@ App::Color PreferencesGui::dimColor()
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Dimensions");
|
||||
App::Color result;
|
||||
result.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
|
||||
return result;
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
QColor PreferencesGui::dimQColor()
|
||||
{
|
||||
return PreferencesGui::dimColor().asValue<QColor>();
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Dimensions");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
|
||||
return fcColor.asValue<QColor>();
|
||||
}
|
||||
|
||||
|
||||
App::Color PreferencesGui::leaderColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/LeaderLine");
|
||||
App::Color result;
|
||||
result.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
|
||||
return result;
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
QColor PreferencesGui::leaderQColor()
|
||||
{
|
||||
return PreferencesGui::leaderColor().asValue<QColor>();
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/LeaderLine");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x000000FF)); //#000000 black
|
||||
return fcColor.asValue<QColor>();
|
||||
}
|
||||
|
||||
int PreferencesGui::dimArrowStyle()
|
||||
@@ -208,20 +226,24 @@ QString PreferencesGui::weldingDirectory()
|
||||
return qSymbolDir;
|
||||
}
|
||||
|
||||
|
||||
App::Color PreferencesGui::gridColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color result;
|
||||
result.setPackedValue(hGrp->GetUnsigned("gridColor", 0x000000FF)); //#000000 black
|
||||
return result;
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("gridColor", 0x000000FF)); //#000000 black
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
QColor PreferencesGui::gridQColor()
|
||||
{
|
||||
return PreferencesGui::gridColor().asValue<QColor>();
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("gridColor", 0x000000FF)); //#000000 black
|
||||
return fcColor.asValue<QColor>();
|
||||
}
|
||||
|
||||
double PreferencesGui::gridSpacing()
|
||||
@@ -241,3 +263,70 @@ bool PreferencesGui::showGrid()
|
||||
bool show = hGrp->GetBool("showGrid", false);
|
||||
return show;
|
||||
}
|
||||
|
||||
App::Color PreferencesGui::pageColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color result;
|
||||
result.setPackedValue(hGrp->GetUnsigned("PageColor", 0xFFFFFFFF)); //#FFFFFFFF white
|
||||
return result;
|
||||
}
|
||||
|
||||
QColor PreferencesGui::pageQColor()
|
||||
{
|
||||
return PreferencesGui::pageColor().asValue<QColor>();
|
||||
}
|
||||
|
||||
QColor PreferencesGui::getAccessibleQColor(QColor orig)
|
||||
{
|
||||
if (Preferences::lightOnDark() && Preferences::monochrome()) {
|
||||
return lightTextQColor();
|
||||
}
|
||||
if (Preferences::lightOnDark()) {
|
||||
return lightenColor(orig);
|
||||
}
|
||||
return orig;
|
||||
}
|
||||
|
||||
QColor PreferencesGui::lightTextQColor()
|
||||
{
|
||||
return Preferences::lightTextColor().asValue<QColor>();
|
||||
}
|
||||
|
||||
QColor PreferencesGui::reverseColor(QColor orig)
|
||||
{
|
||||
int revRed = 255 - orig.red();
|
||||
int revBlue = 255 - orig.blue();
|
||||
int revGreen = 255 - orig.green();
|
||||
return QColor(revRed, revGreen, revBlue);
|
||||
}
|
||||
|
||||
// largely based on code from https://invent.kde.org/graphics/okular and
|
||||
// https://en.wikipedia.org/wiki/HSL_and_HSV#HSL_to_RGB
|
||||
QColor PreferencesGui::lightenColor(QColor orig)
|
||||
{
|
||||
// get component colours on [0, 255]
|
||||
uchar red = orig.red();
|
||||
uchar blue = orig.blue();
|
||||
uchar green = orig.green();
|
||||
uchar alpha = orig.alpha();
|
||||
|
||||
// shift color values
|
||||
uchar m = std::min( {red, blue, green} );
|
||||
red -= m;
|
||||
blue -= m;
|
||||
green -= m;
|
||||
|
||||
// calculate chroma (colour range)
|
||||
uchar chroma = std::max( {red, blue, green} );
|
||||
|
||||
// calculate lightened colour value
|
||||
uchar newm = 255 - chroma - m;
|
||||
red += newm;
|
||||
green += newm;
|
||||
blue += newm;
|
||||
|
||||
return QColor(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@@ -55,6 +55,8 @@ static App::Color leaderColor();
|
||||
static QColor leaderQColor();
|
||||
static App::Color dimColor();
|
||||
static QColor dimQColor();
|
||||
static App::Color pageColor();
|
||||
static QColor pageQColor();
|
||||
|
||||
static int dimArrowStyle();
|
||||
static double dimArrowSize();
|
||||
@@ -71,6 +73,10 @@ static App::Color gridColor();
|
||||
static QColor gridQColor();
|
||||
static double gridSpacing();
|
||||
|
||||
static QColor getAccessibleQColor(QColor orig);
|
||||
static QColor lightTextQColor();
|
||||
static QColor reverseColor(QColor orig);
|
||||
static QColor lightenColor(QColor orig);
|
||||
};
|
||||
|
||||
} //end namespace TechDrawGui
|
||||
|
||||
@@ -234,7 +234,7 @@ void QGEPath::showMarkers(std::vector<QPointF> points)
|
||||
//TODO: double r = getMarkerSize();
|
||||
// v->setRadius(r);
|
||||
v->setRadius(50.0);
|
||||
v->setNormalColor(QColor(Qt::black));
|
||||
v->setNormalColor(PreferencesGui::getAccessibleQColor(QColor(Qt::black)));
|
||||
v->setZValue(ZVALUE::VERTEX);
|
||||
v->setPos(p);
|
||||
v->show();
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include "QGICMark.h"
|
||||
|
||||
#include "PreferencesGui.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
@@ -68,10 +68,7 @@ void QGICMark::setThick(float t)
|
||||
|
||||
QColor QGICMark::getCMarkColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("CMarkColor", 0x08080800));
|
||||
return fcColor.asValue<QColor>();
|
||||
return PreferencesGui::centerQColor();
|
||||
}
|
||||
|
||||
void QGICMark::setPrettyNormal() {
|
||||
|
||||
@@ -85,7 +85,7 @@ QColor QGIEdge::getHiddenColor()
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("HiddenColor", 0x000000FF));
|
||||
return fcColor.asValue<QColor>();
|
||||
return PreferencesGui::getAccessibleQColor(fcColor.asValue<QColor>());
|
||||
}
|
||||
|
||||
Qt::PenStyle QGIEdge::getHiddenStyle()
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <Base/Parameter.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
|
||||
#include "PreferencesGui.h"
|
||||
#include "QGIFace.h"
|
||||
#include <QByteArrayMatcher>
|
||||
#include "QGCustomImage.h"
|
||||
@@ -48,7 +49,6 @@
|
||||
#include "Rez.h"
|
||||
#include "ZVALUE.h"
|
||||
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
|
||||
@@ -64,7 +64,7 @@ QGIFace::QGIFace(int index) :
|
||||
|
||||
//setStyle(Qt::NoPen); //don't draw face lines, just fill for debugging
|
||||
setStyle(Qt::DashLine);
|
||||
m_geomColor = QColor(Qt::black);
|
||||
m_geomColor = PreferencesGui::getAccessibleQColor(QColor(Qt::black));
|
||||
setLineWeight(0.5); //0 = cosmetic
|
||||
|
||||
setPrettyNormal();
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <cmath>
|
||||
#include <cmath>
|
||||
|
||||
# include <QGraphicsScene>
|
||||
# include <QGraphicsSceneMouseEvent>
|
||||
# include <QPainter>
|
||||
# include <QPainterPath>
|
||||
# include <QVector2D>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QVector2D>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
@@ -37,10 +37,10 @@
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
#include <Mod/TechDraw/App/LineGroup.h>
|
||||
|
||||
#include "QGILeaderLine.h"
|
||||
#include "PreferencesGui.h"
|
||||
#include "QGEPath.h"
|
||||
#include "QGIArrow.h"
|
||||
#include "QGILeaderLine.h"
|
||||
#include "QGIPrimPath.h"
|
||||
#include "Rez.h"
|
||||
#include "ViewProviderLeader.h"
|
||||
@@ -51,14 +51,14 @@ using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
|
||||
//**************************************************************
|
||||
QGILeaderLine::QGILeaderLine() :
|
||||
m_parentItem(nullptr),
|
||||
m_lineColor(Qt::black),
|
||||
m_lineStyle(Qt::SolidLine),
|
||||
m_hasHover(false),
|
||||
m_saveX(0.0),
|
||||
m_saveY(0.0),
|
||||
m_blockDraw(false)
|
||||
QGILeaderLine::QGILeaderLine()
|
||||
: m_parentItem(nullptr),
|
||||
m_lineColor(Qt::black),
|
||||
m_lineStyle(Qt::SolidLine),
|
||||
m_hasHover(false),
|
||||
m_saveX(0.0),
|
||||
m_saveY(0.0),
|
||||
m_blockDraw(false)
|
||||
|
||||
{
|
||||
setHandlesChildEvents(false);
|
||||
@@ -96,16 +96,16 @@ QGILeaderLine::QGILeaderLine() :
|
||||
|
||||
setZValue(ZVALUE::DIMENSION);
|
||||
|
||||
QObject::connect(
|
||||
m_editPath, SIGNAL(pointsUpdated(QPointF, std::vector<QPointF>)),
|
||||
this , SLOT (onLineEditFinished(QPointF, std::vector<QPointF>))
|
||||
);
|
||||
QObject::connect(m_editPath,
|
||||
SIGNAL(pointsUpdated(QPointF, std::vector<QPointF>)),
|
||||
this,
|
||||
SLOT(onLineEditFinished(QPointF, std::vector<QPointF>)));
|
||||
}
|
||||
|
||||
void QGILeaderLine::setLeaderFeature(TechDraw::DrawLeaderLine* feat)
|
||||
{
|
||||
// Base::Console().Message("QGILL::setLeaderFeature()\n");
|
||||
setViewFeature(static_cast<TechDraw::DrawView *>(feat));
|
||||
// Base::Console().Message("QGILL::setLeaderFeature()\n");
|
||||
setViewFeature(static_cast<TechDraw::DrawView*>(feat));
|
||||
|
||||
float x = Rez::guiX(feat->X.getValue());
|
||||
float y = Rez::guiX(-feat->Y.getValue());
|
||||
@@ -117,39 +117,41 @@ void QGILeaderLine::setLeaderFeature(TechDraw::DrawLeaderLine* feat)
|
||||
updateView();
|
||||
}
|
||||
|
||||
QVariant QGILeaderLine::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
QVariant QGILeaderLine::itemChange(GraphicsItemChange change, const QVariant& value)
|
||||
{
|
||||
// Base::Console().Message("QGILL::itemChange(%d)\n", change);
|
||||
// Base::Console().Message("QGILL::itemChange(%d)\n", change);
|
||||
if (change == ItemSelectedHasChanged && scene()) {
|
||||
if(isSelected()) {
|
||||
if (isSelected()) {
|
||||
setPrettySel();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setPrettyNormal();
|
||||
}
|
||||
draw();
|
||||
} else if(change == ItemSceneChange && scene()) {
|
||||
}
|
||||
else if (change == ItemSceneChange && scene()) {
|
||||
// nothing special!
|
||||
}
|
||||
return QGIView::itemChange(change, value);
|
||||
}
|
||||
|
||||
//QGILL isn't draggable so skip QGIV::mousePress have event
|
||||
void QGILeaderLine::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
void QGILeaderLine::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
// Base::Console().Message("QGILL::mousePressEvent() - %s\n", getViewName());
|
||||
// Base::Console().Message("QGILL::mousePressEvent() - %s\n", getViewName());
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
|
||||
//QGILL isn't draggable so skip QGIV::mouseRelease
|
||||
void QGILeaderLine::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
void QGILeaderLine::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
// Base::Console().Message("QGILL::mouseReleaseEvent() - %s\n", getViewName());
|
||||
// Base::Console().Message("QGILL::mouseReleaseEvent() - %s\n", getViewName());
|
||||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void QGILeaderLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
void QGILeaderLine::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
|
||||
{
|
||||
// Base::Console().Message("QGILL::hoverEnter() - selected; %d\n", isSelected());
|
||||
// Base::Console().Message("QGILL::hoverEnter() - selected; %d\n", isSelected());
|
||||
m_hasHover = true;
|
||||
if (!isSelected()) {
|
||||
setPrettyPre();
|
||||
@@ -157,11 +159,11 @@ void QGILeaderLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
QGIView::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
void QGILeaderLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
void QGILeaderLine::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
|
||||
{
|
||||
// Base::Console().Message("QGILL::hoverLeave() - selected; %d\n", isSelected());
|
||||
// Base::Console().Message("QGILL::hoverLeave() - selected; %d\n", isSelected());
|
||||
m_hasHover = false;
|
||||
if(!isSelected()) {
|
||||
if (!isSelected()) {
|
||||
setPrettyNormal();
|
||||
}
|
||||
QGIView::hoverLeaveEvent(event);
|
||||
@@ -169,45 +171,51 @@ void QGILeaderLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
|
||||
void QGILeaderLine::onSourceChange(TechDraw::DrawView* newParent)
|
||||
{
|
||||
// Base::Console().Message("QGILL::onSoureChange(%s)\n", newParent->getNameInDocument());
|
||||
// Base::Console().Message("QGILL::onSoureChange(%s)\n", newParent->getNameInDocument());
|
||||
std::string parentName = newParent->getNameInDocument();
|
||||
QGIView* qgiParent = getQGIVByName(parentName);
|
||||
if (qgiParent) {
|
||||
m_parentItem = qgiParent;
|
||||
setParentItem(m_parentItem);
|
||||
draw();
|
||||
} else {
|
||||
Base::Console().Warning("QGILL::onSourceChange - new parent %s has no QGIView\n", parentName.c_str());
|
||||
}
|
||||
else {
|
||||
Base::Console().Warning("QGILL::onSourceChange - new parent %s has no QGIView\n",
|
||||
parentName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void QGILeaderLine::setNormalColorAll()
|
||||
{
|
||||
// Base::Console().Message("QGILL::setNormalColorAll - normal color: %s\n", qPrintable(getNormalColor().name()));
|
||||
m_line->setNormalColor(getNormalColor());
|
||||
m_editPath->setNormalColor(getNormalColor());
|
||||
m_arrow1->setNormalColor(getNormalColor());
|
||||
m_arrow1->setFillColor(getNormalColor());
|
||||
m_arrow2->setNormalColor(getNormalColor());
|
||||
m_arrow2->setFillColor(getNormalColor());
|
||||
// Base::Console().Message("QGILL::setNormalColorAll - normal color: %s\n", qPrintable(getNormalColor().name()));
|
||||
QColor qc = prefNormalColor();
|
||||
m_line->setNormalColor(qc);
|
||||
m_editPath->setNormalColor(qc);
|
||||
m_arrow1->setNormalColor(qc);
|
||||
m_arrow1->setFillColor(qc);
|
||||
m_arrow2->setNormalColor(qc);
|
||||
m_arrow2->setFillColor(qc);
|
||||
}
|
||||
|
||||
void QGILeaderLine::setPrettyNormal() {
|
||||
// Base::Console().Message("QGILL::setPrettyNormal()\n");
|
||||
void QGILeaderLine::setPrettyNormal()
|
||||
{
|
||||
// Base::Console().Message("QGILL::setPrettyNormal()\n");
|
||||
m_line->setPrettyNormal();
|
||||
m_arrow1->setPrettyNormal();
|
||||
m_arrow2->setPrettyNormal();
|
||||
}
|
||||
|
||||
void QGILeaderLine::setPrettyPre() {
|
||||
// Base::Console().Message("QGILL::setPrettyPre()\n");
|
||||
void QGILeaderLine::setPrettyPre()
|
||||
{
|
||||
// Base::Console().Message("QGILL::setPrettyPre()\n");
|
||||
m_line->setPrettyPre();
|
||||
m_arrow1->setPrettyPre();
|
||||
m_arrow2->setPrettyPre();
|
||||
}
|
||||
|
||||
void QGILeaderLine::setPrettySel() {
|
||||
// Base::Console().Message("QGILL::setPrettySel()\n");
|
||||
void QGILeaderLine::setPrettySel()
|
||||
{
|
||||
// Base::Console().Message("QGILL::setPrettySel()\n");
|
||||
m_line->setPrettySel();
|
||||
m_arrow1->setPrettySel();
|
||||
m_arrow2->setPrettySel();
|
||||
@@ -216,36 +224,35 @@ void QGILeaderLine::setPrettySel() {
|
||||
|
||||
void QGILeaderLine::closeEdit()
|
||||
{
|
||||
// Base::Console().Message("QGIL::closeEdit()\n");
|
||||
// Base::Console().Message("QGIL::closeEdit()\n");
|
||||
if (m_editPath) {
|
||||
m_editPath->onEndEdit(); //tell QEPath that edit session ended
|
||||
m_editPath->onEndEdit();//tell QEPath that edit session ended
|
||||
}
|
||||
}
|
||||
|
||||
//signaled from QEPath
|
||||
void QGILeaderLine::onLineEditFinished(QPointF tipDisplace, std::vector<QPointF> points)
|
||||
{
|
||||
// Base::Console().Message("QGILL::onLineEditFinished(%s, %d)\n",
|
||||
// TechDraw::DrawUtil::formatVector(tipDisplace).c_str(),
|
||||
// points.size());
|
||||
// Base::Console().Message("QGILL::onLineEditFinished(%s, %d)\n",
|
||||
// TechDraw::DrawUtil::formatVector(tipDisplace).c_str(),
|
||||
// points.size());
|
||||
m_blockDraw = true;
|
||||
auto featLeader = getFeature();
|
||||
if (!featLeader)
|
||||
if (!featLeader) {
|
||||
return;
|
||||
}
|
||||
double baseScale = featLeader->getBaseScale();
|
||||
|
||||
if ( !(TechDraw::DrawUtil::fpCompare(tipDisplace.x(), 0.0) &&
|
||||
TechDraw::DrawUtil::fpCompare(tipDisplace.y(), 0.0)) ) {
|
||||
if (!(TechDraw::DrawUtil::fpCompare(tipDisplace.x(), 0.0)
|
||||
&& TechDraw::DrawUtil::fpCompare(tipDisplace.y(), 0.0))) {
|
||||
//tip was moved. need to change AttachPoint
|
||||
QPointF oldAttach = getAttachFromFeature();
|
||||
QPointF newAttach = oldAttach + (tipDisplace / baseScale);
|
||||
featLeader->setPosition(Rez::appX(newAttach.x()),
|
||||
Rez::appX(- newAttach.y()),
|
||||
true);
|
||||
featLeader->setPosition(Rez::appX(newAttach.x()), Rez::appX(-newAttach.y()), true);
|
||||
}
|
||||
|
||||
std::vector<Base::Vector3d> waypoints;
|
||||
for (auto& p: points) {
|
||||
for (auto& p : points) {
|
||||
QPointF moved = p - tipDisplace;
|
||||
Base::Vector3d v(moved.x(), moved.y(), 0.0);
|
||||
waypoints.push_back(v);
|
||||
@@ -257,7 +264,7 @@ void QGILeaderLine::onLineEditFinished(QPointF tipDisplace, std::vector<QPointF>
|
||||
featLeader->adjustLastSegment();
|
||||
}
|
||||
|
||||
Q_EMIT editComplete(); //tell task editing is complete
|
||||
Q_EMIT editComplete();//tell task editing is complete
|
||||
|
||||
m_blockDraw = false;
|
||||
m_editPath->hide();
|
||||
@@ -267,9 +274,10 @@ void QGILeaderLine::onLineEditFinished(QPointF tipDisplace, std::vector<QPointF>
|
||||
void QGILeaderLine::startPathEdit()
|
||||
{
|
||||
saveState();
|
||||
auto featLeader( dynamic_cast<TechDraw::DrawLeaderLine*>(getViewObject()) );
|
||||
if (!featLeader)
|
||||
auto featLeader(dynamic_cast<TechDraw::DrawLeaderLine*>(getViewObject()));
|
||||
if (!featLeader) {
|
||||
return;
|
||||
}
|
||||
|
||||
double scale = featLeader->getScale();
|
||||
m_editPath->setScale(scale);
|
||||
@@ -280,7 +288,7 @@ void QGILeaderLine::startPathEdit()
|
||||
|
||||
void QGILeaderLine::saveState()
|
||||
{
|
||||
// Base::Console().Message("QGILL::saveState()\n");
|
||||
// Base::Console().Message("QGILL::saveState()\n");
|
||||
auto featLeader = getFeature();
|
||||
if (featLeader) {
|
||||
m_savePoints = featLeader->WayPoints.getValues();
|
||||
@@ -291,7 +299,7 @@ void QGILeaderLine::saveState()
|
||||
|
||||
void QGILeaderLine::restoreState()
|
||||
{
|
||||
// Base::Console().Message("QGILL::restoreState()\n");
|
||||
// Base::Console().Message("QGILL::restoreState()\n");
|
||||
auto featLeader = getFeature();
|
||||
if (featLeader) {
|
||||
featLeader->WayPoints.setValues(m_savePoints);
|
||||
@@ -305,52 +313,61 @@ void QGILeaderLine::restoreState()
|
||||
|
||||
void QGILeaderLine::updateView(bool update)
|
||||
{
|
||||
// Base::Console().Message("QGIL::updateView() %s\n", getViewObject()->getNameInDocument());
|
||||
// Base::Console().Message("QGIL::updateView() %s\n", getViewObject()->getNameInDocument());
|
||||
Q_UNUSED(update);
|
||||
auto featLeader( dynamic_cast<TechDraw::DrawLeaderLine*>(getViewObject()) );
|
||||
auto featLeader(dynamic_cast<TechDraw::DrawLeaderLine*>(getViewObject()));
|
||||
if (!featLeader) {
|
||||
Base::Console().Warning("QGILL::updateView - no feature!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
auto vp = static_cast<ViewProviderLeader*>(getViewProvider(getViewObject()));
|
||||
if (!vp)
|
||||
if (!vp) {
|
||||
return;
|
||||
}
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGILeaderLine::draw()
|
||||
{
|
||||
// Base::Console().Message("QGILL::draw()- %s\n", getViewObject()->getNameInDocument());
|
||||
if (m_blockDraw)
|
||||
// Base::Console().Message("QGILL::draw()- %s\n", getViewObject()->getNameInDocument());
|
||||
if (m_blockDraw) {
|
||||
return;
|
||||
if (!isVisible())
|
||||
}
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
TechDraw::DrawLeaderLine* featLeader = getFeature();
|
||||
if (!featLeader)
|
||||
if (!featLeader) {
|
||||
return;
|
||||
}
|
||||
auto vp = static_cast<ViewProviderLeader*>(getViewProvider(getViewObject()));
|
||||
if (!vp)
|
||||
if (!vp) {
|
||||
return;
|
||||
}
|
||||
|
||||
double scale = 1.0;
|
||||
TechDraw::DrawView* parent = featLeader->getBaseView();
|
||||
if (parent)
|
||||
if (parent) {
|
||||
scale = parent->getScale();
|
||||
}
|
||||
|
||||
if (m_editPath->inEdit())
|
||||
if (m_editPath->inEdit()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//********
|
||||
if (featLeader->isLocked())
|
||||
//********
|
||||
if (featLeader->isLocked()) {
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
else
|
||||
}
|
||||
else {
|
||||
setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
}
|
||||
|
||||
m_lineStyle = static_cast<Qt::PenStyle>(vp->LineStyle.getValue());
|
||||
double baseScale = featLeader->getBaseScale();
|
||||
double x = Rez::guiX(featLeader->X.getValue());
|
||||
double y = - Rez::guiX(featLeader->Y.getValue());
|
||||
double y = -Rez::guiX(featLeader->Y.getValue());
|
||||
QPointF aPoint(x, y);
|
||||
aPoint *= baseScale;
|
||||
setPos(aPoint);
|
||||
@@ -359,7 +376,7 @@ void QGILeaderLine::draw()
|
||||
m_line->setStyle(m_lineStyle);
|
||||
m_line->setWidth(getLineWidth());
|
||||
|
||||
m_line->setPos(0, 0); //make m_line coords == leader coords
|
||||
m_line->setPos(0, 0);//make m_line coords == leader coords
|
||||
|
||||
std::vector<QPointF> qPoints = getWayPointsFromFeature();
|
||||
if (featLeader->Scalable.getValue()) {
|
||||
@@ -374,9 +391,11 @@ void QGILeaderLine::draw()
|
||||
|
||||
if (isSelected()) {
|
||||
setPrettySel();
|
||||
} else if (m_hasHover) {
|
||||
}
|
||||
else if (m_hasHover) {
|
||||
setPrettyPre();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setPrettyNormal();
|
||||
}
|
||||
update(boundingRect());
|
||||
@@ -384,23 +403,23 @@ void QGILeaderLine::draw()
|
||||
|
||||
QPainterPath QGILeaderLine::makeLeaderPath(std::vector<QPointF> qPoints)
|
||||
{
|
||||
// Base::Console().Message("QGILeaderLine::makeLeaderPath()\n");
|
||||
// Base::Console().Message("QGILeaderLine::makeLeaderPath()\n");
|
||||
QPainterPath result;
|
||||
DrawLeaderLine* featLeader = getFeature();
|
||||
if (!featLeader) {
|
||||
Base::Console().Message("QGILL::makeLeaderPath - featLeader is nullptr\n");
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
QPointF startAdjVec(0.0, 0.0);
|
||||
double startAdjLength(0.0);
|
||||
double startAdjLength(0.0);
|
||||
QPointF endAdjVec(0.0, 0.0);
|
||||
double endAdjLength(0.0);
|
||||
double endAdjLength(0.0);
|
||||
if (qPoints.size() > 1) {
|
||||
//make path adjustment to hide leaderline ends behind arrowheads
|
||||
if (featLeader->StartSymbol.getValue() != ArrowType::NONE) {
|
||||
startAdjLength = QGIArrow::getOverlapAdjust(featLeader->StartSymbol.getValue(),
|
||||
QGIArrow::getPrefArrowSize());
|
||||
QGIArrow::getPrefArrowSize());
|
||||
}
|
||||
if (featLeader->EndSymbol.getValue() != ArrowType::NONE) {
|
||||
endAdjLength = QGIArrow::getOverlapAdjust(featLeader->EndSymbol.getValue(),
|
||||
@@ -409,7 +428,7 @@ QPainterPath QGILeaderLine::makeLeaderPath(std::vector<QPointF> qPoints)
|
||||
|
||||
//get adjustment directions
|
||||
startAdjVec = qPoints.at(1) - qPoints.front();
|
||||
endAdjVec = (*(qPoints.end() - 2))- qPoints.back();
|
||||
endAdjVec = (*(qPoints.end() - 2)) - qPoints.back();
|
||||
|
||||
//get adjustment vectors
|
||||
QVector2D startTemp(startAdjVec);
|
||||
@@ -420,26 +439,26 @@ QPainterPath QGILeaderLine::makeLeaderPath(std::vector<QPointF> qPoints)
|
||||
endAdjVec = endTemp.toPointF() * endAdjLength;
|
||||
|
||||
qPoints.front() += startAdjVec;
|
||||
qPoints.back() += endAdjVec;
|
||||
qPoints.back() += endAdjVec;
|
||||
result.moveTo(qPoints.front());
|
||||
for (int i = 1; i < (int)qPoints.size(); i++) {
|
||||
result.lineTo(qPoints.at(i));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QPointF QGILeaderLine::getAttachFromFeature()
|
||||
{
|
||||
// Base::Console().Message("QGILL::getAttachFromFeature()\n");
|
||||
// Base::Console().Message("QGILL::getAttachFromFeature()\n");
|
||||
QPointF result;
|
||||
TechDraw::DrawLeaderLine* featLeader = getFeature();
|
||||
if((!featLeader) ) {
|
||||
if ((!featLeader)) {
|
||||
Base::Console().Message("QGIL::getAttachFromLeader - no feature\n");
|
||||
return result;
|
||||
}
|
||||
double x = Rez::guiX(featLeader->X.getValue());
|
||||
double y = - Rez::guiX(featLeader->Y.getValue());
|
||||
double y = -Rez::guiX(featLeader->Y.getValue());
|
||||
result = QPointF(x, y);
|
||||
return result;
|
||||
}
|
||||
@@ -451,11 +470,11 @@ std::vector<QPointF> QGILeaderLine::getWayPointsFromFeature()
|
||||
DrawLeaderLine* featLeader = getFeature();
|
||||
if (!featLeader) {
|
||||
Base::Console().Message("QGILL::getWayPointsFromFeature - featLeader is nullptr\n");
|
||||
return qPoints;
|
||||
return qPoints;
|
||||
}
|
||||
|
||||
std::vector<Base::Vector3d> vPoints = featLeader->WayPoints.getValues();
|
||||
for (auto& d: vPoints) {
|
||||
for (auto& d : vPoints) {
|
||||
QPointF temp(d.x, d.y);
|
||||
qPoints.push_back(temp);
|
||||
}
|
||||
@@ -467,7 +486,7 @@ std::vector<QPointF> QGILeaderLine::getWayPointsFromFeature()
|
||||
|
||||
void QGILeaderLine::setArrows(std::vector<QPointF> pathPoints)
|
||||
{
|
||||
// Base::Console().Message("QGILL::setArrows()\n");
|
||||
// Base::Console().Message("QGILL::setArrows()\n");
|
||||
Base::Vector3d stdX(1.0, 0.0, 0.0);
|
||||
TechDraw::DrawLeaderLine* featLeader = getFeature();
|
||||
|
||||
@@ -476,7 +495,7 @@ void QGILeaderLine::setArrows(std::vector<QPointF> pathPoints)
|
||||
if (featLeader->StartSymbol.getValue() != ArrowType::NONE) {
|
||||
m_arrow1->setStyle(featLeader->StartSymbol.getValue());
|
||||
m_arrow1->setWidth(getLineWidth());
|
||||
// TODO: variable size arrow heads
|
||||
// TODO: variable size arrow heads
|
||||
m_arrow1->setSize(QGIArrow::getPrefArrowSize());
|
||||
m_arrow1->setDirMode(true);
|
||||
m_arrow1->setDirection(stdX);
|
||||
@@ -491,7 +510,8 @@ void QGILeaderLine::setArrows(std::vector<QPointF> pathPoints)
|
||||
}
|
||||
m_arrow1->draw();
|
||||
m_arrow1->show();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
m_arrow1->hide();
|
||||
}
|
||||
|
||||
@@ -511,15 +531,16 @@ void QGILeaderLine::setArrows(std::vector<QPointF> pathPoints)
|
||||
}
|
||||
m_arrow2->draw();
|
||||
m_arrow2->show();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
m_arrow2->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void QGILeaderLine::drawBorder()
|
||||
{
|
||||
////Leaders have no border!
|
||||
// QGIView::drawBorder(); //good for debugging
|
||||
////Leaders have no border!
|
||||
// QGIView::drawBorder(); //good for debugging
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
@@ -527,7 +548,7 @@ void QGILeaderLine::drawBorder()
|
||||
|
||||
void QGILeaderLine::abandonEdit()
|
||||
{
|
||||
// Base::Console().Message("QGIL::abandonEdit()\n");
|
||||
// Base::Console().Message("QGIL::abandonEdit()\n");
|
||||
m_editPath->clearMarkers();
|
||||
m_editPath->hide();
|
||||
restoreState();
|
||||
@@ -536,15 +557,15 @@ void QGILeaderLine::abandonEdit()
|
||||
double QGILeaderLine::getLineWidth()
|
||||
{
|
||||
auto vp = static_cast<ViewProviderLeader*>(getViewProvider(getViewObject()));
|
||||
if (!vp)
|
||||
if (!vp) {
|
||||
return Rez::guiX(LineGroup::getDefaultWidth("Graphic"));
|
||||
}
|
||||
return Rez::guiX(vp->LineWidth.getValue());
|
||||
}
|
||||
|
||||
TechDraw::DrawLeaderLine* QGILeaderLine::getFeature()
|
||||
{
|
||||
TechDraw::DrawLeaderLine* result =
|
||||
static_cast<TechDraw::DrawLeaderLine*>(getViewObject());
|
||||
TechDraw::DrawLeaderLine* result = static_cast<TechDraw::DrawLeaderLine*>(getViewObject());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -555,12 +576,13 @@ double QGILeaderLine::getEdgeFuzz() const
|
||||
|
||||
QColor QGILeaderLine::prefNormalColor()
|
||||
{
|
||||
// Base::Console().Message("QGILL::getNormalColor()\n");
|
||||
// Base::Console().Message("QGILL::getNormalColor()\n");
|
||||
setNormalColor(PreferencesGui::leaderQColor());
|
||||
|
||||
auto vp = dynamic_cast<ViewProviderLeader*>(getViewProvider(getViewObject()));
|
||||
if (vp) {
|
||||
setNormalColor(vp->Color.getValue().asValue<QColor>());
|
||||
QColor normal = vp->Color.getValue().asValue<QColor>();
|
||||
setNormalColor(PreferencesGui::getAccessibleQColor(normal));
|
||||
}
|
||||
return getNormalColor();
|
||||
}
|
||||
@@ -570,14 +592,16 @@ QRectF QGILeaderLine::boundingRect() const
|
||||
return childrenBoundingRect();
|
||||
}
|
||||
|
||||
void QGILeaderLine::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
void QGILeaderLine::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
QWidget* widget)
|
||||
{
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
|
||||
// painter->setPen(Qt::blue);
|
||||
// painter->drawRect(boundingRect()); //good for debugging
|
||||
// painter->setPen(Qt::blue);
|
||||
// painter->drawRect(boundingRect()); //good for debugging
|
||||
|
||||
QGIView::paint (painter, &myOption, widget);
|
||||
QGIView::paint(painter, &myOption, widget);
|
||||
}
|
||||
|
||||
#include <Mod/TechDraw/Gui/moc_QGILeaderLine.cpp>
|
||||
|
||||
@@ -36,10 +36,11 @@
|
||||
#include "QGIView.h"
|
||||
|
||||
|
||||
namespace TechDraw {
|
||||
namespace TechDraw
|
||||
{
|
||||
class DrawLeaderLine;
|
||||
class DrawView;
|
||||
}
|
||||
}// namespace TechDraw
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
@@ -50,20 +51,25 @@ class QGEPath;
|
||||
|
||||
//*******************************************************************
|
||||
|
||||
class TechDrawGuiExport QGILeaderLine : public QGIView
|
||||
class TechDrawGuiExport QGILeaderLine: public QGIView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum {Type = QGraphicsItem::UserType + 232};
|
||||
enum
|
||||
{
|
||||
Type = QGraphicsItem::UserType + 232
|
||||
};
|
||||
|
||||
explicit QGILeaderLine();
|
||||
~QGILeaderLine() = default;
|
||||
|
||||
int type() const override { return Type;}
|
||||
void paint( QPainter * painter,
|
||||
const QStyleOptionGraphicsItem * option,
|
||||
QWidget * widget = nullptr ) override;
|
||||
int type() const override
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
QWidget* widget = nullptr) override;
|
||||
QRectF boundingRect() const override;
|
||||
|
||||
void drawBorder() override;
|
||||
@@ -80,10 +86,10 @@ public:
|
||||
double getLineWidth();
|
||||
double getEdgeFuzz() const;
|
||||
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent * event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent * event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override;
|
||||
|
||||
void setPrettyNormal();
|
||||
void setPrettyPre();
|
||||
@@ -92,11 +98,12 @@ public:
|
||||
void setLeaderFeature(TechDraw::DrawLeaderLine* feat);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onLineEditFinished(QPointF tipDisplace, std::vector<QPointF> points); //QGEPath is finished editing points
|
||||
void onLineEditFinished(QPointF tipDisplace,
|
||||
std::vector<QPointF> points);//QGEPath is finished editing points
|
||||
void onSourceChange(TechDraw::DrawView* newParent) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void editComplete(); //tell caller that edit session is finished
|
||||
void editComplete();//tell caller that edit session is finished
|
||||
|
||||
protected:
|
||||
void draw() override;
|
||||
@@ -104,8 +111,7 @@ protected:
|
||||
std::vector<QPointF> getWayPointsFromFeature();
|
||||
QPointF getAttachFromFeature();
|
||||
|
||||
QVariant itemChange( GraphicsItemChange change,
|
||||
const QVariant &value ) override;
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant& value) override;
|
||||
|
||||
void saveState();
|
||||
void restoreState();
|
||||
@@ -116,13 +122,13 @@ protected:
|
||||
private:
|
||||
std::vector<QPointF> m_pathPoints;
|
||||
QGraphicsItem* m_parentItem;
|
||||
QGIPrimPath* m_line; //actual leader line
|
||||
QGIPrimPath* m_line;//actual leader line
|
||||
QColor m_lineColor;
|
||||
Qt::PenStyle m_lineStyle;
|
||||
QGIArrow* m_arrow1;
|
||||
QGIArrow* m_arrow2;
|
||||
|
||||
QGEPath* m_editPath; //line editor
|
||||
QGEPath* m_editPath;//line editor
|
||||
QColor m_editPathColor;
|
||||
|
||||
bool m_hasHover;
|
||||
@@ -131,9 +137,9 @@ private:
|
||||
double m_saveY;
|
||||
std::vector<Base::Vector3d> m_savePoints;
|
||||
|
||||
bool m_blockDraw; //prevent redraws while updating.
|
||||
bool m_blockDraw;//prevent redraws while updating.
|
||||
};
|
||||
|
||||
}
|
||||
}// namespace TechDrawGui
|
||||
|
||||
#endif // DRAWINGGUI_QGRAPHICSITEMLEADERLINE_H
|
||||
#endif// DRAWINGGUI_QGRAPHICSITEMLEADERLINE_H
|
||||
|
||||
@@ -23,35 +23,36 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QDomDocument>
|
||||
# include <QFile>
|
||||
# include <QGraphicsSvgItem>
|
||||
# include <QPen>
|
||||
# include <QSvgRenderer>
|
||||
# include <QXmlQuery>
|
||||
# include <QXmlResultItems>
|
||||
#endif // #ifndef _PreComp_
|
||||
#include <QDomDocument>
|
||||
#include <QFile>
|
||||
#include <QGraphicsColorizeEffect>
|
||||
#include <QGraphicsEffect>
|
||||
#include <QGraphicsSvgItem>
|
||||
#include <QPen>
|
||||
#include <QSvgRenderer>
|
||||
#include <QXmlQuery>
|
||||
#include <QXmlResultItems>
|
||||
#endif// #ifndef _PreComp_
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
#include <Mod/TechDraw/App/DrawSVGTemplate.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
#include <Mod/TechDraw/App/QDomNodeModel.h>
|
||||
|
||||
#include "PreferencesGui.h"
|
||||
#include "QGISVGTemplate.h"
|
||||
#include "QGSPage.h"
|
||||
#include "Rez.h"
|
||||
#include "TemplateTextField.h"
|
||||
#include "ZVALUE.h"
|
||||
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
|
||||
QGISVGTemplate::QGISVGTemplate(QGSPage* scene)
|
||||
: QGITemplate(scene),
|
||||
firstTime(true)
|
||||
QGISVGTemplate::QGISVGTemplate(QGSPage* scene) : QGITemplate(scene), firstTime(true)
|
||||
{
|
||||
|
||||
m_svgItem = new QGraphicsSvgItem(this);
|
||||
@@ -66,22 +67,15 @@ QGISVGTemplate::QGISVGTemplate(QGSPage* scene)
|
||||
|
||||
m_svgItem->setZValue(ZVALUE::SVGTEMPLATE);
|
||||
setZValue(ZVALUE::SVGTEMPLATE);
|
||||
|
||||
}
|
||||
|
||||
QGISVGTemplate::~QGISVGTemplate()
|
||||
{
|
||||
delete m_svgRender;
|
||||
}
|
||||
QGISVGTemplate::~QGISVGTemplate() { delete m_svgRender; }
|
||||
|
||||
void QGISVGTemplate::openFile(const QFile &file)
|
||||
{
|
||||
Q_UNUSED(file);
|
||||
}
|
||||
void QGISVGTemplate::openFile(const QFile& file) { Q_UNUSED(file); }
|
||||
|
||||
void QGISVGTemplate::load(const QByteArray &svgCode)
|
||||
void QGISVGTemplate::load(const QByteArray& svgCode)
|
||||
{
|
||||
m_svgRender->load(svgCode);
|
||||
m_svgRender->load(svgCode);
|
||||
|
||||
QSize size = m_svgRender->defaultSize();
|
||||
m_svgItem->setSharedRenderer(m_svgRender);
|
||||
@@ -92,31 +86,48 @@ void QGISVGTemplate::load(const QByteArray &svgCode)
|
||||
}
|
||||
|
||||
//convert from pixels or mm or inches in svg file to mm page size
|
||||
TechDraw::DrawSVGTemplate *tmplte = getSVGTemplate();
|
||||
TechDraw::DrawSVGTemplate* tmplte = getSVGTemplate();
|
||||
double xaspect, yaspect;
|
||||
xaspect = tmplte->getWidth() / static_cast<double>(size.width());
|
||||
yaspect = tmplte->getHeight() / static_cast<double>(size.height());
|
||||
|
||||
QTransform qtrans;
|
||||
qtrans.translate(0.0, Rez::guiX(-tmplte->getHeight()));
|
||||
qtrans.scale(Rez::guiX(xaspect) , Rez::guiX(yaspect));
|
||||
qtrans.scale(Rez::guiX(xaspect), Rez::guiX(yaspect));
|
||||
m_svgItem->setTransform(qtrans);
|
||||
|
||||
if (Preferences::lightOnDark()) {
|
||||
QColor color = PreferencesGui::getAccessibleQColor(QColor(Qt::black));
|
||||
QGraphicsColorizeEffect* colorizeEffect = new QGraphicsColorizeEffect();
|
||||
colorizeEffect->setColor(color);
|
||||
m_svgItem->setGraphicsEffect(colorizeEffect);
|
||||
}
|
||||
else {
|
||||
//remove and delete any existing graphics effect
|
||||
if (m_svgItem->graphicsEffect()) {
|
||||
m_svgItem->setGraphicsEffect(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TechDraw::DrawSVGTemplate * QGISVGTemplate::getSVGTemplate()
|
||||
TechDraw::DrawSVGTemplate* QGISVGTemplate::getSVGTemplate()
|
||||
{
|
||||
if(pageTemplate && pageTemplate->isDerivedFrom(TechDraw::DrawSVGTemplate::getClassTypeId()))
|
||||
return static_cast<TechDraw::DrawSVGTemplate *>(pageTemplate);
|
||||
else
|
||||
if (pageTemplate && pageTemplate->isDerivedFrom(TechDraw::DrawSVGTemplate::getClassTypeId())) {
|
||||
return static_cast<TechDraw::DrawSVGTemplate*>(pageTemplate);
|
||||
}
|
||||
else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void QGISVGTemplate::draw()
|
||||
{
|
||||
TechDraw::DrawSVGTemplate *tmplte = getSVGTemplate();
|
||||
if(!tmplte)
|
||||
TechDraw::DrawSVGTemplate* tmplte = getSVGTemplate();
|
||||
if (!tmplte) {
|
||||
throw Base::RuntimeError("Template Feature not set for QGISVGTemplate");
|
||||
load(tmplte->processTemplate().toUtf8());
|
||||
}
|
||||
QString templateSvg = tmplte->processTemplate();
|
||||
load(templateSvg.toUtf8());
|
||||
}
|
||||
|
||||
void QGISVGTemplate::updateView(bool update)
|
||||
@@ -127,7 +138,7 @@ void QGISVGTemplate::updateView(bool update)
|
||||
|
||||
void QGISVGTemplate::createClickHandles()
|
||||
{
|
||||
TechDraw::DrawSVGTemplate *svgTemplate = getSVGTemplate();
|
||||
TechDraw::DrawSVGTemplate* svgTemplate = getSVGTemplate();
|
||||
if (svgTemplate->isRestoring()) {
|
||||
//the embedded file is not available yet, so just return
|
||||
return;
|
||||
@@ -141,8 +152,9 @@ void QGISVGTemplate::createClickHandles()
|
||||
|
||||
QFile file(templateFilename);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
Base::Console().Error("QGISVGTemplate::createClickHandles - error opening template file %s\n",
|
||||
svgTemplate->PageResult.getValue());
|
||||
Base::Console().Error(
|
||||
"QGISVGTemplate::createClickHandles - error opening template file %s\n",
|
||||
svgTemplate->PageResult.getValue());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -160,37 +172,41 @@ void QGISVGTemplate::createClickHandles()
|
||||
query.setFocus(QXmlItem(model.fromDomNode(templateDocElem)));
|
||||
|
||||
// XPath query to select all <text> nodes with "freecad:editable" attribute
|
||||
query.setQuery(QString::fromUtf8(
|
||||
"declare default element namespace \"" SVG_NS_URI "\"; "
|
||||
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
|
||||
"//text[@freecad:editable]"));
|
||||
query.setQuery(QString::fromUtf8("declare default element namespace \"" SVG_NS_URI "\"; "
|
||||
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
|
||||
"//text[@freecad:editable]"));
|
||||
|
||||
QXmlResultItems queryResult;
|
||||
query.evaluateTo(&queryResult);
|
||||
|
||||
//TODO: Find location of special fields (first/third angle) and make graphics items for them
|
||||
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/General");
|
||||
double editClickBoxSize = Rez::guiX(hGrp->GetFloat("TemplateDotSize", 3.0));
|
||||
|
||||
QColor editClickBoxColor = Qt::green;
|
||||
editClickBoxColor.setAlpha(128); //semi-transparent
|
||||
editClickBoxColor.setAlpha(128);//semi-transparent
|
||||
|
||||
double width = editClickBoxSize;
|
||||
double height = editClickBoxSize;
|
||||
|
||||
while (!queryResult.next().isNull())
|
||||
{
|
||||
QDomElement textElement = model.toDomNode(queryResult.current().toNodeModelIndex()).toElement();
|
||||
while (!queryResult.next().isNull()) {
|
||||
QDomElement textElement =
|
||||
model.toDomNode(queryResult.current().toNodeModelIndex()).toElement();
|
||||
|
||||
QString name = textElement.attribute(QString::fromUtf8("freecad:editable"));
|
||||
double x = Rez::guiX(textElement.attribute(QString::fromUtf8("x"), QString::fromUtf8("0.0")).toDouble());
|
||||
double y = Rez::guiX(textElement.attribute(QString::fromUtf8("y"), QString::fromUtf8("0.0")).toDouble());
|
||||
double x = Rez::guiX(
|
||||
textElement.attribute(QString::fromUtf8("x"), QString::fromUtf8("0.0")).toDouble());
|
||||
double y = Rez::guiX(
|
||||
textElement.attribute(QString::fromUtf8("y"), QString::fromUtf8("0.0")).toDouble());
|
||||
|
||||
if (name.isEmpty()) {
|
||||
Base::Console().Warning("QGISVGTemplate::createClickHandles - no name for editable text at %f, %f\n",
|
||||
x, y);
|
||||
Base::Console().Warning(
|
||||
"QGISVGTemplate::createClickHandles - no name for editable text at %f, %f\n", x, y);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -198,12 +214,12 @@ void QGISVGTemplate::createClickHandles()
|
||||
|
||||
double pad = 1.0;
|
||||
item->setRect(x - pad, Rez::guiX(-svgTemplate->getHeight()) + y - height - pad,
|
||||
width + 2.0*pad, height + 2.0*pad);
|
||||
width + 2.0 * pad, height + 2.0 * pad);
|
||||
|
||||
QPen myPen;
|
||||
myPen.setStyle(Qt::SolidLine);
|
||||
myPen.setColor(editClickBoxColor);
|
||||
myPen.setWidth(0); // 0 means "cosmetic pen" - always 1px
|
||||
myPen.setWidth(0);// 0 means "cosmetic pen" - always 1px
|
||||
item->setPen(myPen);
|
||||
|
||||
QBrush myBrush(editClickBoxColor, Qt::SolidPattern);
|
||||
|
||||
@@ -32,7 +32,8 @@ class QSvgRenderer;
|
||||
class QFile;
|
||||
class QString;
|
||||
|
||||
namespace TechDraw {
|
||||
namespace TechDraw
|
||||
{
|
||||
class DrawSVGTemplate;
|
||||
}
|
||||
|
||||
@@ -42,33 +43,36 @@ namespace TechDrawGui
|
||||
{
|
||||
class QGSPage;
|
||||
|
||||
class TechDrawGuiExport QGISVGTemplate : public QGITemplate
|
||||
class TechDrawGuiExport QGISVGTemplate: public QGITemplate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QGISVGTemplate(QGSPage* scene);
|
||||
virtual ~QGISVGTemplate();
|
||||
~QGISVGTemplate() override;
|
||||
|
||||
enum {Type = QGraphicsItem::UserType + 153};
|
||||
enum
|
||||
{
|
||||
Type = QGraphicsItem::UserType + 153
|
||||
};
|
||||
int type() const { return Type; }
|
||||
|
||||
void draw();
|
||||
virtual void updateView(bool update = false);
|
||||
void updateView(bool update = false) override;
|
||||
|
||||
TechDraw::DrawSVGTemplate *getSVGTemplate();
|
||||
TechDraw::DrawSVGTemplate* getSVGTemplate();
|
||||
|
||||
protected:
|
||||
void openFile(const QFile &file);
|
||||
void load (const QByteArray& svgCode);
|
||||
void openFile(const QFile& file);
|
||||
void load(const QByteArray& svgCode);
|
||||
void createClickHandles(void);
|
||||
|
||||
protected:
|
||||
bool firstTime;
|
||||
QGraphicsSvgItem *m_svgItem;
|
||||
QSvgRenderer *m_svgRender;
|
||||
}; // class QGISVGTemplate
|
||||
QGraphicsSvgItem* m_svgItem;
|
||||
QSvgRenderer* m_svgRender;
|
||||
};// class QGISVGTemplate
|
||||
|
||||
}
|
||||
}// namespace TechDrawGui
|
||||
|
||||
#endif // DRAWINGGUI_QGRAPHICSITEMSVGTEMPLATE_H
|
||||
#endif// DRAWINGGUI_QGRAPHICSITEMSVGTEMPLATE_H
|
||||
|
||||
@@ -325,7 +325,7 @@ QColor QGITile::getTileColor() const
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("TileColor", 0x00000000));
|
||||
return fcColor.asValue<QColor>();
|
||||
return PreferencesGui::getAccessibleQColor( fcColor.asValue<QColor>());
|
||||
}
|
||||
|
||||
double QGITile::getSymbolWidth() const
|
||||
|
||||
@@ -200,7 +200,7 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
m_colCurrent = getSelectColor();
|
||||
// m_selectState = 2;
|
||||
} else {
|
||||
m_colCurrent = PreferencesGui::normalQColor();
|
||||
m_colCurrent = PreferencesGui::getAccessibleQColor(PreferencesGui::normalQColor());
|
||||
// m_selectState = 0;
|
||||
}
|
||||
drawBorder();
|
||||
@@ -268,7 +268,7 @@ void QGIView::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
if(isSelected()) {
|
||||
m_colCurrent = getSelectColor();
|
||||
} else {
|
||||
m_colCurrent = PreferencesGui::normalQColor();
|
||||
m_colCurrent = PreferencesGui::getAccessibleQColor(PreferencesGui::normalQColor());
|
||||
}
|
||||
drawBorder();
|
||||
}
|
||||
@@ -709,17 +709,17 @@ void QGIView::setStackFromVP()
|
||||
|
||||
QColor QGIView::prefNormalColor()
|
||||
{
|
||||
return PreferencesGui::normalQColor();
|
||||
return PreferencesGui::getAccessibleQColor(PreferencesGui::normalQColor());
|
||||
}
|
||||
|
||||
QColor QGIView::getPreColor()
|
||||
{
|
||||
return PreferencesGui::preselectQColor();
|
||||
return PreferencesGui::getAccessibleQColor(PreferencesGui::preselectQColor());
|
||||
}
|
||||
|
||||
QColor QGIView::getSelectColor()
|
||||
{
|
||||
return PreferencesGui::selectQColor();
|
||||
return PreferencesGui::getAccessibleQColor(PreferencesGui::selectQColor());
|
||||
}
|
||||
|
||||
Base::Reference<ParameterGrp> QGIView::getParmGroupCol()
|
||||
|
||||
@@ -39,13 +39,15 @@
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Widgets.h>
|
||||
#include <Mod/TechDraw/App/DrawViewAnnotation.h>
|
||||
#include <Mod/TechDraw/App/Preferences.h>
|
||||
|
||||
#include "QGIViewAnnotation.h"
|
||||
#include "QGCustomText.h"
|
||||
#include "Rez.h"
|
||||
|
||||
#include "DlgStringListEditor.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
@@ -135,6 +137,7 @@ void QGIViewAnnotation::drawAnnotation()
|
||||
}
|
||||
ss << "line-height:" << viewAnno->LineSpace.getValue() << "%; ";
|
||||
App::Color c = viewAnno->TextColor.getValue();
|
||||
c = TechDraw::Preferences::getAccessibleColor(c);
|
||||
ss << "color:" << c.asHexString() << "; ";
|
||||
ss << "}\n</style>\n</head>\n<body>\n<p>";
|
||||
for(std::vector<std::string>::const_iterator it = annoText.begin(); it != annoText.end(); it++) {
|
||||
@@ -173,44 +176,11 @@ void QGIViewAnnotation::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
|
||||
}
|
||||
|
||||
const std::vector<std::string> &values = annotation->Text.getValues();
|
||||
QString text;
|
||||
if (!values.empty()) {
|
||||
text = QString::fromUtf8(values[0].c_str());
|
||||
|
||||
for (unsigned int i = 1; i < values.size(); ++i) {
|
||||
text += QChar::fromLatin1('\n');
|
||||
text += QString::fromUtf8(values[i].c_str());
|
||||
}
|
||||
}
|
||||
|
||||
QDialog dialog(nullptr);
|
||||
dialog.setWindowTitle(tr("Text"));
|
||||
|
||||
Gui::PropertyListEditor editor(&dialog);
|
||||
editor.setPlainText(text);
|
||||
|
||||
QDialogButtonBox buttonBox(&dialog);
|
||||
buttonBox.setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
||||
QVBoxLayout boxLayout(&dialog);
|
||||
boxLayout.addWidget(&editor);
|
||||
boxLayout.addWidget(&buttonBox);
|
||||
|
||||
connect(&buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept()));
|
||||
connect(&buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject()));
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
QString newText = editor.toPlainText();
|
||||
if (newText != text) {
|
||||
QStringList list = newText.split(QChar::fromLatin1('\n'));
|
||||
std::vector<std::string> newValues;
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
newValues.push_back(list[i].toStdString());
|
||||
}
|
||||
|
||||
App::GetApplication().setActiveTransaction("Set Annotation Text");
|
||||
annotation->Text.setValues(newValues);
|
||||
App::GetApplication().closeActiveTransaction();
|
||||
}
|
||||
DlgStringListEditor dlg(values, Gui::getMainWindow());
|
||||
dlg.setWindowTitle(QString::fromUtf8("Annotation Text Editor"));
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
App::GetApplication().setActiveTransaction("Set Annotation Text");
|
||||
annotation->Text.setValues(dlg.getTexts());
|
||||
App::GetApplication().closeActiveTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <cmath>
|
||||
# include <string>
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
||||
# include <QGraphicsScene>
|
||||
# include <QGraphicsSceneMouseEvent>
|
||||
# include <QPaintDevice>
|
||||
# include <QPainter>
|
||||
# include <QPainterPath>
|
||||
# include <QSvgGenerator>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QPaintDevice>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QSvgGenerator>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -41,15 +41,15 @@
|
||||
#include <Gui/Tools.h>
|
||||
#include <Mod/TechDraw/App/ArrowPropEnum.h>
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
#include <Mod/TechDraw/App/DrawViewBalloon.h>
|
||||
#include <Mod/TechDraw/App/DrawViewPart.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
#include <Mod/TechDraw/App/Geometry.h>
|
||||
|
||||
#include "QGIViewBalloon.h"
|
||||
#include "PreferencesGui.h"
|
||||
#include "QGIArrow.h"
|
||||
#include "QGIDimLines.h"
|
||||
#include "QGIViewBalloon.h"
|
||||
#include "Rez.h"
|
||||
#include "ViewProviderBalloon.h"
|
||||
#include "ViewProviderViewPart.h"
|
||||
@@ -82,18 +82,20 @@ QGIBalloonLabel::QGIBalloonLabel()
|
||||
parent = nullptr;
|
||||
}
|
||||
|
||||
QVariant QGIBalloonLabel::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
QVariant QGIBalloonLabel::itemChange(GraphicsItemChange change, const QVariant& value)
|
||||
{
|
||||
if (change == ItemSelectedHasChanged && scene()) {
|
||||
if(isSelected()) {
|
||||
if (isSelected()) {
|
||||
Q_EMIT selected(true);
|
||||
setPrettySel();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Q_EMIT selected(false);
|
||||
setPrettyNormal();
|
||||
}
|
||||
update();
|
||||
} else if(change == ItemPositionHasChanged && scene()) {
|
||||
}
|
||||
else if (change == ItemPositionHasChanged && scene()) {
|
||||
setLabelCenter();
|
||||
if (m_drag) {
|
||||
Q_EMIT dragging(m_ctrl);
|
||||
@@ -103,20 +105,19 @@ QVariant QGIBalloonLabel::itemChange(GraphicsItemChange change, const QVariant &
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
||||
void QGIBalloonLabel::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
void QGIBalloonLabel::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
m_ctrl = false;
|
||||
m_drag = true;
|
||||
if(event->modifiers() & Qt::ControlModifier) {
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
m_ctrl = true;
|
||||
}
|
||||
QGraphicsItem::mousePressEvent(event);
|
||||
}
|
||||
|
||||
void QGIBalloonLabel::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
void QGIBalloonLabel::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
if (QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton))
|
||||
.length() > 0) {
|
||||
if (QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton)).length() > 0) {
|
||||
if (scene() && this == scene()->mouseGrabberItem()) {
|
||||
Q_EMIT dragFinished();
|
||||
}
|
||||
@@ -126,7 +127,7 @@ void QGIBalloonLabel::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void QGIBalloonLabel::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event)
|
||||
void QGIBalloonLabel::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
QGIViewBalloon* qgivBalloon = dynamic_cast<QGIViewBalloon*>(parentItem());
|
||||
if (!qgivBalloon) {
|
||||
@@ -134,7 +135,8 @@ void QGIBalloonLabel::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event)
|
||||
return;
|
||||
}
|
||||
|
||||
auto ViewProvider = dynamic_cast<ViewProviderBalloon*>(qgivBalloon->getViewProvider(qgivBalloon->getViewObject()));
|
||||
auto ViewProvider = dynamic_cast<ViewProviderBalloon*>(
|
||||
qgivBalloon->getViewProvider(qgivBalloon->getViewObject()));
|
||||
if (!ViewProvider) {
|
||||
qWarning() << "QGIBalloonLabel::mouseDoubleClickEvent: No valid view provider";
|
||||
return;
|
||||
@@ -144,21 +146,22 @@ void QGIBalloonLabel::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event)
|
||||
QGraphicsItem::mouseDoubleClickEvent(event);
|
||||
}
|
||||
|
||||
void QGIBalloonLabel::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
void QGIBalloonLabel::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
|
||||
{
|
||||
Q_EMIT hover(true);
|
||||
hasHover = true;
|
||||
if (!isSelected()) {
|
||||
setPrettyPre();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setPrettySel();
|
||||
}
|
||||
QGraphicsItem::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
void QGIBalloonLabel::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
void QGIBalloonLabel::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
|
||||
{
|
||||
QGIView *view = dynamic_cast<QGIView *> (parentItem());
|
||||
QGIView* view = dynamic_cast<QGIView*>(parentItem());
|
||||
assert(view);
|
||||
Q_UNUSED(view);
|
||||
|
||||
@@ -166,7 +169,8 @@ void QGIBalloonLabel::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
hasHover = false;
|
||||
if (!isSelected()) {
|
||||
setPrettyNormal();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setPrettySel();
|
||||
}
|
||||
QGraphicsItem::hoverLeaveEvent(event);
|
||||
@@ -177,7 +181,8 @@ QRectF QGIBalloonLabel::boundingRect() const
|
||||
return childrenBoundingRect();
|
||||
}
|
||||
|
||||
void QGIBalloonLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void QGIBalloonLabel::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
QWidget* widget)
|
||||
{
|
||||
Q_UNUSED(widget);
|
||||
Q_UNUSED(painter);
|
||||
@@ -187,10 +192,11 @@ void QGIBalloonLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
|
||||
//QGraphicsObject/QGraphicsItem::paint gives link error.
|
||||
}
|
||||
|
||||
void QGIBalloonLabel::setPosFromCenter(const double &xCenter, const double &yCenter)
|
||||
void QGIBalloonLabel::setPosFromCenter(const double& xCenter, const double& yCenter)
|
||||
{
|
||||
//set label's Qt position(top, left) given boundingRect center point
|
||||
setPos(xCenter - m_labelText->boundingRect().width() / 2., yCenter - m_labelText->boundingRect().height() / 2.);
|
||||
setPos(xCenter - m_labelText->boundingRect().width() / 2.,
|
||||
yCenter - m_labelText->boundingRect().height() / 2.);
|
||||
}
|
||||
|
||||
void QGIBalloonLabel::setLabelCenter()
|
||||
@@ -240,13 +246,13 @@ void QGIBalloonLabel::setColor(QColor color)
|
||||
}
|
||||
|
||||
//**************************************************************
|
||||
QGIViewBalloon::QGIViewBalloon() :
|
||||
dvBalloon(nullptr),
|
||||
hasHover(false),
|
||||
m_lineWidth(0.0),
|
||||
m_obtuse(false),
|
||||
parent(nullptr),
|
||||
m_dragInProgress(false)
|
||||
QGIViewBalloon::QGIViewBalloon()
|
||||
: dvBalloon(nullptr),
|
||||
hasHover(false),
|
||||
m_lineWidth(0.0),
|
||||
m_obtuse(false),
|
||||
parent(nullptr),
|
||||
m_dragInProgress(false)
|
||||
{
|
||||
m_ctrl = false;
|
||||
|
||||
@@ -269,7 +275,7 @@ QGIViewBalloon::QGIViewBalloon() :
|
||||
balloonShape = new QGIDimLines();
|
||||
addToGroup(balloonShape);
|
||||
balloonShape->setNormalColor(prefNormalColor());
|
||||
balloonShape->setFill(Qt::white, Qt::SolidPattern);
|
||||
balloonShape->setFill(Qt::transparent, Qt::SolidPattern);
|
||||
balloonShape->setFillOverride(true);
|
||||
balloonShape->setPrettyNormal();
|
||||
|
||||
@@ -286,37 +292,30 @@ QGIViewBalloon::QGIViewBalloon() :
|
||||
balloonLines->setZValue(ZVALUE::DIMENSION);
|
||||
balloonLines->setStyle(Qt::SolidLine);
|
||||
|
||||
balloonShape->setZValue(ZVALUE::DIMENSION + 1); //above balloonLines!
|
||||
balloonShape->setZValue(ZVALUE::DIMENSION + 1);//above balloonLines!
|
||||
balloonShape->setStyle(Qt::SolidLine);
|
||||
|
||||
balloonLabel->setPosFromCenter(0, 0);
|
||||
|
||||
// connecting the needed slots and signals
|
||||
QObject::connect(
|
||||
balloonLabel, SIGNAL(dragging(bool)),
|
||||
this , SLOT (balloonLabelDragged(bool)));
|
||||
QObject::connect(balloonLabel, SIGNAL(dragging(bool)), this, SLOT(balloonLabelDragged(bool)));
|
||||
|
||||
QObject::connect(
|
||||
balloonLabel, SIGNAL(dragFinished()),
|
||||
this , SLOT (balloonLabelDragFinished()));
|
||||
QObject::connect(balloonLabel, SIGNAL(dragFinished()), this, SLOT(balloonLabelDragFinished()));
|
||||
|
||||
QObject::connect(
|
||||
balloonLabel, SIGNAL(selected(bool)),
|
||||
this , SLOT (select(bool)));
|
||||
QObject::connect(balloonLabel, SIGNAL(selected(bool)), this, SLOT(select(bool)));
|
||||
|
||||
QObject::connect(
|
||||
balloonLabel, SIGNAL(hover(bool)),
|
||||
this , SLOT (hover(bool)));
|
||||
QObject::connect(balloonLabel, SIGNAL(hover(bool)), this, SLOT(hover(bool)));
|
||||
|
||||
setZValue(ZVALUE::DIMENSION);
|
||||
}
|
||||
|
||||
QVariant QGIViewBalloon::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
QVariant QGIViewBalloon::itemChange(GraphicsItemChange change, const QVariant& value)
|
||||
{
|
||||
if (change == ItemSelectedHasChanged && scene()) {
|
||||
if(isSelected()) {
|
||||
if (change == ItemSelectedHasChanged && scene()) {
|
||||
if (isSelected()) {
|
||||
balloonLabel->setSelected(true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
balloonLabel->setSelected(false);
|
||||
}
|
||||
draw();
|
||||
@@ -327,7 +326,7 @@ QVariant QGIViewBalloon::itemChange(GraphicsItemChange change, const QVariant &v
|
||||
//Set selection state for this and it's children
|
||||
void QGIViewBalloon::setGroupSelection(bool isSelected)
|
||||
{
|
||||
// Base::Console().Message("QGIVB::setGroupSelection(%d)\n", b);
|
||||
// Base::Console().Message("QGIVB::setGroupSelection(%d)\n", b);
|
||||
setSelected(isSelected);
|
||||
balloonLabel->setSelected(isSelected);
|
||||
balloonLines->setSelected(isSelected);
|
||||
@@ -336,7 +335,7 @@ void QGIViewBalloon::setGroupSelection(bool isSelected)
|
||||
|
||||
void QGIViewBalloon::select(bool state)
|
||||
{
|
||||
// Base::Console().Message("QGIVBall::select(%d)\n", state);
|
||||
// Base::Console().Message("QGIVBall::select(%d)\n", state);
|
||||
setSelected(state);
|
||||
draw();
|
||||
}
|
||||
@@ -347,13 +346,14 @@ void QGIViewBalloon::hover(bool state)
|
||||
draw();
|
||||
}
|
||||
|
||||
void QGIViewBalloon::setViewPartFeature(TechDraw::DrawViewBalloon *balloonFeat)
|
||||
void QGIViewBalloon::setViewPartFeature(TechDraw::DrawViewBalloon* balloonFeat)
|
||||
{
|
||||
// Base::Console().Message("QGIVB::setViewPartFeature()\n");
|
||||
if (!balloonFeat)
|
||||
// Base::Console().Message("QGIVB::setViewPartFeature()\n");
|
||||
if (!balloonFeat) {
|
||||
return;
|
||||
}
|
||||
|
||||
setViewFeature(static_cast<TechDraw::DrawView *>(balloonFeat));
|
||||
setViewFeature(static_cast<TechDraw::DrawView*>(balloonFeat));
|
||||
dvBalloon = balloonFeat;
|
||||
|
||||
DrawView* balloonParent = nullptr;
|
||||
@@ -361,11 +361,12 @@ void QGIViewBalloon::setViewPartFeature(TechDraw::DrawViewBalloon *balloonFeat)
|
||||
App::DocumentObject* docObj = balloonFeat->SourceView.getValue();
|
||||
if (docObj) {
|
||||
balloonParent = dynamic_cast<DrawView*>(docObj);
|
||||
if (balloonParent)
|
||||
if (balloonParent) {
|
||||
scale = balloonParent->getScale();
|
||||
}
|
||||
}
|
||||
|
||||
float x = Rez::guiX(balloonFeat->X.getValue() * scale) ;
|
||||
float x = Rez::guiX(balloonFeat->X.getValue() * scale);
|
||||
float y = Rez::guiX(-balloonFeat->Y.getValue() * scale);
|
||||
|
||||
balloonLabel->setColor(prefNormalColor());
|
||||
@@ -381,25 +382,22 @@ void QGIViewBalloon::setViewPartFeature(TechDraw::DrawViewBalloon *balloonFeat)
|
||||
|
||||
void QGIViewBalloon::updateView(bool update)
|
||||
{
|
||||
// Base::Console().Message("QGIVB::updateView()\n");
|
||||
// Base::Console().Message("QGIVB::updateView()\n");
|
||||
Q_UNUSED(update);
|
||||
auto balloon( dynamic_cast<TechDraw::DrawViewBalloon*>(getViewObject()) );
|
||||
if (!balloon)
|
||||
auto balloon(dynamic_cast<TechDraw::DrawViewBalloon*>(getViewObject()));
|
||||
if (!balloon) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto vp = static_cast<ViewProviderBalloon*>(getViewProvider(getViewObject()));
|
||||
if (!vp)
|
||||
if (!vp) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (update) {
|
||||
QString labelText = QString::fromUtf8(balloon->Text.getStrValue().data());
|
||||
balloonLabel->setDimString(labelText, Rez::guiX(balloon->TextWrapLen.getValue()));
|
||||
balloonLabel->setColor(getNormalColor());
|
||||
balloonLines->setNormalColor(getNormalColor());
|
||||
balloonShape->setNormalColor(getNormalColor());
|
||||
arrow->setNormalColor(getNormalColor());
|
||||
arrow->setFillColor(getNormalColor());
|
||||
|
||||
setNormalColorAll();
|
||||
}
|
||||
|
||||
updateBalloon();
|
||||
@@ -409,9 +407,9 @@ void QGIViewBalloon::updateView(bool update)
|
||||
//update the bubble contents
|
||||
void QGIViewBalloon::updateBalloon(bool obtuse)
|
||||
{
|
||||
// Base::Console().Message("QGIVB::updateBalloon()\n");
|
||||
(void) obtuse;
|
||||
const auto balloon( dynamic_cast<TechDraw::DrawViewBalloon *>(getViewObject()) );
|
||||
// Base::Console().Message("QGIVB::updateBalloon()\n");
|
||||
(void)obtuse;
|
||||
const auto balloon(dynamic_cast<TechDraw::DrawViewBalloon*>(getViewObject()));
|
||||
if (!balloon) {
|
||||
return;
|
||||
}
|
||||
@@ -419,15 +417,14 @@ void QGIViewBalloon::updateBalloon(bool obtuse)
|
||||
if (!vp) {
|
||||
return;
|
||||
}
|
||||
const TechDraw::DrawViewPart *refObj = balloon->getViewPart();
|
||||
const TechDraw::DrawViewPart* refObj = balloon->getViewPart();
|
||||
if (!refObj) {
|
||||
return;
|
||||
}
|
||||
|
||||
QFont font;
|
||||
font.setFamily(QString::fromUtf8(vp->Font.getValue()));
|
||||
font.setPixelSize(exactFontSize(vp->Font.getValue(),
|
||||
vp->Fontsize.getValue()));
|
||||
font.setPixelSize(exactFontSize(vp->Font.getValue(), vp->Fontsize.getValue()));
|
||||
balloonLabel->setFont(font);
|
||||
|
||||
QString labelText = QString::fromUtf8(balloon->Text.getStrValue().data());
|
||||
@@ -455,27 +452,30 @@ void QGIViewBalloon::updateBalloon(bool obtuse)
|
||||
void QGIViewBalloon::balloonLabelDragged(bool ctrl)
|
||||
{
|
||||
m_ctrl = ctrl;
|
||||
auto dvb( dynamic_cast<TechDraw::DrawViewBalloon *>(getViewObject()) );
|
||||
if (!dvb)
|
||||
auto dvb(dynamic_cast<TechDraw::DrawViewBalloon*>(getViewObject()));
|
||||
if (!dvb) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_dragInProgress) { //first drag movement
|
||||
if (!m_dragInProgress) {//first drag movement
|
||||
m_dragInProgress = true;
|
||||
if (ctrl) { //moving whole thing, remember Origin offset from Bubble
|
||||
if (ctrl) {//moving whole thing, remember Origin offset from Bubble
|
||||
m_saveOffset = dvb->getOriginOffset();
|
||||
}
|
||||
}
|
||||
|
||||
// store if origin is also moving to be able to later calc new origin and update feature
|
||||
if (ctrl)
|
||||
if (ctrl) {
|
||||
m_originDragged = true;
|
||||
}
|
||||
|
||||
DrawView* balloonParent = getSourceView();
|
||||
if (balloonParent)
|
||||
if (balloonParent) {
|
||||
// redraw the balloon at the new position
|
||||
// note that we don't store the new position to the X/Y properties
|
||||
// since the dragging is not yet finished
|
||||
drawBalloon(true);
|
||||
}
|
||||
}
|
||||
|
||||
void QGIViewBalloon::balloonLabelDragFinished()
|
||||
@@ -483,29 +483,36 @@ void QGIViewBalloon::balloonLabelDragFinished()
|
||||
// stores the final drag position for undo
|
||||
|
||||
auto dvb(dynamic_cast<TechDraw::DrawViewBalloon*>(getViewObject()));
|
||||
if (!dvb)
|
||||
if (!dvb) {
|
||||
return;
|
||||
}
|
||||
|
||||
double scale = 1.0;
|
||||
DrawView* balloonParent = getSourceView();
|
||||
if (balloonParent)
|
||||
if (balloonParent) {
|
||||
scale = balloonParent->getScale();
|
||||
}
|
||||
|
||||
//set feature position (x, y) from graphic position
|
||||
double x = Rez::appX(balloonLabel->X() / scale),
|
||||
y = Rez::appX(balloonLabel->Y() / scale);
|
||||
double x = Rez::appX(balloonLabel->X() / scale), y = Rez::appX(balloonLabel->Y() / scale);
|
||||
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Drag Balloon"));
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.X = %f", dvb->getNameInDocument(), x);
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Y = %f", dvb->getNameInDocument(), -y);
|
||||
Gui::Command::doCommand(
|
||||
Gui::Command::Doc, "App.ActiveDocument.%s.X = %f", dvb->getNameInDocument(), x);
|
||||
Gui::Command::doCommand(
|
||||
Gui::Command::Doc, "App.ActiveDocument.%s.Y = %f", dvb->getNameInDocument(), -y);
|
||||
|
||||
// for the case that origin was also dragged, calc new origin and update feature
|
||||
if (m_originDragged) {
|
||||
Base::Vector3d pos(x, -y, 0.0);
|
||||
Base::Vector3d newOrg = pos - m_saveOffset;
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.OriginX = %f",
|
||||
dvb->getNameInDocument(), newOrg.x);
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.OriginY = %f",
|
||||
dvb->getNameInDocument(), newOrg.y);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,
|
||||
"App.ActiveDocument.%s.OriginX = %f",
|
||||
dvb->getNameInDocument(),
|
||||
newOrg.x);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,
|
||||
"App.ActiveDocument.%s.OriginY = %f",
|
||||
dvb->getNameInDocument(),
|
||||
newOrg.y);
|
||||
}
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
@@ -517,9 +524,9 @@ void QGIViewBalloon::balloonLabelDragFinished()
|
||||
//from QGVP::mouseReleaseEvent - pos = eventPos in scene coords?
|
||||
void QGIViewBalloon::placeBalloon(QPointF pos)
|
||||
{
|
||||
// Base::Console().Message("QGIVB::placeBalloon(%s)\n",
|
||||
// DrawUtil::formatVector(pos).c_str());
|
||||
auto balloon( dynamic_cast<TechDraw::DrawViewBalloon*>(getViewObject()) );
|
||||
// Base::Console().Message("QGIVB::placeBalloon(%s)\n",
|
||||
// DrawUtil::formatVector(pos).c_str());
|
||||
auto balloon(dynamic_cast<TechDraw::DrawViewBalloon*>(getViewObject()));
|
||||
if (!balloon) {
|
||||
return;
|
||||
}
|
||||
@@ -546,13 +553,13 @@ void QGIViewBalloon::placeBalloon(QPointF pos)
|
||||
if (partVP) {
|
||||
qgivParent = partVP->getQView();
|
||||
if (qgivParent) {
|
||||
//tip position is mouse release pos in parentView coords ==> OriginX, OriginY
|
||||
//bubble pos is some arbitrary shift from tip position ==> X, Y
|
||||
//tip position is mouse release pos in parentView coords ==> OriginX, OriginY
|
||||
//bubble pos is some arbitrary shift from tip position ==> X, Y
|
||||
viewPos = qgivParent->mapFromScene(pos);
|
||||
balloon->OriginX.setValue(Rez::appX(viewPos.x()) / balloonParent->getScale());
|
||||
balloon->OriginY.setValue(-Rez::appX(viewPos.y()) / balloonParent->getScale());
|
||||
balloon->X.setValue(Rez::appX((viewPos.x() + 200.0) / balloonParent->getScale() ));
|
||||
balloon->Y.setValue(- Rez::appX((viewPos.y() - 200.0) / balloonParent->getScale() ));
|
||||
balloon->X.setValue(Rez::appX((viewPos.x() + 200.0) / balloonParent->getScale()));
|
||||
balloon->Y.setValue(-Rez::appX((viewPos.y() - 200.0) / balloonParent->getScale()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,8 +570,7 @@ void QGIViewBalloon::placeBalloon(QPointF pos)
|
||||
QFont font = balloonLabel->getFont();
|
||||
font.setPixelSize(calculateFontPixelSize(vp->Fontsize.getValue()));
|
||||
font.setFamily(QString::fromUtf8(vp->Font.getValue()));
|
||||
font.setPixelSize(exactFontSize(vp->Font.getValue(),
|
||||
vp->Fontsize.getValue()));
|
||||
font.setPixelSize(exactFontSize(vp->Font.getValue(), vp->Fontsize.getValue()));
|
||||
balloonLabel->setFont(font);
|
||||
|
||||
prepareGeometryChange();
|
||||
@@ -584,14 +590,14 @@ void QGIViewBalloon::draw()
|
||||
|
||||
void QGIViewBalloon::drawBalloon(bool dragged)
|
||||
{
|
||||
// Base::Console().Message("QGIVB::draw()\n");
|
||||
// Base::Console().Message("QGIVB::draw()\n");
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
TechDraw::DrawViewBalloon *balloon = dynamic_cast<TechDraw::DrawViewBalloon *>(getViewObject());
|
||||
if((!balloon) || //nothing to draw, don't try
|
||||
(!balloon->isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId()))) {
|
||||
TechDraw::DrawViewBalloon* balloon = dynamic_cast<TechDraw::DrawViewBalloon*>(getViewObject());
|
||||
if ((!balloon) ||//nothing to draw, don't try
|
||||
(!balloon->isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId()))) {
|
||||
balloonLabel->hide();
|
||||
hide();
|
||||
return;
|
||||
@@ -600,11 +606,11 @@ void QGIViewBalloon::drawBalloon(bool dragged)
|
||||
balloonLabel->show();
|
||||
show();
|
||||
|
||||
const TechDraw::DrawViewPart *refObj = balloon->getViewPart();
|
||||
const TechDraw::DrawViewPart* refObj = balloon->getViewPart();
|
||||
if (!refObj) {
|
||||
return;
|
||||
}
|
||||
if(!refObj->hasGeometry()) { // nothing to draw yet (restoring)
|
||||
if (!refObj->hasGeometry()) {// nothing to draw yet (restoring)
|
||||
balloonLabel->hide();
|
||||
hide();
|
||||
return;
|
||||
@@ -646,110 +652,143 @@ void QGIViewBalloon::drawBalloon(bool dragged)
|
||||
|
||||
if (balloon->isLocked()) {
|
||||
balloonLabel->setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
} else
|
||||
}
|
||||
else {
|
||||
balloonLabel->setFlag(QGraphicsItem::ItemIsMovable, true);
|
||||
}
|
||||
|
||||
Base::Vector3d dLineStart;
|
||||
Base::Vector3d kinkPoint;
|
||||
double kinkLength = Rez::guiX(balloon->KinkLength.getValue());
|
||||
|
||||
const char *balloonType = balloon->BubbleShape.getValueAsString();
|
||||
const char* balloonType = balloon->BubbleShape.getValueAsString();
|
||||
|
||||
float scale = balloon->ShapeScale.getValue();
|
||||
double offsetLR = 0;
|
||||
double offsetUD = 0;
|
||||
double offsetLR = 0;
|
||||
double offsetUD = 0;
|
||||
QPainterPath balloonPath;
|
||||
|
||||
if (strcmp(balloonType, "Circular") == 0) {
|
||||
double balloonRadius = sqrt(pow((textHeight / 2.0), 2) + pow((textWidth / 2.0), 2));
|
||||
balloonRadius = balloonRadius * scale;
|
||||
balloonPath.moveTo(lblCenter.x, lblCenter.y);
|
||||
balloonPath.addEllipse(lblCenter.x - balloonRadius, lblCenter.y - balloonRadius, balloonRadius * 2, balloonRadius * 2);
|
||||
offsetLR = balloonRadius;
|
||||
} else if (strcmp(balloonType, "None") == 0) {
|
||||
balloonPath.addEllipse(lblCenter.x - balloonRadius,
|
||||
lblCenter.y - balloonRadius,
|
||||
balloonRadius * 2,
|
||||
balloonRadius * 2);
|
||||
offsetLR = balloonRadius;
|
||||
}
|
||||
else if (strcmp(balloonType, "None") == 0) {
|
||||
balloonPath = QPainterPath();
|
||||
offsetLR = (textWidth / 2.0) + Rez::guiX(2.0);
|
||||
} else if (strcmp(balloonType, "Rectangle") == 0) {
|
||||
offsetLR = (textWidth / 2.0) + Rez::guiX(2.0);
|
||||
}
|
||||
else if (strcmp(balloonType, "Rectangle") == 0) {
|
||||
//Add some room
|
||||
textHeight = (textHeight * scale) + Rez::guiX(1.0);
|
||||
// we add some textWidth later because we first need to handle the text separators
|
||||
if (balloonLabel->getVerticalSep()) {
|
||||
for (auto& sep : balloonLabel->getSeps()) {
|
||||
balloonPath.moveTo(lblCenter.x - (textWidth / 2.0) + sep, lblCenter.y - (textHeight / 2.0));
|
||||
balloonPath.lineTo(lblCenter.x - (textWidth / 2.0) + sep, lblCenter.y + (textHeight / 2.0));
|
||||
balloonPath.moveTo(lblCenter.x - (textWidth / 2.0) + sep,
|
||||
lblCenter.y - (textHeight / 2.0));
|
||||
balloonPath.lineTo(lblCenter.x - (textWidth / 2.0) + sep,
|
||||
lblCenter.y + (textHeight / 2.0));
|
||||
}
|
||||
}
|
||||
textWidth = (textWidth * scale) + Rez::guiX(2.0);
|
||||
balloonPath.addRect(lblCenter.x - (textWidth / 2.0), lblCenter.y - (textHeight / 2.0), textWidth, textHeight);
|
||||
offsetLR = (textWidth / 2.0);
|
||||
} else if (strcmp(balloonType, "Triangle") == 0) {
|
||||
balloonPath.addRect(lblCenter.x - (textWidth / 2.0),
|
||||
lblCenter.y - (textHeight / 2.0),
|
||||
textWidth,
|
||||
textHeight);
|
||||
offsetLR = (textWidth / 2.0);
|
||||
}
|
||||
else if (strcmp(balloonType, "Triangle") == 0) {
|
||||
double radius = sqrt(pow((textHeight / 2.0), 2) + pow((textWidth / 2.0), 2));
|
||||
radius = radius * scale;
|
||||
radius += Rez::guiX(3.0);
|
||||
offsetLR = (tan(30 * M_PI / 180) * radius);
|
||||
offsetLR = (tan(30 * M_PI / 180) * radius);
|
||||
QPolygonF triangle;
|
||||
double startAngle = -M_PI / 2;
|
||||
double angle = startAngle;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
triangle += QPointF(lblCenter.x + (radius * cos(angle)), lblCenter.y + (radius * sin(angle)));
|
||||
triangle +=
|
||||
QPointF(lblCenter.x + (radius * cos(angle)), lblCenter.y + (radius * sin(angle)));
|
||||
angle += (2 * M_PI / 3);
|
||||
}
|
||||
balloonPath.moveTo(lblCenter.x + (radius * cos(startAngle)), lblCenter.y + (radius * sin(startAngle)));
|
||||
balloonPath.moveTo(lblCenter.x + (radius * cos(startAngle)),
|
||||
lblCenter.y + (radius * sin(startAngle)));
|
||||
balloonPath.addPolygon(triangle);
|
||||
} else if (strcmp(balloonType, "Inspection") == 0) {
|
||||
}
|
||||
else if (strcmp(balloonType, "Inspection") == 0) {
|
||||
//Add some room
|
||||
textWidth = (textWidth * scale) + Rez::guiX(2.0);
|
||||
textHeight = (textHeight * scale) + Rez::guiX(1.0);
|
||||
QPointF textBoxCorner(lblCenter.x - (textWidth / 2.0), lblCenter.y - (textHeight / 2.0));
|
||||
balloonPath.moveTo(textBoxCorner);
|
||||
balloonPath.lineTo(textBoxCorner.x() + textWidth, textBoxCorner.y());
|
||||
balloonPath.arcTo(textBoxCorner.x() + textWidth - (textHeight / 2.0), textBoxCorner.y(), textHeight, textHeight, 90, -180);
|
||||
balloonPath.arcTo(textBoxCorner.x() + textWidth - (textHeight / 2.0),
|
||||
textBoxCorner.y(),
|
||||
textHeight,
|
||||
textHeight,
|
||||
90,
|
||||
-180);
|
||||
balloonPath.lineTo(textBoxCorner.x(), textBoxCorner.y() + textHeight);
|
||||
balloonPath.arcTo(textBoxCorner.x() - (textHeight / 2), textBoxCorner.y(), textHeight, textHeight, -90, -180);
|
||||
offsetLR = (textWidth / 2.0) + (textHeight / 2.0);
|
||||
} else if (strcmp(balloonType, "Square") == 0) {
|
||||
balloonPath.arcTo(textBoxCorner.x() - (textHeight / 2),
|
||||
textBoxCorner.y(),
|
||||
textHeight,
|
||||
textHeight,
|
||||
-90,
|
||||
-180);
|
||||
offsetLR = (textWidth / 2.0) + (textHeight / 2.0);
|
||||
}
|
||||
else if (strcmp(balloonType, "Square") == 0) {
|
||||
//Add some room
|
||||
textWidth = (textWidth * scale) + Rez::guiX(2.0);
|
||||
textHeight = (textHeight * scale) + Rez::guiX(1.0);
|
||||
double max = std::max(textWidth, textHeight);
|
||||
balloonPath.addRect(lblCenter.x -(max / 2.0), lblCenter.y - (max / 2.0), max, max);
|
||||
offsetLR = (max / 2.0);
|
||||
} else if (strcmp(balloonType, "Hexagon") == 0) {
|
||||
balloonPath.addRect(lblCenter.x - (max / 2.0), lblCenter.y - (max / 2.0), max, max);
|
||||
offsetLR = (max / 2.0);
|
||||
}
|
||||
else if (strcmp(balloonType, "Hexagon") == 0) {
|
||||
double radius = sqrt(pow((textHeight / 2.0), 2) + pow((textWidth / 2.0), 2));
|
||||
radius = radius * scale;
|
||||
radius += Rez::guiX(1.0);
|
||||
offsetLR = radius;
|
||||
offsetLR = radius;
|
||||
QPolygonF triangle;
|
||||
double startAngle = -2 * M_PI / 3;
|
||||
double angle = startAngle;
|
||||
for (int i = 0; i < 7; i++) {
|
||||
triangle += QPointF(lblCenter.x + (radius * cos(angle)), lblCenter.y + (radius * sin(angle)));
|
||||
triangle +=
|
||||
QPointF(lblCenter.x + (radius * cos(angle)), lblCenter.y + (radius * sin(angle)));
|
||||
angle += (2 * M_PI / 6);
|
||||
}
|
||||
balloonPath.moveTo(lblCenter.x + (radius * cos(startAngle)), lblCenter.y + (radius * sin(startAngle)));
|
||||
balloonPath.moveTo(lblCenter.x + (radius * cos(startAngle)),
|
||||
lblCenter.y + (radius * sin(startAngle)));
|
||||
balloonPath.addPolygon(triangle);
|
||||
}
|
||||
else if (strcmp(balloonType, "Line") == 0) {
|
||||
textHeight = textHeight*scale + Rez::guiX(0.5);
|
||||
textWidth = textWidth*scale + Rez::guiX(1.0);
|
||||
textHeight = textHeight * scale + Rez::guiX(0.5);
|
||||
textWidth = textWidth * scale + Rez::guiX(1.0);
|
||||
|
||||
offsetLR = textWidth/2.0;
|
||||
offsetUD = textHeight/2.0;
|
||||
offsetLR = textWidth / 2.0;
|
||||
offsetUD = textHeight / 2.0;
|
||||
|
||||
balloonPath.moveTo(lblCenter.x - textWidth/2.0, lblCenter.y + offsetUD);
|
||||
balloonPath.lineTo(lblCenter.x + textWidth/2.0, lblCenter.y + offsetUD);
|
||||
balloonPath.moveTo(lblCenter.x - textWidth / 2.0, lblCenter.y + offsetUD);
|
||||
balloonPath.lineTo(lblCenter.x + textWidth / 2.0, lblCenter.y + offsetUD);
|
||||
}
|
||||
|
||||
balloonShape->setPath(balloonPath);
|
||||
|
||||
offsetLR = (lblCenter.x < arrowTipX) ? offsetLR : -offsetLR ;
|
||||
offsetLR = (lblCenter.x < arrowTipX) ? offsetLR : -offsetLR;
|
||||
|
||||
if (DrawUtil::fpCompare(kinkLength, 0.0) && strcmp(balloonType, "Line")) { //if no kink, then dLine start sb on line from center to arrow
|
||||
if (DrawUtil::fpCompare(kinkLength, 0.0)
|
||||
&& strcmp(balloonType,
|
||||
"Line")) {//if no kink, then dLine start sb on line from center to arrow
|
||||
dLineStart = lblCenter;
|
||||
kinkPoint = dLineStart;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dLineStart.y = lblCenter.y + offsetUD;
|
||||
dLineStart.x = lblCenter.x + offsetLR ;
|
||||
dLineStart.x = lblCenter.x + offsetLR;
|
||||
kinkLength = (lblCenter.x < arrowTipX) ? kinkLength : -kinkLength;
|
||||
kinkPoint.y = dLineStart.y;
|
||||
kinkPoint.x = dLineStart.x + kinkLength;
|
||||
@@ -762,41 +801,45 @@ void QGIViewBalloon::drawBalloon(bool dragged)
|
||||
double xAdj = 0.0;
|
||||
double yAdj = 0.0;
|
||||
int endType = balloon->EndType.getValue();
|
||||
double arrowAdj = QGIArrow::getOverlapAdjust(endType,
|
||||
balloon->EndTypeScale.getValue()*QGIArrow::getPrefArrowSize());
|
||||
double arrowAdj = QGIArrow::getOverlapAdjust(
|
||||
endType, balloon->EndTypeScale.getValue() * QGIArrow::getPrefArrowSize());
|
||||
|
||||
if (endType == ArrowType::NONE) {
|
||||
arrow->hide();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
arrow->setStyle(endType);
|
||||
|
||||
arrow->setSize(balloon->EndTypeScale.getValue()*QGIArrow::getPrefArrowSize());
|
||||
arrow->setSize(balloon->EndTypeScale.getValue() * QGIArrow::getPrefArrowSize());
|
||||
arrow->draw();
|
||||
|
||||
Base::Vector3d arrowTipPos(arrowTipX, arrowTipY, 0.0);
|
||||
Base::Vector3d dirballoonLinesLine;
|
||||
if (!DrawUtil::fpCompare(kinkLength, 0.0)) {
|
||||
dirballoonLinesLine = (arrowTipPos - kinkPoint).Normalize();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dirballoonLinesLine = (arrowTipPos - dLineStart).Normalize();
|
||||
}
|
||||
|
||||
float arAngle = atan2(dirballoonLinesLine.y, dirballoonLinesLine.x) * 180 / M_PI;
|
||||
|
||||
arrow->setPos(arrowTipX, arrowTipY);
|
||||
if ( (endType == ArrowType::FILLED_TRIANGLE) &&
|
||||
(prefOrthoPyramid()) ) {
|
||||
if ((endType == ArrowType::FILLED_TRIANGLE) && (prefOrthoPyramid())) {
|
||||
if (arAngle < 0.0) {
|
||||
arAngle += 360.0;
|
||||
}
|
||||
//set the angle to closest cardinal direction
|
||||
if ( (45.0 < arAngle) && (arAngle < 135.0) ) {
|
||||
if ((45.0 < arAngle) && (arAngle < 135.0)) {
|
||||
arAngle = 90.0;
|
||||
} else if ( (135.0 < arAngle) && (arAngle < 225.0) ) {
|
||||
}
|
||||
else if ((135.0 < arAngle) && (arAngle < 225.0)) {
|
||||
arAngle = 180.0;
|
||||
} else if ( (225.0 < arAngle) && (arAngle < 315.0) ) {
|
||||
}
|
||||
else if ((225.0 < arAngle) && (arAngle < 315.0)) {
|
||||
arAngle = 270.0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
arAngle = 0;
|
||||
}
|
||||
double radAngle = arAngle * M_PI / 180.0;
|
||||
@@ -820,15 +863,18 @@ void QGIViewBalloon::drawBalloon(bool dragged)
|
||||
// redraw the Balloon and the parent View
|
||||
if (hasHover && !isSelected()) {
|
||||
setPrettyPre();
|
||||
} else if (isSelected()) {
|
||||
}
|
||||
else if (isSelected()) {
|
||||
setPrettySel();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setPrettyNormal();
|
||||
}
|
||||
|
||||
if (parentItem()) {
|
||||
parentItem()->update();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Base::Console().Log("INFO - QGIVB::draw - no parent to update\n");
|
||||
}
|
||||
}
|
||||
@@ -838,16 +884,16 @@ void QGIViewBalloon::setPrettyPre(void)
|
||||
arrow->setPrettyPre();
|
||||
//TODO: primPath needs override for fill
|
||||
//balloonShape->setFillOverride(true); //don't fill with pre or select colours.
|
||||
// balloonShape->setFill(Qt::white, Qt::NoBrush);
|
||||
// balloonShape->setFill(Qt::white, Qt::NoBrush);
|
||||
balloonShape->setPrettyPre();
|
||||
balloonLines->setPrettyPre();
|
||||
}
|
||||
|
||||
void QGIViewBalloon::setPrettySel(void)
|
||||
{
|
||||
// Base::Console().Message("QGIVBal::setPrettySel()\n");
|
||||
// Base::Console().Message("QGIVBal::setPrettySel()\n");
|
||||
arrow->setPrettySel();
|
||||
// balloonShape->setFill(Qt::white, Qt::NoBrush);
|
||||
// balloonShape->setFill(Qt::white, Qt::NoBrush);
|
||||
balloonShape->setPrettySel();
|
||||
balloonLines->setPrettySel();
|
||||
}
|
||||
@@ -855,7 +901,7 @@ void QGIViewBalloon::setPrettySel(void)
|
||||
void QGIViewBalloon::setPrettyNormal(void)
|
||||
{
|
||||
arrow->setPrettyNormal();
|
||||
// balloonShape->setFill(Qt::white, Qt::SolidPattern);
|
||||
// balloonShape->setFill(Qt::white, Qt::SolidPattern);
|
||||
balloonShape->setPrettyNormal();
|
||||
balloonLines->setPrettyNormal();
|
||||
}
|
||||
@@ -863,11 +909,13 @@ void QGIViewBalloon::setPrettyNormal(void)
|
||||
|
||||
void QGIViewBalloon::drawBorder(void)
|
||||
{
|
||||
//Dimensions have no border!
|
||||
// Base::Console().Message("TRACE - QGIViewDimension::drawBorder - doing nothing!\n");
|
||||
//Dimensions have no border!
|
||||
// Base::Console().Message("TRACE - QGIViewDimension::drawBorder - doing nothing!\n");
|
||||
}
|
||||
|
||||
void QGIViewBalloon::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
void QGIViewBalloon::paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
QWidget* widget)
|
||||
{
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
|
||||
@@ -876,19 +924,20 @@ void QGIViewBalloon::paint ( QPainter * painter, const QStyleOptionGraphicsItem
|
||||
setPens();
|
||||
if (svg) {
|
||||
setSvgPens();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setPens();
|
||||
}
|
||||
QGIView::paint (painter, &myOption, widget);
|
||||
QGIView::paint(painter, &myOption, widget);
|
||||
setPens();
|
||||
}
|
||||
|
||||
void QGIViewBalloon::setSvgPens(void)
|
||||
{
|
||||
double svgLineFactor = 3.0; //magic number. should be a setting somewhere.
|
||||
balloonLines->setWidth(m_lineWidth/svgLineFactor);
|
||||
balloonShape->setWidth(m_lineWidth/svgLineFactor);
|
||||
arrow->setWidth(arrow->getWidth()/svgLineFactor);
|
||||
double svgLineFactor = 3.0;//magic number. should be a setting somewhere.
|
||||
balloonLines->setWidth(m_lineWidth / svgLineFactor);
|
||||
balloonShape->setWidth(m_lineWidth / svgLineFactor);
|
||||
arrow->setWidth(arrow->getWidth() / svgLineFactor);
|
||||
}
|
||||
|
||||
void QGIViewBalloon::setPens(void)
|
||||
@@ -898,16 +947,26 @@ void QGIViewBalloon::setPens(void)
|
||||
arrow->setWidth(m_lineWidth);
|
||||
}
|
||||
|
||||
void QGIViewBalloon::setNormalColorAll()
|
||||
{
|
||||
QColor qc = prefNormalColor();
|
||||
balloonLabel->setColor(qc);
|
||||
balloonLines->setNormalColor(qc);
|
||||
balloonShape->setNormalColor(qc);
|
||||
arrow->setNormalColor(qc);
|
||||
arrow->setFillColor(qc);
|
||||
}
|
||||
|
||||
QColor QGIViewBalloon::prefNormalColor()
|
||||
{
|
||||
setNormalColor(PreferencesGui::dimQColor());
|
||||
setNormalColor(PreferencesGui::getAccessibleQColor(PreferencesGui::dimQColor()));
|
||||
|
||||
ViewProviderBalloon* vpBalloon = nullptr;
|
||||
Gui::ViewProvider* vp = getViewProvider(getBalloonFeat());
|
||||
if (vp) {
|
||||
vpBalloon = dynamic_cast<ViewProviderBalloon*>(vp);
|
||||
if (vpBalloon) {
|
||||
App::Color fcColor = vpBalloon->Color.getValue();
|
||||
App::Color fcColor = Preferences::getAccessibleColor(vpBalloon->Color.getValue());
|
||||
setNormalColor(fcColor.asValue<QColor>());
|
||||
}
|
||||
}
|
||||
@@ -924,9 +983,11 @@ int QGIViewBalloon::prefDefaultArrow() const
|
||||
//when would you want a crooked pyramid?
|
||||
bool QGIViewBalloon::prefOrthoPyramid() const
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Decorations");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/Decorations");
|
||||
bool ortho = hGrp->GetBool("PyramidOrtho", true);
|
||||
return ortho;
|
||||
}
|
||||
|
||||
@@ -38,15 +38,17 @@
|
||||
#include "QGIView.h"
|
||||
|
||||
|
||||
namespace TechDraw {
|
||||
namespace TechDraw
|
||||
{
|
||||
class DrawViewBalloon;
|
||||
class DrawView;
|
||||
}
|
||||
}// namespace TechDraw
|
||||
|
||||
namespace TechDraw {
|
||||
namespace TechDraw
|
||||
{
|
||||
class BaseGeom;
|
||||
class AOC;
|
||||
}
|
||||
}// namespace TechDraw
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
@@ -54,29 +56,43 @@ class QGIArrow;
|
||||
class QGIDimLines;
|
||||
class QGIViewBalloon;
|
||||
|
||||
class QGIBalloonLabel : public QGraphicsObject
|
||||
class QGIBalloonLabel: public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QGIBalloonLabel();
|
||||
~QGIBalloonLabel() = default;
|
||||
|
||||
enum {Type = QGraphicsItem::UserType + 141};
|
||||
int type() const override { return Type;}
|
||||
enum
|
||||
{
|
||||
Type = QGraphicsItem::UserType + 141
|
||||
};
|
||||
int type() const override
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
|
||||
QRectF boundingRect() const override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void paint( QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = nullptr ) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
QWidget* widget = nullptr) override;
|
||||
void setLabelCenter();
|
||||
void setPosFromCenter(const double &xCenter, const double &yCenter);
|
||||
double X() const { return posX; }
|
||||
double Y() const { return posY; } //minus posY?
|
||||
void setPosFromCenter(const double& xCenter, const double& yCenter);
|
||||
double X() const
|
||||
{
|
||||
return posX;
|
||||
}
|
||||
double Y() const
|
||||
{
|
||||
return posY;
|
||||
}//minus posY?
|
||||
|
||||
void setFont(QFont font);
|
||||
QFont getFont() { return m_labelText->font(); }
|
||||
QFont getFont()
|
||||
{
|
||||
return m_labelText->font();
|
||||
}
|
||||
void setDimString(QString text);
|
||||
void setDimString(QString text, qreal maxWidth);
|
||||
void setPrettySel();
|
||||
@@ -84,16 +100,37 @@ public:
|
||||
void setPrettyNormal();
|
||||
void setColor(QColor color);
|
||||
|
||||
void setQBalloon(QGIViewBalloon* qBalloon) { parent = qBalloon;}
|
||||
void setQBalloon(QGIViewBalloon* qBalloon)
|
||||
{
|
||||
parent = qBalloon;
|
||||
}
|
||||
|
||||
|
||||
QGCustomText* getDimText() { return m_labelText; }
|
||||
QGCustomText* getDimText()
|
||||
{
|
||||
return m_labelText;
|
||||
}
|
||||
|
||||
void setDimText(QGCustomText* newText) { m_labelText = newText; }
|
||||
bool getVerticalSep() const { return verticalSep; }
|
||||
void setVerticalSep(bool sep) { verticalSep = sep; }
|
||||
std::vector<int> getSeps() const { return seps; }
|
||||
void setSeps(std::vector<int> newSeps) { seps = newSeps; }
|
||||
void setDimText(QGCustomText* newText)
|
||||
{
|
||||
m_labelText = newText;
|
||||
}
|
||||
bool getVerticalSep() const
|
||||
{
|
||||
return verticalSep;
|
||||
}
|
||||
void setVerticalSep(bool sep)
|
||||
{
|
||||
verticalSep = sep;
|
||||
}
|
||||
std::vector<int> getSeps() const
|
||||
{
|
||||
return seps;
|
||||
}
|
||||
void setSeps(std::vector<int> newSeps)
|
||||
{
|
||||
seps = newSeps;
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void dragging(bool state);
|
||||
@@ -102,16 +139,16 @@ Q_SIGNALS:
|
||||
void dragFinished();
|
||||
|
||||
protected:
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant& value) override;
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override;
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override;
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
|
||||
|
||||
private:
|
||||
bool hasHover;
|
||||
|
||||
QGIViewBalloon *parent;
|
||||
QGIViewBalloon* parent;
|
||||
bool verticalSep;
|
||||
std::vector<int> seps;
|
||||
|
||||
@@ -126,24 +163,29 @@ private:
|
||||
|
||||
//*******************************************************************
|
||||
|
||||
class TechDrawGuiExport QGIViewBalloon : public QGIView
|
||||
class TechDrawGuiExport QGIViewBalloon: public QGIView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum {Type = QGraphicsItem::UserType + 140};
|
||||
enum
|
||||
{
|
||||
Type = QGraphicsItem::UserType + 140
|
||||
};
|
||||
|
||||
explicit QGIViewBalloon();
|
||||
~QGIViewBalloon() = default;
|
||||
|
||||
void setViewPartFeature(TechDraw::DrawViewBalloon *balloonFeat);
|
||||
int type() const override { return Type;}
|
||||
void setViewPartFeature(TechDraw::DrawViewBalloon* balloonFeat);
|
||||
int type() const override
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
|
||||
void drawBorder() override;
|
||||
void updateView(bool update = false) override;
|
||||
void paint( QPainter * painter,
|
||||
const QStyleOptionGraphicsItem * option,
|
||||
QWidget * widget = nullptr ) override;
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
|
||||
QWidget* widget = nullptr) override;
|
||||
|
||||
QString getLabelText();
|
||||
void placeBalloon(QPointF pos);
|
||||
@@ -152,12 +194,20 @@ public:
|
||||
void setPrettyNormal();
|
||||
|
||||
void setGroupSelection(bool isSelected) override;
|
||||
virtual QGIBalloonLabel* getBalloonLabel() { return balloonLabel; }
|
||||
virtual QGIBalloonLabel* getBalloonLabel()
|
||||
{
|
||||
return balloonLabel;
|
||||
}
|
||||
|
||||
void setNormalColorAll();
|
||||
QColor prefNormalColor();
|
||||
int prefDefaultArrow() const;
|
||||
bool prefOrthoPyramid() const;
|
||||
TechDraw::DrawViewBalloon* getBalloonFeat() { return dvBalloon; }
|
||||
|
||||
TechDraw::DrawViewBalloon* getBalloonFeat()
|
||||
{
|
||||
return dvBalloon;
|
||||
}
|
||||
|
||||
public Q_SLOTS:
|
||||
void balloonLabelDragged(bool ctrl);
|
||||
@@ -169,16 +219,15 @@ public Q_SLOTS:
|
||||
protected:
|
||||
void draw() override;
|
||||
void drawBalloon(bool dragged = false);
|
||||
QVariant itemChange( GraphicsItemChange change,
|
||||
const QVariant &value ) override;
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant& value) override;
|
||||
virtual void setSvgPens();
|
||||
virtual void setPens();
|
||||
QString getPrecision();
|
||||
void parentViewMousePressed(QGIView *view, QPointF pos);
|
||||
void parentViewMousePressed(QGIView* view, QPointF pos);
|
||||
TechDraw::DrawView* getSourceView() const;
|
||||
|
||||
private:
|
||||
TechDraw::DrawViewBalloon *dvBalloon;
|
||||
TechDraw::DrawViewBalloon* dvBalloon;
|
||||
bool hasHover;
|
||||
QGIBalloonLabel* balloonLabel;
|
||||
QGIDimLines* balloonLines;
|
||||
@@ -186,7 +235,7 @@ private:
|
||||
QGIArrow* arrow;
|
||||
double m_lineWidth;
|
||||
bool m_obtuse;
|
||||
QGIView *parent; //used to create edit dialog
|
||||
QGIView* parent;//used to create edit dialog
|
||||
|
||||
bool m_dragInProgress;
|
||||
bool m_originDragged = false;
|
||||
@@ -194,6 +243,6 @@ private:
|
||||
Base::Vector3d m_saveOffset;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
}// namespace TechDrawGui
|
||||
|
||||
#endif // TECHDRAWGUI_QGIVBALLOON_H
|
||||
#endif// TECHDRAWGUI_QGIVBALLOON_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -482,8 +482,7 @@ void QGIViewPart::drawViewPart()
|
||||
}
|
||||
|
||||
// Draw Edges
|
||||
QColor edgeColor = PreferencesGui::normalQColor();
|
||||
|
||||
QColor edgeColor = PreferencesGui::getAccessibleQColor(PreferencesGui::normalQColor());
|
||||
const TechDraw::BaseGeomPtrVector& geoms = viewPart->getEdgeGeometry();
|
||||
TechDraw::BaseGeomPtrVector::const_iterator itGeom = geoms.begin();
|
||||
QGIEdge* item;
|
||||
@@ -530,7 +529,8 @@ void QGIViewPart::drawViewPart()
|
||||
else {
|
||||
TechDraw::GeomFormat* gf = viewPart->getGeomFormatBySelection(i);
|
||||
if (gf) {
|
||||
item->setNormalColor(gf->m_format.m_color.asValue<QColor>());
|
||||
App::Color color = Preferences::getAccessibleColor(gf->m_format.m_color);
|
||||
item->setNormalColor(color.asValue<QColor>());
|
||||
item->setWidth(gf->m_format.m_weight * lineScaleFactor);
|
||||
item->setStyle(gf->m_format.m_style);
|
||||
showItem = gf->m_format.m_visible;
|
||||
@@ -571,8 +571,7 @@ void QGIViewPart::drawViewPart()
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/TechDraw/General");
|
||||
double vertexScaleFactor = hGrp->GetFloat("VertexScale", 3.0);
|
||||
QColor vertexColor = PreferencesGui::vertexQColor();
|
||||
|
||||
QColor vertexColor = PreferencesGui::getAccessibleQColor(PreferencesGui::vertexQColor());
|
||||
bool showVertices = true;
|
||||
bool showCenterMarks = true;
|
||||
if (getFrameState()) {//frames are on
|
||||
@@ -637,7 +636,8 @@ bool QGIViewPart::formatGeomFromCosmetic(std::string cTag, QGIEdge* item)
|
||||
auto partFeat(dynamic_cast<TechDraw::DrawViewPart*>(getViewObject()));
|
||||
TechDraw::CosmeticEdge* ce = partFeat ? partFeat->getCosmeticEdge(cTag) : nullptr;
|
||||
if (ce) {
|
||||
item->setNormalColor(ce->m_format.m_color.asValue<QColor>());
|
||||
App::Color color = Preferences::getAccessibleColor(ce->m_format.m_color);
|
||||
item->setNormalColor(color.asValue<QColor>());
|
||||
item->setWidth(ce->m_format.m_weight * lineScaleFactor);
|
||||
item->setStyle(ce->m_format.m_style);
|
||||
result = ce->m_format.m_visible;
|
||||
@@ -653,7 +653,8 @@ bool QGIViewPart::formatGeomFromCenterLine(std::string cTag, QGIEdge* item)
|
||||
auto partFeat(dynamic_cast<TechDraw::DrawViewPart*>(getViewObject()));
|
||||
TechDraw::CenterLine* cl = partFeat ? partFeat->getCenterLine(cTag) : nullptr;
|
||||
if (cl) {
|
||||
item->setNormalColor(cl->m_format.m_color.asValue<QColor>());
|
||||
App::Color color = Preferences::getAccessibleColor(cl->m_format.m_color);
|
||||
item->setNormalColor(color.asValue<QColor>());
|
||||
item->setWidth(cl->m_format.m_weight * lineScaleFactor);
|
||||
item->setStyle(cl->m_format.m_style);
|
||||
result = cl->m_format.m_visible;
|
||||
@@ -800,7 +801,8 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
|
||||
addToGroup(sectionLine);
|
||||
sectionLine->setSymbol(const_cast<char*>(viewSection->SectionSymbol.getValue()));
|
||||
sectionLine->setSectionStyle(vp->SectionLineStyle.getValue());
|
||||
sectionLine->setSectionColor(vp->SectionLineColor.getValue().asValue<QColor>());
|
||||
App::Color color = Preferences::getAccessibleColor(vp->SectionLineColor.getValue());
|
||||
sectionLine->setSectionColor(color.asValue<QColor>());
|
||||
sectionLine->setPathMode(false);
|
||||
|
||||
//find the ends of the section line
|
||||
@@ -883,7 +885,8 @@ void QGIViewPart::drawComplexSectionLine(TechDraw::DrawViewSection* viewSection,
|
||||
addToGroup(sectionLine);
|
||||
sectionLine->setSymbol(const_cast<char*>(viewSection->SectionSymbol.getValue()));
|
||||
sectionLine->setSectionStyle(vp->SectionLineStyle.getValue());
|
||||
sectionLine->setSectionColor(vp->SectionLineColor.getValue().asValue<QColor>());
|
||||
App::Color color = Preferences::getAccessibleColor(vp->SectionLineColor.getValue());
|
||||
sectionLine->setSectionColor(color.asValue<QColor>());
|
||||
sectionLine->setPathMode(true);
|
||||
sectionLine->setPath(wirePath);
|
||||
sectionLine->setEnds(vStart, vEnd);
|
||||
@@ -988,7 +991,8 @@ void QGIViewPart::drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b)
|
||||
scene()->addItem(highlight);
|
||||
highlight->setReference(viewDetail->Reference.getValue());
|
||||
highlight->setStyle((Qt::PenStyle)vp->HighlightLineStyle.getValue());
|
||||
highlight->setColor(vp->HighlightLineColor.getValue().asValue<QColor>());
|
||||
App::Color color = Preferences::getAccessibleColor(vp->HighlightLineColor.getValue());
|
||||
highlight->setColor(color.asValue<QColor>());
|
||||
highlight->setFeatureName(viewDetail->getNameInDocument());
|
||||
highlight->setInteractive(true);
|
||||
|
||||
|
||||
@@ -23,11 +23,12 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <cmath>
|
||||
# include <sstream>
|
||||
|
||||
# include <QGraphicsItem>
|
||||
# include <QRectF>
|
||||
#include <QGraphicsColorizeEffect>
|
||||
#include <QGraphicsEffect>
|
||||
#include <QGraphicsItem>
|
||||
#include <QRectF>
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
@@ -36,13 +37,14 @@
|
||||
#include <Mod/TechDraw/App/DrawViewDraft.h>
|
||||
#include <Mod/TechDraw/App/DrawViewSymbol.h>
|
||||
|
||||
#include "QGIViewSymbol.h"
|
||||
#include "PreferencesGui.h"
|
||||
#include "QGCustomSvg.h"
|
||||
#include "QGDisplayArea.h"
|
||||
#include "QGIViewSymbol.h"
|
||||
#include "Rez.h"
|
||||
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
|
||||
QGIViewSymbol::QGIViewSymbol()
|
||||
{
|
||||
@@ -67,21 +69,19 @@ QGIViewSymbol::~QGIViewSymbol()
|
||||
// m_svgItem belongs to this group and will be deleted by Qt
|
||||
}
|
||||
|
||||
void QGIViewSymbol::setViewSymbolFeature(TechDraw::DrawViewSymbol *obj)
|
||||
void QGIViewSymbol::setViewSymbolFeature(TechDraw::DrawViewSymbol* obj)
|
||||
{
|
||||
// called from QGVPage. (once)
|
||||
setViewFeature(static_cast<TechDraw::DrawView *>(obj));
|
||||
setViewFeature(static_cast<TechDraw::DrawView*>(obj));
|
||||
}
|
||||
|
||||
void QGIViewSymbol::updateView(bool update)
|
||||
{
|
||||
auto viewSymbol( dynamic_cast<TechDraw::DrawViewSymbol *>(getViewObject()) );
|
||||
auto viewSymbol(dynamic_cast<TechDraw::DrawViewSymbol*>(getViewObject()));
|
||||
if (!viewSymbol)
|
||||
return;
|
||||
|
||||
if (update ||
|
||||
viewSymbol->isTouched() ||
|
||||
viewSymbol->Symbol.isTouched()) {
|
||||
if (update || viewSymbol->isTouched() || viewSymbol->Symbol.isTouched()) {
|
||||
draw();
|
||||
}
|
||||
|
||||
@@ -104,20 +104,21 @@ void QGIViewSymbol::draw()
|
||||
|
||||
void QGIViewSymbol::drawSvg()
|
||||
{
|
||||
auto viewSymbol( dynamic_cast<TechDraw::DrawViewSymbol *>(getViewObject()) );
|
||||
auto viewSymbol(dynamic_cast<TechDraw::DrawViewSymbol*>(getViewObject()));
|
||||
if (!viewSymbol)
|
||||
return;
|
||||
|
||||
double rezfactor = Rez::getRezFactor();
|
||||
double scaling = viewSymbol->getScale();
|
||||
double pxMm = 3.78; //96px/25.4mm ( CSS/SVG defined value of 96 pixels per inch)
|
||||
// double pxMm = 3.54; //90px/25.4mm ( inkscape value version <= 0.91)
|
||||
//some software uses different px/in, so symbol will need Scale adjusted.
|
||||
double pxMm = 3.78;//96px/25.4mm ( CSS/SVG defined value of 96 pixels per inch)
|
||||
// double pxMm = 3.54; //90px/25.4mm ( inkscape value version <= 0.91)
|
||||
//some software uses different px/in, so symbol will need Scale adjusted.
|
||||
//Arch/Draft views are in px and need to be scaled @ rezfactor px/mm to ensure proper representation
|
||||
if (viewSymbol->isDerivedFrom(TechDraw::DrawViewArch::getClassTypeId()) ||
|
||||
viewSymbol->isDerivedFrom(TechDraw::DrawViewDraft::getClassTypeId()) ) {
|
||||
if (viewSymbol->isDerivedFrom(TechDraw::DrawViewArch::getClassTypeId())
|
||||
|| viewSymbol->isDerivedFrom(TechDraw::DrawViewDraft::getClassTypeId())) {
|
||||
scaling = scaling * rezfactor;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
scaling = scaling * rezfactor / pxMm;
|
||||
}
|
||||
m_svgItem->setScale(scaling);
|
||||
@@ -135,9 +136,23 @@ void QGIViewSymbol::symbolToSvg(QByteArray qba)
|
||||
|
||||
prepareGeometryChange();
|
||||
if (!m_svgItem->load(&qba)) {
|
||||
Base::Console().Error("Error - Could not load Symbol into SVG renderer for %s\n", getViewName());
|
||||
Base::Console().Error("Error - Could not load Symbol into SVG renderer for %s\n",
|
||||
getViewName());
|
||||
}
|
||||
m_svgItem->centerAt(0., 0.);
|
||||
|
||||
if (Preferences::lightOnDark()) {
|
||||
QColor color = PreferencesGui::getAccessibleQColor(QColor(Qt::black));
|
||||
QGraphicsColorizeEffect* colorizeEffect = new QGraphicsColorizeEffect();
|
||||
colorizeEffect->setColor(color);
|
||||
m_svgItem->setGraphicsEffect(colorizeEffect);
|
||||
}
|
||||
else {
|
||||
//remove and delete any existing graphics effect
|
||||
if (m_svgItem->graphicsEffect()) {
|
||||
m_svgItem->setGraphicsEffect(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QGIViewSymbol::rotateView()
|
||||
@@ -147,4 +162,3 @@ void QGIViewSymbol::rotateView()
|
||||
double rot = getViewObject()->Rotation.getValue();
|
||||
m_displayArea->setRotation(-rot);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <Base/Console.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
|
||||
#include "PreferencesGui.h"
|
||||
#include "QGTracker.h"
|
||||
#include "QGIView.h"
|
||||
#include "QGSPage.h"
|
||||
@@ -480,7 +481,7 @@ QColor QGTracker::getTrackerColor()
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Tracker");
|
||||
App::Color trackColor = App::Color((uint32_t) hGrp->GetUnsigned("TrackerColor", 0xFF000000));
|
||||
result = trackColor.asValue<QColor>();
|
||||
result = PreferencesGui::getAccessibleQColor(trackColor.asValue<QColor>());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ void QGVPage::drawBackground(QPainter *painter, const QRectF &)
|
||||
QRectF paperRect(0, -pageHeight, pageWidth, pageHeight);
|
||||
QPolygon poly = mapFromScene(paperRect);
|
||||
|
||||
QBrush pageBrush(Qt::white);
|
||||
QBrush pageBrush(PreferencesGui::pageQColor());
|
||||
painter->setBrush(pageBrush);
|
||||
|
||||
painter->drawRect(poly.boundingRect());
|
||||
|
||||
@@ -25,14 +25,14 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QList>
|
||||
# include <QMenu>
|
||||
# include <QMessageBox>
|
||||
# include <QPointer>
|
||||
# include <QTextStream>
|
||||
# include <boost_signals2.hpp>
|
||||
# include <boost/signals2/connection.hpp>
|
||||
#include <QAction>
|
||||
#include <QList>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QPointer>
|
||||
#include <QTextStream>
|
||||
#include <boost/signals2/connection.hpp>
|
||||
#include <boost_signals2.hpp>
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
@@ -44,14 +44,15 @@
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/ViewProviderDocumentObject.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawView.h>
|
||||
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
|
||||
#include <Mod/TechDraw/App/DrawViewDimension.h>
|
||||
#include <Mod/TechDraw/App/DrawViewBalloon.h>
|
||||
#include <Mod/TechDraw/App/DrawLeaderLine.h>
|
||||
#include <Mod/TechDraw/App/DrawRichAnno.h>
|
||||
#include <Mod/TechDraw/App/DrawHatch.h>
|
||||
#include <Mod/TechDraw/App/DrawLeaderLine.h>
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
|
||||
#include <Mod/TechDraw/App/DrawRichAnno.h>
|
||||
#include <Mod/TechDraw/App/DrawTemplate.h>
|
||||
#include <Mod/TechDraw/App/DrawView.h>
|
||||
#include <Mod/TechDraw/App/DrawViewBalloon.h>
|
||||
#include <Mod/TechDraw/App/DrawViewDimension.h>
|
||||
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
|
||||
|
||||
#include "MDIViewPage.h"
|
||||
@@ -59,9 +60,9 @@
|
||||
#include "QGITemplate.h"
|
||||
#include "QGSPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "ViewProviderTemplate.h"
|
||||
#include "ViewProviderPage.h"
|
||||
#include "ViewProviderPageExtension.h"
|
||||
#include "ViewProviderTemplate.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
@@ -77,38 +78,38 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderPage, Gui::ViewProviderDocumentObject)
|
||||
// Construction/Destruction
|
||||
|
||||
ViewProviderPage::ViewProviderPage()
|
||||
: m_mdiView(nullptr),
|
||||
m_pageName(""),
|
||||
m_graphicsView(nullptr),
|
||||
m_graphicsScene(nullptr)
|
||||
: m_mdiView(nullptr), m_pageName(""), m_graphicsView(nullptr), m_graphicsScene(nullptr)
|
||||
{
|
||||
initExtension(this);
|
||||
|
||||
sPixmap = "TechDraw_TreePage";
|
||||
static const char *group = "Grid";
|
||||
static const char* group = "Grid";
|
||||
|
||||
ADD_PROPERTY_TYPE(ShowFrames ,(true), group, App::Prop_None, "Show or hide View frames and Labels on this Page");
|
||||
ADD_PROPERTY_TYPE(ShowGrid ,(PreferencesGui::showGrid()), group, App::Prop_None, "Show or hide a grid on this Page");
|
||||
ADD_PROPERTY_TYPE(GridSpacing, (PreferencesGui::gridSpacing()), group, (App::PropertyType::Prop_None),
|
||||
"Grid line spacing in mm");
|
||||
ADD_PROPERTY_TYPE(ShowFrames, (true), group, App::Prop_None,
|
||||
"Show or hide View frames and Labels on this Page");
|
||||
ADD_PROPERTY_TYPE(ShowGrid, (PreferencesGui::showGrid()), group, App::Prop_None,
|
||||
"Show or hide a grid on this Page");
|
||||
ADD_PROPERTY_TYPE(GridSpacing, (PreferencesGui::gridSpacing()), group,
|
||||
(App::PropertyType::Prop_None), "Grid line spacing in mm");
|
||||
|
||||
ShowFrames.setStatus(App::Property::Hidden, true);
|
||||
DisplayMode.setStatus(App::Property::Hidden, true);
|
||||
|
||||
m_graphicsScene = new QGSPage(this);
|
||||
m_graphicsScene->setItemIndexMethod(QGraphicsScene::NoIndex); //this prevents crash when deleting dims.
|
||||
//scene(view?) indices of dirty regions gets
|
||||
//out of sync. missing prepareGeometryChange
|
||||
//somewhere???? QTBUG-18021???
|
||||
m_graphicsScene->setItemIndexMethod(
|
||||
QGraphicsScene::NoIndex);//this prevents crash when deleting dims.
|
||||
//scene(view?) indices of dirty regions gets
|
||||
//out of sync. missing prepareGeometryChange
|
||||
//somewhere???? QTBUG-18021???
|
||||
}
|
||||
|
||||
ViewProviderPage::~ViewProviderPage()
|
||||
{
|
||||
removeMDIView(); //if the MDIViewPage is still in MainWindow, remove it.
|
||||
removeMDIView();//if the MDIViewPage is still in MainWindow, remove it.
|
||||
m_graphicsScene->deleteLater();
|
||||
}
|
||||
|
||||
void ViewProviderPage::attach(App::DocumentObject *pcFeat)
|
||||
void ViewProviderPage::attach(App::DocumentObject* pcFeat)
|
||||
{
|
||||
ViewProviderDocumentObject::attach(pcFeat);
|
||||
|
||||
@@ -118,7 +119,8 @@ void ViewProviderPage::attach(App::DocumentObject *pcFeat)
|
||||
connectGuiRepaint = feature->signalGuiPaint.connect(bnd);
|
||||
m_pageName = feature->getNameInDocument();
|
||||
m_graphicsScene->setObjectName(QString::fromLocal8Bit(m_pageName.c_str()));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Base::Console().Log("VPP::attach has no Feature!\n");
|
||||
}
|
||||
}
|
||||
@@ -136,13 +138,15 @@ std::vector<std::string> ViewProviderPage::getDisplayModes() const
|
||||
return StrList;
|
||||
}
|
||||
|
||||
void ViewProviderPage::onChanged(const App::Property *prop)
|
||||
void ViewProviderPage::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (prop == &(ShowGrid)) {
|
||||
setGrid();
|
||||
} else if (prop == &(GridSpacing)) {
|
||||
}
|
||||
else if (prop == &(GridSpacing)) {
|
||||
setGrid();
|
||||
} else if (prop == &Visibility) {
|
||||
}
|
||||
else if (prop == &Visibility) {
|
||||
//Visibility changes are handled in VPDO::onChanged -> show() or hide()
|
||||
}
|
||||
|
||||
@@ -157,25 +161,28 @@ void ViewProviderPage::updateData(const App::Property* prop)
|
||||
return;
|
||||
}
|
||||
if (prop == &(page->KeepUpdated)) {
|
||||
if (getDrawPage()->KeepUpdated.getValue()) {
|
||||
sPixmap = "TechDraw_TreePage";
|
||||
} else {
|
||||
sPixmap = "TechDraw_TreePageUnsync";
|
||||
}
|
||||
signalChangeIcon();
|
||||
//if the template is changed, rebuild the visual
|
||||
} else if (prop == &(page->Template)) {
|
||||
if (!page->isUnsetting()) {
|
||||
//check if a template has been added to scene first?
|
||||
if (getDrawPage()->KeepUpdated.getValue()) {
|
||||
sPixmap = "TechDraw_TreePage";
|
||||
}
|
||||
else {
|
||||
sPixmap = "TechDraw_TreePageUnsync";
|
||||
}
|
||||
signalChangeIcon();
|
||||
//if the template is changed, rebuild the visual
|
||||
}
|
||||
else if (prop == &(page->Template)) {
|
||||
if (!page->isUnsetting()) {
|
||||
//check if a template has been added to scene first?
|
||||
m_graphicsScene->matchSceneRectToTemplate();
|
||||
m_graphicsScene->updateTemplate();
|
||||
}
|
||||
} else if (prop == &(page->Label)) {
|
||||
if (m_mdiView &&
|
||||
!page->isUnsetting()) {
|
||||
m_mdiView->setTabText(page->Label.getValue());
|
||||
}
|
||||
} else if (prop == &page->Views) {
|
||||
}
|
||||
else if (prop == &(page->Label)) {
|
||||
if (m_mdiView && !page->isUnsetting()) {
|
||||
m_mdiView->setTabText(page->Label.getValue());
|
||||
}
|
||||
}
|
||||
else if (prop == &page->Views) {
|
||||
if (!page->isUnsetting())
|
||||
m_graphicsScene->fixOrphans();
|
||||
}
|
||||
@@ -183,7 +190,7 @@ void ViewProviderPage::updateData(const App::Property* prop)
|
||||
Gui::ViewProviderDocumentObject::updateData(prop);
|
||||
}
|
||||
|
||||
bool ViewProviderPage::onDelete(const std::vector<std::string> &)
|
||||
bool ViewProviderPage::onDelete(const std::vector<std::string>&)
|
||||
{
|
||||
// warn the user if the Page is not empty
|
||||
// but don't do this if there is just the template
|
||||
@@ -202,25 +209,26 @@ bool ViewProviderPage::onDelete(const std::vector<std::string> &)
|
||||
isTemplate = false;
|
||||
}
|
||||
|
||||
if (!objs.empty() && !isTemplate)
|
||||
{
|
||||
if (!objs.empty() && !isTemplate) {
|
||||
// generate dialog
|
||||
QString bodyMessage;
|
||||
QTextStream bodyMessageStream(&bodyMessage);
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
bodyMessageStream << qApp->translate(
|
||||
"Std_Delete",
|
||||
"The page is not empty, therefore the\nfollowing referencing objects might be lost:");
|
||||
bodyMessageStream << '\n';
|
||||
for (auto ObjIterator : objs)
|
||||
bodyMessageStream << '\n' << QString::fromUtf8(ObjIterator->Label.getValue());
|
||||
bodyMessageStream << "\n\n" << QObject::tr("Are you sure you want to continue?");
|
||||
// show and evaluate the dialog
|
||||
int DialogResult = QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
int DialogResult = QMessageBox::warning(
|
||||
Gui::getMainWindow(), qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
QMessageBox::Yes, QMessageBox::No);
|
||||
if (DialogResult == QMessageBox::Yes) {
|
||||
removeMDIView();
|
||||
return true;
|
||||
} else
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
@@ -233,24 +241,26 @@ void ViewProviderPage::setupContextMenu(QMenu* menu, QObject* receiver, const ch
|
||||
{
|
||||
Gui::ViewProviderDocumentObject::setupContextMenu(menu, receiver, member);
|
||||
QAction* act = menu->addAction(QObject::tr("Show drawing"), receiver, member);
|
||||
act->setData(QVariant((int) _SHOWDRAWING));
|
||||
act->setData(QVariant((int)_SHOWDRAWING));
|
||||
QAction* act2 = menu->addAction(QObject::tr("Toggle KeepUpdated"), receiver, member);
|
||||
act2->setData(QVariant((int) _TOGGLEUPDATE));
|
||||
act2->setData(QVariant((int)_TOGGLEUPDATE));
|
||||
}
|
||||
|
||||
bool ViewProviderPage::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == _SHOWDRAWING) {
|
||||
showMDIViewPage(); // show the drawing
|
||||
return false; //finished editing
|
||||
} else if (ModNum == _TOGGLEUPDATE) {
|
||||
auto page = getDrawPage();
|
||||
if (page) {
|
||||
page->KeepUpdated.setValue(!page->KeepUpdated.getValue());
|
||||
page->recomputeFeature();
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
showMDIViewPage();// show the drawing
|
||||
return false; //finished editing
|
||||
}
|
||||
else if (ModNum == _TOGGLEUPDATE) {
|
||||
auto page = getDrawPage();
|
||||
if (page) {
|
||||
page->KeepUpdated.setValue(!page->KeepUpdated.getValue());
|
||||
page->recomputeFeature();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return Gui::ViewProviderDocumentObject::setEdit(ModNum);
|
||||
}
|
||||
}
|
||||
@@ -279,7 +289,7 @@ void ViewProviderPage::show(void)
|
||||
void ViewProviderPage::hide(void)
|
||||
{
|
||||
if (getMDIView()) {
|
||||
getMDIView()->hide(); //this doesn't remove the mdiViewPage from the mainWindow
|
||||
getMDIView()->hide();//this doesn't remove the mdiViewPage from the mainWindow
|
||||
removeMDIView();
|
||||
}
|
||||
ViewProviderDocumentObject::hide();
|
||||
@@ -287,15 +297,17 @@ void ViewProviderPage::hide(void)
|
||||
|
||||
bool ViewProviderPage::showMDIViewPage()
|
||||
{
|
||||
if (m_mdiView.isNull()){
|
||||
if (m_mdiView.isNull()) {
|
||||
createMDIViewPage();
|
||||
m_graphicsScene->addChildrenToPage();
|
||||
m_graphicsScene->updateTemplate(true);
|
||||
m_graphicsScene->redrawAllViews();
|
||||
m_graphicsScene->fixOrphans(true);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
m_graphicsScene->redrawAllViews();
|
||||
m_graphicsScene->fixOrphans(true);
|
||||
m_graphicsView->update();
|
||||
}
|
||||
m_graphicsView->centerOnPage();
|
||||
|
||||
@@ -311,8 +323,7 @@ bool ViewProviderPage::showMDIViewPage()
|
||||
|
||||
void ViewProviderPage::createMDIViewPage()
|
||||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument
|
||||
(pcObject->getDocument());
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(pcObject->getDocument());
|
||||
m_mdiView = new MDIViewPage(this, doc, Gui::getMainWindow());
|
||||
if (!m_graphicsView) {
|
||||
m_graphicsView = new QGVPage(this, m_graphicsScene, m_mdiView);
|
||||
@@ -334,13 +345,15 @@ void ViewProviderPage::createMDIViewPage()
|
||||
//NOTE: removing MDIViewPage (parent) destroys QGVPage (eventually)
|
||||
void ViewProviderPage::removeMDIView(void)
|
||||
{
|
||||
if (!m_mdiView.isNull()) { //m_mdiView is a QPointer
|
||||
QList<QWidget*> wList= Gui::getMainWindow()->windows();
|
||||
if (!m_mdiView.isNull()) {//m_mdiView is a QPointer
|
||||
QList<QWidget*> wList = Gui::getMainWindow()->windows();
|
||||
if (wList.contains(m_mdiView)) {
|
||||
Gui::getMainWindow()->removeWindow(m_mdiView);
|
||||
m_mdiView = nullptr; //m_mdiView will eventually be deleted and
|
||||
m_graphicsView = nullptr; //will take m_graphicsView with it
|
||||
Gui::MDIView* aw = Gui::getMainWindow()->activeWindow(); //WF: this bit should be in the remove window logic, not here.
|
||||
m_mdiView = nullptr; //m_mdiView will eventually be deleted and
|
||||
m_graphicsView = nullptr;//will take m_graphicsView with it
|
||||
Gui::MDIView* aw =
|
||||
Gui::getMainWindow()
|
||||
->activeWindow();//WF: this bit should be in the remove window logic, not here.
|
||||
if (aw)
|
||||
aw->showMaximized();
|
||||
}
|
||||
@@ -355,11 +368,30 @@ MDIViewPage* ViewProviderPage::getMDIViewPage() const
|
||||
return m_mdiView;
|
||||
}
|
||||
|
||||
DrawTemplate* ViewProviderPage::getTemplate() const
|
||||
{
|
||||
return dynamic_cast<DrawTemplate*>(getDrawPage()->Template.getValue());
|
||||
}
|
||||
|
||||
|
||||
QGITemplate* ViewProviderPage::getQTemplate() const
|
||||
{
|
||||
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(getDrawPage()->getDocument());
|
||||
if (guiDoc) {
|
||||
Gui::ViewProvider* vp = guiDoc->getViewProvider(getTemplate());
|
||||
auto vpTemplate = dynamic_cast<ViewProviderTemplate*>(vp);
|
||||
if (vpTemplate) {
|
||||
return vpTemplate->getQTemplate();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
|
||||
{
|
||||
std::vector<App::DocumentObject*> temp;
|
||||
|
||||
App::DocumentObject *templateFeat = nullptr;
|
||||
App::DocumentObject* templateFeat = nullptr;
|
||||
templateFeat = getDrawPage()->Template.getValue();
|
||||
|
||||
if (templateFeat) {
|
||||
@@ -376,58 +408,51 @@ std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
|
||||
// DrawHatch
|
||||
// DrawWeldSymbol
|
||||
|
||||
const std::vector<App::DocumentObject *> &views = getDrawPage()->Views.getValues();
|
||||
const std::vector<App::DocumentObject*>& views = getDrawPage()->Views.getValues();
|
||||
|
||||
try {
|
||||
for (std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
|
||||
TechDraw::DrawView* featView = dynamic_cast<TechDraw::DrawView*> (*it);
|
||||
App::DocumentObject *docObj = *it;
|
||||
for (std::vector<App::DocumentObject*>::const_iterator it = views.begin();
|
||||
it != views.end(); ++it) {
|
||||
TechDraw::DrawView* featView = dynamic_cast<TechDraw::DrawView*>(*it);
|
||||
App::DocumentObject* docObj = *it;
|
||||
//DrawRichAnno with no parent is child of Page
|
||||
TechDraw::DrawRichAnno* dra = dynamic_cast<TechDraw::DrawRichAnno*> (*it);
|
||||
TechDraw::DrawRichAnno* dra = dynamic_cast<TechDraw::DrawRichAnno*>(*it);
|
||||
if (dra) {
|
||||
if (!dra->AnnoParent.getValue()) {
|
||||
temp.push_back(*it); //no parent, belongs to page
|
||||
temp.push_back(*it);//no parent, belongs to page
|
||||
}
|
||||
continue; //has a parent somewhere else
|
||||
continue;//has a parent somewhere else
|
||||
}
|
||||
|
||||
// Don't collect if dimension, projection group item, hatch or member of ClipGroup as these should be grouped elsewhere
|
||||
if (docObj->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId()) ||
|
||||
docObj->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId()) ||
|
||||
docObj->isDerivedFrom(TechDraw::DrawHatch::getClassTypeId()) ||
|
||||
docObj->isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId()) ||
|
||||
docObj->isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId()) ||
|
||||
docObj->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId()) ||
|
||||
docObj->isDerivedFrom(TechDraw::DrawWeldSymbol::getClassTypeId()) ||
|
||||
(featView && featView->isInClip()) )
|
||||
if (docObj->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())
|
||||
|| docObj->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())
|
||||
|| docObj->isDerivedFrom(TechDraw::DrawHatch::getClassTypeId())
|
||||
|| docObj->isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId())
|
||||
|| docObj->isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId())
|
||||
|| docObj->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())
|
||||
|| docObj->isDerivedFrom(TechDraw::DrawWeldSymbol::getClassTypeId())
|
||||
|| (featView && featView->isInClip()))
|
||||
continue;
|
||||
else
|
||||
temp.push_back(*it);
|
||||
}
|
||||
return temp;
|
||||
} catch (...) {
|
||||
}
|
||||
catch (...) {
|
||||
return std::vector<App::DocumentObject*>();
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderPage::isShow(void) const
|
||||
{
|
||||
return Visibility.getValue();
|
||||
}
|
||||
bool ViewProviderPage::isShow(void) const { return Visibility.getValue(); }
|
||||
|
||||
bool ViewProviderPage::getFrameState()
|
||||
{
|
||||
return ShowFrames.getValue();
|
||||
}
|
||||
bool ViewProviderPage::getFrameState() { return ShowFrames.getValue(); }
|
||||
|
||||
void ViewProviderPage::setFrameState(bool state)
|
||||
{
|
||||
ShowFrames.setValue(state);
|
||||
}
|
||||
void ViewProviderPage::setFrameState(bool state) { ShowFrames.setValue(state); }
|
||||
|
||||
void ViewProviderPage::toggleFrameState()
|
||||
{
|
||||
// Base::Console().Message("VPP::toggleFrameState()\n");
|
||||
// Base::Console().Message("VPP::toggleFrameState()\n");
|
||||
if (m_graphicsScene) {
|
||||
setFrameState(!getFrameState());
|
||||
m_graphicsScene->refreshViews();
|
||||
@@ -437,8 +462,8 @@ void ViewProviderPage::toggleFrameState()
|
||||
|
||||
void ViewProviderPage::setTemplateMarkers(bool state)
|
||||
{
|
||||
// Base::Console().Message("VPP::setTemplateMarkers(%d)\n", state);
|
||||
App::DocumentObject *templateFeat = nullptr;
|
||||
// Base::Console().Message("VPP::setTemplateMarkers(%d)\n", state);
|
||||
App::DocumentObject* templateFeat = nullptr;
|
||||
templateFeat = getDrawPage()->Template.getValue();
|
||||
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(templateFeat->getDocument());
|
||||
Gui::ViewProvider* vp = guiDoc->getViewProvider(templateFeat);
|
||||
@@ -452,7 +477,7 @@ void ViewProviderPage::setTemplateMarkers(bool state)
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderPage::canDelete(App::DocumentObject *obj) const
|
||||
bool ViewProviderPage::canDelete(App::DocumentObject* obj) const
|
||||
{
|
||||
// deletions from a page don't necessarily destroy anything
|
||||
// thus we can pass this action
|
||||
@@ -472,11 +497,11 @@ bool ViewProviderPage::canDragObject(App::DocumentObject* docObj) const
|
||||
return getVPPExtension()->extensionCanDragObject(docObj);
|
||||
}
|
||||
|
||||
bool ViewProviderPage::canDropObjectEx(App::DocumentObject* obj, App::DocumentObject *owner,
|
||||
const char *subname, const std::vector<std::string> &elements) const
|
||||
bool ViewProviderPage::canDropObjectEx(App::DocumentObject* obj, App::DocumentObject* owner,
|
||||
const char* subname,
|
||||
const std::vector<std::string>& elements) const
|
||||
{
|
||||
return getVPPExtension()->extensionCanDropObjectEx(obj, owner, subname, elements);
|
||||
|
||||
}
|
||||
|
||||
bool ViewProviderPage::canDropObject(App::DocumentObject* docObj) const
|
||||
@@ -510,12 +535,9 @@ TechDraw::DrawPage* ViewProviderPage::getDrawPage() const
|
||||
return dynamic_cast<TechDraw::DrawPage*>(pcObject);
|
||||
}
|
||||
|
||||
Gui::MDIView *ViewProviderPage::getMDIView() const
|
||||
{
|
||||
return m_mdiView.data();
|
||||
}
|
||||
Gui::MDIView* ViewProviderPage::getMDIView() const { return m_mdiView.data(); }
|
||||
|
||||
void ViewProviderPage::setGrid()
|
||||
void ViewProviderPage::setGrid()
|
||||
{
|
||||
TechDraw::DrawPage* dp = getDrawPage();
|
||||
if (!dp) {
|
||||
@@ -533,7 +555,8 @@ void ViewProviderPage::setGrid()
|
||||
if (ShowGrid.getValue()) {
|
||||
widget->showGrid(true);
|
||||
widget->makeGrid(pageWidth, pageHeight, gridStep);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
widget->showGrid(false);
|
||||
}
|
||||
widget->updateViewport();
|
||||
@@ -547,7 +570,4 @@ ViewProviderPageExtension* ViewProviderPage::getVPPExtension() const
|
||||
return vppe;
|
||||
}
|
||||
|
||||
const char* ViewProviderPage::whoAmI() const
|
||||
{
|
||||
return m_pageName.c_str();
|
||||
}
|
||||
const char* ViewProviderPage::whoAmI() const { return m_pageName.c_str(); }
|
||||
|
||||
@@ -26,26 +26,30 @@
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include <boost_signals2.hpp>
|
||||
#include <QPointer>
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <boost_signals2.hpp>
|
||||
|
||||
#include <App/PropertyUnits.h>
|
||||
#include <Gui/ViewProviderDocumentObject.h>
|
||||
#include <ViewProviderPageExtension.h>
|
||||
|
||||
namespace TechDraw{
|
||||
class DrawPage;
|
||||
}
|
||||
namespace TechDraw
|
||||
{
|
||||
class DrawPage;
|
||||
class DrawTemplate;
|
||||
}// namespace TechDraw
|
||||
|
||||
namespace TechDrawGui {
|
||||
namespace TechDrawGui
|
||||
{
|
||||
|
||||
class MDIViewPage;
|
||||
class QGVPage;
|
||||
class QGSPage;
|
||||
class QGITemplate;
|
||||
|
||||
class TechDrawGuiExport ViewProviderPage : public Gui::ViewProviderDocumentObject,
|
||||
public ViewProviderPageExtension
|
||||
class TechDrawGuiExport ViewProviderPage: public Gui::ViewProviderDocumentObject,
|
||||
public ViewProviderPageExtension
|
||||
{
|
||||
PROPERTY_HEADER_WITH_OVERRIDE(TechDrawGui::ViewProviderPage);
|
||||
|
||||
@@ -55,11 +59,11 @@ public:
|
||||
/// destructor
|
||||
~ViewProviderPage() override;
|
||||
|
||||
App::PropertyBool ShowFrames;
|
||||
App::PropertyBool ShowGrid;
|
||||
App::PropertyBool ShowFrames;
|
||||
App::PropertyBool ShowGrid;
|
||||
App::PropertyDistance GridSpacing;
|
||||
|
||||
void attach(App::DocumentObject *) override;
|
||||
void attach(App::DocumentObject*) override;
|
||||
void setDisplayMode(const char* ModeName) override;
|
||||
|
||||
bool canDragObjects() const override;
|
||||
@@ -69,10 +73,10 @@ public:
|
||||
void dropObject(App::DocumentObject* docObj) override;
|
||||
void constDropObject(App::DocumentObject* docObj) const;
|
||||
|
||||
bool canDropObjectEx(App::DocumentObject *obj, App::DocumentObject *owner,
|
||||
const char *subname, const std::vector<std::string> &elements) const override;
|
||||
bool canDropObjectEx(App::DocumentObject* obj, App::DocumentObject* owner, const char* subname,
|
||||
const std::vector<std::string>& elements) const override;
|
||||
|
||||
bool useNewSelectionModel() const override {return false;}
|
||||
bool useNewSelectionModel() const override { return false; }
|
||||
/// returns a list of all possible modes
|
||||
std::vector<std::string> getDisplayModes() const override;
|
||||
/// Hides the view provider
|
||||
@@ -87,11 +91,13 @@ public:
|
||||
/// Is called by the tree if the user double click on the object
|
||||
bool doubleClicked() override;
|
||||
void setupContextMenu(QMenu*, QObject*, const char*) override;
|
||||
bool onDelete(const std::vector<std::string> &) override;
|
||||
void onChanged(const App::Property *prop) override;
|
||||
bool onDelete(const std::vector<std::string>&) override;
|
||||
void onChanged(const App::Property* prop) override;
|
||||
void updateData(const App::Property* prop) override;
|
||||
|
||||
TechDraw::DrawPage* getDrawPage() const;
|
||||
TechDraw::DrawTemplate* getTemplate() const;
|
||||
QGITemplate* getQTemplate(void) const;
|
||||
|
||||
//slots & connections
|
||||
void onGuiRepaint(const TechDraw::DrawPage* dp);
|
||||
@@ -103,7 +109,7 @@ public:
|
||||
bool showMDIViewPage();
|
||||
void removeMDIView();
|
||||
|
||||
Gui::MDIView *getMDIView() const override;
|
||||
Gui::MDIView* getMDIView() const override;
|
||||
|
||||
bool getFrameState();
|
||||
void setFrameState(bool state);
|
||||
@@ -112,10 +118,10 @@ public:
|
||||
|
||||
bool canDelete(App::DocumentObject* obj) const override;
|
||||
|
||||
void setGrid();
|
||||
void setGrid();
|
||||
|
||||
QGSPage* getQGSPage(void) {return m_graphicsScene;}
|
||||
QGVPage* getQGVPage(void) {return m_graphicsView;}
|
||||
QGSPage* getQGSPage(void) { return m_graphicsScene; }
|
||||
QGVPage* getQGVPage(void) { return m_graphicsView; }
|
||||
|
||||
ViewProviderPageExtension* getVPPExtension() const;
|
||||
|
||||
@@ -132,7 +138,7 @@ private:
|
||||
QGSPage* m_graphicsScene;
|
||||
};
|
||||
|
||||
} // namespace TechDrawGui
|
||||
}// namespace TechDrawGui
|
||||
|
||||
|
||||
#endif // DRAWINGGUI_VIEWPROVIDERPAGE_H
|
||||
#endif// DRAWINGGUI_VIEWPROVIDERPAGE_H
|
||||
|
||||
Reference in New Issue
Block a user