From kde-commits Mon Mar 18 13:57:52 2013 From: Barth Netterfield Date: Mon, 18 Mar 2013 13:57:52 +0000 To: kde-commits Subject: branches/work/kst/portto4/kst/src/libkstapp Message-Id: <20130318135752.94FA9AC879 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=136361508605786 SVN commit 1345052 by netterfield: BUG: 315362 Allow the x and y plot labels to be changed from the command line. M +35 -1 commandlineparser.cpp M +3 -0 commandlineparser.h --- branches/work/kst/portto4/kst/src/libkstapp/commandlineparser.cpp #1345051:1345052 @@ -77,6 +77,10 @@ " -d: use points for the next curve\n" " -l: use lines for the next curve\n" " -b: use bargraph for the next curve\n" +" --xlabel Set X label of all future plots.\n" +" --ylabel Set Y label of all future plots.\n" +" --xlabelauto AutoSet X label of all future plots.\n" +" --ylabelauto AutoSet Y label of all future plots.\n" "Data Object Modifiers\n" " -x : Create vector and use as X vector for curves.\n" " -e : Create vector and use as Y-error vector for next -y.\n" @@ -156,6 +160,8 @@ _fileNames.clear(); _vectors.clear(); _plotItems.clear(); + _xlabel.clear(); + _ylabel.clear(); } @@ -296,6 +302,7 @@ cmd->createItem(); _plotItem = static_cast(cmd->item()); _plotItem->view()->appendToLayout(CurvePlacement::Auto, _plotItem); + applyLabels(); } PlotRenderItem *renderItem = _plotItem->renderItem(PlotRenderItem::Cartesian); renderItem->addRelation(kst_cast(curve)); @@ -316,6 +323,7 @@ cmd->createItem(); _plotItem = static_cast(cmd->item()); _plotItem->view()->appendToLayout(CurvePlacement::Auto, _plotItem); + applyLabels(); } PlotRenderItem *renderItem = _plotItem->renderItem(PlotRenderItem::Cartesian); renderItem->addRelation(kst_cast(image)); @@ -344,10 +352,29 @@ pi->setDescriptiveName( plot_name ); _plotItems.append(pi); pi->view()->appendToLayout(CurvePlacement::Auto, pi); + _plotItem = pi; + applyLabels(); } _plotItem = pi; + } +void CommandLineParser::applyLabels() { + if (!_plotItem) { + return; + } + + if (!_xlabel.isEmpty()) { + _plotItem->bottomLabelDetails()->setText(_xlabel); + _plotItem->bottomLabelDetails()->setIsAuto(false); + } + if (!_ylabel.isEmpty()) { + _plotItem->leftLabelDetails()->setText(_ylabel); + _plotItem->leftLabelDetails()->setIsAuto(false); + } + +} + QString CommandLineParser::kstFileName() { if (_fileNames.size()>0) { return (_fileNames.at(0)); @@ -406,7 +433,6 @@ QString plot_name; *ok = _setStringArg(plot_name,i18n("Usage: -P \n")); _doConsecutivePlots=false; - createOrFindPlot(plot_name); } else if (arg == "-A") { _doConsecutivePlots = true; @@ -519,6 +545,14 @@ new_fileList = true; _overrideStyle = false; } + } else if (arg == "--xlabel") { + *ok = _setStringArg(_xlabel, "Usage -xlabel