Revision: 51765
http://brlcad.svn.sourceforge.net/brlcad/?rev=51765&view=rev
Author: cprecup
Date: 2012-08-06 01:20:13 +0000 (Mon, 06 Aug 2012)
Log Message:
-----------
The *ged_graph_objects_positions* routine now passes objects' names as well as
their positions within the graph to the Tcl field. This command is ran in the
GraphEditor.tcl file and draws the objects at the specified positions using a
Tk Canvas widget.
Modified Paths:
--------------
brlcad/trunk/src/libged/dag.cpp
brlcad/trunk/src/tclscripts/graph/GraphEditor.tcl
Modified: brlcad/trunk/src/libged/dag.cpp
===================================================================
--- brlcad/trunk/src/libged/dag.cpp 2012-08-05 03:19:33 UTC (rev 51764)
+++ brlcad/trunk/src/libged/dag.cpp 2012-08-06 01:20:13 UTC (rev 51765)
@@ -59,6 +59,7 @@
*/
struct _ged_dag_data {
Avoid::Router *router;
+ struct bu_hash_tbl *ids;
uint16_t object_nr;
uint16_t last_connref_id;
};
@@ -110,8 +111,8 @@
entry = bu_hash_tbl_first(htbl, &rec);
while (entry) {
- bu_free(bu_get_hash_value(entry), "hash entry");
- entry = bu_hash_tbl_next(&rec);
+ bu_free(bu_get_hash_value(entry), "hash entry");
+ entry = bu_hash_tbl_next(&rec);
}
}
@@ -356,6 +357,7 @@
/* Create the master "objects" hash table. It will have at most 64
entries. */
objects = bu_create_hash_tbl(1);
+ dag->ids = bu_create_hash_tbl(1);
/* Sets a spacing distance for overlapping orthogonal connectors to be
nudged apart. */
dag->router->setOrthogonalNudgeDistance(25);
@@ -394,6 +396,10 @@
/* Set the id value for this object */
bu_set_hash_value(hsh_entry, (unsigned char *)id);
+
+ /* Add the ID of this object as a key and its name as a
value. */
+ hsh_entry = bu_hash_add_entry(dag->ids, (unsigned char
*)id, strlen(id) + 1, &new_entry);
+ bu_set_hash_value(hsh_entry, (unsigned char *)dp->d_namep);
}
} else {
bu_log("ERROR: Unable to locate [%s] within input database,
skipping.\n", bu_vls_addr(&dp_name_vls));
@@ -461,8 +467,16 @@
ObstacleList::const_iterator finish = dag->router->m_obstacles.end();
for (ObstacleList::const_iterator it =
dag->router->m_obstacles.begin(); it != finish; ++it) {
- (*it)->polygon().getBoundingRect(&minX, &minY, &maxX, &maxY);
- bu_vls_printf(gedp->ged_result_str, "%f %f %f %f\n", minX, minY,
maxX, maxY);
+ char *id = (char *)bu_malloc((size_t)6, "hash entry value");
+ sprintf(id, "%d", (*it)->id());
+
+ struct bu_hash_entry *prev = NULL;
+ unsigned long idx;
+ struct bu_hash_entry *hsh_entry= bu_find_hash_entry(dag->ids,
(unsigned char *)id, strlen(id) + 1, &prev, &idx);
+ if(hsh_entry) {
+ (*it)->polygon().getBoundingRect(&minX, &minY, &maxX, &maxY);
+ bu_vls_printf(gedp->ged_result_str, "%s %f %f %f %f\n",
hsh_entry->value, minX, minY, maxX, maxY);
+ }
}
bu_free(dag, "free DAG");
Modified: brlcad/trunk/src/tclscripts/graph/GraphEditor.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/graph/GraphEditor.tcl 2012-08-05 03:19:33 UTC
(rev 51764)
+++ brlcad/trunk/src/tclscripts/graph/GraphEditor.tcl 2012-08-06 01:20:13 UTC
(rev 51765)
@@ -147,6 +147,21 @@
-alwaysquery 1
}
+ itk_component add cv {
+ ::iwidgets::scrolledcanvas $itk_interior.cv \
+ -textbackground gray \
+ -autoresize 0 \
+ -vscrollmode dynamic \
+ -hscrollmode dynamic
+ } {
+ keep -xscrollincrement
+ keep -xscrollincrement
+ keep -selectbackground -selectforeground
+ keep -width -height
+ }
+
+ pack $itk_interior.cv -padx 0 -pady 0 -expand yes -fill both
+
# save hooks to the cadtree pop-up menus for efficiency and convenience
set _itemMenu [ $itk_interior.cadtree component itemMenu ]
set _bgMenu [ $itk_interior.cadtree component bgMenu ]
@@ -165,13 +180,41 @@
# save the index of this menu entry so we may modify its label later
set _autorenderBgMenuIndex [ $_bgMenu index end ]
- grid $itk_component(pw_pane) -sticky nsew
-
grid rowconfigure $itk_interior 0 -weight 1
grid columnconfigure $itk_interior 0 -weight 1
bind $_itemMenu <ButtonRelease> {::tk::MenuInvoke %W 1}
bind $_bgMenu <ButtonRelease> {::tk::MenuInvoke %W 1}
+
+ # get objects' positions within the graph
+ set objectsPositionsCommand "graph_objects_positions"
+
+ if [ catch $objectsPositionsCommand positions ] {
+ return
+ }
+
+ set i 0
+ foreach position $positions {
+ if { $i == 0 } {
+ incr i
+ } elseif { $i == 1 } {
+ set x1 $position
+ incr i
+ } elseif { $i == 2 } {
+ set y1 $position
+ incr i
+ } elseif { $i == 3 } {
+ set x2 $position
+ incr i
+ } else {
+ set y2 $position
+ set i 0
+ #draw a rectangle for this object within the graph
+ $itk_interior.cv create rectangle $x1 $y1 $x2 $y2 \
+ -fill red \
+ -tags rectangle
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits