diff --git a/client-api/C++/examples/all_commands.cpp b/client-api/C++/examples/all_commands.cpp index 549afb1..b4bc132 100644 --- a/client-api/C++/examples/all_commands.cpp +++ b/client-api/C++/examples/all_commands.cpp @@ -142,6 +142,44 @@ int main() VIBES_TEST( vibes::axisLabels(labels) ); } + cout << "plotting y=abs(cos(x)), y=abs(sin(x)), y=abs(sin(sin(x)))"< > points; + std::vector point(2); + std::vector< double > vect_x2; + std::vector< double > vect_y2; + + std::vector< double > vect_x3; + std::vector< double > vect_y3; + for (int i=0; i labels; + labels.push_back("x"); labels.push_back("abs cos x"); labels.push_back("abs sin x"); labels.push_back("sin sin x"); + VIBES_TEST( vibes::axisLabels(labels) ); + } VIBES_TEST( vibes::newFigure("figureTest") ); @@ -182,7 +220,7 @@ int main() x.push_back(2); y.push_back(7); x.push_back(0.5); y.push_back(4); x.push_back(-0.5); y.push_back(4); - VIBES_TEST( vibes::drawPolygon(x, y, "yellow[red]") ); + VIBES_TEST( vibes::drawPolygon(x, y, "red--[yellowgreen]") ); } cout << "drawVehicle" << std::endl; diff --git a/viewer/vibesgraphicsitem.cpp b/viewer/vibesgraphicsitem.cpp index e9de77b..d77561d 100644 --- a/viewer/vibesgraphicsitem.cpp +++ b/viewer/vibesgraphicsitem.cpp @@ -884,7 +884,7 @@ bool VibesGraphicsLine::computeProjection(int dimX, int dimY) // Get line color (or default if not specified) //const QBrush & brush = vibesDefaults.brush( jsonValue("FaceColor").toString() ); - const QPen & pen = vibesDefaults.pen( jsonValue("EdgeColor") ); + QPen pen = vibesDefaults.pen( jsonValue("EdgeColor") ); // Now process shape-specific properties // (we can only update properties of a shape, but mutation into another type is not supported) @@ -906,6 +906,19 @@ bool VibesGraphicsLine::computeProjection(int dimX, int dimY) path.addPolygon(polygon); this->setPath(path); // Set graphics properties + // Handle lineStyle + if(json.contains("LineStyle")) + { + Q_ASSERT(json["LineStyle"].isString()); + string style=json["LineStyle"].toString().toStdString(); + pen.setStyle(vibesDefaults.styleToPenStyle(style)); + } + // Handle lineStyle + if(json.contains("LineWidth")) + { + Q_ASSERT(json["LineWidth"].isDouble()); + pen.setWidthF(std::fmax(json["LineWidth"].toDouble(0),0)); + } this->setPen(pen); //this->setBrush(brush); @@ -954,8 +967,8 @@ bool VibesGraphicsPolygon::computeProjection(int dimX, int dimY) const QJsonObject & json = this->_json; // Get shape color (or default if not specified) - const QBrush & brush = vibesDefaults.brush( jsonValue("FaceColor") ); - const QPen & pen = vibesDefaults.pen( jsonValue("EdgeColor") ); + QBrush brush = vibesDefaults.brush( jsonValue("FaceColor") ); + QPen pen = vibesDefaults.pen( jsonValue("EdgeColor") ); Q_ASSERT(json.contains("type")); Q_ASSERT(json["type"].toString() == "polygon"); @@ -970,6 +983,21 @@ bool VibesGraphicsPolygon::computeProjection(int dimX, int dimY) this->setPolygon(polygon); // Update polygon color + + // Set graphics properties + // Handle lineStyle + if(json.contains("LineStyle")) + { + Q_ASSERT(json["LineStyle"].isString()); + string style=json["LineStyle"].toString().toStdString(); + pen.setStyle(vibesDefaults.styleToPenStyle(style)); + } + // Handle lineStyle + if(json.contains("LineWidth")) + { + Q_ASSERT(json["LineWidth"].isDouble()); + pen.setWidthF(std::fmax(json["LineWidth"].toDouble(0),0)); + } this->setPen(pen); this->setBrush(brush); diff --git a/viewer/vibesgraphicsitem.h b/viewer/vibesgraphicsitem.h index 9b7b11f..a9ba426 100644 --- a/viewer/vibesgraphicsitem.h +++ b/viewer/vibesgraphicsitem.h @@ -120,6 +120,11 @@ class VibesDefaults { name=value.toString(); } } + QColor c(name.toLower()); + if(c.isValid()) + { + return QBrush(c); + } return _brushes[name]; } @@ -143,6 +148,12 @@ class VibesDefaults { name=value.toString(); } } + QColor c; + c.setNamedColor(name.toLower()); + if(c.isValid()) + { + return QPen(c,0); + } return _pens[name]; } private: