15template<
typename ObjectT>
18 std::string typeName = ObjectT::TypeName();
19 if ( typeName.starts_with(
"Object" ) && !typeName.ends_with(
"Object" ) )
20 typeName = typeName.substr( 6 );
21 if ( typeName ==
"Points" )
22 typeName =
"Point Cloud";
23 else if ( typeName ==
"Lines" )
24 typeName =
"Polyline";
25 else if ( typeName ==
"Voxels" )
30 if ( typeName.ends_with(
"s" ) || typeName.ends_with(
"sh" ) )
39 return "one " + typeName;
41 return "two " + typeName;
43 return "three " + typeName;
45 return "four " + typeName;
47 return std::to_string( n ) +
" " + typeName;
53template<
typename ObjectT,
bool visualRepresentationCheck,
bool modelCheck>
56 if ( objs.size() != n )
58 for (
const auto& obj : objs )
60 auto tObj =
dynamic_cast<const ObjectT*
>( obj.get() );
62 return std::string(
"Selected object(s) must have type: " ) + ObjectT::TypeName();
64 if constexpr ( modelCheck )
65 if ( !tObj->hasModel() )
66 return "Selected object(s) must have valid model";
68 if constexpr ( visualRepresentationCheck )
69 if ( !tObj->hasVisualRepresentation() )
70 return "Selected object(s) must have valid visual representation";
77template<
typename ObjectT,
bool visualRepresentationCheck,
bool modelCheck>
80 if ( objs.size() < n )
83 for (
const auto& obj : objs )
85 auto tObj =
dynamic_cast<const ObjectT*
>( obj.get() );
89 if constexpr ( modelCheck )
90 if ( !tObj->hasModel() )
93 if constexpr ( visualRepresentationCheck )
94 if ( !tObj->hasVisualRepresentation() )
104template<
unsigned N,
typename ObjectT,
typename =
void>
109 virtual std::string
isAvailable(
const std::vector<std::shared_ptr<const Object>>& objs )
const override
115template<
unsigned N,
typename ObjectT>
120 virtual std::string
isAvailable(
const std::vector<std::shared_ptr<const Object>>& objs )
const override
126template<
unsigned N,
typename ObjectT>
131 virtual std::string
isAvailable(
const std::vector<std::shared_ptr<const Object>>& objs )
const override
138template<
unsigned N,
typename ObjectT,
typename =
void>
143 virtual std::string
isAvailable(
const std::vector<std::shared_ptr<const Object>>& objs )
const override
149template<
unsigned N,
typename ObjectT>
154 virtual std::string
isAvailable(
const std::vector<std::shared_ptr<const Object>>& objs )
const override
160template<
unsigned N,
typename ObjectT>
165 virtual std::string
isAvailable(
const std::vector<std::shared_ptr<const Object>>& objs )
const override
172template<
typename ...Checks>
177 virtual std::string
isAvailable(
const std::vector<std::shared_ptr<const Object>>&objs )
const override
179 std::vector<std::string> checkRes;
180 checkRes.reserve(
sizeof...( Checks ) );
181 ( checkRes.push_back( Checks::isAvailable( objs ) ), ... );
182 std::string combinedRes;
183 for (
int i = 0; i < checkRes.size(); ++i )
185 if ( checkRes[i].empty() )
189 checkRes[i].front() = ( char )tolower( checkRes[i].front() );
191 combinedRes += checkRes[i];
192 if ( i + 1 < checkRes.size() )
193 combinedRes +=
" or ";
200template<
typename ...Checks>
205 virtual std::string
isAvailable(
const std::vector<std::shared_ptr<const Object>>& objs )
const override
207 std::vector<std::string> checkRes;
208 checkRes.reserve(
sizeof...( Checks ) );
209 ( checkRes.push_back( Checks::isAvailable( objs ) ), ... );
210 std::string combinedRes;
211 for (
int i = 0; i < checkRes.size(); ++i )
213 if ( checkRes[i].empty() )
216 if ( !combinedRes.empty() )
218 combinedRes +=
" and ";
219 checkRes[i].front() = ( char )tolower( checkRes[i].front() );
221 combinedRes += checkRes[i];
Definition MRISceneStateCheck.h:14
Definition MRSceneStateCheck.h:202
virtual std::string isAvailable(const std::vector< std::shared_ptr< const Object > > &objs) const override
Definition MRSceneStateCheck.h:205
virtual ~SceneStateAndCheck()=default
virtual ~SceneStateAtLeastCheck()=default
virtual std::string isAvailable(const std::vector< std::shared_ptr< const Object > > &objs) const override
Definition MRSceneStateCheck.h:165
virtual ~SceneStateAtLeastCheck()=default
virtual std::string isAvailable(const std::vector< std::shared_ptr< const Object > > &objs) const override
Definition MRSceneStateCheck.h:154
Definition MRSceneStateCheck.h:140
virtual std::string isAvailable(const std::vector< std::shared_ptr< const Object > > &objs) const override
Definition MRSceneStateCheck.h:143
virtual ~SceneStateAtLeastCheck()=default
virtual ~SceneStateExactCheck()=default
virtual std::string isAvailable(const std::vector< std::shared_ptr< const Object > > &objs) const override
Definition MRSceneStateCheck.h:131
virtual std::string isAvailable(const std::vector< std::shared_ptr< const Object > > &objs) const override
Definition MRSceneStateCheck.h:120
virtual ~SceneStateExactCheck()=default
Definition MRSceneStateCheck.h:106
virtual ~SceneStateExactCheck()=default
virtual std::string isAvailable(const std::vector< std::shared_ptr< const Object > > &objs) const override
Definition MRSceneStateCheck.h:109
Definition MRSceneStateCheck.h:174
virtual std::string isAvailable(const std::vector< std::shared_ptr< const Object > > &objs) const override
Definition MRSceneStateCheck.h:177
virtual ~SceneStateOrCheck()=default
Definition MRCameraOrientationPlugin.h:8
std::string getNObjectsLine(unsigned n)
Definition MRSceneStateCheck.h:16
std::string sceneSelectedExactly(const std::vector< std::shared_ptr< const Object > > &objs, unsigned n)
Definition MRSceneStateCheck.h:54
std::string sceneSelectedAtLeast(const std::vector< std::shared_ptr< const Object > > &objs, unsigned n)
Definition MRSceneStateCheck.h:78
Definition MRSceneStateCheck.h:13
Definition MRSceneStateCheck.h:10