New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: Dimension styles #3167
Draft: Dimension styles #3167
Conversation
""" | ||
Apply the style to the related dimensions | ||
""" | ||
from draftutils import gui_utils |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import should be at the top of the file, after draftutils.utils
, not inside the function.
f3f137f
to
85ba603
Compare
super().__init__() | ||
self.command_name = "DimensionStyle" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
def __init__(self):
super().__init__(name="Dimension style")
The parent class, GuiCommandSimplest
, sets up the command_name
attribute.
|
||
|
||
def execute(self, obj): | ||
import DraftGeomUtils |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be imported at the top of the file.
class LinearDimension(DimensionBase): | ||
"""The Draft Dimension object""" | ||
def __init__(self, obj): | ||
DimensionBase.__init__(self,obj,"Dimension") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The better way is to call super().__init__(self,obj,"Dimension")
.
We prefer to avoid repeating the parent class in case it changes.
from PySide.QtCore import QT_TRANSLATE_NOOP | ||
|
||
if App.GuiUp: | ||
import FreeCADGui as Gui | ||
from draftviewproviders.view_style_dimension import ViewProviderDraftDimensionStyle | ||
from draftviewproviders.view_dimensionstyle import ViewProviderDraftDimensionStyle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to guard the view providers because they won't be executed by the import, so there is no risk of causing an error. I mean, it doesn't hurt at all to guard them like this, I just think it looks a bit ugly.
We have to guard FreeCADGui
because if we don't we will definitely cause an error in console mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About this, I think some Travis tests are failing when we import the view provider module because inside this module FreeCADGui
is not guarded.
So inside view_dimensionstyle.py
and all those new view providers.
if App.GuiUp:
import FreeCADGui as Gui
self.node3d.removeChild(self.marks) | ||
|
||
def draw_dim_arrows(self, vobj): | ||
from pivy import coin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't be importing coin inside functions. These should be at the top.
src/Mod/Draft/Draft.py
Outdated
_Dimension = LinearDimension | ||
|
||
from draftviewproviders.view_dimension import ViewProviderLinearDimension | ||
_ViewProviderDimension = ViewProviderLinearDimension | ||
|
||
return obj |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carlopav You forgot to remove this return obj
statement, and when the entire Draft.py
is imported, it causes a syntax error. The Travis tests show this and fail because of it.
f913716
to
eeb22b5
Compare
Just another note, the Travis tests fail because when other workbenches import |
0c7ca8a
to
c5a6556
Compare
elif p3 == "diameter": | ||
#l.append((p1,"Diameter")) | ||
if App.GuiUp: | ||
obj.ViewObject.Override = "Ø $dim" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Travis tests are failing in this line because of the unicode character "Ø $dim"
. You have to add the codification at the beginning of the file. # -*- coding: utf8 -*-
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for looking into this. I'll add it right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't I add it to every file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't add it to every file, only to the one reported by our tests. This is actually only required in Python 2. But if it causes this error in Travis, it may mask other errors elsewhere, so we try to have no errors at all when making a pull request.
b5e6a55
to
3502877
Compare
elif obj.LabelType == "Area": | ||
if hasattr(obj.Target[0],'Shape'): | ||
if hasattr(obj.Target[0].Shape,"Area"): | ||
obj.Text = [App.Units.Quantity(obj.Target[0].Shape.Area,App.Units.Area).UserString.replace("^2","²")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This small 2 is also causing codification problems. # -*- coding: utf8 -*-
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx for spotting it!
a8682c0
to
a6fdd49
Compare
@vocx-fc any idea why the build fail on linux? (if I can read it correctly) |
src/Mod/Draft/Draft.py
Outdated
from draftviewproviders.view_dimension import ViewProviderAngularDimension | ||
_ViewProviderDimension = ViewProviderLinearDimension | ||
|
||
_ViewProviderAngularDimension = ViewProviderAngularDimension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Travis the gui doesn't exist. So this view provider also has to be inside the if gui:
so it is skipped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!
a6fdd49
to
22bd60a
Compare
and made it derived from DimensionBase <- Draft Annotation
And based them on Draft Annotation object
Further cleanup and guarded imports of Gui in modules. .
Dimension style property is auto-set on dimension creation. Further improvementes in DimensionStyleContainer. .
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.
- corrected super() methods to be Py2 compatible - further cleanup of the code. further cleanup changed again to avoid super method updated super() functions updated to correct the parent classess targeted by super()
93df349
to
f5ad28f
Compare
@vocx-fc thanks! it worked. (i didn't realize also the base object for bim assembly experimentations that realthunder provided had the |
Victory!! |
Wow! A big thank you to everyone! :D |
I just noticed that the image files |
Also, I noticed that the Once they were added in this branch (530e8b6), and the second time they were added in my branch #3182 (017226e). Obviously this is not ideal, so I rebased my branch #3291 and added a new commit to remove the repeated classes. |
My bad, those Icons ( |
About the icons, it seems you only added one, however, I checked your partial commits and that's when I noticed the error displaying all of them. Nevertheless, I'm unsure if this is really a problem from your side. Maybe something is wrong with GitHub at the moment because I can't see any icons. For example, #3060 introduced many icons and they were visible without problems then, but now they aren't displayed. I've read that GitHub has been having a few issues the last few weeks, so that may be a cause. |
Yes, just one of the icons is still present in the code. I think I just forget about it... I'll delete it during the weekend! |
Just one more thing Carlo. Can you check why the size of the text is now different? Use the test script. import drafttests.draft_test_objects as dt
dt.create_test_file() Before your changes, all text would fit correctly in the rectangle, now it's too big. Maybe the sizes need to be set to a different value in the test script. |
I think this is because of the scale multiplier property: when you create a dimension it automatically takes the ScaleMultiplier property according to the statusbar scale. EDIT: you remember me that I have to update the wiki |
Yes, I figured that much, the issue is the default scale multiplier is too large. In that case, you should set the scale multiplier to 1 by default to keep the same presentation as before. Otherwise new users will see their texts changed and won't know the reason. |
well, not exactly: this affect only new created objects. |
Yes, but why should the default scale be anything but 1? That's more or less the issue. The test script is supposed to produce the same result every time it is run; if it doesn't it means something is changing the behavior. In this case, I think the natural solution is to set the scale to 1 by default, not to modify the make functions. Of course, the make functions can also be improved, but that's a separate discussion. |
The default is in fact set to 1, but it is stored inside FreeCAD parameters:
this is the code involved. |
I set it to something else myself? Huh? Well, I wouldn't know. Maybe at some point I tested your branch and that value was written at that point. I think keeping them as Draft parameters is fine. This is a similar discussion as with your annotation styles concept. If you move the file to another system, it should display the same, and not change the text arbitrarily because of the different setup. This works correctly right now, because you save the scale as a property, so it should work fine. As long as only new objects are affected, there shouldn't be a problem. |
This PR provide objects to store annotation styles inside the document, and modify the annotation objects to store the link to their stile.
To be merged after PR #3102
Thank you for creating a pull request to contribute to FreeCAD! To ease integration, please confirm the following:
git pull --rebase upstream master
./bin/FreeCAD --run-test 0
issue #<id>
orfixes #<id>
where<id>
is the associated MantisBT issue id if one existsAnd please remember to update the Wiki with the features added or changed once this PR is merged.
Note: If you don't have wiki access, then please mention your contribution on the 0.19 Changelog Forum Thread.