void RS_ActionDrawEllipseInscribe::mouseMoveEvent(QMouseEvent* e) { RS_DEBUG->print("RS_ActionDrawEllipse4Line::mouseMoveEvent begin"); if(getStatus() == SetLine4) { RS_Entity* en = catchEntity(e, RS2::EntityLine, RS2::ResolveAll); if(!en) return; if(!(en->isVisible() && en->rtti()== RS2::EntityLine)) return; for(auto p: lines){ if(en == p) return; //do not pull in the same line again } if(en->getParent() && en->getParent()->ignoredOnModification()){ return; } deletePreview(); clearLines(true); lines.push_back(static_cast<RS_Line*>(en)); if(preparePreview()) { lines.back()->setHighlighted(true); graphicView->drawEntity(lines.back()); RS_Ellipse* e=new RS_Ellipse(preview.get(), *eData); preview->addEntity(e); drawPreview(); } } RS_DEBUG->print("RS_ActionDrawEllipse4Line::mouseMoveEvent end"); }
void RS_ActionDrawLineRelAngle::mouseReleaseEvent(QMouseEvent* e) { if (e->button()==Qt::LeftButton) { switch (getStatus()) { case SetEntity: { RS_Entity* en = catchEntity(e, enTypeList, RS2::ResolveAll); if (en) { entity = en; entity->setHighlighted(true); graphicView->drawEntity(entity); setStatus(SetPos); } } break; case SetPos: { RS_CoordinateEvent ce(snapPoint(e)); coordinateEvent(&ce); } break; default: break; } } else if (e->button()==Qt::RightButton) { deletePreview(); if (entity) { entity->setHighlighted(false); graphicView->drawEntity(entity); } init(getStatus()-1); } }
void RS_ActionDrawLineBisector::mouseReleaseEvent(QMouseEvent* e) { if (e->button()==Qt::RightButton) { deletePreview(); init(getStatus()-1); } else { RS_Vector mouse = RS_Vector(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y())); switch (getStatus()) { case SetLine1: { coord1 = mouse; RS_Entity* en = catchEntity(e, RS2::ResolveAll); if (en!=NULL && en->rtti()==RS2::EntityLine) { line1 = (RS_Line*)en; } } setStatus(SetLine2); break; case SetLine2: coord2 = mouse; trigger(); setStatus(SetLine1); break; } } }
void RS_ActionDrawLineParallel::mouseMoveEvent(RS_MouseEvent* e) { RS_DEBUG->print("RS_ActionDrawLineParallel::mouseMoveEvent begin"); coord = RS_Vector(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y())); entity = catchEntity(e, RS2::ResolveAll); switch (getStatus()) { case SetEntity: { deletePreview(); RS_Creation creation(preview, NULL, false); creation.createParallel(coord, distance, number, entity); drawPreview(); } break; default: break; } RS_DEBUG->print("RS_ActionDrawLineParallel::mouseMoveEvent end"); }
void RS_ActionModifyEntity::mouseReleaseEvent(RS_MouseEvent* e) { if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) { init(getStatus()-1); } else { en = catchEntity(e); trigger(); } }
/** * Catches an entity which is close to the mouse cursor. * * @param e A mouse event. * @param level The level of resolving for iterating through the entity * container * @return Pointer to the entity or NULL. */ RS_Entity* RS_Snapper::catchEntity(RS_MouseEvent* e, RS2::ResolveLevel level) { return catchEntity( RS_Vector(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y())), level); }
void RS_ActionSelectLayer::mouseReleaseEvent(QMouseEvent* e) { if (e->button()==Qt::RightButton) { init(getStatus()-1); } else { en = catchEntity(e); trigger(); } }
void RS_ActionSelectSingle::mouseReleaseEvent(QMouseEvent* e) { if (e->button()==Qt::RightButton) { //need to finish the parent RS_ActionSelect as well, bug#3437138 //need to check actionSelect is set, bug#3437138 if(actionSelect) { actionSelect->requestFinish(false); } init(getStatus()-1); } else { if(entityTypeList.size()) { // std::cout<<"RS_ActionSelectSingle::mouseReleaseEvent(): entityTypeList->size()="<< entityTypeList->size()<<std::endl; en = catchEntity(e, entityTypeList); }else{ en = catchEntity(e); } trigger(); } }
void RS_ActionPolylineAdd::mouseReleaseEvent(QMouseEvent* e) { if (e->button()==Qt::LeftButton) { switch (getStatus()) { case ChooseSegment: addEntity = catchEntity(e); if (addEntity==NULL) { RS_DIALOGFACTORY->commandMessage(tr("No Entity found.")); } else if (addEntity->rtti()!=RS2::EntityPolyline) { RS_DIALOGFACTORY->commandMessage( tr("Entity must be a polyline.")); } else { addEntity->setHighlighted(true); graphicView->drawEntity(addEntity); setStatus(SetAddCoord); ////////////////////////////////////////2006/06/15 graphicView->redraw(RS2::RedrawDrawing); //////////////////////////////////////// } break; case SetAddCoord: addCoord = snapPoint(e); if (addEntity==NULL) { RS_DIALOGFACTORY->commandMessage(tr("No Entity found.")); } else if (!addCoord.valid) { RS_DIALOGFACTORY->commandMessage(tr("Adding point is invalid.")); } else { RS_Vector clickCoord = snapPoint(e); addSegment = NULL; double dist = graphicView->toGraphDX(snapRange)*0.9; addSegment = ((RS_Polyline*)addEntity)->getNearestEntity( clickCoord, &dist, RS2::ResolveNone); if(addSegment == NULL) { RS_DIALOGFACTORY->commandMessage( tr("Adding point is not on entity.")); break; } deleteSnapper(); trigger(); } break; default: break; } } else if (e->button()==Qt::RightButton) { deleteSnapper(); if (addEntity) { addEntity->setHighlighted(false); graphicView->drawEntity(addEntity); ////////////////////////////////////////2006/06/15 graphicView->redraw(RS2::RedrawDrawing); //////////////////////////////////////// } init(getStatus()-1); } }
void RS_ActionDrawEllipseInscribe::mouseReleaseEvent(QMouseEvent* e) { // Proceed to next status if (e->button()==Qt::LeftButton) { if (e==NULL) { return; } RS_Entity* en = catchEntity(e, RS2::EntityLine, RS2::ResolveAll); if(en == NULL) return; if(!(en->isVisible() && en->rtti()== RS2::EntityLine)) return; for(int i=0;i<getStatus();i++) { if(en->getId() == lines[i]->getId()) return; //do not pull in the same line again } if(en->getParent() != NULL) { if ( en->getParent()->rtti() == RS2::EntityInsert /**Insert*/ || en->getParent()->rtti() == RS2::EntitySpline || en->getParent()->rtti() == RS2::EntityText /**< Text 15*/ || en->getParent()->rtti() == RS2::EntityDimAligned /**< Aligned Dimension */ || en->getParent()->rtti() == RS2::EntityDimLinear /**< Linear Dimension */ || en->getParent()->rtti() == RS2::EntityDimRadial /**< Radial Dimension */ || en->getParent()->rtti() == RS2::EntityDimDiametric /**< Diametric Dimension */ || en->getParent()->rtti() == RS2::EntityDimAngular /**< Angular Dimension */ || en->getParent()->rtti() == RS2::EntityDimLeader /**< Leader Dimension */ ){ return; } } lines.resize(getStatus()); lines.push_back(static_cast<RS_Line*>(en)); switch (getStatus()) { case SetLine1: case SetLine2: case SetLine3: en->setHighlighted(true); setStatus(getStatus()+1); graphicView->redraw(RS2::RedrawDrawing); break; case SetLine4: if( preparePreview()) { trigger(); } default: break; } } else if (e->button()==Qt::RightButton) { // Return to last status: if(getStatus()>0){ lines[getStatus()-1]->setHighlighted(false); lines.pop_back(); graphicView->redraw(RS2::RedrawDrawing); deletePreview(); } init(getStatus()-1); } }
void RS_ActionModifyRound::mouseMoveEvent(RS_MouseEvent* e) { RS_DEBUG->print("RS_ActionModifyRound::mouseMoveEvent begin"); RS_Vector mouse = graphicView->toGraph(e->x(), e->y()); RS_Entity* se = catchEntity(e, RS2::ResolveAll); switch (getStatus()) { case SetEntity1: entity1 = se; coord1 = mouse; break; case SetEntity2: entity2 = se; coord2 = mouse; if (entity1!=NULL && entity2!=NULL && entity2->isAtomic() && RS_Information::isTrimmable(entity1, entity2)) { deletePreview(); clearPreview(); //preview->addSelectionFrom(*container); //preview->move(targetPoint-referencePoint); RS_Entity* tmp1 = entity1->clone(); RS_Entity* tmp2 = entity2->clone(); tmp1->reparent(preview); tmp2->reparent(preview); preview->addEntity(tmp1); preview->addEntity(tmp2); bool trim = data.trim; data.trim = false; RS_Modification m(*preview, NULL, false); m.round(coord2, coord1, (RS_AtomicEntity*)tmp1, coord2, (RS_AtomicEntity*)tmp2, data); data.trim = trim; preview->removeEntity(tmp1); preview->removeEntity(tmp2); drawPreview(); } break; default: break; } RS_DEBUG->print("RS_ActionModifyRound::mouseMoveEvent end"); }
RS_Entity* RS_ActionDrawCircleTan1_2P::catchCircle(QMouseEvent* e) { RS_Entity* ret=NULL; RS_Entity* en = catchEntity(e,enTypeList, RS2::ResolveAll); if(en == NULL) return ret; if(en->isVisible()==false) return ret; if(en->getParent() != NULL) { if ( en->getParent()->ignoredOnModification()){ return NULL; } } return en; }
RS_Entity* RS_ActionDrawCircleTan1_2P::catchCircle(QMouseEvent* e) { RS_Entity* ret=nullptr; RS_Entity* en = catchEntity(e,enTypeList, RS2::ResolveAll); if (!en) return ret; if (!en->isVisible()) return ret; if (en->getParent()) { if ( en->getParent()->ignoredOnModification()){ return nullptr; } } return en; }
void RS_ActionPolylineDel::mouseReleaseEvent(QMouseEvent* e) { if (e->button()==Qt::LeftButton) { switch (getStatus()) { case ChooseEntity: delEntity = catchEntity(e); if (delEntity==NULL) { RS_DIALOGFACTORY->commandMessage(tr("No Entity found.")); } else if (delEntity->rtti()!=RS2::EntityPolyline) { RS_DIALOGFACTORY->commandMessage( tr("Entity must be a polyline.")); } else { snapPoint(e); delEntity->setHighlighted(true); graphicView->drawEntity(delEntity); setStatus(SetDelPoint); ////////////////////////////////////////2006/06/15 graphicView->redraw(); //////////////////////////////////////// } break; case SetDelPoint: delPoint = snapPoint(e); if (delEntity==NULL) { RS_DIALOGFACTORY->commandMessage(tr("No Entity found.")); } else if (!delPoint.valid) { RS_DIALOGFACTORY->commandMessage(tr("Deleting point is invalid.")); } else if (!delEntity->isPointOnEntity(delPoint)) { RS_DIALOGFACTORY->commandMessage( tr("Deleting point is not on entity.")); } else { deleteSnapper(); trigger(); } break; default: break; } } else if (e->button()==Qt::RightButton) { deleteSnapper(); if (delEntity) { delEntity->setHighlighted(false); graphicView->drawEntity(delEntity); ////////////////////////////////////////2006/06/15 graphicView->redraw(); //////////////////////////////////////// } init(getStatus()-1); } }
RS_Entity* RS_ActionDrawCircleTan2_1P::catchCircle(QMouseEvent* e) { RS_Entity* ret=NULL; RS_Entity* en = catchEntity(e,enTypeList, RS2::ResolveAll); if(en == NULL) return ret; if(en->isVisible()==false) return ret; for(auto p: circles){ if(p && en->getId() == p->getId()) return ret; //do not pull in the same line again } if(en->getParent() && en->getParent()->ignoredOnModification()){ return nullptr; } return en; }
void RS_ActionDrawLineRelAngle::mouseMoveEvent(QMouseEvent* e) { RS_DEBUG->print("RS_ActionDrawLineRelAngle::mouseMoveEvent begin"); RS_Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y())); switch (getStatus()) { case SetEntity: entity = catchEntity(e, RS2::ResolveAll); break; case SetPos: { //length = graphicView->toGraphDX(graphicView->getWidth()); //RS_Vector mouse = snapPoint(e); pos = snapPoint(e); /*RS_Creation creation(NULL, NULL); RS_Line* l = creation.createLineRelAngle(mouse, entity, angle, length);*/ deletePreview(); RS_Creation creation(preview, NULL, false); creation.createLineRelAngle(pos, entity, angle, length); drawPreview(); /*if (l!=NULL) { if (line!=NULL) { delete line; } line = (RS_Line*)l->clone(); deletePreview(); preview->addEntity(l); drawPreview(); }*/ } break; default: break; } RS_DEBUG->print("RS_ActionDrawLineRelAngle::mouseMoveEvent end"); }
RS_Entity* RS_ActionDrawCircleTan2::catchCircle(QMouseEvent* e) { RS_Entity* en = catchEntity(e,enTypeList, RS2::ResolveAll); if(en == nullptr) return nullptr; if(en->isVisible()==false) return nullptr; for(int i=0;i<getStatus();i++) { if(en->getId() == circles[i]->getId()) return nullptr; //do not pull in the same line again } if(en->getParent()) { if ( en->getParent()->ignoredOnModification()){ return nullptr; } } return en; }
void RS_ActionDrawLineOrthTan::mouseReleaseEvent(QMouseEvent* e) { if (e->button()==Qt::RightButton) { if( normal != NULL) { normal->setHighlighted(false); graphicView->drawEntity(normal); } if (tangent != NULL) { delete tangent; tangent=NULL; } deletePreview(); if (getStatus() == SetLine) { finish(false); }else{ init(getStatus()-1); } } else { switch (getStatus()) { case SetLine: { RS_Entity* en=catchEntity(e,RS2::EntityLine); if(en != NULL){ if (en->getLength() < RS_TOLERANCE) { //ignore lines not long enough break; } if(normal != NULL) { normal->setHighlighted(false); graphicView->drawEntity(normal); } normal=static_cast<RS_Line*>(en); normal->setHighlighted(true); graphicView->drawEntity(normal); setStatus(SetCircle); } } break; case SetCircle: if(tangent!=NULL){ trigger(); } break; default: break; } } }
void RS_ActionDrawCircleInscribe::mouseReleaseEvent(QMouseEvent* e) { // Proceed to next status if (e->button()==Qt::LeftButton) { if (!e) { return; } RS_Entity* en = catchEntity(e, RS2::EntityLine, RS2::ResolveAll); if(!en) return; if(!(en->isVisible() && en->rtti()== RS2::EntityLine)) return; for(int i=0;i<getStatus();i++) { if(en->getId() == lines[i]->getId()) return; //do not pull in the same line again } if(en->getParent()) { if ( en->getParent()->ignoredOnModification()) return; } while((int) lines.size()>getStatus()){ lines.back()->setHighlighted(false); graphicView->drawEntity(lines.back()); lines.pop_back(); } lines.push_back(static_cast<RS_Line*>(en)); pPoints->coord= graphicView->toGraph(e->x(), e->y()); switch (getStatus()) { case SetLine1: case SetLine2: en->setHighlighted(true); setStatus(getStatus()+1); graphicView->redraw(RS2::RedrawDrawing); break; case SetLine3: if( preparePreview()) { trigger(); } default: break; } } else if (e->button()==Qt::RightButton) { // Return to last status: if(getStatus()>0){ clearLines(true); lines.back()->setHighlighted(false); lines.pop_back(); graphicView->redraw(RS2::RedrawDrawing); deletePreview(); } init(getStatus()-1); } }
void RS_ActionDrawLineBisector::mouseMoveEvent(QMouseEvent* e) { RS_DEBUG->print("RS_ActionDrawLineBisector::mouseMoveEvent begin"); RS_Vector mouse = RS_Vector(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y())); switch (getStatus()) { case SetLine1: break; case SetLine2: { coord2 = mouse; RS_Entity* en = catchEntity(e, RS2::ResolveAll); if(en==line1) break; if (en && en->rtti()==RS2::EntityLine) { if(line2 && line2->isHighlighted()){ line2->setHighlighted(false); } line2 = static_cast<RS_Line*>(en); line2->setHighlighted(true); graphicView->redraw(RS2::RedrawDrawing); deletePreview(); RS_Creation creation(preview.get(), nullptr, false); creation.createBisector(coord1, coord2, length, number, line1, line2); drawPreview(); }else{ if(line2 && line2->isHighlighted()){ line2->setHighlighted(false); graphicView->redraw(RS2::RedrawDrawing); } line2=nullptr; } } break; default: break; } RS_DEBUG->print("RS_ActionDrawLineBisector::mouseMoveEvent end"); }
void RS_ActionPolylineAppend::mouseReleaseEvent(QMouseEvent* e) { if (e->button()==Qt::LeftButton) { if (getStatus()==SetStartpoint) { originalPolyline = dynamic_cast<RS_Polyline*>(catchEntity(e)); if (!originalPolyline) { RS_DIALOGFACTORY->commandMessage(tr("No Entity found.")); return; } else if (originalPolyline->rtti()!=RS2::EntityPolyline) { RS_DIALOGFACTORY->commandMessage( tr("Entity must be a polyline.")); return; } else if (originalPolyline->isClosed()) { RS_DIALOGFACTORY->commandMessage( tr("Can not append nodes in a closed polyline.")); return; } else { snapPoint(e); RS_Polyline* op=static_cast<RS_Polyline*>(originalPolyline); RS_Entity* entFirst = op->firstEntity(); RS_Entity* entLast = op->lastEntity(); double dist = graphicView->toGraphDX(snapRange)*0.9; RS_Entity* nearestSegment = originalPolyline->getNearestEntity( RS_Vector(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y())), &dist, RS2::ResolveNone); polyline = static_cast<RS_Polyline*>(originalPolyline->clone()); container->addEntity(polyline); prepend = false; if (nearestSegment == entFirst){ prepend = true; point = originalPolyline->getStartpoint(); }else if (nearestSegment == entLast){ point = originalPolyline->getEndpoint(); }else{ RS_DIALOGFACTORY->commandMessage( tr("Click somewhere near the beginning or end of existing polyline.")); } } } RS_CoordinateEvent ce(snapPoint(e)); coordinateEvent(&ce); } else if (e->button()==Qt::RightButton) { if (getStatus()==SetNextPoint) { trigger(); } // deletePreview(); //clearPreview(); deleteSnapper(); init(getStatus()-1); } }
void RS_ActionPolylineSegment::mouseReleaseEvent(QMouseEvent* e) { if (e->button()==Qt::LeftButton) { switch (getStatus()) { case ChooseEntity: targetEntity = catchEntity(e); if (targetEntity==NULL) { RS_DIALOGFACTORY->commandMessage(tr("No Entity found.")); } else if (targetEntity->rtti()!=RS2::EntityLine && targetEntity->rtti()!=RS2::EntityArc && targetEntity->rtti()!=RS2::EntityPolyline) { RS_DIALOGFACTORY->commandMessage( tr("Entity must be a line, arc or polyline.")); } else if (targetEntity->rtti()==RS2::EntityPolyline && ((RS_Polyline*)targetEntity)->isClosed()){ RS_DIALOGFACTORY->commandMessage( tr("Entity can not be a closed polyline.")); } else { targetEntity->setHighlighted(true); graphicView->drawEntity(targetEntity); // setStatus(SetReferencePoint); ////////////////////////////////////////2006/06/15 graphicView->redraw(); //////////////////////////////////////// trigger(); } break; default: break; } } else if (e->button()==Qt::RightButton) { deleteSnapper(); if (targetEntity!=NULL) { targetEntity->setHighlighted(false); graphicView->drawEntity(targetEntity); ////////////////////////////////////////2006/06/15 graphicView->redraw(); //////////////////////////////////////// } init(getStatus()-1); } /* if (e->button())==Qt::LeftButton) { RS_CoordinateEvent ce(snapPoint(e)); coordinateEvent(&ce); } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) { deletePreview(); deleteSnapper init(getStatus()-1); } */ }
void RS_ActionPolylineEquidistant::mouseReleaseEvent(QMouseEvent* e) { if (e->button()==Qt::LeftButton) { switch (getStatus()) { case ChooseEntity: originalEntity = catchEntity(e); if (originalEntity==NULL) { RS_DIALOGFACTORY->commandMessage(tr("No Entity found.")); } else if (originalEntity->rtti()!=RS2::EntityPolyline) { RS_DIALOGFACTORY->commandMessage( tr("Entity must be a polyline.")); } else { targetPoint = snapFree(e); originalEntity->setHighlighted(true); graphicView->drawEntity(originalEntity); double d = graphicView->toGraphDX(snapRange)*0.9; RS_Entity* Segment = ((RS_Polyline*)originalEntity)->getNearestEntity( targetPoint, &d, RS2::ResolveNone); if (Segment->rtti() == RS2::EntityLine) { double ang = ((RS_Line*)Segment)->getAngle1(); double ang1 = ((RS_Line*)Segment)->getStartpoint().angleTo(RS_Vector(targetPoint)); if( ang > ang1 || ang + M_PI < ang1 ) bRightSide = true; } else { RS_Vector cen = ((RS_Arc*)Segment)->getCenter(); if (cen.distanceTo(targetPoint) > ((RS_Arc*)Segment)->getRadius() && ((RS_Arc*)Segment)->getBulge() > 0 ) bRightSide = true; } ////////////////////////////////////////2006/06/15 graphicView->redraw(); //////////////////////////////////////// trigger(); } break; default: break; } } else if (e->button()==Qt::RightButton) { deleteSnapper(); if (originalEntity!=NULL) { originalEntity->setHighlighted(false); graphicView->drawEntity(originalEntity); ////////////////////////////////////////2006/06/15 graphicView->redraw(); //////////////////////////////////////// } init(getStatus()-1); } }
void RS_ActionModifyCut::mouseReleaseEvent(RS_MouseEvent* e) { if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) { switch (getStatus()) { case ChooseCutEntity: cutEntity = catchEntity(e); if (cutEntity==NULL) { RS_DIALOGFACTORY->commandMessage(tr("No Entity found.")); } else if (cutEntity->rtti()!=RS2::EntityLine && cutEntity->rtti()!=RS2::EntityArc && cutEntity->rtti()!=RS2::EntityCircle && cutEntity->rtti()!=RS2::EntityEllipse) { RS_DIALOGFACTORY->commandMessage( tr("Entity must be a line, arc, circle or ellipse.")); } else { cutEntity->setHighlighted(true); graphicView->drawEntity(cutEntity); setStatus(SetCutCoord); } break; case SetCutCoord: cutCoord = snapPoint(e); if (cutEntity==NULL) { RS_DIALOGFACTORY->commandMessage(tr("No Entity found.")); } else if (!cutCoord.valid) { RS_DIALOGFACTORY->commandMessage(tr("Cutting point is invalid.")); } else if (!cutEntity->isPointOnEntity(cutCoord)) { RS_DIALOGFACTORY->commandMessage( tr("Cutting point is not on entity.")); } else { deleteSnapper(); trigger(); } break; default: break; } } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) { deleteSnapper(); if (cutEntity!=NULL) { cutEntity->setHighlighted(false); graphicView->drawEntity(cutEntity); } init(getStatus()-1); } }
void RS_ActionSnapIntersectionManual::mouseMoveEvent(QMouseEvent* e) { RS_DEBUG->print("RS_ActionSnapIntersectionManual::mouseMoveEvent begin"); RS_Entity* se = catchEntity(e); RS_Vector mouse = graphicView->toGraph(e->x(), e->y()); switch (getStatus()) { case ChooseEntity1: entity1 = se; break; case ChooseEntity2: { entity2 = se; coord = mouse; RS_VectorSolutions sol = RS_Information::getIntersection(entity1, entity2, false); //for (int i=0; i<sol.getNumber(); i++) { // ip = sol.get(i); // break; //} RS_Vector ip = sol.getClosest(coord); if (ip.valid) { deletePreview(); preview->addEntity( new RS_Circle(preview.get(), RS_CircleData( ip, graphicView->toGraphDX(4)))); drawPreview(); RS_DIALOGFACTORY->updateCoordinateWidget(ip, ip - graphicView->getRelativeZero()); } } break; default: break; } RS_DEBUG->print("RS_ActionSnapIntersectionManual::mouseMoveEvent end"); }
void RS_ActionDimDiametric::mouseReleaseEvent(RS_MouseEvent* e) { if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) { switch (getStatus()) { case SetEntity: { RS_Entity* en = catchEntity(e, RS2::ResolveAll); if (en!=NULL) { if (en->rtti()==RS2::EntityArc || en->rtti()==RS2::EntityCircle) { entity = en; RS_Vector center; if (entity->rtti()==RS2::EntityArc) { center = ((RS_Arc*)entity)->getCenter(); } else if (entity->rtti()==RS2::EntityCircle) { center = ((RS_Circle*)entity)->getCenter(); } graphicView->moveRelativeZero(center); setStatus(SetPos); } else { RS_DIALOGFACTORY->commandMessage(tr("Not a circle " "or arc entity")); } } } break; case SetPos: { RS_CoordinateEvent ce(snapPoint(e)); coordinateEvent(&ce); } break; default: break; } } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) { deletePreview(); init(getStatus()-1); } }
void RS_ActionDimRadial::mouseReleaseEvent(QMouseEvent* e) { if (e->button()==Qt::LeftButton) { switch (getStatus()) { case SetEntity: { RS_Entity* en = catchEntity(e, RS2::ResolveAll); if (en) { if (en->rtti()==RS2::EntityArc || en->rtti()==RS2::EntityCircle) { entity = en; if (entity->rtti()==RS2::EntityArc) { data->definitionPoint = static_cast<RS_Arc*>(entity)->getCenter(); } else if (entity->rtti()==RS2::EntityCircle) { data->definitionPoint = static_cast<RS_Circle*>(entity)->getCenter(); } graphicView->moveRelativeZero(data->definitionPoint); setStatus(SetPos); } else { RS_DIALOGFACTORY->commandMessage(tr("Not a circle " "or arc entity")); } } } break; case SetPos: { RS_CoordinateEvent ce(snapPoint(e)); coordinateEvent(&ce); } break; default: break; } } else if (e->button()==Qt::RightButton) { deletePreview(); init(getStatus()-1); } }
void RS_ActionDrawArcTangential::mouseReleaseEvent(QMouseEvent* e) { if (e->button()==Qt::LeftButton) { switch (getStatus()) { // set base entity: case SetBaseEntity: { RS_Vector coord = graphicView->toGraph(e->x(), e->y()); RS_Entity* entity = catchEntity(coord, RS2::ResolveAll); if (entity!=NULL) { if (entity->isAtomic()) { baseEntity = (RS_AtomicEntity*)entity; if (baseEntity->getStartpoint().distanceTo(coord) < baseEntity->getEndpoint().distanceTo(coord)) { isStartPoint = true; } else { isStartPoint = false; } setStatus(SetEndAngle); updateMouseButtonHints(); } else { // TODO: warning } } else { } } break; // set angle (point that defines the angle) case SetEndAngle: { RS_CoordinateEvent ce(snapPoint(e)); coordinateEvent(&ce); } break; } } else if (e->button()==Qt::RightButton) { deletePreview(); init(getStatus()-1); } }
void RS_ActionDrawLineParallelThrough::mouseMoveEvent(QMouseEvent* e) { RS_DEBUG->print("RS_ActionDrawLineParallelThrough::mouseMoveEvent begin"); switch (getStatus()) { case SetEntity: { entity = catchEntity(e, RS2::ResolveAll); /*deletePreview(); RS_Creation creation(preview, NULL, false); creation.createParallelThrough(coord, number, entity); drawPreview();*/ } break; case SetPos: { coord = snapPoint(e); //RS_Vector(graphicView->toGraphX(e->x()), // graphicView->toGraphY(e->y())); deletePreview(); RS_Creation creation(preview, NULL, false); creation.createParallelThrough(coord, number, entity); drawPreview(); } break; default: break; } RS_DEBUG->print("RS_ActionDrawLineParallelThrough::mouseMoveEvent end"); }
void RS_ActionDrawCircleInscribe::mouseMoveEvent(QMouseEvent* e) { RS_DEBUG->print("RS_ActionDrawCircle4Line::mouseMoveEvent begin"); if(getStatus() == SetLine3) { RS_Entity* en = catchEntity(e, RS2::EntityLine, RS2::ResolveAll); if(en == NULL) return; if(!(en->isVisible() && en->rtti()== RS2::EntityLine)) return; for(int i=0;i<getStatus();i++) { if(en->getId() == lines[i]->getId()) return; //do not pull in the same line again } if(en->getParent() != NULL) { if ( en->getParent()->rtti() == RS2::EntityInsert /**Insert*/ || en->getParent()->rtti() == RS2::EntitySpline || en->getParent()->rtti() == RS2::EntityText /**< Text 15*/ || en->getParent()->rtti() == RS2::EntityDimAligned /**< Aligned Dimension */ || en->getParent()->rtti() == RS2::EntityDimLinear /**< Linear Dimension */ || en->getParent()->rtti() == RS2::EntityDimRadial /**< Radial Dimension */ || en->getParent()->rtti() == RS2::EntityDimDiametric /**< Diametric Dimension */ || en->getParent()->rtti() == RS2::EntityDimAngular /**< Angular Dimension */ || en->getParent()->rtti() == RS2::EntityDimLeader /**< Leader Dimension */ ){ return; } } coord= graphicView->toGraph(e->x(), e->y()); lines.resize(getStatus()); lines.push_back(static_cast<RS_Line*>(en)); // lines[getStatus()]=static_cast<RS_Line*>(en); if(preparePreview()) { deletePreview(); RS_Circle* e=new RS_Circle(preview, cData); preview->addEntity(e); drawPreview(); } } RS_DEBUG->print("RS_ActionDrawCircle4Line::mouseMoveEvent end"); }