作図ソフト dia の改良版
Revisión | bf8a5f53be87af155cb8cd2777eeff7406eb21ff (tree) |
---|---|
Tiempo | 2007-03-17 20:08:26 |
Autor | Hans Breuer <hans@breu...> |
Commiter | Hans Breuer |
Self Documenation Part III and stress test, creates all Dia Objects
2007-03-17 Hans Breuer <hans@breuer.org>
* plug-ins/python/aobjects.py plug-ins/python/Makefile.am :
Self Documenation Part III and stress test, creates all Dia Objects
* objects/FS/flow-ortho.c objects/FS/flow.c : removed partial
left over of 'static DiaFont*' which caused a crash on creation
* objects/UML/umlattribute.c objects/UML/umlformalparameter.c
objects/UML/umloperation.c : don't crash on name being NULL
* objects/custom/custom_object.c : call *_update_data in *_copy
Fixes the disappearance of object drawing after cut&paste
(bug #416414, Stein Somers)
* plug-ins/python/pydia-font.c : cmpfunc is supposed to return out
of (-1, 0, 1)
* lib/utils.h lib/message.h : added C++ guards
svn path=/trunk/; revision=3636
@@ -1,3 +1,22 @@ | ||
1 | +2007-03-17 Hans Breuer <hans@breuer.org> | |
2 | + | |
3 | + * plug-ins/python/aobjects.py plug-ins/python/Makefile.am : | |
4 | + Self Documenation Part III and stress test, creates all Dia Objects | |
5 | + * objects/FS/flow-ortho.c objects/FS/flow.c : removed partial | |
6 | + left over of 'static DiaFont*' which caused a crash on creation | |
7 | + | |
8 | + * objects/UML/umlattribute.c objects/UML/umlformalparameter.c | |
9 | + objects/UML/umloperation.c : don't crash on name being NULL | |
10 | + | |
11 | + * objects/custom/custom_object.c : call *_update_data in *_copy | |
12 | + Fixes the disappearance of object drawing after cut&paste | |
13 | + (bug #416414, Stein Somers) | |
14 | + | |
15 | + * plug-ins/python/pydia-font.c : cmpfunc is supposed to return out | |
16 | + of (-1, 0, 1) | |
17 | + | |
18 | + * lib/utils.h lib/message.h : added C++ guards | |
19 | + | |
1 | 20 | 2007-03-17 Steffen Macke <sdteffen@gmail.com> |
2 | 21 | |
3 | 22 | * installer/win32/locale/slovak.nsh: Use Codepage 1250, fixed errors |
@@ -148,7 +167,7 @@ | ||
148 | 167 | * objects/UML/state.c |
149 | 168 | * objects/UML/small_package.c |
150 | 169 | * objects/GRAFCET/boolequation.c: Make sure to call set_font |
151 | - before calling draw_string | |
170 | + before calling draw_string, fixes bug #408519 | |
152 | 171 | |
153 | 172 | * objects/UML/class.c (umlclass_set_props): #ifdef out debugging |
154 | 173 | statement. |
@@ -20,6 +20,8 @@ | ||
20 | 20 | |
21 | 21 | #include <stdarg.h> |
22 | 22 | |
23 | +G_BEGIN_DECLS | |
24 | + | |
23 | 25 | typedef void (*MessageInternal)(const char *title, const char *fmt, |
24 | 26 | va_list *args, va_list *args2); |
25 | 27 |
@@ -32,6 +34,8 @@ void message_error(const char *format, ...); | ||
32 | 34 | /* also declared in dia_dirs.h, where I think it does not belong! --hb */ |
33 | 35 | const gchar *dia_message_filename (const gchar *filename); |
34 | 36 | |
37 | +G_END_DECLS | |
38 | + | |
35 | 39 | #endif /* MESSAGES_H */ |
36 | 40 | |
37 | 41 |
@@ -20,6 +20,8 @@ | ||
20 | 20 | |
21 | 21 | #include <stdarg.h> |
22 | 22 | |
23 | +G_BEGIN_DECLS | |
24 | + | |
23 | 25 | int nearest_pow (int num); |
24 | 26 | int format_string_length_upper_bound (const char* fmt, |
25 | 27 | va_list *args); |
@@ -28,6 +30,8 @@ int format_string_length_upper_bound (const char* fmt, | ||
28 | 30 | int snprintf ( char *str, size_t n, const char *format, ... ); |
29 | 31 | #endif |
30 | 32 | |
33 | +G_END_DECLS | |
34 | + | |
31 | 35 | #endif /* UTILS_H */ |
32 | 36 | |
33 | 37 |
@@ -91,8 +91,6 @@ Color orthflow_color_signal = { 0.0f, 0.0f, 1.0f }; | ||
91 | 91 | #define ORTHFLOW_ARROWWIDTH 0.5 |
92 | 92 | #define HANDLE_MOVE_TEXT (HANDLE_CUSTOM2) |
93 | 93 | |
94 | -static DiaFont *orthflow_font = NULL; | |
95 | - | |
96 | 94 | static ObjectChange* orthflow_move_handle(Orthflow *orthflow, Handle *handle, |
97 | 95 | Point *to, ConnectionPoint *cp, |
98 | 96 | HandleMoveReason reason, |
@@ -389,9 +387,6 @@ orthflow_draw(Orthflow *orthflow, DiaRenderer *renderer) | ||
389 | 387 | render_color, |
390 | 388 | NULL, &arrow); |
391 | 389 | |
392 | - renderer_ops->set_font(renderer, orthflow_font, | |
393 | - ORTHFLOW_FONTHEIGHT); | |
394 | - | |
395 | 390 | text_draw(orthflow->text, renderer); |
396 | 391 | } |
397 | 392 |
@@ -435,11 +430,6 @@ orthflow_create(Point *startpoint, | ||
435 | 430 | } else { |
436 | 431 | Color* color = &orthflow_color_signal; |
437 | 432 | |
438 | - if (orthflow_font == NULL) { | |
439 | - orthflow_font = dia_font_new_from_style(DIA_FONT_SANS|DIA_FONT_ITALIC, | |
440 | - 1.0); | |
441 | - } | |
442 | - | |
443 | 433 | switch (orthflow->type) { |
444 | 434 | case ORTHFLOW_ENERGY: |
445 | 435 | color = &orthflow_color_energy ; |
@@ -452,8 +442,6 @@ orthflow_create(Point *startpoint, | ||
452 | 442 | break ; |
453 | 443 | } |
454 | 444 | |
455 | - orthflow->text = new_text("", orthflow_font, ORTHFLOW_FONTHEIGHT, | |
456 | - &p, color, ALIGN_CENTER); | |
457 | 445 | } |
458 | 446 | #endif |
459 | 447 |
@@ -566,11 +554,6 @@ orthflow_load(ObjectNode obj_node, int version, const char *filename) | ||
566 | 554 | DiaObject *obj; |
567 | 555 | PolyBBExtras *extra; |
568 | 556 | |
569 | - if (orthflow_font == NULL) { | |
570 | - orthflow_font = dia_font_new_from_style(DIA_FONT_SANS|DIA_FONT_ITALIC, | |
571 | - 1.0); | |
572 | - } | |
573 | - | |
574 | 557 | orthflow = g_malloc0(sizeof(Orthflow)); |
575 | 558 | |
576 | 559 | orth = &orthflow->orth; |
@@ -70,8 +70,6 @@ struct _Flow { | ||
70 | 70 | #define FLOW_ARROWWIDTH 0.5 |
71 | 71 | #define HANDLE_MOVE_TEXT (HANDLE_CUSTOM1) |
72 | 72 | |
73 | -static DiaFont *flow_font = NULL; | |
74 | - | |
75 | 73 | static ObjectChange* flow_move_handle(Flow *flow, Handle *handle, |
76 | 74 | Point *to, ConnectionPoint *cp, |
77 | 75 | HandleMoveReason reason, |
@@ -355,8 +353,6 @@ flow_draw(Flow *flow, DiaRenderer *renderer) | ||
355 | 353 | render_color, |
356 | 354 | &arrow, NULL); |
357 | 355 | |
358 | - renderer_ops->set_font(renderer, flow_font,FLOW_FONTHEIGHT); | |
359 | - | |
360 | 356 | text_draw(flow->text, renderer); |
361 | 357 | } |
362 | 358 |
@@ -523,11 +519,6 @@ flow_load(ObjectNode obj_node, int version, const char *filename) | ||
523 | 519 | DiaObject *obj; |
524 | 520 | LineBBExtras *extra; |
525 | 521 | |
526 | - if (flow_font == NULL) { | |
527 | - flow_font = dia_font_new_from_style (DIA_FONT_SANS|DIA_FONT_ITALIC, | |
528 | - FLOW_FONTHEIGHT); | |
529 | - } | |
530 | - | |
531 | 522 | flow = g_malloc0(sizeof(Flow)); |
532 | 523 | |
533 | 524 | conn = &flow->connection; |
@@ -193,8 +193,9 @@ uml_get_attribute_string (UMLAttribute *attribute) | ||
193 | 193 | int len; |
194 | 194 | char *str; |
195 | 195 | |
196 | - len = 1 + strlen (attribute->name) + strlen (attribute->type); | |
197 | - if (attribute->name[0] && attribute->type[0]) { | |
196 | + len = 1 + (attribute->name ? strlen (attribute->name) : 0) | |
197 | + + (attribute->type ? strlen (attribute->type) : 0); | |
198 | + if (attribute->name && attribute->name[0] && attribute->type && attribute->type[0]) { | |
198 | 199 | len += 2; |
199 | 200 | } |
200 | 201 | if (attribute->value != NULL && attribute->value[0] != '\0') { |
@@ -206,11 +207,11 @@ uml_get_attribute_string (UMLAttribute *attribute) | ||
206 | 207 | str[0] = visible_char[(int) attribute->visibility]; |
207 | 208 | str[1] = 0; |
208 | 209 | |
209 | - strcat (str, attribute->name); | |
210 | - if (attribute->name[0] && attribute->type[0]) { | |
210 | + strcat (str, attribute->name ? attribute->name : ""); | |
211 | + if (attribute->name && attribute->name[0] && attribute->type && attribute->type[0]) { | |
211 | 212 | strcat (str, ": "); |
212 | 213 | } |
213 | - strcat (str, attribute->type); | |
214 | + strcat (str, attribute->type ? attribute->type : ""); | |
214 | 215 | if (attribute->value != NULL && attribute->value[0] != '\0') { |
215 | 216 | strcat (str, " = "); |
216 | 217 | strcat (str, attribute->value); |
@@ -109,7 +109,7 @@ uml_get_formalparameter_string (UMLFormalParameter *parameter) | ||
109 | 109 | char *str; |
110 | 110 | |
111 | 111 | /* Calculate length: */ |
112 | - len = strlen (parameter->name); | |
112 | + len = parameter->name ? strlen (parameter->name) : 0; | |
113 | 113 | |
114 | 114 | if (parameter->type != NULL) { |
115 | 115 | len += 1 + strlen (parameter->type); |
@@ -117,7 +117,7 @@ uml_get_formalparameter_string (UMLFormalParameter *parameter) | ||
117 | 117 | |
118 | 118 | /* Generate string: */ |
119 | 119 | str = g_malloc (sizeof (char) * (len + 1)); |
120 | - strcpy (str, parameter->name); | |
120 | + strcpy (str, parameter->name ? parameter->name : ""); | |
121 | 121 | if (parameter->type != NULL) { |
122 | 122 | strcat (str, ":"); |
123 | 123 | strcat (str, parameter->type); |
@@ -310,7 +310,7 @@ uml_get_operation_string (UMLOperation *operation) | ||
310 | 310 | UMLParameter *param; |
311 | 311 | |
312 | 312 | /* Calculate length: */ |
313 | - len = 1 + strlen (operation->name) + 1; | |
313 | + len = 1 + (operation->name ? strlen (operation->name) : 0) + 1; | |
314 | 314 | if(operation->stereotype != NULL && operation->stereotype[0] != '\0') { |
315 | 315 | len += 5 + strlen (operation->stereotype); |
316 | 316 | } |
@@ -334,7 +334,7 @@ uml_get_operation_string (UMLOperation *operation) | ||
334 | 334 | len += 6; |
335 | 335 | break; |
336 | 336 | } |
337 | - len += strlen (param->name); | |
337 | + len += (param->name ? strlen (param->name) : 0); | |
338 | 338 | if (param->type != NULL) { |
339 | 339 | len += strlen (param->type); |
340 | 340 | if (param->type[0] && param->name[0]) { |
@@ -371,7 +371,7 @@ uml_get_operation_string (UMLOperation *operation) | ||
371 | 371 | strcat(str, " "); |
372 | 372 | } |
373 | 373 | |
374 | - strcat (str, operation->name); | |
374 | + strcat (str, operation->name ? operation->name : ""); | |
375 | 375 | strcat (str, "("); |
376 | 376 | |
377 | 377 | list = operation->parameters; |
@@ -393,7 +393,7 @@ uml_get_operation_string (UMLOperation *operation) | ||
393 | 393 | strcat (str, "inout "); |
394 | 394 | break; |
395 | 395 | } |
396 | - strcat (str, param->name); | |
396 | + strcat (str, param->name ? param->name : ""); | |
397 | 397 | |
398 | 398 | if (param->type != NULL) { |
399 | 399 | if (param->type[0] && param->name[0]) { |
@@ -656,6 +656,7 @@ custom_draw(Custom *custom, DiaRenderer *renderer) | ||
656 | 656 | |
657 | 657 | renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID); |
658 | 658 | renderer_ops->set_linewidth(renderer, custom->border_width); |
659 | + cur_line = custom->border_width; | |
659 | 660 | renderer_ops->set_linestyle(renderer, cur_style); |
660 | 661 | renderer_ops->set_dashlength(renderer, custom->dashlength); |
661 | 662 | renderer_ops->set_linecaps(renderer, cur_caps); |
@@ -1347,6 +1348,8 @@ custom_copy(Custom *custom) | ||
1347 | 1348 | newcustom->connections[i].flags = custom->connections[i].flags; |
1348 | 1349 | } |
1349 | 1350 | |
1351 | + custom_update_data(newcustom, ANCHOR_MIDDLE, ANCHOR_MIDDLE); | |
1352 | + | |
1350 | 1353 | return &newcustom->element.object; |
1351 | 1354 | } |
1352 | 1355 |
@@ -58,37 +58,41 @@ pkgdata_DATA = python-startup.py | ||
58 | 58 | |
59 | 59 | pyplugindir = $(pkgdatadir)/python |
60 | 60 | pyplugin_DATA = \ |
61 | - gtkcons.py \ | |
61 | + aobjects.py \ | |
62 | 62 | codegen.py \ |
63 | 63 | diasvg.py \ |
64 | 64 | diasvg_import.py \ |
65 | + dot.py \ | |
66 | + doxrev.py \ | |
65 | 67 | group_props.py \ |
68 | + gtkcons.py \ | |
66 | 69 | otypes.py \ |
67 | - scascale.py \ | |
68 | - select_by.py \ | |
69 | 70 | pydiadoc.py \ |
70 | - dot.py | |
71 | + scascale.py \ | |
72 | + select_by.py | |
71 | 73 | |
72 | 74 | endif |
73 | 75 | |
74 | 76 | EXTRA_DIST = \ |
75 | 77 | python-startup.py \ |
76 | - debug_objects.py \ | |
78 | + \ | |
79 | + aobjects.py \ | |
77 | 80 | codegen.py \ |
78 | - export-object.py \ | |
79 | - export-render.py \ | |
80 | 81 | diasvg.py \ |
81 | 82 | diasvg_import.py \ |
83 | + dot.py \ | |
84 | + doxrev.py \ | |
82 | 85 | group_props.py \ |
86 | + gtkcons.py \ | |
83 | 87 | otypes.py \ |
84 | - scascale.py \ | |
85 | - select_by.py \ | |
86 | 88 | pydiadoc.py \ |
87 | - dot.py \ | |
89 | + scascale.py \ | |
88 | 90 | scascale.py \ |
89 | 91 | select_by.py \ |
90 | - gtkcons.py \ | |
92 | + \ | |
91 | 93 | bbox.py \ |
92 | - doxrev.py \ | |
94 | + debug_objects.py \ | |
95 | + export-object.py \ | |
96 | + export-render.py \ | |
97 | + \ | |
93 | 98 | makefile.msc |
94 | - |
@@ -0,0 +1,89 @@ | ||
1 | +# PyDia Self Documentation Series - Part III : All Objects | |
2 | +# Copyright (c) 2007, Hans Breuer <hans@breuer.org> | |
3 | +# | |
4 | +# generates a new diagram which contains all the currently | |
5 | +# registered objects sorted to layers by their containing package | |
6 | +# | |
7 | + | |
8 | +# This program is free software; you can redistribute it and/or modify | |
9 | +# it under the terms of the GNU General Public License as published by | |
10 | +# the Free Software Foundation; either version 2 of the License, or | |
11 | +# (at your option) any later version. | |
12 | +# | |
13 | +# This program is distributed in the hope that it will be useful, | |
14 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | +# GNU General Public License for more details. | |
17 | +# | |
18 | +# You should have received a copy of the GNU General Public License | |
19 | +# along with this program; if not, write to the Free Software | |
20 | +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
21 | + | |
22 | +import sys, dia, string | |
23 | + | |
24 | +def aobjects_cb(data, flags) : | |
25 | + | |
26 | + # copied from otypes.py | |
27 | + if data : | |
28 | + diagram = None # we may be running w/o GUI | |
29 | + else : | |
30 | + diagram = dia.new("All Objects.dia") | |
31 | + data = diagram.data | |
32 | + layer = data.active_layer | |
33 | + | |
34 | + otypes = dia.registered_types() | |
35 | + keys = otypes.keys() | |
36 | + keys.sort() | |
37 | + | |
38 | + packages = {} | |
39 | + for s in keys : | |
40 | + kt = string.split(s, " - ") | |
41 | + if len(kt) == 2 : | |
42 | + if len(kt[0]) == 0 : | |
43 | + sp = "<unnamed>" | |
44 | + else : | |
45 | + sp = kt[0] | |
46 | + st = kt[1] | |
47 | + else : | |
48 | + sp = "<broken>" | |
49 | + st = kt[0] | |
50 | + if packages.has_key(sp) : | |
51 | + packages[sp].append(s) | |
52 | + else : | |
53 | + packages[sp] = [s] | |
54 | + | |
55 | + for sp in packages.keys() : | |
56 | + # add a layer per package | |
57 | + layer = data.add_layer (sp) | |
58 | + | |
59 | + cx = 0.0 | |
60 | + cy = 0.0 | |
61 | + n = 0 # counting objects | |
62 | + my = 0.0 | |
63 | + pkg = packages[sp] | |
64 | + for st in pkg : | |
65 | + if st == "Group" : | |
66 | + continue # can't create empty group | |
67 | + #print st | |
68 | + o, h1, h2 = dia.get_object_type(st).create (cx, cy) | |
69 | + w = o.bounding_box.right - o.bounding_box.left | |
70 | + h = o.bounding_box.bottom - o.bounding_box.top | |
71 | + o.move (cx, cy) | |
72 | + cx += w * 1.5 | |
73 | + if h > my : my = h | |
74 | + n += 1 | |
75 | + if n % 10 == 0 : | |
76 | + cx = 0.0 | |
77 | + cy += my * 1.5 | |
78 | + my = 0 | |
79 | + layer.add_object (o) | |
80 | + layer.update_extents() | |
81 | + data.update_extents() | |
82 | + if diagram : | |
83 | + diagram.updated_extents() | |
84 | + diagram.flush() | |
85 | + return data | |
86 | + | |
87 | +dia.register_action ("HelpAObjects", "All Objects", | |
88 | + "/ToolboxMenu/Help/HelpExtensionStart", | |
89 | + aobjects_cb) |
@@ -73,7 +73,7 @@ PyDiaFont_Compare(PyDiaFont *self, | ||
73 | 73 | return ret; |
74 | 74 | |
75 | 75 | ret = dia_font_get_style (self->font) - dia_font_get_style (other->font); |
76 | - return ret; | |
76 | + return ret > 0 ? 1 : (ret < 0 ? -1 : 0); | |
77 | 77 | } |
78 | 78 | |
79 | 79 | /* |