X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Fselection.cpp;h=8550de145d9a4b4335df4a1deff703178712ab3c;hb=a18a12fc3bcb18e5c7ca5494d7f97fb8b93f90a2;hp=1261f7098325549366d71d4d9443e0ed9cab1978;hpb=3239ef39dcee08fa6e8cd68cdf2727fc68cc7a8c;p=architektonas diff --git a/src/base/selection.cpp b/src/base/selection.cpp index 1261f70..8550de1 100644 --- a/src/base/selection.cpp +++ b/src/base/selection.cpp @@ -29,17 +29,18 @@ * entities. Usually that's an Drawing entity but * it can also be a polyline, text, ... */ -RS_Selection::RS_Selection(RS_EntityContainer & container, GraphicView * graphicView) +Selection::Selection(EntityContainer & container, GraphicView * graphicView) { this->container = &container; this->graphicView = graphicView; - graphic = container.getGraphic(); +#warning "!!! Need to rename graphic to drawing !!!" + graphic = container.GetDrawing(); } /** * Selects or deselects the given entitiy. */ -void RS_Selection::selectSingle(RS_Entity * e) +void Selection::selectSingle(Entity * e) { if (e && (e->getLayer() == NULL || e->getLayer()->isLocked() == false)) { @@ -52,7 +53,7 @@ void RS_Selection::selectSingle(RS_Entity * e) //Most likely because while the painter is valid, the QPainter is not... //[WAS]#warning "!!! This is causing a segfault in the draw code !!!" - if (graphicView != NULL) + if (graphicView) // graphicView->drawEntity(e); graphicView->redraw(); } @@ -61,29 +62,28 @@ void RS_Selection::selectSingle(RS_Entity * e) /** * Selects all entities on visible layers. */ -void RS_Selection::selectAll(bool select) +void Selection::selectAll(bool select) { - if (graphicView != NULL) + if (graphicView) { //graphicView->deleteEntity(container); } //container->setSelected(select); - for(RS_Entity * e=container->firstEntity(); e!=NULL; e=container->nextEntity()) + for(Entity * e=container->firstEntity(); e!=NULL; e=container->nextEntity()) { //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); + //Entity* e = container->entityAt(i); if (e != NULL && e->isVisible()) e->setSelected(select); } - if (graphicView!=NULL) - //graphicView->drawEntity(container); + if (graphicView) graphicView->redraw(); } -void RS_Selection::deselectAll() +void Selection::deselectAll() { selectAll(false); } @@ -91,17 +91,17 @@ void RS_Selection::deselectAll() /** * Selects all entities on visible layers. */ -void RS_Selection::invertSelection() +void Selection::invertSelection() { if (graphicView != NULL) { //graphicView->deleteEntity(container); } - for(RS_Entity * e=container->firstEntity(); e!=NULL; e=container->nextEntity()) + for(Entity * e=container->firstEntity(); e!=NULL; e=container->nextEntity()) { //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); + //Entity* e = container->entityAt(i); if (e != NULL && e->isVisible()) e->toggleSelected(); @@ -119,7 +119,7 @@ void RS_Selection::invertSelection() * @param v2 Second corner of the window to select. * @param select true: select, false: deselect */ -void RS_Selection::selectWindow(const Vector & v1, const Vector & v2, bool select, bool cross) +void Selection::selectWindow(const Vector & v1, const Vector & v2, bool select, bool cross) { //if (graphicView!=NULL) { // graphicView->drawWindow(v1, v2, true); @@ -132,7 +132,7 @@ void RS_Selection::selectWindow(const Vector & v1, const Vector & v2, bool selec graphicView->redraw(); } -void RS_Selection::deselectWindow(const Vector & v1, const Vector & v2) +void Selection::deselectWindow(const Vector & v1, const Vector & v2) { selectWindow(v1, v2, false); } @@ -144,29 +144,26 @@ void RS_Selection::deselectWindow(const Vector & v1, const Vector & v2) * @param v2 Endpoint of line. * @param select true: select, false: deselect */ -void RS_Selection::selectIntersected(const Vector & v1, const Vector & v2, bool select) +void Selection::selectIntersected(const Vector & v1, const Vector & v2, bool select) { - RS_Line line(NULL, RS_LineData(v1, v2)); + Line line(NULL, LineData(v1, v2)); bool inters; - for (RS_Entity* e=container->firstEntity(); e!=NULL; - e=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //RS_Entity* e = container->entityAt(i); - - if (e!=NULL && e->isVisible()) + for(Entity * e=container->firstEntity(); e!=NULL; e=container->nextEntity()) + { + if (e && e->isVisible()) { inters = false; // select containers / groups: if (e->isContainer()) { - RS_EntityContainer * ec = (RS_EntityContainer *)e; + EntityContainer * ec = (EntityContainer *)e; - for(RS_Entity * e2=ec->firstEntity(RS2::ResolveAll); e2!=NULL; + for(Entity * e2=ec->firstEntity(RS2::ResolveAll); e2!=NULL; e2=ec->nextEntity(RS2::ResolveAll)) { - VectorSolutions sol = RS_Information::getIntersection(&line, e2, true); + VectorSolutions sol = Information::getIntersection(&line, e2, true); if (sol.hasValid()) inters = true; @@ -174,7 +171,7 @@ void RS_Selection::selectIntersected(const Vector & v1, const Vector & v2, bool } else { - VectorSolutions sol = RS_Information::getIntersection(&line, e, true); + VectorSolutions sol = Information::getIntersection(&line, e, true); if (sol.hasValid()) inters = true; @@ -200,7 +197,7 @@ void RS_Selection::selectIntersected(const Vector & v1, const Vector & v2, bool } } -void RS_Selection::deselectIntersected(const Vector & v1, const Vector & v2) +void Selection::deselectIntersected(const Vector & v1, const Vector & v2) { selectIntersected(v1, v2, false); } @@ -210,13 +207,13 @@ void RS_Selection::deselectIntersected(const Vector & v1, const Vector & v2) * * @param e The entity where the algorithm starts. Must be an atomic entity. */ -void RS_Selection::selectContour(RS_Entity * e) +void Selection::selectContour(Entity * e) { if (!e || !e->isAtomic()) return; bool select = !e->isSelected(); - RS_AtomicEntity * ae = (RS_AtomicEntity *)e; + AtomicEntity * ae = (AtomicEntity *)e; Vector p1 = ae->getStartpoint(); Vector p2 = ae->getEndpoint(); bool found = false; @@ -240,39 +237,43 @@ void RS_Selection::selectContour(RS_Entity * e) { found = false; - for(RS_Entity * en=container->firstEntity(); en!=NULL; + for(Entity * en=container->firstEntity(); en!=NULL; en=container->nextEntity()) { //for (uint i=0; icount(); ++i) { - //RS_Entity* en = container->entityAt(i); + //Entity* en = container->entityAt(i); - if (en!=NULL && en->isVisible() && - en->isAtomic() && en->isSelected()!=select && - (en->getLayer()==NULL || en->getLayer()->isLocked()==false)) + if (en && en->isVisible() && en->isAtomic() + && en->isSelected() != select && (en->getLayer() == NULL + || en->getLayer()->isLocked() == false)) { - ae = (RS_AtomicEntity *)en; + ae = (AtomicEntity *)en; bool doit = false; // startpoint connects to 1st point - if (ae->getStartpoint().distanceTo(p1)<1.0e-4) { + if (ae->getStartpoint().distanceTo(p1) < 1.0e-4) + { doit = true; p1 = ae->getEndpoint(); } // endpoint connects to 1st point - else if (ae->getEndpoint().distanceTo(p1)<1.0e-4) { + else if (ae->getEndpoint().distanceTo(p1) < 1.0e-4) + { doit = true; p1 = ae->getStartpoint(); } // startpoint connects to 2nd point - else if (ae->getStartpoint().distanceTo(p2)<1.0e-4) { + else if (ae->getStartpoint().distanceTo(p2) < 1.0e-4) + { doit = true; p2 = ae->getEndpoint(); } // endpoint connects to 1st point - else if (ae->getEndpoint().distanceTo(p2)<1.0e-4) { + else if (ae->getEndpoint().distanceTo(p2) < 1.0e-4) + { doit = true; p2 = ae->getStartpoint(); } @@ -297,20 +298,21 @@ void RS_Selection::selectContour(RS_Entity * e) } } } - } while(found); + } + while(found); } /** * Selects all entities on the given layer. */ -void RS_Selection::selectLayer(RS_Entity * e) +void Selection::selectLayer(Entity * e) { if (e == NULL) return; bool select = !e->isSelected(); - RS_Layer * layer = e->getLayer(true); + Layer * layer = e->getLayer(true); if (layer == NULL) return; @@ -322,14 +324,14 @@ void RS_Selection::selectLayer(RS_Entity * e) /** * Selects all entities on the given layer. */ -void RS_Selection::selectLayer(const QString & layerName, bool select) +void Selection::selectLayer(const QString & layerName, bool select) { - for(RS_Entity * en=container->firstEntity(); en!=NULL; en=container->nextEntity()) + for(Entity * en=container->firstEntity(); en!=NULL; en=container->nextEntity()) { if (en != NULL && en->isVisible() && en->isSelected() != select && (en->getLayer() == NULL || en->getLayer()->isLocked() == false)) { - RS_Layer * l = en->getLayer(true); + Layer * l = en->getLayer(true); if (l != NULL && l->getName() == layerName) { @@ -351,7 +353,7 @@ void RS_Selection::selectLayer(const QString & layerName, bool select) } } -void RS_Selection::deselectLayer(QString & layerName) +void Selection::deselectLayer(QString & layerName) { selectLayer(layerName, false); }