Skip to content

Commit

Permalink
Gui/Renderer: support outline rendering in hidden line draw style
Browse files Browse the repository at this point in the history
  • Loading branch information
realthunder committed May 25, 2021
1 parent 164bcb1 commit 633dd92
Show file tree
Hide file tree
Showing 11 changed files with 240 additions and 92 deletions.
3 changes: 3 additions & 0 deletions src/Gui/DlgSettingsDrawStyles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ DlgSettingsDrawStyles::DlgSettingsDrawStyles(QWidget* parent)
FC_DRAW_STYLE_PARAM(HiddenLineOverrideColor, isChecked, setChecked)\
FC_DRAW_STYLE_PARAM(HiddenLineOverrideFaceColor, isChecked, setChecked)\
FC_DRAW_STYLE_PARAM(HiddenLineOverrideBackground, isChecked, setChecked)\
FC_DRAW_STYLE_PARAM(HiddenLineShowOutline, isChecked, setChecked)\
FC_DRAW_STYLE_PARAM(HiddenLineWidth, value, setValue)\
FC_DRAW_STYLE_PARAM(HiddenLinePointSize, value, setValue)\
FC_DRAW_STYLE_PARAM(TransparencyOnTop, value, setValue)\
FC_DRAW_STYLE_PARAM(SelectionLineThicken, value, setValue)\
FC_DRAW_STYLE_PARAM(SelectionLineMaxWidth, value, setValue)\
Expand Down
153 changes: 97 additions & 56 deletions src/Gui/DlgSettingsDrawStyles.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>601</width>
<height>1256</height>
<height>1413</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -294,63 +294,24 @@
<property name="spacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="HiddenLineOverrideFaceColor">
<property name="minimumSize">
<size>
<width>240</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Override face color</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Transparency</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::ColorButton" name="HiddenLineFaceColor">
<item row="1" column="1">
<widget class="Gui::ColorButton" name="HiddenLineColor">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="color" stdset="0">
<color>
<red>255</red>
<green>255</green>
<blue>255</blue>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="HiddenLineOverrideColor">
<property name="text">
<string>Override line color</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="HiddenLineTransparency">
<property name="inputMethodHints">
<set>Qt::ImhPreferNumbers</set>
Expand All @@ -372,27 +333,33 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::ColorButton" name="HiddenLineColor">
<item row="2" column="1">
<widget class="Gui::ColorButton" name="HiddenLineBackground">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="color" stdset="0">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="HiddenLineShaded">
<item row="6" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Shaded</string>
<string>Line width</string>
</property>
</widget>
</item>
Expand All @@ -403,8 +370,48 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Gui::ColorButton" name="HiddenLineBackground">
<item row="3" column="0">
<widget class="QCheckBox" name="HiddenLineShaded">
<property name="text">
<string>Shaded</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="HiddenLineOverrideFaceColor">
<property name="minimumSize">
<size>
<width>240</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Override face color</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="HiddenLineOverrideColor">
<property name="text">
<string>Override line color</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Transparency</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Gui::ColorButton" name="HiddenLineFaceColor">
<property name="enabled">
<bool>false</bool>
</property>
Expand All @@ -426,6 +433,40 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="HiddenLineShowOutline">
<property name="text">
<string>Draw outline</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Point size</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QDoubleSpinBox" name="HiddenLineWidth">
<property name="decimals">
<number>1</number>
</property>
<property name="singleStep">
<double>0.500000000000000</double>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QDoubleSpinBox" name="HiddenLinePointSize">
<property name="decimals">
<number>1</number>
</property>
<property name="singleStep">
<double>0.500000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
Expand Down
5 changes: 4 additions & 1 deletion src/Gui/Inventor/SoFCDisplayMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ SoFCDisplayMode::SoFCDisplayMode()
SO_NODE_ADD_FIELD(lineColor, (SbColor()));
SO_NODE_ADD_FIELD(transparency, (0.0f));
SO_NODE_ADD_FIELD(showHiddenLines, (FALSE));
SO_NODE_ADD_FIELD(showOutline, (FALSE));
SO_NODE_ADD_FIELD(displayMode, (""));
}

Expand All @@ -52,7 +53,9 @@ void SoFCDisplayMode::doAction(SoAction * action)
SoState * state = action->getState();
if (!this->displayMode.isIgnored()) {
SoFCDisplayModeElement::set(state, this,
this->displayMode.getValue(), this->showHiddenLines.getValue());
this->displayMode.getValue(),
this->showHiddenLines.getValue(),
this->showOutline.getValue());
}
if (!this->faceColor.isIgnored()
|| !this->lineColor.isIgnored()
Expand Down
1 change: 1 addition & 0 deletions src/Gui/Inventor/SoFCDisplayMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class GuiExport SoFCDisplayMode: public SoNode {
public:
SoSFName displayMode;
SoSFBool showHiddenLines;
SoSFBool showOutline;
SoSFColor faceColor;
SoSFColor lineColor;
SoSFFloat transparency;
Expand Down
28 changes: 21 additions & 7 deletions src/Gui/Inventor/SoFCDisplayModeElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ void
SoFCDisplayModeElement::set(SoState * const state,
SoNode * const node,
const SbName &mode,
SbBool hiddenLines)
SbBool hiddenLines,
SbBool outline)
{
auto element = static_cast<SoFCDisplayModeElement*>(
inherited::getElement(state, classStackIndex, node));
Expand All @@ -83,11 +84,13 @@ SoFCDisplayModeElement::set(SoState * const state,
if((element->hasLineColor = ViewParams::getHiddenLineOverrideColor()))
element->lineColor.setPackedValue(ViewParams::getHiddenLineColor(),f);
element->transp = ViewParams::getHiddenLineTransparency();
element->outline = outline;
}
else {
element->hasFaceColor = false;
element->hasLineColor = false;
element->transp = 0.0f;
element->outline = false;
}
}
}
Expand Down Expand Up @@ -132,11 +135,12 @@ SoFCDisplayModeElement::get() const
return displayMode;
}

SbBool
SoFCDisplayModeElement::showHiddenLines(SoState * const state)
SbBool
SoFCDisplayModeElement::showHiddenLines(SoState * const state, SbBool *outline)
{
auto element = static_cast<const SoFCDisplayModeElement*>(
inherited::getConstElement(state, classStackIndex));
if (outline) *outline = element->outline;
return element->hiddenLines;
}

Expand All @@ -146,7 +150,13 @@ SoFCDisplayModeElement::showHiddenLines() const
return hiddenLines;
}

const SbColor *
SbBool
SoFCDisplayModeElement::showOutline() const
{
return outline;
}

const SbColor *
SoFCDisplayModeElement::getFaceColor(SoState * const state)
{
auto element = static_cast<const SoFCDisplayModeElement*>(
Expand All @@ -160,7 +170,7 @@ SoFCDisplayModeElement::getFaceColor() const
return hasFaceColor ? &faceColor : nullptr;
}

const SbColor *
const SbColor *
SoFCDisplayModeElement::getLineColor(SoState * const state)
{
auto element = static_cast<const SoFCDisplayModeElement*>(
Expand All @@ -174,7 +184,7 @@ SoFCDisplayModeElement::getLineColor() const
return hasLineColor ? &lineColor : nullptr;
}

float
float
SoFCDisplayModeElement::getTransparency(SoState * const state)
{
auto element = static_cast<const SoFCDisplayModeElement*>(
Expand All @@ -196,7 +206,9 @@ SoFCDisplayModeElement::matches(const SoElement * element) const
if (element->getTypeId() != SoFCDisplayModeElement::getClassTypeId())
return FALSE;
auto other = static_cast<const SoFCDisplayModeElement *>(element);
if (this->displayMode != other->displayMode || this->hiddenLines != other->hiddenLines)
if (this->displayMode != other->displayMode
|| this->hiddenLines != other->hiddenLines
|| this->outline != other->outline)
return FALSE;
if(this->hasFaceColor != other->hasFaceColor
|| this->hasLineColor != other->hasLineColor
Expand All @@ -216,6 +228,7 @@ SoFCDisplayModeElement::copyMatchInfo(void) const

element->displayMode = this->displayMode;
element->hiddenLines = this->hiddenLines;
element->outline = this->outline;
element->hasFaceColor = this->hasFaceColor;
element->hasLineColor = this->hasLineColor;
element->transp = this->transp;
Expand All @@ -233,6 +246,7 @@ SoFCDisplayModeElement::init(SoState * state)
inherited::init(state);
this->displayMode = SbName::empty();
this->hiddenLines = FALSE;
this->outline = FALSE;
this->hasFaceColor = FALSE;
this->hasLineColor = FALSE;
this->transp = 0.0f;
Expand Down
6 changes: 4 additions & 2 deletions src/Gui/Inventor/SoFCDisplayModeElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ class GuiExport SoFCDisplayModeElement: public SoReplacedElement {
virtual void init(SoState *state);

static void set(SoState * const state, SoNode * const node,
const SbName &mode, SbBool hiddenLine);
const SbName &mode, SbBool hiddenLine, SbBool outline = FALSE);

static void setColors(SoState * const state, SoNode * const node,
const SbColor *faceColor, const SbColor *lineColor, float transp);

static const SbName &get(SoState * const state);
static SbBool showHiddenLines(SoState * const state);
static SbBool showHiddenLines(SoState * const state, SbBool *outline = nullptr);
static const SbColor *getFaceColor(SoState * const state);
static const SbColor *getLineColor(SoState * const state);
static float getTransparency(SoState * const state);
Expand All @@ -54,6 +54,7 @@ class GuiExport SoFCDisplayModeElement: public SoReplacedElement {

const SbName &get() const;
SbBool showHiddenLines() const;
SbBool showOutline() const;
const SbColor *getFaceColor() const;
const SbColor *getLineColor() const;
float getTransparency() const;
Expand All @@ -66,6 +67,7 @@ class GuiExport SoFCDisplayModeElement: public SoReplacedElement {
SbBool hiddenLines;
SbBool hasFaceColor;
SbBool hasLineColor;
SbBool outline;
SbColor faceColor;
SbColor lineColor;
float transp;
Expand Down

0 comments on commit 633dd92

Please sign in to comment.