Dimension Graphic Properties to Gui side
This commit is contained in:
@@ -87,30 +87,13 @@ enum RefType{
|
||||
|
||||
DrawViewDimension::DrawViewDimension(void)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels");
|
||||
std::string fontName = hGrp->GetASCII("LabelFont", "osifont");
|
||||
hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
double fontSize = hGrp->GetFloat("FontSize", 3.5);
|
||||
|
||||
ADD_PROPERTY_TYPE(References2D,(0,0),"",(App::PropertyType)(App::Prop_None),"Projected Geometry References");
|
||||
References2D.setScope(App::LinkScope::Global);
|
||||
ADD_PROPERTY_TYPE(References3D,(0,0),"",(App::PropertyType)(App::Prop_None),"3D Geometry References");
|
||||
References3D.setScope(App::LinkScope::Global);
|
||||
ADD_PROPERTY_TYPE(Font ,(fontName.c_str()),"Format",App::Prop_None, "The name of the font to use");
|
||||
ADD_PROPERTY_TYPE(Fontsize,(fontSize) ,"Format",(App::PropertyType)(App::Prop_None),"Dimension text size in mm");
|
||||
ADD_PROPERTY_TYPE(FormatSpec,(getDefaultFormatSpec().c_str()) ,
|
||||
"Format",(App::PropertyType)(App::Prop_None),"Dimension Format");
|
||||
|
||||
hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
|
||||
auto lg = LineGroup::lineGroupFactory(lgName);
|
||||
double weight = lg->getWeight("Graphic");
|
||||
delete lg; //Coverity CID 169507
|
||||
ADD_PROPERTY_TYPE(LineWidth,(weight) ,"Format",(App::PropertyType)(App::Prop_None),"Dimension line weight");
|
||||
//ADD_PROPERTY_TYPE(CentreLines,(0) ,"Format",(App::PropertyType)(App::Prop_None),"Arc Dimension Center Mark");
|
||||
|
||||
Type.setEnums(TypeEnums); //dimension type: length, radius etc
|
||||
ADD_PROPERTY(Type,((long)0));
|
||||
MeasureType.setEnums(MeasureTypeEnums);
|
||||
@@ -178,6 +161,7 @@ short DrawViewDimension::mustExecute() const
|
||||
if (!isRestoring()) {
|
||||
result = (References2D.isTouched() ||
|
||||
Type.isTouched() ||
|
||||
FormatSpec.isTouched() ||
|
||||
MeasureType.isTouched());
|
||||
}
|
||||
if (result) {
|
||||
|
||||
@@ -57,13 +57,7 @@ public:
|
||||
App::PropertyLinkSubList References2D; //Points to Projection SubFeatures
|
||||
App::PropertyLinkSubList References3D; //Points to 3D Geometry SubFeatures
|
||||
App::PropertyEnumeration Type; //DistanceX,DistanceY,Diameter, etc
|
||||
|
||||
/// Properties for Visualisation
|
||||
App::PropertyFont Font;
|
||||
App::PropertyFloat Fontsize;
|
||||
App::PropertyString FormatSpec;
|
||||
App::PropertyFloat LineWidth;
|
||||
//App::PropertyBool CentreLines;
|
||||
App::PropertyString FormatSpec;
|
||||
|
||||
short mustExecute() const;
|
||||
bool has2DReferences(void) const;
|
||||
|
||||
@@ -266,19 +266,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -478,32 +465,6 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="toolTip">
|
||||
<string>Default weight for GeomHatch lines</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hatch Weight</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="Gui::PrefDoubleSpinBox" name="doubleSpinBox">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>GeomWeight</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/TechDraw/PAT</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
#include "QGIArrow.h"
|
||||
#include "QGIDimLines.h"
|
||||
#include "QGIViewDimension.h"
|
||||
#include "ViewProviderDimension.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
@@ -155,6 +156,12 @@ QGIViewDimension::QGIViewDimension() :
|
||||
addToGroup(aHead1);
|
||||
aHead2 = new QGIArrow();
|
||||
addToGroup(aHead2);
|
||||
|
||||
datumLabel->setZValue(ZVALUE::DIMENSION);
|
||||
dimLines->setZValue(ZVALUE::DIMENSION);
|
||||
aHead1->setZValue(ZVALUE::DIMENSION);
|
||||
aHead2->setZValue(ZVALUE::DIMENSION);
|
||||
|
||||
//centerMark = new QGICMark();
|
||||
//addToGroup(centerMark);
|
||||
|
||||
@@ -179,6 +186,9 @@ QGIViewDimension::QGIViewDimension() :
|
||||
dimLines->setStyle(Qt::SolidLine);
|
||||
|
||||
toggleBorder(false);
|
||||
setZValue(ZVALUE::DIMENSION); //note: this won't paint dimensions over another View if it stacks
|
||||
//above this Dimension's parent view. need Layers?
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -195,8 +205,6 @@ void QGIViewDimension::setViewPartFeature(TechDraw::DrawViewDimension *obj)
|
||||
|
||||
datumLabel->setPosFromCenter(x, y);
|
||||
|
||||
m_lineWidth = Rez::guiX(obj->LineWidth.getValue());
|
||||
|
||||
updateDim();
|
||||
draw();
|
||||
}
|
||||
@@ -220,12 +228,17 @@ void QGIViewDimension::updateView(bool update)
|
||||
if( dim == nullptr )
|
||||
return;
|
||||
|
||||
auto vp = static_cast<ViewProviderDimension*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Identify what changed to prevent complete redraw
|
||||
if(dim->Fontsize.isTouched() ||
|
||||
dim->Font.isTouched()) {
|
||||
if(vp->Fontsize.isTouched() ||
|
||||
vp->Font.isTouched()) {
|
||||
QFont font = datumLabel->font();
|
||||
font.setPointSizeF(Rez::guiX(dim->Fontsize.getValue()));
|
||||
font.setFamily(QString::fromLatin1(dim->Font.getValue()));
|
||||
font.setPointSizeF(Rez::guiX(vp->Fontsize.getValue()));
|
||||
font.setFamily(QString::fromLatin1(vp->Font.getValue()));
|
||||
|
||||
datumLabel->setFont(font);
|
||||
//datumLabel->setLabelCenter();
|
||||
@@ -234,8 +247,8 @@ void QGIViewDimension::updateView(bool update)
|
||||
dim->Y.isTouched()) {
|
||||
datumLabel->setPosFromCenter(datumLabel->X(),datumLabel->Y());
|
||||
updateDim();
|
||||
} else if (dim->LineWidth.isTouched()) { //never happens!!
|
||||
m_lineWidth = dim->LineWidth.getValue();
|
||||
} else if (vp->LineWidth.isTouched()) { //never happens!!
|
||||
m_lineWidth = vp->LineWidth.getValue();
|
||||
updateDim();
|
||||
} else {
|
||||
updateDim();
|
||||
@@ -250,11 +263,15 @@ void QGIViewDimension::updateDim()
|
||||
if( dim == nullptr ) {
|
||||
return;
|
||||
}
|
||||
auto vp = static_cast<ViewProviderDimension*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString labelText = QString::fromUtf8(dim->getFormatedValue().data(),dim->getFormatedValue().size());
|
||||
QFont font = datumLabel->font();
|
||||
font.setPointSizeF(Rez::guiX(dim->Fontsize.getValue()));
|
||||
font.setFamily(QString::fromUtf8(dim->Font.getValue()));
|
||||
font.setPointSizeF(Rez::guiX(vp->Fontsize.getValue()));
|
||||
font.setFamily(QString::fromUtf8(vp->Font.getValue()));
|
||||
|
||||
datumLabel->setFont(font);
|
||||
prepareGeometryChange();
|
||||
@@ -309,7 +326,12 @@ void QGIViewDimension::draw()
|
||||
return;
|
||||
}
|
||||
|
||||
m_lineWidth = Rez::guiX(dim->LineWidth.getValue());
|
||||
auto vp = static_cast<ViewProviderDimension*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_lineWidth = Rez::guiX(vp->LineWidth.getValue());
|
||||
float margin = Rez::guiX(5.f);
|
||||
|
||||
QString labelText = datumLabel->toPlainText();
|
||||
@@ -469,7 +491,7 @@ void QGIViewDimension::draw()
|
||||
// text to left of vertical dims
|
||||
// text above horizontal dims
|
||||
double offsetFudge = 2.0;
|
||||
double textOffset = 0.75 * Rez::guiX(dim->Fontsize.getValue()) + offsetFudge;
|
||||
double textOffset = 0.75 * Rez::guiX(vp->Fontsize.getValue()) + offsetFudge;
|
||||
Base::Vector3d dir, norm; //direction/normal vectors of distance line (not dimension Line)
|
||||
if (strcmp(dimType, "Distance") == 0 ) {
|
||||
dir = (distEnd-distStart);
|
||||
@@ -1399,6 +1421,18 @@ QColor QGIViewDimension::getNormalColor()
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x00000000));
|
||||
m_colNormal = fcColor.asValue<QColor>();
|
||||
|
||||
auto dim( dynamic_cast<TechDraw::DrawViewDimension*>(getViewObject()) );
|
||||
if( dim == nullptr )
|
||||
return m_colNormal;
|
||||
|
||||
auto vp = static_cast<ViewProviderDimension*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
return m_colNormal;
|
||||
}
|
||||
|
||||
// Identify what changed to prevent complete redraw
|
||||
m_colNormal = vp->Color.getValue().asValue<QColor>();
|
||||
return m_colNormal;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,9 @@
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Gui/SoFCSelection.h>
|
||||
#include <Gui/Selection.h>
|
||||
|
||||
#include <Mod/TechDraw/App/LineGroup.h>
|
||||
|
||||
|
||||
#include "ViewProviderDimension.h"
|
||||
|
||||
@@ -50,6 +51,31 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderDimension, TechDrawGui::ViewProviderDra
|
||||
ViewProviderDimension::ViewProviderDimension()
|
||||
{
|
||||
sPixmap = "TechDraw_Dimension";
|
||||
|
||||
static const char *group = "Dim Format";
|
||||
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels");
|
||||
std::string fontName = hGrp->GetASCII("LabelFont", "osifont");
|
||||
hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
double fontSize = hGrp->GetFloat("FontSize", 3.5);
|
||||
|
||||
ADD_PROPERTY_TYPE(Font ,(fontName.c_str()),group,App::Prop_None, "The name of the font to use");
|
||||
ADD_PROPERTY_TYPE(Fontsize,(fontSize) ,group,(App::PropertyType)(App::Prop_None),"Dimension text size in mm");
|
||||
|
||||
hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
|
||||
auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
|
||||
double weight = lg->getWeight("Graphic");
|
||||
ADD_PROPERTY_TYPE(LineWidth,(weight) ,group,(App::PropertyType)(App::Prop_None),"Dimension line weight");
|
||||
|
||||
hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x00000000));
|
||||
ADD_PROPERTY_TYPE(Color,(fcColor),group,App::Prop_None,"The color of the Dimension");
|
||||
|
||||
}
|
||||
|
||||
ViewProviderDimension::~ViewProviderDimension()
|
||||
@@ -93,6 +119,19 @@ void ViewProviderDimension::updateData(const App::Property* p)
|
||||
ViewProviderDrawingView::updateData(p);
|
||||
}
|
||||
|
||||
void ViewProviderDimension::onChanged(const App::Property* p)
|
||||
{
|
||||
if ((p == &Font) ||
|
||||
(p == &Fontsize) ||
|
||||
(p == &LineWidth) ) {
|
||||
QGIView* qgiv = getQView();
|
||||
if (qgiv) {
|
||||
qgiv->updateView(true);
|
||||
}
|
||||
}
|
||||
Gui::ViewProviderDocumentObject::onChanged(p);
|
||||
}
|
||||
|
||||
TechDraw::DrawViewDimension* ViewProviderDimension::getViewObject() const
|
||||
{
|
||||
return dynamic_cast<TechDraw::DrawViewDimension*>(pcObject);
|
||||
|
||||
@@ -42,6 +42,11 @@ public:
|
||||
/// destructor
|
||||
virtual ~ViewProviderDimension();
|
||||
|
||||
App::PropertyFont Font;
|
||||
App::PropertyFloat Fontsize;
|
||||
App::PropertyFloat LineWidth;
|
||||
App::PropertyColor Color;
|
||||
|
||||
|
||||
virtual void attach(App::DocumentObject *);
|
||||
virtual void setDisplayMode(const char* ModeName);
|
||||
@@ -49,6 +54,7 @@ public:
|
||||
/// returns a list of all possible modes
|
||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||
virtual void updateData(const App::Property*);
|
||||
virtual void onChanged(const App::Property* p);
|
||||
|
||||
virtual TechDraw::DrawViewDimension* getViewObject() const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user