From 13b9ea2be2dbe2ee110128dfef0b0081757c7161 Mon Sep 17 00:00:00 2001 From: Rafael Vega Date: Mon, 5 Jun 2017 10:16:06 -0500 Subject: [PATCH 1/2] Added Graph::mFill flag to render flag with or without fill. --- include/nanogui/graph.h | 4 ++++ python/misc.cpp | 4 +++- src/graph.cpp | 15 ++++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/nanogui/graph.h b/include/nanogui/graph.h index fddfaceb1a..583bd267ad 100644 --- a/include/nanogui/graph.h +++ b/include/nanogui/graph.h @@ -43,6 +43,9 @@ class NANOGUI_EXPORT Graph : public Widget { const Color &textColor() const { return mTextColor; } void setTextColor(const Color &textColor) { mTextColor = textColor; } + bool fill() const { return mFill; } + void setFill(bool fill) { mFill = fill; } + const VectorXf &values() const { return mValues; } VectorXf &values() { return mValues; } void setValues(const VectorXf &values) { mValues = values; } @@ -56,6 +59,7 @@ class NANOGUI_EXPORT Graph : public Widget { std::string mCaption, mHeader, mFooter; Color mBackgroundColor, mForegroundColor, mTextColor; VectorXf mValues; + bool mFill; public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; diff --git a/python/misc.cpp b/python/misc.cpp index a831091d72..71396377a9 100644 --- a/python/misc.cpp +++ b/python/misc.cpp @@ -41,7 +41,9 @@ void register_misc(py::module &m) { .def("textColor", &Graph::textColor, D(Graph, textColor)) .def("setTextColor", &Graph::setTextColor, D(Graph, setTextColor)) .def("values", (VectorXf &(Graph::*)(void)) &Graph::values, D(Graph, values)) - .def("setValues", &Graph::setValues, D(Graph, setValues)); + .def("setValues", &Graph::setValues, D(Graph, setValues)) + .def("fill", &Graph::fill, D(Graph, fill)) + .def("setFill", &Graph::setFill, D(Graph, setFill)); py::class_, PyImageView>(m, "ImageView", D(ImageView)) .def(py::init(), D(ImageView, ImageView)) diff --git a/src/graph.cpp b/src/graph.cpp index 838f0f7679..0574d3a0f1 100644 --- a/src/graph.cpp +++ b/src/graph.cpp @@ -17,7 +17,7 @@ NAMESPACE_BEGIN(nanogui) Graph::Graph(Widget *parent, const std::string &caption) - : Widget(parent), mCaption(caption) { + : Widget(parent), mCaption(caption), mFill(true) { mBackgroundColor = Color(20, 128); mForegroundColor = Color(255, 192, 0, 128); mTextColor = Color(240, 192); @@ -48,10 +48,15 @@ void Graph::draw(NVGcontext *ctx) { } nvgLineTo(ctx, mPos.x() + mSize.x(), mPos.y() + mSize.y()); - nvgStrokeColor(ctx, Color(100, 255)); - nvgStroke(ctx); - nvgFillColor(ctx, mForegroundColor); - nvgFill(ctx); + if (mFill) { + nvgStrokeColor(ctx, Color(100, 255)); + nvgStroke(ctx); + nvgFillColor(ctx, mForegroundColor); + nvgFill(ctx); + } else { + nvgStrokeColor(ctx, mForegroundColor); + nvgStroke(ctx); + } nvgFontFace(ctx, "sans"); From d7f8dd9687193eacaec805a99a54ad6d3cded56a Mon Sep 17 00:00:00 2001 From: Rafael Vega Date: Mon, 5 Jun 2017 10:34:16 -0500 Subject: [PATCH 2/2] Added Graph::setFill and Graph::fill to py_doc.h --- python/py_doc.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/py_doc.h b/python/py_doc.h index 09b97000df..aa75711e6a 100644 --- a/python/py_doc.h +++ b/python/py_doc.h @@ -1041,6 +1041,10 @@ static const char *__doc_nanogui_Graph_values = R"doc()doc"; static const char *__doc_nanogui_Graph_values_2 = R"doc()doc"; +static const char *__doc_nanogui_Graph_setFill = R"doc()doc"; + +static const char *__doc_nanogui_Graph_fill = R"doc()doc"; + static const char *__doc_nanogui_GridLayout = R"doc(Grid layout.