00001
00011
00012
00013 #ifndef IMEDGINE_CONTROLLER_H
00014 #define IMEDGINE_CONTROLLER_H
00015
00016 #include "data_view_mediator.h"
00017 #include "../datasets/dataset.h"
00018 #include "../viewer/view.h"
00019 #include "../datasets/data_io_factory.h"
00020
00021 #include "../algorithms/algorithm_factory.h"
00022 #include "../algorithms/algorithm_config.h"
00023 #include "../global/global_definitions.h"
00024 #include "../exceptions/null_pointer_exception.h"
00025 #include "../exceptions/algorithm_not_found_exception.h"
00026 #include "../exceptions/dataset_not_found_exception.h"
00027 #include "../exceptions/null_pointer_exception.h"
00028 #include "../exceptions/format_not_supported_exception.h"
00029 #include "../exceptions/invalid_cast_exception.h"
00030
00031 #include <boost/shared_ptr.hpp>
00032
00033 #include <memory>
00034 #include <string>
00035 #include <vector>
00036 #include <itkImage.h>
00037
00038 #include <QObject>
00039
00040 namespace imedgine
00041 {
00042
00043
00046
00047
00063
00064
00065 class Controller : public QObject
00066 {
00067 Q_OBJECT
00068
00069 public:
00070
00071
00074
00075 typedef std::string dataset_key_type;
00076
00077
00081
00082 static Controller& getInstance();
00083
00084
00089
00090 std::pair<dataset_key_type, dataset_type> loadDataset(std::string filename)
00091 throw(FormatNotSupportedException, NullPointerException);
00092
00093
00102
00103 void writeDataset(dataset_key_type dataset_key, std::string filename)
00104 throw(DatasetNotFoundException, FormatNotSupportedException);
00105
00106
00110
00111 bool removeDataset(dataset_key_type dataset_key);
00112
00113
00121
00122 std::string const& getDatasetFilename(dataset_key_type dataset_key)
00123 throw(DatasetNotFoundException);
00124
00125
00130
00131 void getLoadedDatasetKeys(std::vector<dataset_key_type>& key_container) const;
00132
00133
00141
00142 dataset_pointer_type getDataset(dataset_key_type dataset_key) const
00143 throw(DatasetNotFoundException);
00144
00145
00153
00154 metadata_pointer_type getMetadataFor(dataset_key_type dataset_key) const
00155 throw(DatasetNotFoundException, NullPointerException);
00156
00157
00161
00162 void getDatasetKeysOfType(dataset_type type,
00163 dataset_key_container_type& dataset_key_container)
00164 throw(NullPointerException);
00165
00166
00171
00172 void getDatasetKeysOfTypes(AlgorithmDefinition::accepted_datasets_type types,
00173 dataset_key_container_type& dataset_key_container)
00174 throw(NullPointerException);
00175
00176
00184
00185 view_pointer_type getViewOfDataset(
00186 view_type type, dataset_key_type dataset_key)
00187 throw(DatasetNotFoundException);
00188
00189
00196
00197 void getDependentViewIDsOfDataset(
00198 dataset_key_type dataset_key, view_id_container_type& target_container) const
00199 throw(DatasetNotFoundException, NullPointerException);
00200
00201
00213
00214 view_type getViewTypeForDatasetSlice(dataset_key_type dataset_key, slice_type slice)
00215 throw(DatasetNotFoundException);
00216
00217
00231
00232 slice_type getDatasetSliceForViewType(
00233 dataset_key_type dataset_key, view_type type)
00234 throw(DatasetNotFoundException);
00235
00236
00240
00241 void deleteViews(view_id_container_type view_ids)
00242 throw(NullPointerException);
00243
00244
00249
00250 void loadConfiguration(std::string config_file_name);
00251
00252
00257
00258 algorithm_name_container_type getLoadedAlgorithmNames() const;
00259
00260
00268
00269 AlgorithmConfig::algorithm_definition_pointer_type
00270 getAlgorithmDefinition(std::string name) const
00271 throw(AlgorithmNotFoundException);
00272
00273
00278
00279 void runAlgorithm(std::string key, configuration_pointer_type algorithm_config)
00280 throw(AlgorithmNotFoundException, NullPointerException);
00281
00282
00290
00291 config_widget_pointer_type createConfigWidget(
00292 std::string key) const
00293 throw(AlgorithmNotFoundException, NullPointerException);
00294
00295
00303
00304 configuration_pointer_type createConfiguration(std::string key) const
00305 throw(AlgorithmNotFoundException, NullPointerException);
00306
00307
00314
00315 void loadAlgorithm(std::string name)
00316 throw(AlgorithmNotFoundException);
00317
00318
00324
00325 bool isAlgorithmLoaded(std::string name);
00326
00327
00335
00336 metadata_pointer_type getMetadataForDataset(std::string dataset_key) const
00337 throw(DatasetNotFoundException, NullPointerException);
00338
00339
00343
00344 void setGuiInteractionMode(gui_interaction_mode_type gui_interaction_mode);
00345
00346
00350
00351 gui_interaction_mode_type getGuiInteractionMode();
00352
00353
00367
00368 void setInputDatasetsInConfiguration(configuration_pointer_type configuration,
00369 config_dataset_id_to_input_map_type input_datasets,
00370 std::map<config_dataset_id_type, std::pair<dataset_key_type, dataset_type> >&
00371 new_dataset_keys_and_types)
00372 throw(NullPointerException, DatasetNotFoundException, InvalidCastException);
00373
00374
00387
00388 void setOutputDatasetsInConfiguration(configuration_pointer_type configuration,
00389 config_dataset_id_to_output_map_type output_datasets,
00390 std::map<config_dataset_id_type, std::pair<dataset_key_type, dataset_type> >&
00391 new_dataset_keys_and_types)
00392 throw(NullPointerException);
00393
00394 public slots:
00395
00396
00402 void datasetChangedSlot(dataset_key_type const& dataset_key);
00403
00404 private:
00405
00406
00409
00410 Controller();
00411
00412
00415
00416 ~Controller();
00417
00418
00421
00422 Controller( const Controller& );
00423
00424
00427
00428 Controller& operator=( const Controller& );
00429
00430
00435
00436 std::string extractExtension(std::string filename) const;
00437
00438
00443
00444 dataset_key_type generateDatasetKeyFromFilename(
00445 std::string filename) const;
00446
00447
00448
00452
00453 void makeDatasetKeyUnique(dataset_key_type& key) const;
00454
00455
00461
00462 slice_type datasetPartToSliceType(dataset_part_type dataset_part);
00463
00464 typedef std::map<dataset_key_type, dataset_pointer_type>
00465 dataset_pointer_map_type;
00466 typedef dataset_pointer_map_type::iterator
00467 dataset_pointer_map_iterator_type;
00468 typedef dataset_pointer_map_type::const_iterator
00469 dataset_pointer_map_const_iterator_type;
00470 typedef std::map<dataset_key_type, std::string> dataset_filename_map_type;
00471 typedef dataset_filename_map_type::const_iterator
00472 dataset_filename_map_const_iterator_type;
00473
00474
00478 DataIOFactory data_io_factory_;
00479
00480
00484 AlgorithmConfig::algorithm_config_pointer_type algorithm_config_;
00485
00486
00490 AlgorithmFactory algorithm_factory_;
00491
00492
00496 dataset_pointer_map_type dataset_pointer_map_;
00497
00498
00503 dataset_filename_map_type dataset_filename_map_;
00504
00505
00508 DataViewMediator data_view_mediator_;
00509
00510
00513 gui_interaction_mode_type gui_interaction_mode_;
00514 };
00515 }
00516
00517 #endif // IMEDGINE_CONTROLLER_H