Skip to content

Commit

Permalink
Get user prefs at time of use
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Jul 14, 2016
1 parent 9dec3c5 commit 2c8f497
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 122 deletions.
8 changes: 8 additions & 0 deletions src/Mod/TechDraw/Gui/DlgPrefsTechDraw.ui
Expand Up @@ -197,12 +197,20 @@
</item>
<item row="1" column="1">
<widget class="Gui::PrefComboBox" name="cb_HidLine">
<property name="currentIndex">
<number>1</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>HiddenLine</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw</cstring>
</property>
<item>
<property name="text">
<string>NeverShow</string>
</property>
</item>
<item>
<property name="text">
<string>Solid</string>
Expand Down
31 changes: 31 additions & 0 deletions src/Mod/TechDraw/Gui/QGCustomText.cpp
Expand Up @@ -104,3 +104,34 @@ void QGCustomText::paint ( QPainter * painter, const QStyleOptionGraphicsItem *

QGraphicsTextItem::paint (painter, &myOption, widget);
}

QColor QGCustomText::getNormalColor()
{
Base::Reference<ParameterGrp> hGrp = getParmGroup();
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000));
return fcColor.asValue<QColor>();
}

QColor QGCustomText::getPreColor()
{
Base::Reference<ParameterGrp> hGrp = getParmGroup();
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("PreSelectColor", 0xFFFF0000));
return fcColor.asValue<QColor>();
}

QColor QGCustomText::getSelectColor()
{
Base::Reference<ParameterGrp> hGrp = getParmGroup();
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("SelectColor", 0x00FF0000));
return fcColor.asValue<QColor>();
}

Base::Reference<ParameterGrp> QGCustomText::getParmGroup()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
return hGrp;
}
5 changes: 4 additions & 1 deletion src/Mod/TechDraw/Gui/QGCustomText.h
Expand Up @@ -49,6 +49,10 @@ class TechDrawGuiExport QGCustomText : public QGraphicsTextItem
virtual void centerAt(double cX, double cY);

protected:
QColor getNormalColor(void);
QColor getPreColor(void);
QColor getSelectColor(void);
Base::Reference<ParameterGrp> getParmGroup(void);

private:

Expand All @@ -57,4 +61,3 @@ class TechDrawGuiExport QGCustomText : public QGraphicsTextItem
} // namespace MDIViewPageGui

#endif // DRAWINGGUI_QGCUSTOMTEXT_H

55 changes: 32 additions & 23 deletions src/Mod/TechDraw/Gui/QGIEdge.cpp
Expand Up @@ -43,27 +43,13 @@
using namespace TechDrawGui;

QGIEdge::QGIEdge(int index) :
projIndex(index)
projIndex(index),
isCosmetic(false),
isHiddenEdge(false),
isSmoothEdge(false),
strokeWidth(1.0)
{
strokeWidth = 1.;

isCosmetic = false;
m_pen.setCosmetic(isCosmetic);
isHiddenEdge = false;
isSmoothEdge = false;

Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
m_defNormal = m_colNormal;
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("HiddenColor", 0x08080800));
m_colHid = fcColor.asValue<QColor>();

hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw");
m_styleHid = static_cast<Qt::PenStyle> (hGrp->GetInt("HiddenLine",2));

//m_pen.setStyle(Qt::SolidLine);
//m_pen.setCapStyle(Qt::RoundCap);
}

QRectF QGIEdge::boundingRect() const
Expand Down Expand Up @@ -96,15 +82,38 @@ void QGIEdge::setStrokeWidth(float width) {
void QGIEdge::setHiddenEdge(bool b) {
isHiddenEdge = b;
if (b) {
m_pen.setStyle(m_styleHid);
m_colNormal = m_colHid;
m_styleCurrent = getHiddenStyle();
} else {
m_pen.setStyle(Qt::SolidLine);
m_colNormal = m_defNormal;
m_styleCurrent = Qt::SolidLine;
}
update();
}

void QGIEdge::setPrettyNormal() {
if (isHiddenEdge) {
m_colCurrent = getHiddenColor();
} else {
m_colCurrent = getNormalColor();
}
update();
}

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", 0x08080800));
return fcColor.asValue<QColor>();
}

Qt::PenStyle QGIEdge::getHiddenStyle()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw");
Qt::PenStyle hidStyle = static_cast<Qt::PenStyle> (hGrp->GetInt("HiddenLine",2));
return hidStyle;
}

void QGIEdge::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/TechDraw/Gui/QGIEdge.h
Expand Up @@ -49,19 +49,19 @@ class TechDrawGuiExport QGIEdge : public QGIPrimPath
bool getHiddenEdge() { return(isHiddenEdge); }
void setSmoothEdge(bool b) { isSmoothEdge = b; }
bool getSmoothEdge() { return(isSmoothEdge); }
virtual void setPrettyNormal();

protected:
int projIndex; //index of edge in Projection. must exist.

bool isCosmetic;
bool isHiddenEdge;
bool isSmoothEdge;
QColor getHiddenColor();
Qt::PenStyle getHiddenStyle();

private:
float strokeWidth;
QColor m_colHid;
QColor m_defNormal;
Qt::PenStyle m_styleHid;
};

}
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/TechDraw/Gui/QGIFace.cpp
Expand Up @@ -61,7 +61,7 @@ QGIFace::QGIFace(int index) :
setFlag(QGraphicsItem::ItemClipsChildrenToShape,true);
//setFiltersChildEvents(true);

m_pen.setCosmetic(true);
m_styleCurrent = Qt::NoPen; //don't draw face lines, just fill

m_styleNormal = m_styleDef;
m_colNormalFill = m_colDefFill;
Expand All @@ -88,13 +88,13 @@ void QGIFace::setPrettyNormal() {

void QGIFace::setPrettyPre() {
m_fillStyle = m_styleSelect;
m_fillColor = m_colPre;
m_fillColor = getPreColor();
QGIPrimPath::setPrettyPre();
}

void QGIFace::setPrettySel() {
m_fillStyle = m_styleSelect;
m_fillColor = m_colSel;
m_fillColor = getSelectColor();
QGIPrimPath::setPrettySel();
}

Expand Down
55 changes: 38 additions & 17 deletions src/Mod/TechDraw/Gui/QGIPrimPath.cpp
Expand Up @@ -34,7 +34,6 @@
#include <App/Application.h>
#include <App/Material.h>
#include <Base/Console.h>
#include <Base/Parameter.h>

#include "QGIPrimPath.h"
#include "QGIView.h"
Expand All @@ -51,21 +50,11 @@ QGIPrimPath::QGIPrimPath()
setAcceptHoverEvents(true);

isHighlighted = false;

Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000));
m_colNormal = fcColor.asValue<QColor>();
fcColor.setPackedValue(hGrp->GetUnsigned("SelectColor", 0x00FF0000));
m_colSel = fcColor.asValue<QColor>();
fcColor.setPackedValue(hGrp->GetUnsigned("PreSelectColor", 0xFFFF0000));
m_colPre = fcColor.asValue<QColor>();

setPrettyNormal();

m_pen.setColor(m_colNormal);
m_pen.setStyle(Qt::SolidLine);
m_colCurrent = getNormalColor();
m_styleCurrent = Qt::SolidLine;
m_pen.setStyle(m_styleCurrent);
m_pen.setCapStyle(Qt::RoundCap);
}

Expand Down Expand Up @@ -110,17 +99,17 @@ void QGIPrimPath::setHighlighted(bool b)
}

void QGIPrimPath::setPrettyNormal() {
m_colCurrent = m_colNormal;
m_colCurrent = getNormalColor();
update();
}

void QGIPrimPath::setPrettyPre() {
m_colCurrent = m_colPre;
m_colCurrent = getPreColor();
update();
}

void QGIPrimPath::setPrettySel() {
m_colCurrent = m_colSel;
m_colCurrent = getSelectColor();
update();
}

Expand All @@ -129,6 +118,38 @@ void QGIPrimPath::paint ( QPainter * painter, const QStyleOptionGraphicsItem * o
myOption.state &= ~QStyle::State_Selected;

m_pen.setColor(m_colCurrent);
m_pen.setStyle(m_styleCurrent);
setPen(m_pen);
QGraphicsPathItem::paint (painter, &myOption, widget);
}

QColor QGIPrimPath::getNormalColor()
{
Base::Reference<ParameterGrp> hGrp = getParmGroup();
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000));
return fcColor.asValue<QColor>();
}

QColor QGIPrimPath::getPreColor()
{
Base::Reference<ParameterGrp> hGrp = getParmGroup();
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("PreSelectColor", 0xFFFF0000));
return fcColor.asValue<QColor>();
}

QColor QGIPrimPath::getSelectColor()
{
Base::Reference<ParameterGrp> hGrp = getParmGroup();
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("SelectColor", 0x00FF0000));
return fcColor.asValue<QColor>();
}

Base::Reference<ParameterGrp> QGIPrimPath::getParmGroup()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
return hGrp;
}
13 changes: 9 additions & 4 deletions src/Mod/TechDraw/Gui/QGIPrimPath.h
Expand Up @@ -23,13 +23,15 @@
#ifndef DRAWINGGUI_QGIPRIMPATH_H
#define DRAWINGGUI_QGIPRIMPATH_H

# include <QGraphicsItem>
#include <QGraphicsItem>

QT_BEGIN_NAMESPACE
class QPainter;
class QStyleOptionGraphicsItem;
QT_END_NAMESPACE

#include <Base/Parameter.h>

namespace TechDrawGui
{

Expand All @@ -54,12 +56,15 @@ class TechDrawGuiExport QGIPrimPath : public QGraphicsPathItem
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
QVariant itemChange(GraphicsItemChange change, const QVariant &value);

QColor getNormalColor(void);
QColor getPreColor(void);
QColor getSelectColor(void);
Base::Reference<ParameterGrp> getParmGroup(void);

bool isHighlighted;
QPen m_pen;
QColor m_colCurrent;
QColor m_colNormal;
QColor m_colPre;
QColor m_colSel;
Qt::PenStyle m_styleCurrent;

private:

Expand Down

0 comments on commit 2c8f497

Please sign in to comment.