Let param observer trigger grid color change
If you change the grid color in the preferences and cick the Apply button, the color of all grids is updated now. So you can experiment while the Preferences Editor is open. I have kept but moved the grid color button in the Draft_SelectPlane task panel for now. So that both options can be tested.
This commit is contained in:
@@ -153,6 +153,16 @@ will be moved to the center of the view</string>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Grid color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::ColorButton" name="buttonColor"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="toolTip">
|
||||
@@ -243,20 +253,6 @@ value by using the [ and ] keys while drawing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Grid color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::ColorButton" name="buttonColor"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
|
||||
@@ -37,6 +37,7 @@ import WorkingPlane
|
||||
from FreeCAD import Units
|
||||
from drafttaskpanels import task_selectplane
|
||||
from draftutils import params
|
||||
from draftutils import utils
|
||||
from draftutils.messages import _msg
|
||||
from draftutils.todo import todo
|
||||
from draftutils.translate import translate
|
||||
@@ -112,12 +113,9 @@ class Draft_SelectPlane:
|
||||
form.buttonPrevious.setIcon(QtGui.QIcon(":/icons/sel-back.svg"))
|
||||
form.buttonNext.setIcon(QtGui.QIcon(":/icons/sel-forward.svg"))
|
||||
|
||||
# color and transparency
|
||||
# Grid color
|
||||
color = params.get_param("gridColor")
|
||||
r = ((color >> 24) & 0xFF) / 255.0
|
||||
g = ((color >> 16) & 0xFF) / 255.0
|
||||
b = ((color >> 8) & 0xFF) / 255.0
|
||||
form.buttonColor.setProperty("color", QtGui.QColor.fromRgbF(r, g, b))
|
||||
form.buttonColor.setProperty("color", QtGui.QColor(utils.rgba_to_argb(color)))
|
||||
|
||||
# Connect slots
|
||||
form.buttonTop.clicked.connect(self.on_click_top)
|
||||
@@ -285,10 +283,8 @@ class Draft_SelectPlane:
|
||||
Gui.Snapper.showradius()
|
||||
|
||||
def on_color_changed(self):
|
||||
color = self.taskd.form.buttonColor.property("color").rgb() << 8
|
||||
color = utils.argb_to_rgba(self.taskd.form.buttonColor.property("color").rgba())
|
||||
params.set_param("gridColor", color)
|
||||
if self.grid is not None:
|
||||
self.grid.update()
|
||||
|
||||
Gui.addCommand('Draft_SelectPlane', Draft_SelectPlane())
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ import FreeCAD
|
||||
import FreeCADGui
|
||||
import Draft
|
||||
import DraftVecUtils
|
||||
import WorkingPlane
|
||||
from FreeCAD import Vector
|
||||
from draftutils import params
|
||||
from draftutils import utils
|
||||
@@ -1173,12 +1172,12 @@ class gridTracker(Tracker):
|
||||
self.coords3.point.setValues(apts)
|
||||
#self.lines3.numVertices.setValues(aidx)
|
||||
self.pts = pts
|
||||
|
||||
# update the grid colors
|
||||
col, red, green, blue, gtrans = self.getGridColors()
|
||||
self.mat1.diffuseColor.setValue(col)
|
||||
self.mat2.diffuseColor.setValue(col)
|
||||
self.mat3.diffuseColor.setValues([col,red,green,blue])
|
||||
self.setAxesColor()
|
||||
|
||||
def getGridColors(self):
|
||||
"""Returns grid colors stored in the preferences"""
|
||||
@@ -1222,12 +1221,8 @@ class gridTracker(Tracker):
|
||||
self.coords_human.point.setValues(pts)
|
||||
self.human.numVertices.setValues(pidx)
|
||||
|
||||
def setAxesColor(self, wp=None):
|
||||
def setAxesColor(self, wp):
|
||||
"""set axes color"""
|
||||
if not wp:
|
||||
wp = getattr(FreeCAD, "DraftWorkingPlane", None)
|
||||
if not wp:
|
||||
wp = WorkingPlane.plane()
|
||||
cols = [0,0]
|
||||
if params.get_param("coloredGridAxes"):
|
||||
if round(wp.u.getAngle(FreeCAD.Vector(1,0,0)),2) in (0,3.14):
|
||||
|
||||
Reference in New Issue
Block a user