forked from isis-group/vast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
187 lines (162 loc) · 7.56 KB
/
Copy pathmain.cpp
File metadata and controls
187 lines (162 loc) · 7.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/****************************************************************
*
* <Copyright information>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Author: Erik Tuerke, tuerke@cbs.mpg.de
*
* main.cpp
*
* Description:
*
* Created on: Aug 12, 2011
* Author: tuerke
******************************************************************/
#include <iostream>
#include <signal.h>
#include <Adapter/qtapplication.hpp>
#include <Adapter/qdefaultmessageprint.hpp>
#include <DataStorage/io_factory.hpp>
#include <CoreUtils/log.hpp>
#include "CoreUtils/singletons.hpp"
#include <DataStorage/image.hpp>
#include "viewer/pluginloader.hpp"
#include "viewer/qviewercore.hpp"
#include "viewer/color.hpp"
#include "viewer/uicore.hpp"
#include "viewer/widgetensemble.hpp"
#include "viewer/fileinformation.hpp"
#include "viewer/common.hpp"
#include "viewer/error.hpp"
#include "widgets/mainwindow.hpp"
#include "viewer/style.hpp"
int main( int argc, char *argv[] )
{
using namespace isis;
using namespace viewer;
signal( SIGSEGV, error::sigsegv );
std::string appName = "vast";
std::string orgName = "cbs.mpg.de";
QCoreApplication::setApplicationName( appName.c_str() );
QCoreApplication::setOrganizationName( orgName.c_str() );
//setting up vast graphics_system
#if QT_VERSION >= 0x040500
const char *graphics_system = getenv( "VAST_GRAPHICS_SYSTEM" );
LOG( Dev, info ) << "QT_VERSION >= 0x040500";
if( graphics_system && ( !strcmp( graphics_system, "raster" ) || !strcmp( graphics_system, "opengl" ) || !strcmp( graphics_system, "native" ) ) ) {
QApplication::setGraphicsSystem( graphics_system );
LOG( Dev, info ) << "Using graphics_system=\"" << std::string( graphics_system ) << "\"";
} else {
QApplication::setGraphicsSystem( "raster" );
LOG( Dev, info ) << "Using graphics_system=\"raster\"";
}
#else
std::cout << "Warning! Your Qt version is below Qt4.5. Not able to set graghics system." << std::endl;
LOG( Dev, warning ) << "QT_VERSION < 0x040500";
#endif
qt4::IOQtApplication app( appName.c_str(), false, false );
app.parameters["in"] = util::slist();
app.parameters["in"].needed() = false;
app.parameters["in"].setDescription( "The input image file list." );
app.parameters["zmap"] = util::slist();
app.parameters["zmap"].needed() = false;
app.parameters["zmap"].setDescription( "The input image file list is interpreted as statistical maps. " );
//alias to zmap
app.parameters["stats"] = util::slist();
app.parameters["stats"].needed() = false;
app.parameters["stats"].setDescription( "The input image file list is interpreted as statistical maps. " );
app.parameters["rf"] = std::string();
app.parameters["rf"].needed() = false;
app.parameters["rf"].setDescription( "Override automatic detection of file suffix for reading with given value" );
app.parameters["rf"].hidden() = true;
app.parameters["rdialect"] = std::string();
app.parameters["rdialect"].needed() = false;
app.parameters["rdialect"].hidden() = true;
app.parameters["rdialect"].setDescription( "Dialect for reading" );
app.parameters["split"] = false;
app.parameters["split"].needed() = false;
app.parameters["split"].setDescription( "Show each image in a separate view" );
app.parameters["widget"] = std::string();
app.parameters["widget"].needed() = false;
app.parameters["widget"].setDescription( "Use specific widget" );
app.init( argc, argv, false );
QViewerCore *core = new QViewerCore;
boost::shared_ptr<qt4::QDefaultMessagePrint> logging_hanlder_runtime ( new qt4::QDefaultMessagePrint( verbose_info ) );
boost::shared_ptr<qt4::QDefaultMessagePrint> logging_hanlder_dev ( new qt4::QDefaultMessagePrint( verbose_info ) );
util::_internal::Log<viewer::Dev>::setHandler( logging_hanlder_dev );
util::_internal::Log<viewer::Runtime>::setHandler( logging_hanlder_runtime );
//make vast showing qmessage if an error log is thrown
logging_hanlder_dev->qmessageBelow( isis::warning );
logging_hanlder_runtime->qmessageBelow( isis::warning );
//setting stylesheet
if ( core->getSettings()->getPropertyAs<bool>( "useStyleSheet" ) ) {
app.getQApplication().setStyleSheet( util::Singletons::get<style::Style, 10>().getStyleSheet( core->getSettings()->getPropertyAs<std::string>( "styleSheet" ) ) );
}
util::_internal::Log<isis::data::Runtime>::setHandler( logging_hanlder_runtime );
util::_internal::Log<isis::util::Runtime>::setHandler( logging_hanlder_runtime );
util::_internal::Log<isis::util::Debug>::setHandler( logging_hanlder_runtime );
util::_internal::Log<isis::data::Debug>::setHandler( logging_hanlder_runtime );
util::_internal::Log<isis::image_io::Runtime>::setHandler( logging_hanlder_runtime );
util::_internal::Log<isis::image_io::Debug>::setHandler( logging_hanlder_runtime );
core->addMessageHandler( logging_hanlder_runtime.get() );
core->addMessageHandlerDev( logging_hanlder_dev.get() );
//scan for plugins and hand them to the core
core->addPlugins( plugin::PluginLoader::get().getPlugins() );
core->getUICore()->reloadPluginsToGUI();
std::string widget_name = app.parameters["widget"];
if( widget_name.empty() ) {
if( core->getSettings()->getPropertyAs<bool>( "showImagesGeometricalView" ) && core->hasWidget( core->getSettings()->getPropertyAs<std::string>( "widgetGeometrical" ) ) ) {
widget_name = core->getSettings()->getPropertyAs<std::string>( "widgetGeometrical" );
} else if ( !core->getSettings()->getPropertyAs<bool>( "showImagesGeometricalView" ) && core->hasWidget( core->getSettings()->getPropertyAs<std::string>( "widgetLatched" ) ) ) {
widget_name = core->getSettings()->getPropertyAs<std::string>( "widgetLatched" );
} else {
widget_name = core->getSettings()->getPropertyAs<std::string>( "defaultViewWidgetIdentifier" );
}
}
if( !core->hasWidget( widget_name ) ) {
std::cerr << "Error loading widget!" << std::endl;
}
util::slist fileList = app.parameters["in"];
const bool zmapIsSet = app.parameters["zmap"].isSet() || app.parameters["stats"].isSet();
util::slist zmapFileList = app.parameters["zmap"];
if( !zmapFileList.size() ) {
zmapFileList = app.parameters["stats"];
}
if( zmapIsSet ) {
core->setMode( ViewerCoreBase::statistical_mode );
} else {
core->setMode( ViewerCoreBase::default_mode );
}
std::list<FileInformation> fileInfoList;
BOOST_FOREACH( util::slist::const_reference file, fileList ) {
fileInfoList.push_back( FileInformation( file,
app.parameters["rdialect"].as<std::string>().c_str(),
app.parameters["rf"].as<std::string>().c_str(),
widget_name,
ImageHolder::structural_image,
app.parameters["split"].as<bool>() ) );
}
BOOST_FOREACH( util::slist::const_reference file, zmapFileList ) {
fileInfoList.push_back( FileInformation( file,
app.parameters["rdialect"].as<std::string>().c_str(),
app.parameters["rf"].as<std::string>().c_str(),
widget_name,
ImageHolder::statistical_image,
app.parameters["split"].as<bool>() ) );
}
core->getUICore()->showMainWindow( fileInfoList );
return app.getQApplication().exec();
}