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   try { myCTK.openDatabase( datbaseFileName ); }
00053   catch (std::exception e)
00054   {
00055     std::cerr << "Database error:" << qPrintable(myCTK.GetLastError());
00056     myCTK.closeDatabase();
00057     return EXIT_FAILURE;
00058   }
00059 
00060   try { myCTK.initializeDatabase(datbaseScriptFileName); }
00061   catch (std::exception e)
00062   {
00063     std::cerr << "Error when initializing the data base: " << datbaseScriptFileName
00064               << " error: " << myCTK.GetLastError().toStdString();
00065     return EXIT_FAILURE;
00066   }
00067 
00068   ctkDICOMModel model;
00069   model.setDatabase(myCTK.database());
00070   
00071   ctkDICOMQueryRetrieveWidget queryRetrieve;
00072   QTreeView *treeView = queryRetrieve.findChild<QTreeView *>("treeView");
00073   if (!treeView)
00074     {
00075     std::cerr << "Could not access tree view from QueryRetrieve widget\n";
00076     return EXIT_FAILURE;
00077     }
00078   treeView->setModel(&model);
00079 
00080   queryRetrieve.show();
00081   queryRetrieve.raise();
00082   return app.exec();
00083 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated on 21 May 2010 for CTK by  doxygen 1.6.1