diff options
| author | Mikko Syrjä <mikko@3d-system.fi> | 2019-02-26 23:28:08 +0200 |
|---|---|---|
| committer | Mikko Syrjä <mikko@3d-system.fi> | 2019-02-26 23:28:08 +0200 |
| commit | cbbdab342fc0c117443d6f4455b0852ccf561be1 (patch) | |
| tree | 77de90a110b66c8964898b21369fbb0fad32f0b9 | |
| parent | e1b36719796209bfe47320c493b708d27dab3f25 (diff) | |
| download | symedit-cbbdab342fc0c117443d6f4455b0852ccf561be1.tar.gz symedit-cbbdab342fc0c117443d6f4455b0852ccf561be1.zip | |
Implemented area filling.
| -rw-r--r-- | Editor.qml | 1 | ||||
| -rw-r--r-- | main.qml | 13 | ||||
| -rw-r--r-- | symbol.cpp | 18 | ||||
| -rw-r--r-- | symbol.h | 2 |
4 files changed, 25 insertions, 9 deletions
@@ -18,6 +18,7 @@ Rectangle enum Operation { + Fill = 70, // F Line = 68, // D Rectangle = 66, // B Circle = 82 // R @@ -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 } @@ -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); @@ -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. }; |
