Skip to content

Commit

Permalink
[PLOTS] check if plot commands are called on actual plots
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffstadt committed Aug 13, 2020
1 parent 984da54 commit 6ced9ab
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 2 deletions.
114 changes: 114 additions & 0 deletions DearPyGui/src/Core/mvMarvel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,14 @@ namespace Marvel {
ThrowPythonException(message + " plot does not exist.");
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}

mvPlot* graph = static_cast<mvPlot*>(aplot);

graph->clear();
Expand All @@ -883,6 +891,14 @@ namespace Marvel {
ThrowPythonException(message + " plot does not exist.");
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}

mvPlot* graph = static_cast<mvPlot*>(aplot);

graph->resetXTicks();
Expand All @@ -904,6 +920,14 @@ namespace Marvel {
ThrowPythonException(message + " plot does not exist.");
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}

mvPlot* graph = static_cast<mvPlot*>(aplot);

graph->resetXTicks();
Expand All @@ -926,6 +950,14 @@ namespace Marvel {
ThrowPythonException(message + " plot does not exist.");
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}

mvPlot* graph = static_cast<mvPlot*>(aplot);

auto mlabel_pairs = mvPythonTranslator::ToVectPairStringFloat(label_pairs);
Expand Down Expand Up @@ -959,6 +991,14 @@ namespace Marvel {
ThrowPythonException(message + " plot does not exist.");
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}

mvPlot* graph = static_cast<mvPlot*>(aplot);

auto mlabel_pairs = mvPythonTranslator::ToVectPairStringFloat(label_pairs);
Expand Down Expand Up @@ -991,6 +1031,13 @@ namespace Marvel {
ThrowPythonException(message + " plot does not exist.");
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}
mvPlot* graph = static_cast<mvPlot*>(aplot);

graph->setXLimitsAuto();
Expand All @@ -1012,6 +1059,14 @@ namespace Marvel {
ThrowPythonException(message + " plot does not exist.");
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}

mvPlot* graph = static_cast<mvPlot*>(aplot);

graph->setYLimitsAuto();
Expand All @@ -1035,6 +1090,14 @@ namespace Marvel {
ThrowPythonException(message + " plot does not exist.");
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}

mvPlot* graph = static_cast<mvPlot*>(aplot);

graph->setXLimits(xmin, xmax);
Expand All @@ -1058,6 +1121,13 @@ namespace Marvel {
ThrowPythonException(message + " plot does not exist.");
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}
mvPlot* graph = static_cast<mvPlot*>(aplot);

graph->setYLimits(ymin, ymax);
Expand All @@ -1079,6 +1149,13 @@ namespace Marvel {
ThrowPythonException(message + " plot does not exist.");
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}
mvPlot* graph = static_cast<mvPlot*>(aplot);

return Py_BuildValue("b", graph->isPlotQueried());
Expand All @@ -1098,6 +1175,13 @@ namespace Marvel {
ThrowPythonException(message + " plot does not exist.");
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}
mvPlot* graph = static_cast<mvPlot*>(aplot);

auto area = graph->getPlotQueryArea();
Expand All @@ -1120,6 +1204,14 @@ namespace Marvel {
ThrowPythonException(message + " plot does not exist.");
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}

mvPlot* graph = static_cast<mvPlot*>(aplot);

graph->SetColorMap(map);
Expand Down Expand Up @@ -1191,6 +1283,13 @@ namespace Marvel {
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}

mvPlot* graph = static_cast<mvPlot*>(aplot);

auto datapoints = mvPythonTranslator::ToVectVec2(data);
Expand Down Expand Up @@ -1249,6 +1348,13 @@ namespace Marvel {
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}

mvPlot* graph = static_cast<mvPlot*>(aplot);

auto datapoints = mvPythonTranslator::ToVectVec2(data);
Expand Down Expand Up @@ -1290,6 +1396,14 @@ namespace Marvel {
ThrowPythonException(message + " plot does not exist.");
return mvPythonTranslator::GetPyNone();
}

if (aplot->getType() != mvAppItemType::Plot)
{
std::string message = plot;
ThrowPythonException(message + " is not a plot.");
return mvPythonTranslator::GetPyNone();
}

mvPlot* graph = static_cast<mvPlot*>(aplot);

mvSeries* series = new mvLabelSeries(name, { {(float)x, (float)y} }, xoffset, yoffset, vertical);
Expand Down
2 changes: 0 additions & 2 deletions DearSandbox/Demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ def InsertCol(sender, data):
add_button("Plot data", callback="PlotCallback")
add_listbox("Colormaps", ("Default", "Dark", "Pastel", "Paired", "Viridis", "Plasma", "Hot", "Cool", "Pink", "Jet"), width=500, height=3, callback="colormapCallback")
add_plot("Plot", "x-axis", "y-axis", height=-1);
set_xticks("Plot", [["X-axis", 0], ["1", 1]])
set_yticks("Plot", [["Y-axis", 0], ["1", 1]])
end_tab()
add_tab("Simple Plots")
add_simple_plot("Simpleplot1", (0.3, 0.9, 2.5, 8.9))
Expand Down

0 comments on commit 6ced9ab

Please sign in to comment.