Revision: 51838
http://brlcad.svn.sourceforge.net/brlcad/?rev=51838&view=rev
Author: cprecup
Date: 2012-08-09 02:13:22 +0000 (Thu, 09 Aug 2012)
Log Message:
-----------
Added *decorate_object* routine that adds an entry into a hash table depending
on the object's type (primitive/combination/something else). Used this in the
View part - differently coloured nodes correspond to different types. Added
text with the object's name within each rectangle of a node.
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-08 20:10:22 UTC (rev 51837)
+++ brlcad/trunk/src/libged/dag.cpp 2012-08-09 02:13:22 UTC (rev 51838)
@@ -34,7 +34,7 @@
#define BRLCAD_PARALLEL PARALLEL
#undef PARALLEL
-#define POSITION_COORDINATE 10.0
+#define POSITION_COORDINATE 30.0
/* Adaptagrams Header */
#include "libavoid/libavoid.h"
@@ -60,6 +60,7 @@
struct _ged_dag_data {
Avoid::Router *router;
struct bu_hash_tbl *ids;
+ struct bu_hash_tbl *object_types;
uint16_t object_nr;
uint16_t last_connref_id;
};
@@ -118,6 +119,23 @@
/**
+ * Method that "decorates" each object depending on its type: primitive /
combination / something else.
+ * A new entry is added into the objects_types hash table with the name of the
object as a key and
+ * the type of the object as a value.
+ */
+void
+decorate_object(struct _ged_dag_data *dag, char *object_name, int object_type)
+{
+ int new_entry;
+ struct bu_hash_entry *hsh_entry = bu_hash_add_entry(dag->object_types,
(unsigned char *)object_name, strlen(object_name) + 1, &new_entry);
+
+ char *type = (char *)bu_malloc((size_t)1, "hash entry value");
+ sprintf(type, "%d", object_type);
+ bu_set_hash_value(hsh_entry, (unsigned char *)type);
+}
+
+
+/**
* Function which processes a combination node. I.e., it adds a new entry into
the hash tables, if necessary.
* In this case, it also adds a Avoid::ShapeRef object to the graph. It also
traverses its subtree, adds
* entries into the hash table for solid objects, if neccessary. In this case
as well, it also adds a
@@ -303,6 +321,9 @@
std::string name((const char *)dp->d_namep);
o->primitives.push_back(name);
+ /* "Decorate" the object. Add its name and type into the hash
table. */
+ decorate_object(dag, dp->d_namep, dp->d_flags);
+
/* Check if a shape was already created for this subnode. */
bool shape_exists = false;
ObstacleList::const_iterator finish =
dag->router->m_obstacles.end();
@@ -323,6 +344,9 @@
} else if (dp->d_flags & RT_DIR_COMB) {
bu_log("Adding COMB object [%s]\n", bu_vls_addr(&dp_name_vls));
dag_comb(dbip, ndp, o, dag, objects);
+
+ /* "Decorate" the object. Add its name and type into the hash table. */
+ decorate_object(dag, dp->d_namep, dp->d_flags);
} else {
bu_log("Something else: [%s]\n", bu_vls_addr(&dp_name_vls));
prev = NULL;
@@ -332,6 +356,9 @@
o->non_geometries.reserve(o->non_geometries.size() + 1);
std::string name((const char *)dp->d_namep);
o->non_geometries.push_back(name);
+
+ /* "Decorate" the object. Add its name and type into the hash
table. */
+ decorate_object(dag, dp->d_namep, dp->d_flags);
}
}
@@ -358,6 +385,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);
+ dag->object_types = bu_create_hash_tbl(1);
/* Sets a spacing distance for overlapping orthogonal connectors to be
nudged apart. */
dag->router->setOrthogonalNudgeDistance(25);
@@ -472,16 +500,22 @@
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);
+ 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);
+
+ prev = NULL;
+ struct bu_hash_entry *hsh_entry_type =
bu_find_hash_entry(dag->object_types, hsh_entry->value,
+
strlen((char *)hsh_entry->value) + 1, &prev, &idx);
+ if(hsh_entry_type) {
+ bu_vls_printf(gedp->ged_result_str, "%s %s %f %f %f %f\n",
hsh_entry->value, hsh_entry_type->value, minX,
+ minY, maxX, maxY);
+ }
}
}
bu_free(dag, "free DAG");
}
-
return GED_OK;
}
Modified: brlcad/trunk/src/tclscripts/graph/GraphEditor.tcl
===================================================================
--- brlcad/trunk/src/tclscripts/graph/GraphEditor.tcl 2012-08-08 20:10:22 UTC
(rev 51837)
+++ brlcad/trunk/src/tclscripts/graph/GraphEditor.tcl 2012-08-09 02:13:22 UTC
(rev 51838)
@@ -186,33 +186,58 @@
bind $_itemMenu <ButtonRelease> {::tk::MenuInvoke %W 1}
bind $_bgMenu <ButtonRelease> {::tk::MenuInvoke %W 1}
- # get objects' positions within the graph
+ # get objects' names, types and positions within the graph
set objectsPositionsCommand "graph_objects_positions"
if [ catch $objectsPositionsCommand positions ] {
return
}
+ # set constant values for the following type of objects: primitive,
combination and something else
+ set primitive 1
+ set combination 2
+
set i 0
- foreach position $positions {
+ foreach element $positions {
if { $i == 0 } {
+ # set the name of the object
+ set name $element
incr i
} elseif { $i == 1 } {
- set x1 $position
+ # set the color depending on the type of object: primitive /
combination / something else
+ if { [string equal $element $primitive] } {
+ set color red
+ } elseif { [string equal $element $combination] } {
+ set color green
+ } else {
+ set color yellow
+ }
incr i
} elseif { $i == 2 } {
- set y1 $position
+ # set the x coordinate for the lower left corner
+ set x1 $element
incr i
} elseif { $i == 3 } {
- set x2 $position
+ # set the y coordinate for the lower left corner
+ set y1 $element
incr i
+ } elseif { $i == 4 } {
+ # set the x coordinate for the upper right corner
+ set x2 $element
+ incr i
} else {
- set y2 $position
+ # set the y coordinate for the upper right corner
+ set y2 $element
set i 0
- #draw a rectangle for this object within the graph
+
+ # draw a rectangle for this object within the graph
$itk_interior.cv create rectangle $x1 $y1 $x2 $y2 \
- -fill red \
+ -fill $color \
-tags rectangle
+
+ # write the object's name inside the rectangle
+ $itk_interior.cv create text [expr "($x1 + $x2)/2" ] [expr "($y1 +
$y2)/2" ] \
+ -text $name
}
}
}
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