Skip to content

Commit

Permalink
[ISSUE #193][PLOT_VIEW] Add name label above each axis rectangle
Browse files Browse the repository at this point in the history
- Implement support of the 'PARL' group name parameter
- Rename console command 'plot-sequence-ids' into the 'plot-ids'
- Update README.md

Signed-off-by: Vladyslav Goncharuk <[email protected]>
  • Loading branch information
Vladyslav Goncharuk committed May 29, 2024
1 parent 135d1b2 commit a862b58
Show file tree
Hide file tree
Showing 7 changed files with 226 additions and 42 deletions.
34 changes: 31 additions & 3 deletions dltmessageanalyzerplugin/src/common/PlotDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

//////// PLOT_IDENTIFIERS ////////
const QString s_PLOT_AXIS_RECTANGLE_TYPE = "PARType";
const QString s_PLOT_AXIS_RECTANGLE_LABEL = "PARL";
const QString s_PLOT_X_MAX = "PXMx";
const QString s_PLOT_X_MIN = "PXMn";
const QString s_PLOT_Y_MAX = "PYMx";
Expand Down Expand Up @@ -138,13 +139,40 @@ static tPlotViewIDsMap createPlotIDsMap()

item.description = QString("Plot axis rectangle type. %1. "
"PARType_CPUC_LINEAR. Type of the specific plot axis rectangle. "
"Supported types are - GANNT, BAR, POINT, LINEAR. "
"Supported types are - GANTT, BAR, POINT, LINEAR. "
"If not specified, the LINEAR value is used. "
"If multiple values appear - the 'last win' strategy is applied.").arg(item.getParametersDescription());

result.insert(std::make_pair(ePlotViewID::PLOT_AXIS_RECTANGLE_TYPE, item));
}

{
tPlotViewIDItem item;
item.id_type = ePlotViewIDType::e_Optional;
item.id_str = s_PLOT_AXIS_RECTANGLE_LABEL;

{
tPlotViewIDParameterPtr pParameter = std::make_shared<tPlotViewIDparameter>();
pParameter->name = "axisRectName";
pParameter->type = ePlotViewParameterType::e_Mandatory;
item.addParameter(pParameter);
}

{
tPlotViewIDParameterPtr pParameter = std::make_shared<tPlotViewIDparameter>();
pParameter->name = "axisRectLabel";
pParameter->type = ePlotViewParameterType::e_Mandatory;
item.addParameter(pParameter);
}

item.description = QString("Plot axis rectangle label. %1. "
"PARL_CPUC_MyChart. The label, that will be created above the corresponding plot axis rectangle. "
"If not specified, the label is not created. "
"If multiple values appear for the same 'axisRectName' - they are concatenated.").arg(item.getParametersDescription());

result.insert(std::make_pair(ePlotViewID::PLOT_AXIS_RECTANGLE_LABEL, item));
}

auto formMinMaxParameters = [](tPlotViewIDItem& item)
{
{
Expand Down Expand Up @@ -873,9 +901,9 @@ QRegularExpression createPlotViewRegex()

for( auto it = sPlotViewIDsMap.begin(); it != sPlotViewIDsMap.end(); ++it )
{
const auto& UML_IDs_MapItem = *it;
const auto& Plot_IDs_MapItem = *it;

resultRegex.append(UML_IDs_MapItem.second.id_str);
resultRegex.append(Plot_IDs_MapItem.second.id_str);

if(it != finalIter)
{
Expand Down
39 changes: 39 additions & 0 deletions dltmessageanalyzerplugin/src/common/PlotDefinitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ typedef std::unordered_map<tPlotGraphMetadataKey, tPlotGraphMetadataValue> tPlot
enum class ePlotViewID
{
PLOT_AXIS_RECTANGLE_TYPE = 0,
PLOT_AXIS_RECTANGLE_LABEL,
PLOT_X_MAX,
PLOT_X_MIN,
PLOT_Y_MAX,
Expand Down Expand Up @@ -203,6 +204,44 @@ struct tPlotParametersParser<ePlotViewID::PLOT_AXIS_RECTANGLE_TYPE>
}
};

template<>
struct tPlotParametersParser<ePlotViewID::PLOT_AXIS_RECTANGLE_LABEL>
{
ePlotViewID plotViewId = ePlotViewID::PLOT_AXIS_RECTANGLE_LABEL;

struct tParsingResult
{
bool bParsingSuccessful = false;
QString errors;
QString axisRectName;
QString axisRectLabel;
};

tParsingResult parse(bool fillInStringMsg,
const tQStringPtr& pPlotViewGroupName,
const tQStringPtrVec& splitParameters)
{
tParsingResult result;

if(checkPlotViewParameter(result.errors,
fillInStringMsg,
plotViewId,
pPlotViewGroupName,
splitParameters))
{
assert(splitParameters[0] != nullptr);
result.axisRectName = *splitParameters[0];

assert(splitParameters[1] != nullptr);
result.axisRectLabel = *splitParameters[1];

result.bParsingSuccessful = true;
}

return result;
}
};

template<>
struct tPlotParametersParser<ePlotViewID::PLOT_X_MAX>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static void UML_sequence_identifiers()
}
}

static void plot_sequence_identifiers()
static void plot_identifiers()
{
SEND_MSG("Plot regex group identifiers, which are supported by the plugin:");

Expand Down Expand Up @@ -387,7 +387,7 @@ CConsoleInputProcessor::tScenariosMap CConsoleInputProcessor::createScenariosMap
"- clears debug view");
result["color-aliases"] = CConsoleInputProcessor::tScenarioData([](const CConsoleInputProcessor::tParamMap&){supportedColors();}
, "- prints all supported color aliases");
result["plot-sequence-ids"] = CConsoleInputProcessor::tScenarioData([](const CConsoleInputProcessor::tParamMap&){plot_sequence_identifiers();}
result["plot-ids"] = CConsoleInputProcessor::tScenarioData([](const CConsoleInputProcessor::tParamMap&){plot_identifiers();}
, "- prints information about regex names scripting in area of the plot diagrams.");
result["plot-operations"] = CConsoleInputProcessor::tScenarioData([](const CConsoleInputProcessor::tParamMap&){plot_operations();}
, "- prints information about regex names scripting in area of the plot diagrams.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,24 @@ void generateAxisRect(const std::pair<ISearchResultModel::tPlotAxisName, ISearch
pAxisRect->insetLayout()->addElement(pLegend, Qt::AlignRight|Qt::AlignTop); // Adjust position as needed
pLegend->setLayer(QLatin1String("legend"));

pAxisRect->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignRight); // Position of legend
auto* pLeftAxis = pAxisRect->axis(QCPAxis::atLeft);
auto* pBottomAxis = pAxisRect->axis(QCPAxis::atBottom);

pPlot->plotLayout()->addElement(rowCounter, 0, pAxisRect);
pAxisRect->axis(QCPAxis::atBottom)->setLayer("axes");
pAxisRect->axis(QCPAxis::atBottom)->grid()->setLayer("grid");

{
if (plotAxis.axisLabel.isSet())
{
QCPTextElement *pTitleLabel = new QCPTextElement(pPlot, plotAxis.axisLabel.getValue(), QFont("sans", 12, QFont::Bold));
pTitleLabel->setVisible(true);
pAxisRect->insetLayout()->addElement(pTitleLabel, QRectF(0.005, 0.0, 0.0, 0.0));
pTitleLabel->setLayer(QLatin1String("axis_rect_label"));
pTitleLabel->setSelectable(false);
}
}

// bring bottom and main axis rect closer together:
pAxisRect->setAutoMargins(QCP::msLeft|QCP::msRight|QCP::msBottom);
pAxisRect->setMargins(QMargins(0, 0, 0, 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class ISearchResultModel
struct tPlotAxisItem
{
TOptional<ePlotViewAxisType> axisType;
TOptional<QString> axisLabel;
TOptional<QString> xName;
TOptional<QString> yName;
TOptional<QString> xUnit;
Expand Down
Loading

0 comments on commit a862b58

Please sign in to comment.