X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fbase%2Frs_creation.cpp;h=be969ef3dd5309d2b945021c45712dd6125d50a3;hb=bd2b29c8735d83ab48df13c3efee53f63570473e;hp=39e5ee7f11073f66680f6bd3d0169048ac7be39c;hpb=865303923fcb231a171992b75a73364ff469ff8c;p=architektonas diff --git a/src/base/rs_creation.cpp b/src/base/rs_creation.cpp index 39e5ee7..be969ef 100644 --- a/src/base/rs_creation.cpp +++ b/src/base/rs_creation.cpp @@ -480,73 +480,61 @@ RS_Circle* RS_Creation::createParallelCircle(const Vector& coord, * @return Pointer to the first bisector created or NULL if no bisectors * were created. */ -RS_Line* RS_Creation::createBisector(const Vector& coord1, - const Vector& coord2, - double length, - int num, - RS_Line* l1, - RS_Line* l2) { +RS_Line * RS_Creation::createBisector(const Vector & coord1, const Vector & coord2, + double length, int num, RS_Line * l1, RS_Line * l2) +{ + // check given entities: + if (!l1 || !l2 || l1->rtti() != RS2::EntityLine || l2->rtti() != RS2::EntityLine) + return NULL; - VectorSolutions sol; + // intersection between entities: + VectorSolutions sol = RS_Information::getIntersection(l1, l2, false); + Vector inters = sol.get(0); - // check given entities: - if (l1==NULL || l2==NULL || - l1->rtti()!=RS2::EntityLine || l2->rtti()!=RS2::EntityLine) { - return NULL; - } + if (!inters.valid) + return NULL; - // intersection between entities: - sol = RS_Information::getIntersection(l1, l2, false); - Vector inters = sol.get(0); - if (inters.valid==false) { - return NULL; - } + double angle1 = inters.angleTo(l1->getNearestPointOnEntity(coord1)); + double angle2 = inters.angleTo(l2->getNearestPointOnEntity(coord2)); + double angleDiff = RS_Math::getAngleDifference(angle1, angle2); - double angle1 = inters.angleTo(l1->getNearestPointOnEntity(coord1)); - double angle2 = inters.angleTo(l2->getNearestPointOnEntity(coord2)); - double angleDiff = RS_Math::getAngleDifference(angle1, angle2); - if (angleDiff>M_PI) { - angleDiff = angleDiff - 2*M_PI; - } - RS_Line* ret = NULL; + if (angleDiff > M_PI) + angleDiff = angleDiff - 2 * M_PI; - if (document!=NULL && handleUndo) { - document->startUndoCycle(); - } + RS_Line * ret = NULL; - for (int n=1; n<=num; ++n) { + if (document && handleUndo) + document->startUndoCycle(); - double angle = angle1 + - (angleDiff / (num+1) * n); + for(int n=1; n<=num; n++) + { + double angle = angle1 + (angleDiff / (num + 1) * n); + Vector v; + v.setPolar(length, angle); + RS_LineData d = RS_LineData(inters, inters + v); + RS_Line * newLine = new RS_Line(container, d); - RS_LineData d; - Vector v; + if (container) + { + newLine->setLayerToActive(); + newLine->setPenToActive(); + container->addEntity(newLine); + } - Vector c; - v.setPolar(length, angle); - d = RS_LineData(inters, inters + v); + if (document && handleUndo) + document->addUndoable(newLine); - RS_Line* newLine = new RS_Line(container, d); - if (container!=NULL) { - newLine->setLayerToActive(); - newLine->setPenToActive(); - container->addEntity(newLine); - } - if (document!=NULL && handleUndo) { - document->addUndoable(newLine); - } - if (graphicView!=NULL) { - graphicView->drawEntity(newLine); - } - if (ret==NULL) { - ret = newLine; - } - } - if (document!=NULL && handleUndo) { - document->endUndoCycle(); - } + if (graphicView) + graphicView->drawEntity(newLine); - return ret; + if (!ret) + ret = newLine; + } + + if (document && handleUndo) + document->endUndoCycle(); + + return ret; } @@ -1146,25 +1134,33 @@ RS_Block * RS_Creation::createBlock(const RS_BlockData & data, //for (uint i=0; icount(); ++i) { //RS_Entity* e = container->entityAt(i); - if (e != NULL && e->isSelected()) + if (e && e->isSelected()) { // delete / redraw entity in graphic view: if (remove) { - if (graphicView != NULL) +#warning "!!! Old rendering path needs upgrading !!!" +#if 0 + if (graphicView) graphicView->deleteEntity(e); +#endif e->setSelected(false); } else { - if (graphicView != NULL) +#warning "!!! Old rendering path needs upgrading !!!" +#if 0 + if (graphicView) graphicView->deleteEntity(e); - +#endif e->setSelected(false); - if (graphicView != NULL) +#warning "!!! Old rendering path needs upgrading !!!" +#if 0 + if (graphicView) graphicView->drawEntity(e); +#endif } // add entity to block: @@ -1178,7 +1174,7 @@ RS_Block * RS_Creation::createBlock(const RS_BlockData & data, //i=0; e->changeUndoState(); - if (document != NULL) + if (document) document->addUndoable(e); } }