File: main.cpp

package info (click to toggle)
aeskulap 0.2.2b1+git20161206-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,840 kB
  • ctags: 1,302
  • sloc: cpp: 8,894; sh: 5,551; ansic: 685; makefile: 317; xml: 25
file content (136 lines) | stat: -rw-r--r-- 3,275 bytes parent folder | download | duplicates (3)
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
/*
    Aeskulap - DICOM image viewer and network client
    Copyright (C) 2005  Alexander Pipelka

    This file is part of Aeskulap.

    Aeskulap 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 2 of the License, or
    (at your option) any later version.

    Aeskulap 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 Aeskulap; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

    Alexander Pipelka
*/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif // HAVE_CONFIG_H

#include "imagepool.h"
#include "mainwindow.h"

#include "aiconfactory.h"
#include "abusycursor.h"
#include "aconfiguration.h"

#include "binreloc.h"

#include <gtkmm.h>
#include <libglademm/xml.h>

#include <iostream>
#include "gettext.h"

int main(int argc, char* argv[]) {

	br_init(NULL);

	std::string datadir = br_find_data_dir(AESKULAP_DATADIR);

	std::cout << "datadir: " << datadir << std::endl;

	std::string localedir = datadir + "/locale";
	std::string gladedir = datadir + "/aeskulap/glade";

	bindtextdomain(GETTEXT_PACKAGE, localedir.c_str());
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
	textdomain(GETTEXT_PACKAGE);
 

	// initialize glib threads
	if(!Glib::thread_supported()) {
		Glib::thread_init();
	}

	// initialize DICOM interface
	ImagePool::init();

	// get configuration values
	Aeskulap::Configuration& config = Aeskulap::Configuration::get_instance();
	
	// set default DICOM encoding (characterset)
	ImagePool::set_encoding(config.get_encoding());

	Gtk::Main kit(argc, argv);

 	// set locale "C" for numeric conversion (strtod)
 
 	if(setlocale(LC_NUMERIC, "C") == NULL) {
		std::cout << "locale C failed" << std::endl;
	}
 
	Glib::RefPtr<Gnome::Glade::Xml> refXml;

	try  {
		refXml = Gnome::Glade::Xml::create(gladedir+"/aeskulap.glade");
	}
	catch(Gnome::Glade::XmlError) {	
		refXml = Gnome::Glade::Xml::create("aeskulap.glade");
	}

	Aeskulap::IconFactory aeskulap_icons;

	MainWindow* mainWindow = NULL;
	refXml->get_widget_derived("window_main", mainWindow);
	
	if(mainWindow == NULL) {
		exit(-1);
	}

	Aeskulap::set_mainwindow(mainWindow);

	mainWindow->maximize();
	mainWindow->show();

	std::list< Glib::ustring > list;
	for(int c=1; c<argc; c++) {
		if(argv[c][0] != '-') {
			list.push_back(argv[c]);
		}else{
		        if (!strcmp(argv[c], "--dicomdir") ||
			      !strcmp(argv[c], "-d")) {
			       if (c + 1 < argc) {
				       mainWindow->open_dicomdir(argv[c+1]);
				       ++c;
			       }else{
				       std::cerr << "option '" << argv[c]
						 << "' requires a parameters" << std::endl;
			       }
			}else{
			       std::cerr << "unknown option '" << argv[c] << "'given, ignoring"  << std::endl;  
			}
		}
	}
	
	if(list.size() > 0) {
		mainWindow->load_files(list);
		list.clear();
	}

	kit.run(*mainWindow);

	delete mainWindow;

	ImagePool::close();
	
	return 0;
}