Skip to content

Commit 89f2f96

Browse files
committed
Add cmdline parameter
1 parent b902ea3 commit 89f2f96

File tree

6 files changed

+87
-47
lines changed

6 files changed

+87
-47
lines changed

src/Core/Application/Application.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ NetworkEditorControllerHandle Application::controller()
220220
/// @todo: these all get configured
221221
ModuleFactoryHandle moduleFactory(new HardCodedModuleFactory);
222222
ModuleStateFactoryHandle sf(new SimpleMapModuleStateFactory);
223-
ExecutionStrategyFactoryHandle exe(new DesktopExecutionStrategyFactory(parameters()->threadMode()));
223+
ExecutionStrategyFactoryHandle exe(new DesktopExecutionStrategyFactory(parameters()->developerParameters()->threadMode()));
224224
AlgorithmFactoryHandle algoFactory(new HardCodedAlgorithmFactory);
225-
ReexecuteStrategyFactoryHandle reexFactory(new DynamicReexecutionStrategyFactory(parameters()->reexecuteMode()));
225+
ReexecuteStrategyFactoryHandle reexFactory(new DynamicReexecutionStrategyFactory(parameters()->developerParameters()->reexecuteMode()));
226226
auto eventCmdFactory(makeNetworkEventCommandFactory());
227227
private_->controller_.reset(new NetworkEditorController(moduleFactory, sf, exe, algoFactory, reexFactory, private_->cmdFactory_, eventCmdFactory));
228228

src/Core/CommandLine/CommandLine.cc

Lines changed: 62 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class CommandLineParserInternal
6565
("threadMode", po::value<std::string>(), "network execution threading mode--DEVELOPER USE ONLY")
6666
("reexecuteMode", po::value<std::string>(), "network reexecution mode--DEVELOPER USE ONLY")
6767
("frameInitLimit", po::value<int>(), "ViewScene frame init limit--increase if renderer fails")
68+
("guiExpandFactor", po::value<double>(), "Expansion factor for high resolution displays")
6869
("list-modules", "print list of available modules")
6970
;
7071

@@ -105,6 +106,44 @@ class CommandLineParserInternal
105106
namespace
106107
{
107108

109+
class DeveloperParametersImpl : public DeveloperParameters
110+
{
111+
public:
112+
DeveloperParametersImpl(
113+
const boost::optional<std::string>& threadMode,
114+
const boost::optional<std::string>& reexecuteMode,
115+
const boost::optional<int>& frameInitLimit,
116+
const boost::optional<int>& regressionTimeout,
117+
const boost::optional<double>& guiExpandFactor
118+
) : threadMode_(threadMode), reexecuteMode_(reexecuteMode), frameInitLimit_(frameInitLimit),
119+
regressionTimeout_(regressionTimeout), guiExpandFactor_(guiExpandFactor)
120+
{}
121+
virtual boost::optional<int> regressionTimeoutSeconds() const override
122+
{
123+
return regressionTimeout_;
124+
}
125+
virtual boost::optional<std::string> threadMode() const override
126+
{
127+
return threadMode_;
128+
}
129+
virtual boost::optional<std::string> reexecuteMode() const override
130+
{
131+
return reexecuteMode_;
132+
}
133+
virtual boost::optional<int> frameInitLimit() const override
134+
{
135+
return frameInitLimit_;
136+
}
137+
virtual boost::optional<double> guiExpandFactor() const override
138+
{
139+
return guiExpandFactor_;
140+
}
141+
private:
142+
boost::optional<std::string> threadMode_, reexecuteMode_;
143+
boost::optional<int> frameInitLimit_, regressionTimeout_;
144+
boost::optional<double> guiExpandFactor_;
145+
};
146+
108147
class ApplicationParametersImpl : public ApplicationParameters
109148
{
110149
public:
@@ -122,7 +161,7 @@ class ApplicationParametersImpl : public ApplicationParameters
122161
bool isVerboseMode,
123162
bool printModules) : help_(help), version_(version), executeNetwork_(executeNetwork),
124163
executeNetworkAndQuit_(executeNetworkAndQuit), disableGui_(disableGui),
125-
disableSplash_(disableSplash), isRegressionMode_(isRegressionMode),
164+
disableSplash_(disableSplash), isRegressionMode_(isRegressionMode),
126165
interactiveMode_(interactiveMode),
127166
loadMostRecentFile_(loadMostRecentFile),
128167
isVerboseMode_(isVerboseMode),
@@ -135,15 +174,11 @@ class ApplicationParametersImpl : public ApplicationParameters
135174
std::vector<std::string>&& inputFiles,
136175
const boost::optional<boost::filesystem::path>& pythonScriptFile,
137176
const boost::optional<boost::filesystem::path>& dataDirectory,
138-
const boost::optional<std::string>& threadMode,
139-
const boost::optional<std::string>& reexecuteMode,
140-
const boost::optional<int>& frameInitLimit,
141-
const boost::optional<int>& regressionTimeout,
177+
DeveloperParametersPtr devParams,
142178
const Flags& flags
143179
) : entireCommandLine_(entireCommandLine),
144180
inputFiles_(inputFiles), pythonScriptFile_(pythonScriptFile), dataDirectory_(dataDirectory),
145-
threadMode_(threadMode), reexecuteMode_(reexecuteMode), frameInitLimit_(frameInitLimit),
146-
regressionTimeout_(regressionTimeout),
181+
devParams_(devParams),
147182
flags_(flags)
148183
{}
149184

@@ -207,31 +242,16 @@ class ApplicationParametersImpl : public ApplicationParameters
207242
return flags_.loadMostRecentFile_;
208243
}
209244

210-
virtual boost::optional<int> regressionTimeoutSeconds() const override
245+
virtual DeveloperParametersPtr developerParameters() const override
211246
{
212-
return regressionTimeout_;
247+
return devParams_;
213248
}
214249

215250
virtual bool verboseMode() const override
216251
{
217252
return flags_.isVerboseMode_;
218253
}
219254

220-
virtual boost::optional<std::string> threadMode() const override
221-
{
222-
return threadMode_;
223-
}
224-
225-
virtual boost::optional<std::string> reexecuteMode() const override
226-
{
227-
return reexecuteMode_;
228-
}
229-
230-
virtual boost::optional<int> frameInitLimit() const override
231-
{
232-
return frameInitLimit_;
233-
}
234-
235255
virtual bool printModuleList() const override
236256
{
237257
return flags_.printModules_;
@@ -247,8 +267,7 @@ class ApplicationParametersImpl : public ApplicationParameters
247267
std::vector<std::string> inputFiles_;
248268
boost::optional<boost::filesystem::path> pythonScriptFile_;
249269
boost::optional<boost::filesystem::path> dataDirectory_;
250-
boost::optional<std::string> threadMode_, reexecuteMode_;
251-
boost::optional<int> frameInitLimit_, regressionTimeout_;
270+
DeveloperParametersPtr devParams_;
252271
Flags flags_;
253272
};
254273

@@ -263,6 +282,15 @@ std::string CommandLineParser::describe() const
263282
return impl_->describe();
264283
}
265284

285+
namespace
286+
{
287+
template <typename T>
288+
boost::optional<T> parseOptionalArg(const po::variables_map& parsed, const std::string& label)
289+
{
290+
return parsed.count(label) != 0 ? parsed[label].as<T>() : boost::optional<T>();
291+
}
292+
}
293+
266294
ApplicationParametersHandle CommandLineParser::parse(int argc, const char* argv[]) const
267295
{
268296
try
@@ -280,19 +308,19 @@ ApplicationParametersHandle CommandLineParser::parse(int argc, const char* argv[
280308
{
281309
dataDirectory = boost::filesystem::path(parsed["datadir"].as<std::string>());
282310
}
283-
auto threadMode = parsed.count("threadMode") != 0 ? parsed["threadMode"].as<std::string>() : boost::optional<std::string>();
284-
auto reexecuteMode = parsed.count("reexecuteMode") != 0 ? parsed["reexecuteMode"].as<std::string>() : boost::optional<std::string>();
285-
auto frameInitLimit = parsed.count("frameInitLimit") != 0 ? parsed["frameInitLimit"].as<int>() : boost::optional<int>();
286-
auto regressionTimeout = parsed.count("regression") != 0 ? parsed["regression"].as<int>() : boost::optional<int>();
311+
287312
return boost::make_shared<ApplicationParametersImpl>
288313
(boost::algorithm::join(cmdline, " "),
289314
std::move(inputFiles),
290315
pythonScriptFile,
291316
dataDirectory,
292-
threadMode,
293-
reexecuteMode,
294-
frameInitLimit,
295-
regressionTimeout,
317+
boost::make_shared<DeveloperParametersImpl>(
318+
parseOptionalArg<std::string>(parsed, "threadMode"),
319+
parseOptionalArg<std::string>(parsed, "reexecuteMode"),
320+
parseOptionalArg<int>(parsed, "frameInitLimit"),
321+
parseOptionalArg<int>(parsed, "regression"),
322+
parseOptionalArg<double>(parsed, "guiExpandFactor")
323+
),
296324
ApplicationParametersImpl::Flags(
297325
parsed.count("help") != 0,
298326
parsed.count("version") != 0,

src/Core/CommandLine/CommandLine.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ namespace SCIRun {
4040
namespace Core {
4141
namespace CommandLine {
4242

43+
class DeveloperParameters;
44+
using DeveloperParametersPtr = boost::shared_ptr<DeveloperParameters>;
45+
4346
class SCISHARE ApplicationParameters : boost::noncopyable
4447
{
4548
public:
@@ -56,13 +59,21 @@ namespace SCIRun {
5659
virtual bool isRegressionMode() const = 0;
5760
virtual bool interactiveMode() const = 0;
5861
virtual bool loadMostRecentFile() const = 0;
59-
virtual boost::optional<int> regressionTimeoutSeconds() const = 0;
62+
virtual DeveloperParametersPtr developerParameters() const = 0;
6063
virtual bool verboseMode() const = 0;
64+
virtual bool printModuleList() const = 0;
65+
virtual const std::string& entireCommandLine() const = 0;
66+
};
67+
68+
class SCISHARE DeveloperParameters : boost::noncopyable
69+
{
70+
public:
71+
virtual ~DeveloperParameters() {}
72+
virtual boost::optional<int> regressionTimeoutSeconds() const = 0;
6173
virtual boost::optional<std::string> threadMode() const = 0;
6274
virtual boost::optional<std::string> reexecuteMode() const = 0;
6375
virtual boost::optional<int> frameInitLimit() const = 0;
64-
virtual bool printModuleList() const = 0;
65-
virtual const std::string& entireCommandLine() const = 0;
76+
virtual boost::optional<double> guiExpandFactor() const = 0;
6677
};
6778

6879
typedef boost::shared_ptr<ApplicationParameters> ApplicationParametersHandle;

src/Core/CommandLine/Tests/ScirunCommandLineSpecTests.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ TEST(ScirunCommandLineSpecTest, CanReadBasicOptions)
5656
" --reexecuteMode arg network reexecution mode--DEVELOPER USE ONLY\n"
5757
" --frameInitLimit arg ViewScene frame init limit--increase if renderer \n"
5858
" fails\n"
59+
" --guiExpandFactor arg Expansion factor for high resolution displays\n"
5960
" --list-modules print list of available modules\n";
6061

6162
EXPECT_EQ(expectedHelp, parser.describe());
@@ -143,8 +144,8 @@ TEST(ScirunCommandLineSpecTest, CanReadBasicOptions)
143144

144145
ApplicationParametersHandle aph = parser.parse(argc, argv);
145146

146-
ASSERT_TRUE(!!aph->threadMode());
147-
EXPECT_EQ("serial", *aph->threadMode());
147+
ASSERT_TRUE(!!aph->developerParameters()->threadMode());
148+
EXPECT_EQ("serial", *aph->developerParameters()->threadMode());
148149
}
149150

150151
{
@@ -153,8 +154,8 @@ TEST(ScirunCommandLineSpecTest, CanReadBasicOptions)
153154

154155
ApplicationParametersHandle aph = parser.parse(argc, argv);
155156

156-
ASSERT_TRUE(!!aph->threadMode());
157-
EXPECT_EQ("serial", *aph->threadMode());
157+
ASSERT_TRUE(!!aph->developerParameters()->threadMode());
158+
EXPECT_EQ("serial", *aph->developerParameters()->threadMode());
158159
}
159160

160161
{

src/Interface/Application/SCIRunMainWindow.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ void SCIRunMainWindow::executeAll()
533533
{
534534
if (Application::Instance().parameters()->isRegressionMode())
535535
{
536-
auto timeout = Application::Instance().parameters()->regressionTimeoutSeconds();
536+
auto timeout = Application::Instance().parameters()->developerParameters()->regressionTimeoutSeconds();
537537
QTimer::singleShot(1000 * *timeout, this, SLOT(networkTimedOut()));
538538
}
539539

src/Interface/Modules/Render/GLWidget.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ GLWidget::GLWidget(QtGLContext* context, QWidget* parent) :
5959

6060
// Call gl platform init.
6161
CPM_GL_PLATFORM_NS::glPlatformInit();
62-
63-
auto frameInitLimitFromCommandLine = Core::Application::Instance().parameters()->frameInitLimit();
62+
63+
auto frameInitLimitFromCommandLine = Core::Application::Instance().parameters()->developerParameters()->frameInitLimit();
6464
if (frameInitLimitFromCommandLine)
6565
{
6666
std::cout << "Renderer frame init limit changed to " << *frameInitLimitFromCommandLine << std::endl;
@@ -119,7 +119,7 @@ void GLWidget::mouseMoveEvent(QMouseEvent* event)
119119
//------------------------------------------------------------------------------
120120
void GLWidget::mousePressEvent(QMouseEvent* event)
121121
{
122-
122+
123123
SCIRun::Render::SRInterface::MouseButton btn = getSpireButton(event);
124124
mGraphics->inputMouseDown(glm::ivec2(event->x(), event->y()), btn);
125125
event->ignore();

0 commit comments

Comments
 (0)