void LC_ActionDrawSplinePoints::coordinateEvent(RS_CoordinateEvent* e) { if(e == NULL) return; RS_Vector mouse = e->getCoordinate(); switch (getStatus()) { case SetStartPoint: undoBuffer.clear(); if(spline == NULL) { spline = new LC_SplinePoints(container, data); spline->addPoint(mouse); preview->addEntity(new RS_Point(preview, RS_PointData(mouse))); } setStatus(SetNextPoint); graphicView->moveRelativeZero(mouse); updateMouseButtonHints(); break; case SetNextPoint: graphicView->moveRelativeZero(mouse); if(spline != NULL) { spline->addPoint(mouse); drawPreview(); drawSnapper(); } updateMouseButtonHints(); break; default: break; } }
void RS_ActionDrawPolyline::coordinateEvent(RS_CoordinateEvent* e) { if (e==NULL) { return; } RS_Vector mouse = e->getCoordinate(); double bulge=solveBulge(mouse); if (calculatedSegment) mouse=calculatedEndpoint; switch (getStatus()) { case SetStartpoint: // data.startpoint = mouse; //printf ("SetStartpoint\n"); point = mouse; history.clear(); history.append(mouse); bHistory.clear(); bHistory.append(0.0); start = point; setStatus(SetNextPoint); graphicView->moveRelativeZero(mouse); updateMouseButtonHints(); break; case SetNextPoint: graphicView->moveRelativeZero(mouse); point = mouse; history.append(mouse); bHistory.append(bulge); if (polyline==NULL) { //printf("polyline==NULL\n"); polyline = new RS_Polyline(container, *data); polyline->addVertex(start, 0.0); } if (polyline) { polyline->setNextBulge(bulge); polyline->addVertex(mouse, 0.0); polyline->setEndpoint(mouse); if (polyline->count()==1) { polyline->setLayerToActive(); polyline->setPenToActive(); container->addEntity(polyline); } deletePreview(); // clearPreview(); deleteSnapper(); graphicView->drawEntity(polyline); drawSnapper(); } //trigger(); //data.startpoint = data.endpoint; updateMouseButtonHints(); //graphicView->moveRelativeZero(mouse); break; default: break; } }
void RS_ActionDrawPolyline::commandEvent(RS_CommandEvent* e) { QString c = e->getCommand().toLower(); switch (getStatus()) { case SetStartpoint: if (checkCommand("help", c)) { RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")); return; } break; case SetNextPoint: if (checkCommand("close", c)) { close(); e->accept(); updateMouseButtonHints(); return; } if (checkCommand("undo", c)) { undo(); e->accept(); updateMouseButtonHints(); return; } break; default: break; } }
void RS_ActionDrawSpline::coordinateEvent(RS_CoordinateEvent* e) { if (e==NULL) { return; } RS_Vector mouse = e->getCoordinate(); switch (getStatus()) { case SetStartpoint: //data.startpoint = mouse; //point = mouse; history.clear(); history.append(mouse); if (spline==NULL) { spline = new RS_Spline(container, data); spline->addControlPoint(mouse); } //bHistory.clear(); //bHistory.append(new double(0.0)); //start = mouse; setStatus(SetNextPoint); graphicView->moveRelativeZero(mouse); updateMouseButtonHints(); break; case SetNextPoint: graphicView->moveRelativeZero(mouse); //point = mouse; history.append(mouse); //bHistory.append(new double(0.0)); if (spline!=NULL) { //graphicView->deleteEntity(spline); spline->addControlPoint(mouse); //spline->setEndpoint(mouse); //if (spline->count()==1) { //spline->setLayerToActive(); //spline->setPenToActive(); //container->addEntity(spline); //} deletePreview(); //graphicView->drawEntity(spline); drawSnapper(); } //trigger(); //data.startpoint = data.endpoint; updateMouseButtonHints(); //graphicView->moveRelativeZero(mouse); break; default: break; } }
void RS_ActionPolylineAppend::coordinateEvent(RS_CoordinateEvent* e) { if (!e) { return; } RS_Vector mouse = e->getCoordinate(); switch (getStatus()) { case SetStartpoint: history.clear(); history.append(point); bHistory.clear(); bHistory.append(0.0); start = point; setStatus(SetNextPoint); graphicView->moveRelativeZero(point); updateMouseButtonHints(); break; case SetNextPoint: graphicView->moveRelativeZero(mouse); point = mouse; history.append(mouse); bHistory.append(0.0); if (!polyline) { polyline = new RS_Polyline(container, *data); polyline->addVertex(start, 0.0, prepend); } if (polyline) { polyline->addVertex(mouse, 0.0, prepend); // polyline->setEndpoint(mouse); if (polyline->count()==1) { polyline->setLayerToActive(); polyline->setPenToActive(); } // RVT_PORT (can be deleted) deletePreview(); //clearPreview(); deleteSnapper(); graphicView->drawEntity(polyline); drawSnapper(); } //trigger(); //data.startpoint = data.endpoint; updateMouseButtonHints(); //graphicView->moveRelativeZero(mouse); break; default: break; } }
void RS_ActionBlocksCreate::trigger() { if (graphic!=nullptr) { RS_BlockList* blockList = graphic->getBlockList(); if (blockList!=nullptr) { RS_BlockData d = RS_DIALOGFACTORY->requestNewBlockDialog(blockList); if (!d.name.isEmpty()) { RS_Creation creation(container, graphicView); creation.createBlock(&d, referencePoint, true); RS_InsertData id( d.name, referencePoint, RS_Vector(1.0,1.0), 0.0, 1, 1, RS_Vector(0.0,0.0) ); creation.createInsert(&id); } } } graphicView->redraw(RS2::RedrawDrawing); setStatus(getStatus()+1); // clear mouse button hints updateMouseButtonHints(); // if(RS_DIALOGFACTORY!=nullptr){ // RS_DIALOGFACTORY->requestPreviousToolBar(); // } graphicView->killSelectActions(); finish(false); }
void RS_ActionSetRelativeZero::coordinateEvent(RS_CoordinateEvent* e) { if (e==nullptr) return; *pt = e->getCoordinate(); trigger(); updateMouseButtonHints(); }
/** * Sets the current status (progress) of this action. * The default implementation sets the class variable 'status' to the * given value and finishes the action if 'status' is negative. * * @param status Status number. It's up to the action implementor * what the action uses the status for. However, a * negative status number finishes the action. Usually * the status of an action increases for every step * of progress and decreases when the user goes one * step back (i.e. presses the right mouse button). */ void RS_ActionInterface::setStatus(int status) { this->status = status; updateMouseButtonHints(); updateToolBar(); updateMouseCursor(); if(status<0) finish(); }
void RS_ActionDrawLineParallel::showOptions() { RS_ActionInterface::showOptions(); if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->requestOptions(this, true); } updateMouseButtonHints(); }
void RS_ActionDrawArcTangential::showOptions() { RS_ActionInterface::showOptions(); if (RS_DIALOGFACTORY!=NULL) { RS_DIALOGFACTORY->requestOptions(this, true); } updateMouseButtonHints(); }
/** * Called to initiate an action. This funtcion is often * overwritten by the implementing action. * * @param status The status on which to initiate this action. * default is 0 to begin the action. */ void RS_ActionInterface::init(int status) { RS_Snapper::init(); setStatus(status); if (status>=0) { //graphicView->setMouseCursor(cursor); updateMouseButtonHints(); updateMouseCursor(); updateToolBar(); }else{ //delete snapper when finished, bug#3416878 deleteSnapper(); } }
void RS_ActionDrawLine::coordinateEvent(RS_CoordinateEvent* e) { RS_DEBUG->print("RS_ActionDrawLine::coordinateEvent"); if (e==NULL) { RS_DEBUG->print("RS_ActionDrawLine::coordinateEvent: event was NULL"); return; } RS_Vector mouse = e->getCoordinate(); if(pPoints->data.startpoint.valid == false && getStatus()==SetEndpoint) setStatus(SetStartpoint); switch (getStatus()) { case SetStartpoint: pPoints->data.startpoint = mouse; addHistory(mouse); pPoints->start = pPoints->data.startpoint; setStatus(SetEndpoint); graphicView->moveRelativeZero(mouse); updateMouseButtonHints(); break; case SetEndpoint: if((mouse-pPoints->data.startpoint).squared() > RS_TOLERANCE2) { //refuse zero length lines pPoints->data.endpoint = mouse; addHistory(mouse); trigger(); pPoints->data.startpoint = pPoints->data.endpoint; if(pPoints->history.size()>=2) updateMouseButtonHints(); } //graphicView->moveRelativeZero(mouse); break; default: break; } RS_DEBUG->print("RS_ActionDrawLine::coordinateEvent: OK"); }
void RS_ActionDrawLine::commandEvent(RS_CommandEvent* e) { RS_DEBUG->print("RS_ActionDrawLine::commandEvent"); QString c = e->getCommand().toLower(); switch (getStatus()) { case SetStartpoint: if (checkCommand("help", c)) { RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")); return; } break; case SetEndpoint: if (checkCommand("close", c)) { close(); updateMouseButtonHints(); return; } if (checkCommand("undo", c)) { undo(); updateMouseButtonHints(); return; } break; default: break; } if (checkCommand("redo", c)) { redo(); updateMouseButtonHints(); return; } // RS_DEBUG->print("RS_ActionDrawLine::commandEvent: OK"); }
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_ActionBlocksCreate::trigger() { //deletePreview(); //RS_Modification m(*container, graphicView); //m.paste(data.insertionPoint); //std::cout << *RS_Clipboard::instance(); if (graphic!=NULL) { RS_BlockList* blockList = graphic->getBlockList(); if (blockList!=NULL) { RS_BlockData d = RS_DIALOGFACTORY->requestNewBlockDialog(blockList); if (!d.name.isEmpty()) { RS_Creation creation(container, graphicView); creation.createBlock(d, referencePoint, true); RS_InsertData id( d.name, referencePoint, RS_Vector(1.0,1.0), 0.0, 1, 1, RS_Vector(0.0,0.0) ); creation.createInsert(id); } } } graphicView->redraw(RS2::RedrawDrawing); setStatus(getStatus()+1); // clear mouse button hints updateMouseButtonHints(); finish(); graphicView->killSelectActions(); }
void RS_ActionDrawLineParallel::commandEvent(RS_CommandEvent* e) { QString c = e->getCommand().toLower(); if (checkCommand("help", c)) { if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")); } return; } switch (getStatus()) { case SetEntity: { if (checkCommand("through", c)) { finish(false); graphicView->setCurrentAction( new RS_ActionDrawLineParallelThrough(*container, *graphicView)); } else if (checkCommand("number", c)) { deletePreview(); setStatus(SetNumber); } else { bool ok; double d = RS_Math::eval(c, &ok); if(ok) e->accept(); if (ok && d>1.0e-10) { distance = d; } else { if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression")); } } if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->requestOptions(this, true, true); } updateMouseButtonHints(); //setStatus(SetEntity); } } break; case SetNumber: { bool ok; int n = c.toInt(&ok); if (ok) { e->accept(); if (n>0 && n<100) { number = n; } else { if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->commandMessage(tr("Not a valid number. " "Try 1..99")); } } } else { if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression")); } } if (RS_DIALOGFACTORY) { RS_DIALOGFACTORY->requestOptions(this, true, true); } setStatus(SetEntity); } break; default: break; } }
/** * Resumes an action after it was suspended. */ void RS_ActionInterface::resume() { updateMouseCursor(); updateToolBar(); updateMouseButtonHints(); RS_Snapper::resume(); }
void QC_ActionGetPoint::trigger() { RS_DEBUG->print("QC_ActionGetPoint::trigger()"); completed = true; updateMouseButtonHints(); }