+ {
+ // Bail out if there's no object to trim
+ if (toolObj[0] == NULL)
+ return;
+
+ Vector v(toolObj[0]->p[0], toolObj[0]->p[1]);
+
+ // Check to see which case we have.
+ if ((toolParam[0] == 0) && (toolParam[1] == 1.0))
+ {
+ // There was no intersection, so delete the object
+ toolObj[0]->selected = true;
+ DeleteSelectedObjects(document.objects);
+ }
+ else if (toolParam[0] == 0)
+ {
+ // We delete the end near point #1
+ toolObj[0]->p[0] = toolObj[0]->p[0] + (v * toolParam[1]);
+ }
+ else if (toolParam[1] == 1.0)
+ {
+ // We delete the end near point #2
+ toolObj[0]->p[1] = toolObj[0]->p[0] + (v * toolParam[0]);
+ }
+ else
+ {
+ // We delete the segment in between, and create a new line in the process
+ Point p1 = toolObj[0]->p[0] + (v * toolParam[0]);
+ Point p2 = toolObj[0]->p[0] + (v * toolParam[1]);
+ Point p3 = toolObj[0]->p[1];
+ toolObj[0]->p[1] = p1;
+ Line * l = new Line(p2, p3, toolObj[0]->thickness, toolObj[0]->color, toolObj[0]->style);
+ document.objects.push_back(l);
+// Global::toolState = TSNone;
+ }
+
+ toolObj[0]->hitObject = toolObj[0]->hitPoint[0] = toolObj[0]->hitPoint[1] = false;
+ toolObj[0] = NULL;
+ }