aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikko Syrjä <mikko@3d-system.fi>2019-02-26 23:28:08 +0200
committerMikko Syrjä <mikko@3d-system.fi>2019-02-26 23:28:08 +0200
commitcbbdab342fc0c117443d6f4455b0852ccf561be1 (patch)
tree77de90a110b66c8964898b21369fbb0fad32f0b9
parente1b36719796209bfe47320c493b708d27dab3f25 (diff)
downloadsymedit-cbbdab342fc0c117443d6f4455b0852ccf561be1.tar.gz
symedit-cbbdab342fc0c117443d6f4455b0852ccf561be1.zip
Implemented area filling.
-rw-r--r--Editor.qml1
-rw-r--r--main.qml13
-rw-r--r--symbol.cpp18
-rw-r--r--symbol.h2
4 files changed, 25 insertions, 9 deletions
diff --git a/Editor.qml b/Editor.qml
index b7aef56..38b1fd9 100644
--- a/Editor.qml
+++ b/Editor.qml
@@ -18,6 +18,7 @@ Rectangle
enum Operation
{
+ Fill = 70, // F
Line = 68, // D
Rectangle = 66, // B
Circle = 82 // R
diff --git a/main.qml b/main.qml
index c8700ec..f310378 100644
--- a/main.qml
+++ b/main.qml
@@ -139,7 +139,7 @@ ApplicationWindow
ComboBox
{
id: snaplist
- implicitWidth: 60
+ implicitWidth: 50
model: [ 1, 5, 10 ]
onCurrentIndexChanged:
{
@@ -160,8 +160,9 @@ ApplicationWindow
ComboBox
{
id: filllist
- implicitWidth: 60
- model: [ 0, 1, 2 ]
+ implicitWidth: 100
+ model: [ "No fill", "Area fill", "Backgroud" ] //%%
+// model: [ "Ei täyttöä", "Aluetäyttö", "Taustaväri" ] //%%
onCurrentIndexChanged: { fillitem = currentIndex; editor.update() }
function setFill() { currentIndex = fillitem }
}
@@ -170,7 +171,7 @@ ApplicationWindow
ComboBox
{
id: widthlist
- implicitWidth: 60
+ implicitWidth: 50
model: [ 1, 2, 3, 4, 5 ]
onCurrentIndexChanged: { linewidth = currentIndex + 1; editor.update() }
function setWidth() { currentIndex = linewidth - 1 }
@@ -180,7 +181,7 @@ ApplicationWindow
ComboBox
{
id: sizelist
- implicitWidth: 60
+ implicitWidth: 50
model: [ 1, 2, 3, 4, 5 ]
onCurrentIndexChanged: { textsize = currentIndex + 1; editor.update() }
function setSize() { currentIndex = textsize - 1 }
@@ -190,7 +191,7 @@ ApplicationWindow
ComboBox
{
id: alignlist
- implicitWidth: 60
+ implicitWidth: 50
model: [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
onCurrentIndexChanged: { alignment = currentIndex + 1 }
function setAlign() { currentIndex = alignment - 1 }
diff --git a/symbol.cpp b/symbol.cpp
index 32dd7d0..93891ea 100644
--- a/symbol.cpp
+++ b/symbol.cpp
@@ -48,6 +48,7 @@ SymEditSymbol::SymEditSymbol() : ActiveIndex(-1)
void SymEditSymbol::Load(const QString& buffer)
{
Items.clear();
+ int fill = 0;
QPoint position(0, 0);
for ( const auto& string : buffer.split(';', QString::SkipEmptyParts) )
{
@@ -58,13 +59,15 @@ void SymEditSymbol::Load(const QString& buffer)
int x = string.mid(1, comma - 1).toInt();
int y = string.mid(comma + 1).toInt();
if ( operation != 'U' )
- Items.push_back(Item(operation, position, QPoint(x, y), false));
+ Items.push_back(Item(operation, position, QPoint(x, y), fill));
position = QPoint(x, y);
}
+ else if ( operation == 'F' )
+ fill = string.mid(1).toInt();
else // single parameter
{
int value = string.mid(1).toInt();
- Items.push_back(Item(operation, position, value, false));
+ Items.push_back(Item(operation, position, value, fill));
}
}
ActiveIndex = static_cast<int>(Items.size()) - 1;
@@ -85,7 +88,14 @@ QString& SymEditSymbol::Save(QString& buffer) const
buffer.append(',').append(value.setNum(point.y()));
buffer.append(';');
};
+ auto appendfill = [](QString& buffer, int fill)
+ {
+ QString value;
+ buffer.append('F').append(value.setNum(fill)).append(';');
+ return fill;
+ };
+ int fill = 0;
buffer.clear();
QPoint position(0, 0);
for ( const auto& item : Items ) switch ( item.Operation )
@@ -93,6 +103,8 @@ QString& SymEditSymbol::Save(QString& buffer) const
case 'D': // line
case 'B': // rectangle
{
+ if ( item.Fill != fill )
+ fill = appendfill(buffer, item.Fill);
if ( item.Point != position )
appendvalue(buffer.append('U'), item.Point, 2);
appendvalue(buffer.append(item.Operation), item.Value, 2);
@@ -101,6 +113,8 @@ QString& SymEditSymbol::Save(QString& buffer) const
}
case 'R': // circle
{
+ if ( item.Fill != fill )
+ fill = appendfill(buffer, item.Fill);
if ( item.Point != position )
appendvalue(buffer.append('U'), item.Point, 2);
appendvalue(buffer.append(item.Operation), item.Value, 1);
diff --git a/symbol.h b/symbol.h
index 633e2a4..aa4f3d9 100644
--- a/symbol.h
+++ b/symbol.h
@@ -23,7 +23,7 @@ public:
QPoint Point; //!< Item coordinates.
QPoint Value; //!< Item value.
QString Text; //!< Text string.
- bool Fill; //!< Fill area.
+ int Fill; //!< Fill area.
int Align; //!< Text alignment.
};