-
Notifications
You must be signed in to change notification settings - Fork 3
HOWTO: adding options
Uladzislau Bohdan edited this page May 11, 2017
·
2 revisions
- add a private field to the Options class:
int num_threads_
. We don't usually create getters or setters for them: some classes has friend access to the fields. - you may want your new option to be returned from Options class: add it to an appropriate public method (like
Options::GetReconstructionEstimatorOptions()
) or create your own. - define default value and make your options parseable using
DEFINE_bool
,DEFINE_string
, ... macros insrc/options.cpp
. That would allow GFlags to read your option from command line. - initialize your private field either with default value or with option from CL by adding the rules to
Options::ParseCommandLineArguments()
method.
in the moment we don't have any options, which we don't want to be definable through CL. In case you want to add some I would recommend implementing Options::Init() method with default, for which we don't want to have a DEFINE macro.
you may want your options to be changeable from UI.
- add the label and/or data-input widget to the
ui/options_dialog.ui
file to the appropriate section. Give the widget a non-default name (try to be consistent with existent naming). Example:optimize_focal_length_checkBox
- initialize widget in accordance with your option: add the rules to
OptionsDialog::InitializeForms()
method. - implement a return of an option from the dialog back to the app by implementing the rules in
OptionsDialog::accept()
method. You may want to add verification.
are defined using GFlags macros in cli/cli.cpp
. This options will be then accessible in cli/
only.