summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2016-06-01 19:18:58 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2016-06-01 19:18:58 (GMT)
commit93cc52b2c67a9ae92fc23df09fe5261d2a1fc4bf (patch)
treeaa6fb4068e110043fbb441f363086cf5aff2798c
parente1f45c15fbcad4653c23834d2583217b5a59bce5 (diff)
downloadblt-93cc52b2c67a9ae92fc23df09fe5261d2a1fc4bf.zip
blt-93cc52b2c67a9ae92fc23df09fe5261d2a1fc4bf.tar.gz
blt-93cc52b2c67a9ae92fc23df09fe5261d2a1fc4bf.tar.bz2
fixed duplicate element problem for show,raise,lower
-rw-r--r--src/tkbltGrElemOp.C49
1 files changed, 43 insertions, 6 deletions
diff --git a/src/tkbltGrElemOp.C b/src/tkbltGrElemOp.C
index 445f31b..c4bcbef 100644
--- a/src/tkbltGrElemOp.C
+++ b/src/tkbltGrElemOp.C
@@ -365,8 +365,21 @@ static int LowerOp(ClientData clientData, Tcl_Interp* interp,
if (graphPtr->getElement(objv[ii], &elemPtr) != TCL_OK)
return TCL_ERROR;
- graphPtr->elements_.displayList->unlinkLink(elemPtr->link);
- chain->linkAfter(elemPtr->link, NULL);
+ // look for duplicates
+ int ok=1;
+ for (ChainLink* link = Chain_FirstLink(chain);
+ link; link = Chain_NextLink(link)) {
+ Element* ptr = (Element*)Chain_GetValue(link);
+ if (ptr == elemPtr) {
+ ok=0;
+ break;
+ }
+ }
+
+ if (ok && elemPtr->link) {
+ graphPtr->elements_.displayList->unlinkLink(elemPtr->link);
+ chain->linkAfter(elemPtr->link, NULL);
+ }
}
// Append the links to end of the display list
@@ -424,14 +437,26 @@ static int RaiseOp(ClientData clientData, Tcl_Interp* interp,
Graph* graphPtr = (Graph*)clientData;
Chain* chain = new Chain();
-
for (int ii=3; ii<objc; ii++) {
Element* elemPtr;
if (graphPtr->getElement(objv[ii], &elemPtr) != TCL_OK)
return TCL_ERROR;
- graphPtr->elements_.displayList->unlinkLink(elemPtr->link);
- chain->linkAfter(elemPtr->link, NULL);
+ // look for duplicates
+ int ok=1;
+ for (ChainLink* link = Chain_FirstLink(chain);
+ link; link = Chain_NextLink(link)) {
+ Element* ptr = (Element*)Chain_GetValue(link);
+ if (ptr == elemPtr) {
+ ok=0;
+ break;
+ }
+ }
+
+ if (ok && elemPtr->link) {
+ graphPtr->elements_.displayList->unlinkLink(elemPtr->link);
+ chain->linkAfter(elemPtr->link, NULL);
+ }
}
// Prepend the links to beginning of the display list in reverse order
@@ -471,7 +496,19 @@ static int ShowOp(ClientData clientData, Tcl_Interp* interp,
return TCL_ERROR;
}
- chain->append(elemPtr);
+ // look for duplicates
+ int ok=1;
+ for (ChainLink* link = Chain_FirstLink(chain);
+ link; link = Chain_NextLink(link)) {
+ Element* ptr = (Element*)Chain_GetValue(link);
+ if (ptr == elemPtr) {
+ ok=0;
+ break;
+ }
+ }
+
+ if (ok)
+ chain->append(elemPtr);
}
// Clear the links from the currently displayed elements