Added code to split up a display list if part of the list is no longer being displayed. That is, if "all.g" which contains "tor.r", "box.r", "platform.r", "cone.r", "ellipse.r" and "light.r" was originally being display and "all/tor.r" was removed from the display then the display list for "all" would be split up into the following new lists: "all.g/box.r", "all.g/platform.r", "all.g/cone.r", "all.g/ellipse.r" and "all.g/light.r".

svn:revision:35872
svn:branch:trunk
svn:account:bob1961
This commit is contained in:
Robert Parker committed 2009-09-09 21:34:53 +00:00
1 parent fd9a6acd13
commit ace8abe3b5
5 files changed
+147 -16

No files matched your search

+3 -2
View File
@@ -517,8 +517,9 @@ GED_EXPORT BU_EXTERN (struct ged_display_list *ged_addToDisplay,
/* defined in erase.c */
GED_EXPORT BU_EXTERN (void ged_erasePathFromDisplay,
(struct ged *gedp,
const char *path));
(struct ged *gedp,
const char *path,
int allow_split));
/* defined in ged.c */
GED_EXPORT BU_EXTERN(void ged_close,
+1 -1
View File
@@ -2156,7 +2156,7 @@ ged_E(struct ged *gedp, int argc, const char *argv[])
av[1] = (char *)0;
for (i = 0; i < argc; ++i) {
ged_erasePathFromDisplay(gedp, argv[i]);
ged_erasePathFromDisplay(gedp, argv[i], 0);
dgcdp->gdlp = ged_addToDisplay(dgcdp->gedp, argv[i]);
#if 0
+36 -8
View File
@@ -976,7 +976,7 @@ ged_invent_solid(struct ged *gedp,
* Name exists from some other overlay,
* zap any associated solids
*/
ged_erasePathFromDisplay(gedp, name);
ged_erasePathFromDisplay(gedp, name, 0);
}
/* Need to enter phony name in directory structure */
dp = db_diradd(gedp->ged_wdbp->dbip, name, RT_DIR_PHONY_ADDR, 0, DIR_SOLID, (genptr_t)&type);
@@ -1216,7 +1216,7 @@ ged_draw_guts(struct ged *gedp, int argc, const char *argv[], int kind)
if (new_argv[i][0] == '-')
continue;
ged_erasePathFromDisplay(gedp, new_argv[i]);
ged_erasePathFromDisplay(gedp, new_argv[i], 0);
}
ged_drawtrees(gedp, new_argc, (const char **)new_argv, kind, (struct ged_client_data *)0);
@@ -1233,7 +1233,7 @@ ged_draw_guts(struct ged *gedp, int argc, const char *argv[], int kind)
if (argv[i][0] == '-')
continue;
ged_erasePathFromDisplay(gedp, argv[i]);
ged_erasePathFromDisplay(gedp, argv[i], 0);
}
ged_drawtrees(gedp, argc, argv, kind, (struct ged_client_data *)0);
@@ -1265,6 +1265,8 @@ ged_addToDisplay(struct ged *gedp,
struct directory *dp;
register struct ged_display_list *gdlp;
char *cp;
int found_namepath = 0;
struct db_full_path namepath;
cp = strrchr(name, '/');
if (cp == '\0')
@@ -1272,19 +1274,41 @@ ged_addToDisplay(struct ged *gedp,
else
++cp;
if ((dp = db_lookup(gedp->ged_wdbp->dbip, cp, LOOKUP_NOISY)) == DIR_NULL) {
gdlp = GED_DISPLAY_LIST_NULL;
goto end;
}
if (db_string_to_path(&namepath, gedp->ged_wdbp->dbip, name) == 0)
found_namepath = 1;
/* Make sure name is not already in the list */
gdlp = BU_LIST_NEXT(ged_display_list, &gedp->ged_gdp->gd_headDisplay);
while (BU_LIST_NOT_HEAD(gdlp, &gedp->ged_gdp->gd_headDisplay)) {
if (!strcmp(name, bu_vls_addr(&gdlp->gdl_path))) {
return gdlp;
register struct solid *sp;
register struct solid *nsp;
if (!strcmp(name, bu_vls_addr(&gdlp->gdl_path)))
goto end;
/*
*/
if (found_namepath) {
struct db_full_path gdlpath;
if (db_string_to_path(&gdlpath, gedp->ged_wdbp->dbip, bu_vls_addr(&gdlp->gdl_path)) == 0) {
if (db_full_path_match_top(&gdlpath, &namepath)) {
db_free_full_path(&gdlpath);
goto end;
}
db_free_full_path(&gdlpath);
}
}
gdlp = BU_LIST_PNEXT(ged_display_list, gdlp);
}
if ((dp = db_lookup(gedp->ged_wdbp->dbip, cp, LOOKUP_NOISY)) == DIR_NULL)
return GED_DISPLAY_LIST_NULL;
BU_GETSTRUCT(gdlp, ged_display_list);
BU_LIST_INSERT(&gedp->ged_gdp->gd_headDisplay, &gdlp->l);
BU_LIST_INIT(&gdlp->gdl_headSolid);
@@ -1292,6 +1316,10 @@ ged_addToDisplay(struct ged *gedp,
bu_vls_init(&gdlp->gdl_path);
bu_vls_printf(&gdlp->gdl_path, name);
end:
if (found_namepath)
db_free_full_path(&namepath);
return gdlp;
}
+106 -4
View File
@@ -33,6 +33,7 @@
#include "./ged_private.h"
void ged_splitGDL(struct ged *gedp, struct ged_display_list *gdlp, struct db_full_path *path);
/*
* Erase objects from the display.
@@ -179,30 +180,93 @@ ged_erase(struct ged *gedp, int argc, const char *argv[])
if (new_argv[i][0] == '-')
continue;
ged_erasePathFromDisplay(gedp, new_argv[i]);
ged_erasePathFromDisplay(gedp, new_argv[i], 1);
}
} else {
for (i = 0; i < argc; ++i)
ged_erasePathFromDisplay(gedp, argv[i]);
ged_erasePathFromDisplay(gedp, argv[i], 1);
}
return GED_OK;
}
void
ged_splitGDL(struct ged *gedp,
struct ged_display_list *gdlp,
struct db_full_path *path)
{
register struct solid *sp;
register struct solid *nsp;
struct ged_display_list *new_gdlp;
char *pathname;
int savelen;
int newlen = path->fp_len + 1;
if (newlen < 3) {
while (BU_LIST_WHILE(sp, solid, &gdlp->gdl_headSolid)) {
savelen = sp->s_fullpath.fp_len;
sp->s_fullpath.fp_len = newlen;
pathname = db_path_to_string(&sp->s_fullpath);
sp->s_fullpath.fp_len = savelen;
new_gdlp = ged_addToDisplay(gedp, pathname);
bu_free((genptr_t)pathname, "ged_splitGDL pathname");
BU_LIST_DEQUEUE(&sp->l);
BU_LIST_INSERT(&new_gdlp->gdl_headSolid, &sp->l);
}
} else {
sp = BU_LIST_NEXT(solid, &gdlp->gdl_headSolid);
while (BU_LIST_NOT_HEAD(sp, &gdlp->gdl_headSolid)) {
nsp = BU_LIST_PNEXT(solid, sp);
if (db_full_path_match_top(path, &sp->s_fullpath)) {
savelen = sp->s_fullpath.fp_len;
sp->s_fullpath.fp_len = newlen;
pathname = db_path_to_string(&sp->s_fullpath);
sp->s_fullpath.fp_len = savelen;
new_gdlp = ged_addToDisplay(gedp, pathname);
bu_free((genptr_t)pathname, "ged_splitGDL pathname");
BU_LIST_DEQUEUE(&sp->l);
BU_LIST_INSERT(&new_gdlp->gdl_headSolid, &sp->l);
}
sp = nsp;
}
--path->fp_len;
ged_splitGDL(gedp, gdlp, path);
++path->fp_len;
}
}
/*
* Erase/remove the display list item from headDisplay if path matches the list item's path.
*
*/
void
ged_erasePathFromDisplay(struct ged *gedp,
const char *path)
const char *path,
int allow_split)
{
register struct ged_display_list *gdlp;
register struct ged_display_list *next_gdlp;
register struct ged_display_list *last_gdlp;
register struct solid *sp;
struct directory *dp;
struct db_full_path subpath;
int found_subpath;
if (db_string_to_path(&subpath, gedp->ged_wdbp->dbip, path) == 0)
found_subpath = 1;
else
found_subpath = 0;
gdlp = BU_LIST_NEXT(ged_display_list, &gedp->ged_gdp->gd_headDisplay);
last_gdlp = BU_LIST_LAST(ged_display_list, &gedp->ged_gdp->gd_headDisplay);
while (BU_LIST_NOT_HEAD(gdlp, &gedp->ged_gdp->gd_headDisplay)) {
next_gdlp = BU_LIST_PNEXT(ged_display_list, gdlp);
@@ -226,10 +290,48 @@ ged_erasePathFromDisplay(struct ged *gedp,
free((void *)gdlp);
break;
} else if (found_subpath) {
register int need_split = 0;
register struct solid *nsp;
sp = BU_LIST_NEXT(solid, &gdlp->gdl_headSolid);
while (BU_LIST_NOT_HEAD(sp, &gdlp->gdl_headSolid)) {
nsp = BU_LIST_PNEXT(solid, sp);
if (db_full_path_match_top(&subpath, &sp->s_fullpath)) {
BU_LIST_DEQUEUE(&sp->l);
FREE_SOLID(sp, &FreeSolid.l);
need_split = 1;
}
sp = nsp;
}
if (BU_LIST_IS_EMPTY(&gdlp->gdl_headSolid)) {
BU_LIST_DEQUEUE(&gdlp->l);
bu_vls_free(&gdlp->gdl_path);
free((void *)gdlp);
} else if (allow_split && need_split) {
BU_LIST_DEQUEUE(&gdlp->l);
--subpath.fp_len;
ged_splitGDL(gedp, gdlp, &subpath);
++subpath.fp_len;
/* Free up the display list */
bu_vls_free(&gdlp->gdl_path);
free((void *)gdlp);
}
}
gdlp = next_gdlp;
if (gdlp == last_gdlp)
gdlp = (struct ged_display_list *)&gedp->ged_gdp->gd_headDisplay;
else
gdlp = next_gdlp;
}
if (found_subpath)
db_free_full_path(&subpath);
}
/*
+1 -1
View File
@@ -1183,7 +1183,7 @@ invent_solid(
/* Name exists from some other overlay,
* zap any associated solids
*/
ged_erasePathFromDisplay(gedp, name);
ged_erasePathFromDisplay(gedp, name, 0);
}
/* Need to enter phony name in directory structure */
dp = db_diradd( dbip, name, RT_DIR_PHONY_ADDR, 0, DIR_SOLID, &type );