[Draft] Removed annotation styles objects

Removed Annotation styles current implementation.
As pointed out by yorik, in https://forum.freecadweb.org/viewtopic.php?f=23&t=44051&p=385710#p385179, this feature will be added using document Meta property.
This commit is contained in:
carlopav
2020-04-10 17:39:32 +02:00
committed by Yorik van Havre
parent 8e3dfe7c26
commit 0745f760a0
9 changed files with 4 additions and 1337 deletions

View File

@@ -32,7 +32,7 @@
import FreeCAD as App
import math
from PySide.QtCore import QT_TRANSLATE_NOOP
import DraftGeomUtils
import DraftGeomUtils, DraftVecUtils
import draftutils.gui_utils as gui_utils
import draftutils.utils as utils
from draftobjects.draft_annotation import DraftAnnotation
@@ -113,22 +113,13 @@ def make_dimension(p1,p2,p3=None,p4=None):
normal = normal.negative()
obj.Normal = normal
# format dimension according to ActiveDimensionStyle or user Preferences
_style_applied = False
if hasattr(App.ActiveDocument, "DimensionStyles"):
active_style = App.ActiveDocument.DimensionStyles.ActiveDimensionStyle
if active_style is not None:
obj.DimensionStyle = active_style
_style_applied = True
if App.GuiUp:
if not _style_applied:
gui_utils.format_object(obj)
gui_utils.format_object(obj)
gui_utils.select(obj)
return obj
def make_angular_dimension(center,angles,p3,normal=None):
"""makeAngularDimension(center,angle1,angle2,p3,[normal]): creates an angular Dimension
from the given center, with the given list of angles, passing through p3.
@@ -159,18 +150,9 @@ def make_angular_dimension(center,angles,p3,normal=None):
normal = normal.negative()
obj.Normal = normal
# format dimension according to ActiveDimensionStyle or user Preferences
_style_applied = False
if hasattr(App.ActiveDocument, "DimensionStyles"):
active_style = App.ActiveDocument.DimensionStyles.ActiveDimensionStyle
if active_style is not None:
obj.DimensionStyle = active_style
_style_applied = True
if App.GuiUp:
if not _style_applied:
gui_utils.format_object(obj)
gui_utils.format_object(obj)
gui_utils.select(obj)
return obj
@@ -188,12 +170,6 @@ class DimensionBase(DraftAnnotation):
"Initialize common properties for dimension objects"
DraftAnnotation.__init__(self,obj, tp)
# Annotation
obj.addProperty("App::PropertyLink","DimensionStyle",
"Annotation",
QT_TRANSLATE_NOOP("App::Property",
"Link dimension style"))
# Draft
obj.addProperty("App::PropertyVector",
"Normal",
@@ -222,9 +198,7 @@ class DimensionBase(DraftAnnotation):
def onChanged(self,obj,prop):
if prop == "DimensionStyle":
if hasattr(obj, "DimensionStyle"):
gui_utils.format_object(target = obj, origin = obj.DimensionStyle)
return
def execute(self, obj):
@@ -284,9 +258,6 @@ class LinearDimension(DimensionBase):
# obj.setEditorMode('Normal', 2)
if hasattr(obj, "Support"):
obj.setEditorMode('Support', 2)
if prop == "DimensionStyle":
if hasattr(obj, "DimensionStyle"):
gui_utils.format_object(target = obj, origin = obj.DimensionStyle)
def execute(self, obj):

View File

@@ -1,123 +0,0 @@
# ***************************************************************************
# * *
# * 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 dimensionstyle
# \ingroup DRAFT
# \brief This module provides the object code for Draft DimensionStyle.
import FreeCAD as App
from PySide.QtCore import QT_TRANSLATE_NOOP
from draftobjects.draft_annotation import DraftAnnotation
from draftobjects.draft_annotation import StylesContainerBase
if App.GuiUp:
import FreeCADGui as Gui
from draftviewproviders.view_dimensionstyle import ViewProviderDimensionStyle
from draftviewproviders.view_dimensionstyle import ViewProviderDimensionStylesContainer
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:
ViewProviderDimensionStyle(obj.ViewObject, existing_dimension)
get_dimension_styles_container().addObject(obj)
return obj
def get_dimension_styles_container():
"""get_dimension_styles_container(): returns a group object to put dimensions in"""
for obj in App.ActiveDocument.Objects:
if obj.Name == "DimensionStyles":
return obj
obj = App.ActiveDocument.addObject("App::DocumentObjectGroupPython", "DimensionStyles")
obj.Label = QT_TRANSLATE_NOOP("draft", "Dimension Styles")
DimensionStylesContainer(obj)
if App.GuiUp:
ViewProviderDimensionStylesContainer(obj.ViewObject)
return obj
class DimensionStylesContainer(StylesContainerBase):
"""The Dimension Container"""
def __init__(self, obj):
super().__init__(obj, tp = "DimensionStyles")
# init properties
obj.addProperty("App::PropertyLink","ActiveDimensionStyle",
"Annotation",
QT_TRANSLATE_NOOP("App::Property",
"Active dimension style"))
# sets properties read only
obj.setEditorMode("Visibility", 1)
obj.setEditorMode("ActiveDimensionStyle", 1)
def onChanged(self, obj, prop):
if prop == "Visibility" and hasattr(obj, "Visibility"):
if obj.Visibility == False:
obj.Visibility = True
if hasattr(obj, "ActiveDimensionStyle"):
if obj.ActiveDimensionStyle:
super().make_unique_visible(obj, obj.ActiveDimensionStyle)
if prop == "ActiveDimensionStyle" and hasattr(obj, "ActiveDimensionStyle"):
super().make_unique_visible(obj, obj.ActiveDimensionStyle)
class DimensionStyle(DraftAnnotation):
def __init__(self, obj):
super().__init__(obj, "DimensionStyle")
obj.setEditorMode("Visibility", 1) # sets visibility read only
def onChanged(self, obj, prop):
""" visibility property controls setting the activeDimensionStyle
so the only visible style is the current one
"""
if prop == "Visibility" and hasattr(obj, "Visibility"):
if obj.Visibility == True:
self.set_current(obj)
elif obj.Visibility == False:
self.remove_from_current(obj)
def set_visible(self, obj):
obj.Visibility = True
def set_current(self, obj):
get_dimension_styles_container().ActiveDimensionStyle = obj
def remove_from_current(self, obj):
if get_dimension_styles_container().ActiveDimensionStyle:
if get_dimension_styles_container().ActiveDimensionStyle.Name == obj.Name:
get_dimension_styles_container().ActiveDimensionStyle = None