Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
still have to split viewprovider from object. [Draft] Dimension Style code cleanup thx @vocx-fc for reviewing further cleanup [Draft] Dimension Style improvements Added a property to the dimension object to link the dimension style. Improved the update of dimensions when style changes. This can be done in 2 different ways: by setting AutoUpdate property to True or by activating Update function from the viewprovider context menu.
- Loading branch information
1 parent
0e097ae
commit 34cf981
Showing
5 changed files
with
416 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# *************************************************************************** | ||
# * (c) 2020 Carlo Pavan * | ||
# * * | ||
# * This file is part of the FreeCAD CAx development system. * | ||
# * * | ||
# * This program is free software; you can redistribute it and/or modify * | ||
# * it under the terms of the GNU Lesser General Public License (LGPL) * | ||
# * as published by the Free Software Foundation; either version 2 of * | ||
# * the License, or (at your option) any later version. * | ||
# * for detail see the LICENCE text file. * | ||
# * * | ||
# * FreeCAD 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 FreeCAD; if not, write to the Free Software * | ||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * | ||
# * USA * | ||
# * * | ||
# *************************************************************************** | ||
|
||
"""This module provides the Draft Dimension Style tool. | ||
""" | ||
## @package gui_style_dimension | ||
# \ingroup DRAFT | ||
# \brief This module provides the Draft Dimension Style tool. | ||
|
||
import FreeCAD as App | ||
import FreeCADGui as Gui | ||
from PySide import QtCore | ||
from . import gui_base | ||
from draftutils import utils | ||
from draftobjects.style_dimension import make_dimension_style | ||
|
||
class GuiCommandDimensionStyle(gui_base.GuiCommandBase): | ||
""" | ||
The command creates a dimension style object | ||
""" | ||
|
||
def GetResources(self): | ||
_msg = ("Creates a new dimension style.\n" | ||
"The object stores dimension preferences into the document." | ||
) | ||
return {'Pixmap' : 'Draft_AutoGroup', | ||
'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft", "Dimension Style"), | ||
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft", _msg)} | ||
|
||
def IsActive(self): | ||
if Gui.ActiveDocument: | ||
return True | ||
else: | ||
return False | ||
|
||
def Activated(self): | ||
sel = Gui.Selection.getSelection() | ||
|
||
if len(sel) == 1: | ||
if utils.get_type(sel[0]) == 'Dimension': | ||
make_dimension_style(sel[0]) | ||
return self.finish() | ||
|
||
make_dimension_style() | ||
return self.finish() | ||
|
||
|
||
Gui.addCommand('Draft_DimensionStyle', GuiCommandDimensionStyle()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# *************************************************************************** | ||
# * (c) 2020 Carlo Pavan * | ||
# * * | ||
# * This file is part of the FreeCAD CAx development system. * | ||
# * * | ||
# * This program is free software; you can redistribute it and/or modify * | ||
# * it under the terms of the GNU Lesser General Public License (LGPL) * | ||
# * as published by the Free Software Foundation; either version 2 of * | ||
# * the License, or (at your option) any later version. * | ||
# * for detail see the LICENCE text file. * | ||
# * * | ||
# * FreeCAD 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 FreeCAD; if not, write to the Free Software * | ||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * | ||
# * USA * | ||
# * * | ||
# *************************************************************************** | ||
|
||
"""This module provides the object code for Draft DimensionStyle. | ||
""" | ||
## @package style_dimension | ||
# \ingroup DRAFT | ||
# \brief This module provides the object code for Draft DimensionStyle. | ||
|
||
import FreeCAD as App | ||
import Draft | ||
from Draft import _DraftObject | ||
from PySide.QtCore import QT_TRANSLATE_NOOP | ||
|
||
if App.GuiUp: | ||
import FreeCADGui as Gui | ||
from draftviewproviders.view_style_dimension import ViewProviderDraftDimensionStyle | ||
|
||
def make_dimension_style(existing_dimension = None): | ||
""" | ||
Make dimension style | ||
""" | ||
if not App.ActiveDocument: | ||
App.Console.PrintError("No active document. Aborting\n") | ||
return | ||
obj = App.ActiveDocument.addObject("App::FeaturePython","DimensionStyle") | ||
DimensionStyle(obj) | ||
if App.GuiUp: | ||
ViewProviderDraftDimensionStyle(obj.ViewObject, existing_dimension) | ||
return obj | ||
|
||
class DimensionStyle(_DraftObject): | ||
def __init__(self, obj): | ||
_DraftObject.__init__(self, obj, "DimensionStyle") |
Oops, something went wrong.