• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

作図ソフト dia の改良版


Commit MetaInfo

Revisiónbf8a5f53be87af155cb8cd2777eeff7406eb21ff (tree)
Tiempo2007-03-17 20:08:26
AutorHans Breuer <hans@breu...>
CommiterHans Breuer

Log Message

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

Cambiar Resumen

Diferencia incremental

--- a/ChangeLog
+++ b/ChangeLog
@@ -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+
120 2007-03-17 Steffen Macke <sdteffen@gmail.com>
221
322 * installer/win32/locale/slovak.nsh: Use Codepage 1250, fixed errors
@@ -148,7 +167,7 @@
148167 * objects/UML/state.c
149168 * objects/UML/small_package.c
150169 * objects/GRAFCET/boolequation.c: Make sure to call set_font
151- before calling draw_string
170+ before calling draw_string, fixes bug #408519
152171
153172 * objects/UML/class.c (umlclass_set_props): #ifdef out debugging
154173 statement.
--- a/lib/message.h
+++ b/lib/message.h
@@ -20,6 +20,8 @@
2020
2121 #include <stdarg.h>
2222
23+G_BEGIN_DECLS
24+
2325 typedef void (*MessageInternal)(const char *title, const char *fmt,
2426 va_list *args, va_list *args2);
2527
@@ -32,6 +34,8 @@ void message_error(const char *format, ...);
3234 /* also declared in dia_dirs.h, where I think it does not belong! --hb */
3335 const gchar *dia_message_filename (const gchar *filename);
3436
37+G_END_DECLS
38+
3539 #endif /* MESSAGES_H */
3640
3741
--- a/lib/utils.h
+++ b/lib/utils.h
@@ -20,6 +20,8 @@
2020
2121 #include <stdarg.h>
2222
23+G_BEGIN_DECLS
24+
2325 int nearest_pow (int num);
2426 int format_string_length_upper_bound (const char* fmt,
2527 va_list *args);
@@ -28,6 +30,8 @@ int format_string_length_upper_bound (const char* fmt,
2830 int snprintf ( char *str, size_t n, const char *format, ... );
2931 #endif
3032
33+G_END_DECLS
34+
3135 #endif /* UTILS_H */
3236
3337
--- a/objects/FS/flow-ortho.c
+++ b/objects/FS/flow-ortho.c
@@ -91,8 +91,6 @@ Color orthflow_color_signal = { 0.0f, 0.0f, 1.0f };
9191 #define ORTHFLOW_ARROWWIDTH 0.5
9292 #define HANDLE_MOVE_TEXT (HANDLE_CUSTOM2)
9393
94-static DiaFont *orthflow_font = NULL;
95-
9694 static ObjectChange* orthflow_move_handle(Orthflow *orthflow, Handle *handle,
9795 Point *to, ConnectionPoint *cp,
9896 HandleMoveReason reason,
@@ -389,9 +387,6 @@ orthflow_draw(Orthflow *orthflow, DiaRenderer *renderer)
389387 render_color,
390388 NULL, &arrow);
391389
392- renderer_ops->set_font(renderer, orthflow_font,
393- ORTHFLOW_FONTHEIGHT);
394-
395390 text_draw(orthflow->text, renderer);
396391 }
397392
@@ -435,11 +430,6 @@ orthflow_create(Point *startpoint,
435430 } else {
436431 Color* color = &orthflow_color_signal;
437432
438- if (orthflow_font == NULL) {
439- orthflow_font = dia_font_new_from_style(DIA_FONT_SANS|DIA_FONT_ITALIC,
440- 1.0);
441- }
442-
443433 switch (orthflow->type) {
444434 case ORTHFLOW_ENERGY:
445435 color = &orthflow_color_energy ;
@@ -452,8 +442,6 @@ orthflow_create(Point *startpoint,
452442 break ;
453443 }
454444
455- orthflow->text = new_text("", orthflow_font, ORTHFLOW_FONTHEIGHT,
456- &p, color, ALIGN_CENTER);
457445 }
458446 #endif
459447
@@ -566,11 +554,6 @@ orthflow_load(ObjectNode obj_node, int version, const char *filename)
566554 DiaObject *obj;
567555 PolyBBExtras *extra;
568556
569- if (orthflow_font == NULL) {
570- orthflow_font = dia_font_new_from_style(DIA_FONT_SANS|DIA_FONT_ITALIC,
571- 1.0);
572- }
573-
574557 orthflow = g_malloc0(sizeof(Orthflow));
575558
576559 orth = &orthflow->orth;
--- a/objects/FS/flow.c
+++ b/objects/FS/flow.c
@@ -70,8 +70,6 @@ struct _Flow {
7070 #define FLOW_ARROWWIDTH 0.5
7171 #define HANDLE_MOVE_TEXT (HANDLE_CUSTOM1)
7272
73-static DiaFont *flow_font = NULL;
74-
7573 static ObjectChange* flow_move_handle(Flow *flow, Handle *handle,
7674 Point *to, ConnectionPoint *cp,
7775 HandleMoveReason reason,
@@ -355,8 +353,6 @@ flow_draw(Flow *flow, DiaRenderer *renderer)
355353 render_color,
356354 &arrow, NULL);
357355
358- renderer_ops->set_font(renderer, flow_font,FLOW_FONTHEIGHT);
359-
360356 text_draw(flow->text, renderer);
361357 }
362358
@@ -523,11 +519,6 @@ flow_load(ObjectNode obj_node, int version, const char *filename)
523519 DiaObject *obj;
524520 LineBBExtras *extra;
525521
526- if (flow_font == NULL) {
527- flow_font = dia_font_new_from_style (DIA_FONT_SANS|DIA_FONT_ITALIC,
528- FLOW_FONTHEIGHT);
529- }
530-
531522 flow = g_malloc0(sizeof(Flow));
532523
533524 conn = &flow->connection;
--- a/objects/UML/umlattribute.c
+++ b/objects/UML/umlattribute.c
@@ -193,8 +193,9 @@ uml_get_attribute_string (UMLAttribute *attribute)
193193 int len;
194194 char *str;
195195
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]) {
198199 len += 2;
199200 }
200201 if (attribute->value != NULL && attribute->value[0] != '\0') {
@@ -206,11 +207,11 @@ uml_get_attribute_string (UMLAttribute *attribute)
206207 str[0] = visible_char[(int) attribute->visibility];
207208 str[1] = 0;
208209
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]) {
211212 strcat (str, ": ");
212213 }
213- strcat (str, attribute->type);
214+ strcat (str, attribute->type ? attribute->type : "");
214215 if (attribute->value != NULL && attribute->value[0] != '\0') {
215216 strcat (str, " = ");
216217 strcat (str, attribute->value);
--- a/objects/UML/umlformalparameter.c
+++ b/objects/UML/umlformalparameter.c
@@ -109,7 +109,7 @@ uml_get_formalparameter_string (UMLFormalParameter *parameter)
109109 char *str;
110110
111111 /* Calculate length: */
112- len = strlen (parameter->name);
112+ len = parameter->name ? strlen (parameter->name) : 0;
113113
114114 if (parameter->type != NULL) {
115115 len += 1 + strlen (parameter->type);
@@ -117,7 +117,7 @@ uml_get_formalparameter_string (UMLFormalParameter *parameter)
117117
118118 /* Generate string: */
119119 str = g_malloc (sizeof (char) * (len + 1));
120- strcpy (str, parameter->name);
120+ strcpy (str, parameter->name ? parameter->name : "");
121121 if (parameter->type != NULL) {
122122 strcat (str, ":");
123123 strcat (str, parameter->type);
--- a/objects/UML/umloperation.c
+++ b/objects/UML/umloperation.c
@@ -310,7 +310,7 @@ uml_get_operation_string (UMLOperation *operation)
310310 UMLParameter *param;
311311
312312 /* Calculate length: */
313- len = 1 + strlen (operation->name) + 1;
313+ len = 1 + (operation->name ? strlen (operation->name) : 0) + 1;
314314 if(operation->stereotype != NULL && operation->stereotype[0] != '\0') {
315315 len += 5 + strlen (operation->stereotype);
316316 }
@@ -334,7 +334,7 @@ uml_get_operation_string (UMLOperation *operation)
334334 len += 6;
335335 break;
336336 }
337- len += strlen (param->name);
337+ len += (param->name ? strlen (param->name) : 0);
338338 if (param->type != NULL) {
339339 len += strlen (param->type);
340340 if (param->type[0] && param->name[0]) {
@@ -371,7 +371,7 @@ uml_get_operation_string (UMLOperation *operation)
371371 strcat(str, " ");
372372 }
373373
374- strcat (str, operation->name);
374+ strcat (str, operation->name ? operation->name : "");
375375 strcat (str, "(");
376376
377377 list = operation->parameters;
@@ -393,7 +393,7 @@ uml_get_operation_string (UMLOperation *operation)
393393 strcat (str, "inout ");
394394 break;
395395 }
396- strcat (str, param->name);
396+ strcat (str, param->name ? param->name : "");
397397
398398 if (param->type != NULL) {
399399 if (param->type[0] && param->name[0]) {
--- a/objects/custom/custom_object.c
+++ b/objects/custom/custom_object.c
@@ -656,6 +656,7 @@ custom_draw(Custom *custom, DiaRenderer *renderer)
656656
657657 renderer_ops->set_fillstyle(renderer, FILLSTYLE_SOLID);
658658 renderer_ops->set_linewidth(renderer, custom->border_width);
659+ cur_line = custom->border_width;
659660 renderer_ops->set_linestyle(renderer, cur_style);
660661 renderer_ops->set_dashlength(renderer, custom->dashlength);
661662 renderer_ops->set_linecaps(renderer, cur_caps);
@@ -1347,6 +1348,8 @@ custom_copy(Custom *custom)
13471348 newcustom->connections[i].flags = custom->connections[i].flags;
13481349 }
13491350
1351+ custom_update_data(newcustom, ANCHOR_MIDDLE, ANCHOR_MIDDLE);
1352+
13501353 return &newcustom->element.object;
13511354 }
13521355
--- a/plug-ins/python/Makefile.am
+++ b/plug-ins/python/Makefile.am
@@ -58,37 +58,41 @@ pkgdata_DATA = python-startup.py
5858
5959 pyplugindir = $(pkgdatadir)/python
6060 pyplugin_DATA = \
61- gtkcons.py \
61+ aobjects.py \
6262 codegen.py \
6363 diasvg.py \
6464 diasvg_import.py \
65+ dot.py \
66+ doxrev.py \
6567 group_props.py \
68+ gtkcons.py \
6669 otypes.py \
67- scascale.py \
68- select_by.py \
6970 pydiadoc.py \
70- dot.py
71+ scascale.py \
72+ select_by.py
7173
7274 endif
7375
7476 EXTRA_DIST = \
7577 python-startup.py \
76- debug_objects.py \
78+ \
79+ aobjects.py \
7780 codegen.py \
78- export-object.py \
79- export-render.py \
8081 diasvg.py \
8182 diasvg_import.py \
83+ dot.py \
84+ doxrev.py \
8285 group_props.py \
86+ gtkcons.py \
8387 otypes.py \
84- scascale.py \
85- select_by.py \
8688 pydiadoc.py \
87- dot.py \
89+ scascale.py \
8890 scascale.py \
8991 select_by.py \
90- gtkcons.py \
92+ \
9193 bbox.py \
92- doxrev.py \
94+ debug_objects.py \
95+ export-object.py \
96+ export-render.py \
97+ \
9398 makefile.msc
94-
--- /dev/null
+++ b/plug-ins/python/aobjects.py
@@ -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)
--- a/plug-ins/python/pydia-font.c
+++ b/plug-ins/python/pydia-font.c
@@ -73,7 +73,7 @@ PyDiaFont_Compare(PyDiaFont *self,
7373 return ret;
7474
7575 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);
7777 }
7878
7979 /*