Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::Forms::LinearScaleQuestion Class Reference

A Question whose possible responses are represented by a discrete linear scale. More...

#include <mitkLinearScaleQuestion.h>

Inheritance diagram for mitk::Forms::LinearScaleQuestion:
Collaboration diagram for mitk::Forms::LinearScaleQuestion:

Public Member Functions

 LinearScaleQuestion ()
 Constructor. More...
 
 ~LinearScaleQuestion () override
 Virtual destructor. More...
 
std::string GetType () const override
 Return the type string "Linear scale". More...
 
Question * CreateAnother () const override
 Create a new default-constructed LinearScaleQuestion instance. More...
 
void FromJSON (const nlohmann::ordered_json &j) override
 Deserialize this LinearScaleQuestion from JSON. More...
 
void ToJSON (nlohmann::ordered_json &j) const override
 Serialize this LinearScaleQuestion to JSON. More...
 
std::vector< std::string > GetResponsesAsStrings () const override
 Return the numeric response as a single-element vector of strings. More...
 
void ClearResponses () override
 Clear the response. More...
 
bool IsComplete () const override
 Check whether a response has been given. More...
 
std::optional< int > GetResponse () const
 Get the current numeric response. More...
 
void SetResponse (int response)
 Set the numeric response. More...
 
std::pair< int, int > GetRange () const
 Get the allowed range. More...
 
void SetRange (const std::pair< int, int > &range)
 Set the allowed range of numbers for a valid response. More...
 
std::pair< std::string, std::string > GetRangeLabels () const
 Get the labels for the low and high ends of the scale. More...
 
void SetRangeLabels (const std::pair< std::string, std::string > &labels)
 Set the labels for the low and high ends of the scale. More...
 
- Public Member Functions inherited from mitk::Forms::Question
 Question ()
 Default constructor. More...
 
virtual ~Question ()
 Virtual destructor. More...
 
std::string GetQuestionText () const
 Get the literal question text. More...
 
void SetQuestionText (const std::string &question)
 Set the literal question text. More...
 
bool IsRequired () const
 Check whether a response to this question is required to complete a form. More...
 
void SetRequired (bool required=true)
 Set whether a response to this question is required to complete a form. More...
 
virtual std::string GetRequiredText () const
 Get the text that should be displayed to clearly mark a question as required. More...
 
virtual bool HasFileResponses () const
 Query whether the responses given to this question are file paths. More...
 
virtual std::vector< fs::path > SubmitFileResponses (const fs::path &basePath) const
 Attach response files to submission. More...
 

Detailed Description

A Question whose possible responses are represented by a discrete linear scale.

The question can have a single response, which is one of the numbers within the allowed range. The range must start with 0 or 1 and end with any number between 2 and 10 (1 to 5 by default). Optional labels can be assigned to the low and high ends of the scale.

See also
Question

Definition at line 30 of file mitkLinearScaleQuestion.h.

Constructor & Destructor Documentation

◆ LinearScaleQuestion()

mitk::Forms::LinearScaleQuestion::LinearScaleQuestion ( )

Constructor.

Initializes the range to [1, 5] with no response and empty labels.

◆ ~LinearScaleQuestion()

mitk::Forms::LinearScaleQuestion::~LinearScaleQuestion ( )
override

Virtual destructor.

Member Function Documentation

◆ ClearResponses()

void mitk::Forms::LinearScaleQuestion::ClearResponses ( )
overridevirtual

Clear the response.

Implements mitk::Forms::Question.

◆ CreateAnother()

Question* mitk::Forms::LinearScaleQuestion::CreateAnother ( ) const
overridevirtual

Create a new default-constructed LinearScaleQuestion instance.

Returns
A pointer to a new LinearScaleQuestion. The caller takes ownership.

Implements mitk::Forms::Question.

◆ FromJSON()

void mitk::Forms::LinearScaleQuestion::FromJSON ( const nlohmann::ordered_json &  j)
overridevirtual

Deserialize this LinearScaleQuestion from JSON.

Parameters
[in]jThe JSON object to deserialize from.

Implements mitk::Forms::Question.

◆ GetRange()

std::pair<int, int> mitk::Forms::LinearScaleQuestion::GetRange ( ) const

Get the allowed range.

Returns
A pair where first is the lower bound and second is the upper bound.

◆ GetRangeLabels()

std::pair<std::string, std::string> mitk::Forms::LinearScaleQuestion::GetRangeLabels ( ) const

Get the labels for the low and high ends of the scale.

Returns
A pair where first is the low-end label and second is the high-end label.

◆ GetResponse()

std::optional<int> mitk::Forms::LinearScaleQuestion::GetResponse ( ) const

Get the current numeric response.

Returns
The response value, or std::nullopt if no response has been given.

◆ GetResponsesAsStrings()

std::vector<std::string> mitk::Forms::LinearScaleQuestion::GetResponsesAsStrings ( ) const
overridevirtual

Return the numeric response as a single-element vector of strings.

Returns
A vector containing the response as a string, or an empty vector if no response has been given.

Implements mitk::Forms::Question.

◆ GetType()

std::string mitk::Forms::LinearScaleQuestion::GetType ( ) const
overridevirtual

Return the type string "Linear scale".

Returns
The string "Linear scale".

Implements mitk::Forms::Question.

◆ IsComplete()

bool mitk::Forms::LinearScaleQuestion::IsComplete ( ) const
overridevirtual

Check whether a response has been given.

Returns
true if a response value is set, false otherwise.

Implements mitk::Forms::Question.

◆ SetRange()

void mitk::Forms::LinearScaleQuestion::SetRange ( const std::pair< int, int > &  range)

Set the allowed range of numbers for a valid response.

A valid range must start with 0 or 1 and end with any number between 2 and 10 (1 to 5 by default).

Parameters
[in]rangeA pair where first is the lower bound (0 or 1) and second is the upper bound (2 to 10).
Exceptions
mitk::ExceptionIf the range is invalid.

◆ SetRangeLabels()

void mitk::Forms::LinearScaleQuestion::SetRangeLabels ( const std::pair< std::string, std::string > &  labels)

Set the labels for the low and high ends of the scale.

Parameters
[in]labelsA pair where first is the low-end label and second is the high-end label.

◆ SetResponse()

void mitk::Forms::LinearScaleQuestion::SetResponse ( int  response)

Set the numeric response.

Parameters
[in]responseThe selected number on the scale.

◆ ToJSON()

void mitk::Forms::LinearScaleQuestion::ToJSON ( nlohmann::ordered_json &  j) const
overridevirtual

Serialize this LinearScaleQuestion to JSON.

Parameters
[out]jThe JSON object to serialize into.

Implements mitk::Forms::Question.


The documentation for this class was generated from the following file: