Skip to content

Commit

Permalink
gui Path improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
redteam316 committed Jan 15, 2014
1 parent 9d6c757 commit 6c1b80c
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 2 deletions.
37 changes: 36 additions & 1 deletion embroidermodder2/mdiwindow.cpp
Expand Up @@ -4,6 +4,7 @@
#include "statusbar-button.h"
#include "object-save.h"
#include "object-data.h"
#include "object-path.h"
#include "object-polygon.h"
#include "object-polyline.h"

Expand Down Expand Up @@ -134,7 +135,7 @@ bool MDIWindow::loadFile(const QString &fileName)

if(readSuccessful)
{
//moveStitchListToPolyline(p); //TODO: Test more
embPattern_moveStitchListToPolylines(p); //TODO: Test more
int stitchCount = embStitchList_count(p->stitchList);
QPainterPath path;

Expand Down Expand Up @@ -171,6 +172,40 @@ bool MDIWindow::loadFile(const QString &fileName)
curLineObj = curLineObj->next;
}
}
if(p->pathObjList)
{
//TODO: This is unfinished. It needs more work
EmbPathObjectList* curPathObjList = p->pathObjList;
while(curPathObjList)
{
QPainterPath pathPath;
EmbPointList* curPointList = curPathObjList->pathObj->pointList;
EmbColor thisColor = curPathObjList->pathObj->color;
if(curPointList)
{
EmbPoint pp = curPointList->point;
pathPath.moveTo(embPoint_x(pp), -embPoint_y(pp)); //NOTE: Qt Y+ is down and libembroidery Y+ is up, so inverting the Y is needed.
curPointList = curPointList->next;
}
while(curPointList)
{
EmbPoint pp = curPointList->point;
pathPath.lineTo(embPoint_x(pp), -embPoint_y(pp)); //NOTE: Qt Y+ is down and libembroidery Y+ is up, so inverting the Y is needed.
curPointList = curPointList->next;
}

QPen loadPen(qRgb(thisColor.r, thisColor.g, thisColor.b));
loadPen.setWidthF(0.35);
loadPen.setCapStyle(Qt::RoundCap);
loadPen.setJoinStyle(Qt::RoundJoin);

PathObject* obj = new PathObject(0,0, pathPath, loadPen.color().rgb());
obj->setObjectRubberMode(OBJ_RUBBER_OFF);
gscene->addItem(obj);

curPathObjList = curPathObjList->next;
}
}
if(p->pointObjList)
{
EmbPointObjectList* curPointObj = p->pointObjList;
Expand Down
68 changes: 68 additions & 0 deletions embroidermodder2/property-editor.cpp
Expand Up @@ -78,6 +78,8 @@ PropertyEditor::PropertyEditor(const QString& iconDirectory, bool pickAddMode, Q
vboxLayoutProperties->addWidget(createGroupBoxMiscImage());
vboxLayoutProperties->addWidget(createGroupBoxGeometryInfiniteLine());
vboxLayoutProperties->addWidget(createGroupBoxGeometryLine());
vboxLayoutProperties->addWidget(createGroupBoxGeometryPath());
vboxLayoutProperties->addWidget(createGroupBoxMiscPath());
vboxLayoutProperties->addWidget(createGroupBoxGeometryPoint());
vboxLayoutProperties->addWidget(createGroupBoxGeometryPolygon());
vboxLayoutProperties->addWidget(createGroupBoxGeometryPolyline());
Expand Down Expand Up @@ -218,6 +220,7 @@ void PropertyEditor::setSelectedItems(QList<QGraphicsItem*> itemList)
int numImage = 0;
int numInfLine = 0;
int numLine = 0;
int numPath = 0;
int numPoint = 0;
int numPolygon = 0;
int numPolyline = 0;
Expand Down Expand Up @@ -249,6 +252,7 @@ void PropertyEditor::setSelectedItems(QList<QGraphicsItem*> itemList)
else if(objType == OBJ_TYPE_IMAGE) numImage++;
else if(objType == OBJ_TYPE_INFINITELINE) numInfLine++;
else if(objType == OBJ_TYPE_LINE) numLine++;
else if(objType == OBJ_TYPE_PATH) numPath++;
else if(objType == OBJ_TYPE_POINT) numPoint++;
else if(objType == OBJ_TYPE_POLYGON) numPolygon++;
else if(objType == OBJ_TYPE_POLYLINE) numPolyline++;
Expand Down Expand Up @@ -288,6 +292,7 @@ void PropertyEditor::setSelectedItems(QList<QGraphicsItem*> itemList)
else if(objType == OBJ_TYPE_IMAGE) comboBoxStr = tr("Image") + " (" + QString().setNum(numImage) + ")";
else if(objType == OBJ_TYPE_INFINITELINE) comboBoxStr = tr("Infinite Line") + " (" + QString().setNum(numInfLine) + ")";
else if(objType == OBJ_TYPE_LINE) comboBoxStr = tr("Line") + " (" + QString().setNum(numLine) + ")";
else if(objType == OBJ_TYPE_PATH) comboBoxStr = tr("Path") + " (" + QString().setNum(numPath) + ")";
else if(objType == OBJ_TYPE_POINT) comboBoxStr = tr("Point") + " (" + QString().setNum(numPoint) + ")";
else if(objType == OBJ_TYPE_POLYGON) comboBoxStr = tr("Polygon") + " (" + QString().setNum(numPolygon) + ")";
else if(objType == OBJ_TYPE_POLYLINE) comboBoxStr = tr("Polyline") + " (" + QString().setNum(numPolyline) + ")";
Expand Down Expand Up @@ -420,6 +425,10 @@ void PropertyEditor::setSelectedItems(QList<QGraphicsItem*> itemList)
updateLineEditNumIfVaries(lineEditLineLength, obj->objectLength(), false);
}
}
else if(objType == OBJ_TYPE_PATH)
{
//TODO: load path data
}
else if(objType == OBJ_TYPE_POINT)
{
PointObject* obj = static_cast<PointObject*>(item);
Expand Down Expand Up @@ -619,6 +628,7 @@ void PropertyEditor::showGroups(int objType)
else if(objType == OBJ_TYPE_IMAGE) { groupBoxGeometryImage->show(); groupBoxMiscImage->show(); }
else if(objType == OBJ_TYPE_INFINITELINE) { groupBoxGeometryInfiniteLine->show(); }
else if(objType == OBJ_TYPE_LINE) { groupBoxGeometryLine->show(); }
else if(objType == OBJ_TYPE_PATH) { groupBoxGeometryPath->show(); groupBoxMiscPath->show(); }
else if(objType == OBJ_TYPE_POINT) { groupBoxGeometryPoint->show(); }
else if(objType == OBJ_TYPE_POLYGON) { groupBoxGeometryPolygon->show(); }
else if(objType == OBJ_TYPE_POLYLINE) { groupBoxGeometryPolyline->show(); groupBoxMiscPolyline->show(); }
Expand Down Expand Up @@ -654,6 +664,8 @@ void PropertyEditor::hideAllGroups()
groupBoxMiscImage->hide();
groupBoxGeometryInfiniteLine->hide();
groupBoxGeometryLine->hide();
groupBoxGeometryPath->hide();
groupBoxMiscPath->hide();
groupBoxGeometryPoint->hide();
groupBoxGeometryPolygon->hide();
groupBoxGeometryPolyline->hide();
Expand Down Expand Up @@ -743,6 +755,14 @@ void PropertyEditor::clearAllFields()
lineEditLineAngle->clear();
lineEditLineLength->clear();

//Path
comboBoxPathVertexNum->clear();
lineEditPathVertexX->clear();
lineEditPathVertexY->clear();
lineEditPathArea->clear();
lineEditPathLength->clear();
comboBoxPathClosed->clear();

//Point
lineEditPointX->clear();
lineEditPointY->clear();
Expand Down Expand Up @@ -1181,6 +1201,52 @@ QGroupBox* PropertyEditor::createGroupBoxGeometryLine()
return groupBoxGeometryLine;
}

QGroupBox* PropertyEditor::createGroupBoxGeometryPath()
{
groupBoxGeometryPath = new QGroupBox(tr("Geometry"), this);

toolButtonPathVertexNum = createToolButton("blank", tr("Vertex #")); //TODO: use proper icon
toolButtonPathVertexX = createToolButton("blank", tr("Vertex X")); //TODO: use proper icon
toolButtonPathVertexY = createToolButton("blank", tr("Vertex Y")); //TODO: use proper icon
toolButtonPathArea = createToolButton("blank", tr("Area")); //TODO: use proper icon
toolButtonPathLength = createToolButton("blank", tr("Length")); //TODO: use proper icon

comboBoxPathVertexNum = createComboBox(false);
lineEditPathVertexX = createLineEdit("double", false);
lineEditPathVertexY = createLineEdit("double", false);
lineEditPathArea = createLineEdit("double", true);
lineEditPathLength = createLineEdit("double", true);

//TODO: mapSignal for paths

QFormLayout* formLayout = new QFormLayout(this);
formLayout->addRow(toolButtonPathVertexNum, comboBoxPathVertexNum);
formLayout->addRow(toolButtonPathVertexX, lineEditPathVertexX);
formLayout->addRow(toolButtonPathVertexY, lineEditPathVertexY);
formLayout->addRow(toolButtonPathArea, lineEditPathArea);
formLayout->addRow(toolButtonPathLength, lineEditPathLength);
groupBoxGeometryPath->setLayout(formLayout);

return groupBoxGeometryPath;
}

QGroupBox* PropertyEditor::createGroupBoxMiscPath()
{
groupBoxMiscPath = new QGroupBox(tr("Misc"), this);

toolButtonPathClosed = createToolButton("blank", tr("Closed")); //TODO: use proper icon

comboBoxPathClosed = createComboBox(false);

//TODO: mapSignal for paths

QFormLayout* formLayout = new QFormLayout(this);
formLayout->addRow(toolButtonPathClosed, comboBoxPathClosed);
groupBoxMiscPath->setLayout(formLayout);

return groupBoxMiscPath;
}

QGroupBox* PropertyEditor::createGroupBoxGeometryPoint()
{
groupBoxGeometryPoint = new QGroupBox(tr("Geometry"), this);
Expand Down Expand Up @@ -1619,6 +1685,8 @@ void PropertyEditor::fieldEdited(QObject* fieldObj)
tempLineObj = static_cast<LineObject*>(item);
if(tempLineObj) { tempLineObj->setObjectY2(-lineEditLineEndY->text().toDouble()); } }
break;
case OBJ_TYPE_PATH: //TODO: field editing
break;
case OBJ_TYPE_POINT:
if(objName == "lineEditPointX") {
tempPointObj = static_cast<PointObject*>(item);
Expand Down
25 changes: 25 additions & 0 deletions embroidermodder2/property-editor.h
Expand Up @@ -20,6 +20,7 @@ class HatchObject;
class ImageObject;
class InfiniteLineObject;
class LineObject;
class PathObject;
class PointObject;
class PolygonObject;
class PolylineObject;
Expand Down Expand Up @@ -93,6 +94,7 @@ private slots:
ImageObject* tempImageObj;
InfiniteLineObject* tempInfLineObj;
LineObject* tempLineObj;
PathObject* tempPathObj;
PointObject* tempPointObj;
PolygonObject* tempPolygonObj;
PolylineObject* tempPolylineObj;
Expand Down Expand Up @@ -358,6 +360,29 @@ private slots:
QLineEdit* lineEditLineAngle;
QLineEdit* lineEditLineLength;

//Path
QGroupBox* createGroupBoxGeometryPath();
QGroupBox* groupBoxGeometryPath;

QToolButton* toolButtonPathVertexNum;
QToolButton* toolButtonPathVertexX;
QToolButton* toolButtonPathVertexY;
QToolButton* toolButtonPathArea;
QToolButton* toolButtonPathLength;

QComboBox* comboBoxPathVertexNum;
QLineEdit* lineEditPathVertexX;
QLineEdit* lineEditPathVertexY;
QLineEdit* lineEditPathArea;
QLineEdit* lineEditPathLength;

QGroupBox* createGroupBoxMiscPath();
QGroupBox* groupBoxMiscPath;

QToolButton* toolButtonPathClosed;

QComboBox* comboBoxPathClosed;

//Point
QGroupBox* createGroupBoxGeometryPoint();
QGroupBox* groupBoxGeometryPoint;
Expand Down
7 changes: 6 additions & 1 deletion embroidermodder2/view.cpp
Expand Up @@ -2050,7 +2050,12 @@ QList<QGraphicsItem*> View::createObjectList(QList<QGraphicsItem*> list)
}
else if(objType == OBJ_TYPE_PATH)
{
//TODO: cut/copy paths
PathObject* pathObj = static_cast<PathObject*>(item);
if(pathObj)
{
PathObject* copyPathObj = new PathObject(pathObj);
copyList.append(copyPathObj);
}
}
else if(objType == OBJ_TYPE_POINT)
{
Expand Down

0 comments on commit 6c1b80c

Please sign in to comment.