Skip to content

Commit

Permalink
polyline: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dxli committed Jan 3, 2016
1 parent 631424d commit 6713e7d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 43 deletions.
9 changes: 0 additions & 9 deletions librecad/src/actions/rs_actioneditcopy.cpp
Expand Up @@ -48,8 +48,6 @@ RS_ActionEditCopy::RS_ActionEditCopy(bool copy,
{
}



RS_ActionEditCopy::~RS_ActionEditCopy() = default;


Expand All @@ -72,13 +70,6 @@ void RS_ActionEditCopy::trigger() {
RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected(),container->totalSelectedLength());
}


void RS_ActionEditCopy::mouseMoveEvent(QMouseEvent* e) {
snapPoint(e);
}



void RS_ActionEditCopy::mouseReleaseEvent(QMouseEvent* e) {
if (e->button()==Qt::LeftButton) {
RS_CoordinateEvent ce(snapPoint(e));
Expand Down
1 change: 0 additions & 1 deletion librecad/src/actions/rs_actioneditcopy.h
Expand Up @@ -55,7 +55,6 @@ class RS_ActionEditCopy : public RS_ActionInterface {

virtual void trigger();

virtual void mouseMoveEvent(QMouseEvent* e);
virtual void mouseReleaseEvent(QMouseEvent* e);

virtual void coordinateEvent(RS_CoordinateEvent* e);
Expand Down
41 changes: 12 additions & 29 deletions librecad/src/actions/rs_actionpolylinesegment.cpp
Expand Up @@ -35,7 +35,10 @@
#include "rs_polyline.h"
#include "rs_debug.h"


namespace {
std::initializer_list<RS2::EntityType>
entityType{RS2::EntityLine, RS2::EntityPolyline, RS2::EntityArc};
}

RS_ActionPolylineSegment::RS_ActionPolylineSegment(RS_EntityContainer& container,
RS_GraphicView& graphicView)
Expand All @@ -46,7 +49,7 @@ RS_ActionPolylineSegment::RS_ActionPolylineSegment(RS_EntityContainer& container

void RS_ActionPolylineSegment::init(int status) {
RS_ActionInterface::init(status);
targetEntity = NULL;
targetEntity = nullptr;
}

/**
Expand Down Expand Up @@ -240,7 +243,7 @@ void RS_ActionPolylineSegment::trigger() {
// container->optimizeContours();
convertPolyline(targetEntity);

targetEntity = NULL;
targetEntity = nullptr;
setStatus(ChooseEntity);

RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected(),container->totalSelectedLength());
Expand All @@ -250,42 +253,22 @@ void RS_ActionPolylineSegment::trigger() {
////////////////////////////////////////
}



void RS_ActionPolylineSegment::mouseMoveEvent(QMouseEvent* e) {
RS_DEBUG->print("RS_ActionPolylineSegment::mouseMoveEvent begin");

switch (getStatus()) {
case ChooseEntity:
snapPoint(e);
break;
default:
break;
}


RS_DEBUG->print("RS_ActionPolylineSegment::mouseMoveEvent end");
}



void RS_ActionPolylineSegment::mouseReleaseEvent(QMouseEvent* e) {
if (e->button()==Qt::LeftButton) {
switch (getStatus()) {
case ChooseEntity:
targetEntity = catchEntity(e);
if (targetEntity==NULL) {
targetEntity = catchEntity(e, entityType);

if (targetEntity==nullptr) {
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()){
} else if (targetEntity->rtti()==RS2::EntityPolyline && ((RS_Polyline*)targetEntity)->isClosed()){
RS_DIALOGFACTORY->commandMessage(
tr("Entity can not be a closed polyline."));
} else {
//TODO, verify topology of selected
targetEntity->setHighlighted(true);
graphicView->drawEntity(targetEntity);

// setStatus(SetReferencePoint);
////////////////////////////////////////2006/06/15
graphicView->redraw();
Expand Down
5 changes: 1 addition & 4 deletions librecad/src/actions/rs_actionpolylinesegment.h
Expand Up @@ -37,24 +37,21 @@ class RS_Polyline;
*/
class RS_ActionPolylineSegment : public RS_PreviewActionInterface {
Q_OBJECT
public:
/**
* Action States.
*/
enum Status {
ChooseEntity /**< Choosing one of the polyline segments. */
ChooseEntity = 0 /**< Choosing one of the polyline segments. */
};

public:
RS_ActionPolylineSegment(RS_EntityContainer& container,
RS_GraphicView& graphicView);
~RS_ActionPolylineSegment()=default;

virtual void init(int status=0);

virtual void trigger();

virtual void mouseMoveEvent(QMouseEvent* e);
virtual void mouseReleaseEvent(QMouseEvent* e);

virtual void updateMouseButtonHints();
Expand Down

0 comments on commit 6713e7d

Please sign in to comment.