ctkDICOM.cpp

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Library:   CTK
00004  
00005   Copyright (c) 2010  Kitware Inc.
00006 
00007   Licensed under the Apache License, Version 2.0 (the "License");
00008   you may not use this file except in compliance with the License.
00009   You may obtain a copy of the License at
00010 
00011       http://www.commontk.org/LICENSE
00012 
00013   Unless required by applicable law or agreed to in writing, software
00014   distributed under the License is distributed on an "AS IS" BASIS,
00015   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016   See the License for the specific language governing permissions and
00017   limitations under the License.
00018  
00019 =========================================================================*/
00020 
00021 // Qt includes
00022 #include <QApplication>
00023 #include <QTreeView>
00024 
00025 // CTK widget includes
00026 #include <ctkDICOMQueryRetrieveWidget.h>
00027 
00028 // ctkDICOMCore includes
00029 #include "ctkDICOM.h"
00030 #include "ctkDICOMModel.h"
00031 
00032 // STD includes
00033 #include <iostream>
00034 
00035 int main(int argc, char** argv)
00036 {
00037   QApplication app(argc, argv);
00038 
00039   // set up the database 
00040   const char *datbaseFileName = "/tmp/test.db";
00041   const char *datbaseScriptFileName = "/Users/pieper/ctk/latest/CTK/Libs/DICOM/Core/Resources/dicom-sample.sql";
00042   if (argc > 1)
00043     {
00044     datbaseFileName = argv[1];
00045     }
00046   if (argc > 2)
00047     {
00048     datbaseScriptFileName = argv[2];
00049     }
00050 
00051   ctkDICOM myCTK;
00052   if (!myCTK.openDatabase( datbaseFileName ))
00053     {
00054     std::cerr << "Error when opening the data base file: " << datbaseFileName
00055               << " error: " << myCTK.GetLastError().toStdString();
00056     return EXIT_FAILURE;
00057     }
00058   if (!myCTK.initializeDatabase(datbaseScriptFileName))
00059     {
00060     std::cerr << "Error when initializing the data base: " << datbaseScriptFileName
00061               << " error: " << myCTK.GetLastError().toStdString();
00062     return EXIT_FAILURE;
00063     }
00064 
00065   ctkDICOMModel model;
00066   model.setDatabase(myCTK.database());
00067   
00068   ctkDICOMQueryRetrieveWidget queryRetrieve;
00069   QTreeView *treeView = queryRetrieve.findChild<QTreeView *>("treeView");
00070   if (!treeView)
00071     {
00072     std::cerr << "Could not access tree view from QueryRetrieve widget\n";
00073     return EXIT_FAILURE;
00074     }
00075   treeView->setModel(&model);
00076 
00077   queryRetrieve.show();
00078   return app.exec();
00079 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines