#=========================================================
# CLITK = Command Line ITK
-cmake_minimum_required(VERSION 2.4)
-cmake_policy(VERSION 2.4)
+cmake_minimum_required(VERSION 2.8)
+cmake_policy(VERSION 2.8)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
INCLUDE(cmake/common.cmake)
#=========================================================
+#=========================================================
+#Support for the CTest dashboard testing system
+OPTION(BUILD_TESTING "Build the testing tree" OFF)
+IF (BUILD_TESTING)
+ OPTION(CLITK_BUILD_TESTING "Test ITK" ON)
+ INCLUDE(CTest)
+ENDIF(BUILD_TESTING)
+#=========================================================
+
#=========================================================
# Find ITK (required)
FIND_PACKAGE(ITK)
# Select what is compiled
ADD_SUBDIRECTORY(common)
-add_subdirectory(tools)
-add_subdirectory(segmentation)
-add_subdirectory(registration)
+ADD_SUBDIRECTORY(tools)
+ADD_SUBDIRECTORY(segmentation)
+ADD_SUBDIRECTORY(registration)
# Compilation options
#=========================================================
-#Support for the CTest dashboard testing system
-OPTION(CLITK_BUILD_TESTING "Build the testing tree" OFF)
-#=========================================================
-IF (CLITK_BUILD_TESTING)
- ENABLE_TESTING()
+# Build test when vv has been compiled
+IF(BUILD_TESTING)
ADD_SUBDIRECTORY(tests)
-ENDIF(CLITK_BUILD_TESTING)
-#=========================================================
-
-
-#=========================================================
-
+ENDIF(BUILD_TESTING)
-set(CTEST_PROJECT_NAME "vv_itk4")
-set(CTEST_NIGHTLY_START_TIME "1:00:00 UTC")
-
-set(CTEST_DROP_METHOD "http")
-set(CTEST_DROP_SITE "www.cdash.org")
-set(CTEST_DROP_LOCATION "/CDash/submit.php?project=Insight")
+SET(CTEST_PROJECT_NAME "vv")
+SET(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
set(CTEST_DROP_SITE_CDASH TRUE)
+IF(NOT DEFINED CTEST_DROP_METHOD)
+ SET(CTEST_DROP_METHOD "http")
+ENDIF(NOT DEFINED CTEST_DROP_METHOD)
+
+IF(CTEST_DROP_METHOD STREQUAL "http")
+ SET(CTEST_DROP_SITE "localhost")
+ SET(CTEST_DROP_LOCATION "/cdash/submit.php?project=vv")
+ SET(CTEST_TRIGGER_SITE "")
+ENDIF(CTEST_DROP_METHOD STREQUAL "http")
--- /dev/null
+# This file is configured by CMake automatically as DartConfiguration.tcl
+# If you choose not to use CMake, this file may be hand configured, by
+# filling in the required variables.
+
+
+# Configuration directories and files
+SourceDirectory: /home/mpech/workspace/vvSource
+BuildDirectory: /home/mpech/workspace/vvSource
+
+# Where to place the cost data store
+CostDataFile:
+
+# Site is something like machine.domain, i.e. pragmatic.crd
+Site: russule
+
+# Build name is osname-revision-compiler, i.e. Linux-2.4.2-2smp-c++
+BuildName: Linux-c++
+
+# Submission information
+IsCDash: TRUE
+CDashVersion:
+QueryCDashVersion:
+DropSite: localhost
+DropLocation: /cdash/submit.php?project=vv
+DropSiteUser:
+DropSitePassword:
+DropSiteMode:
+DropMethod: http
+TriggerSite:
+ScpCommand: /usr/bin/scp
+
+# Dashboard start time
+NightlyStartTime: 00:00:00 EST
+
+# Commands for the build/test/submit cycle
+ConfigureCommand: "/usr/bin/cmake" "/home/mpech/workspace/vvSource"
+MakeCommand: /usr/bin/gmake -i
+DefaultCTestConfigurationType: Release
+
+# CVS options
+# Default is "-d -P -A"
+CVSCommand: /usr/bin/cvs
+CVSUpdateOptions: -d -A -P
+
+# Subversion options
+SVNCommand: /usr/bin/svn
+SVNUpdateOptions:
+
+# Git options
+GITCommand: /usr/bin/git
+GITUpdateOptions:
+GITUpdateCustom:
+
+# Generic update command
+UpdateCommand: /usr/bin/git
+UpdateOptions:
+UpdateType: git
+
+# Compiler info
+Compiler: /usr/bin/c++
+
+# Dynamic analysis and coverage
+PurifyCommand:
+ValgrindCommand:
+ValgrindCommandOptions:
+MemoryCheckCommand: MEMORYCHECK_COMMAND-NOTFOUND
+MemoryCheckCommandOptions:
+MemoryCheckSuppressionFile:
+CoverageCommand: /usr/bin/gcov
+
+# Cluster commands
+SlurmBatchCommand: SLURM_SBATCH_COMMAND-NOTFOUND
+SlurmRunCommand: SLURM_SRUN_COMMAND-NOTFOUND
+
+# Testing options
+# TimeOut is the amount of time in seconds to wait for processes
+# to complete during testing. After TimeOut seconds, the
+# process will be summarily terminated.
+# Currently set to 25 minutes
+TimeOut: 1500
+
+UseLaunchers:
+CurlOptions:
+# warning, if you add new options here that have to do with submit,
+# you have to update cmCTestSubmitCommand.cxx
+
+# For CTest submissions that timeout, these options
+# specify behavior for retrying the submission
+CTestSubmitRetryDelay: 5
+CTestSubmitRetryCount: 3
#ADD_LIBRARY(clitkCommonShared SHARED ${clitkCommon_SRC})
#SET_TARGET_PROPERTIES(clitkCommonShared PROPERTIES COMPILE_FLAGS -fPIC)
+
+#passing environnment variable
+configure_file (
+ globals.h.in
+ globals.h
+)
--- /dev/null
+#define OS_NAME "@CMAKE_SYSTEM@"
+
\ No newline at end of file
-# Tests are organized to mirror the clitk directory tree.
-# Eacho subdirectory has its own CMakeLists.txt with the compiling directives
+macro(ADD_GOOGLE_TESTS executable)
+ foreach ( source ${ARGN} )
+ file(READ "${source}" contents)
+ string(REGEX MATCHALL "TEST_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
+ foreach(hit ${found_tests})
+ string(REGEX REPLACE ".*\\(([A-Za-z_0-9]+)[, ]*([A-Za-z_0-9]+)\\).*" "\\1.\\2" test_name ${hit})
+ add_test(${test_name} ${executable} --gtest_filter=${test_name})
+ endforeach(hit)
+ endforeach()
+endmacro()
+SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/tests/bin)
+SET(BUILDNAME ${CMAKE_SYSTEM_NAME}${CMAKE_OSX_ARCHITECTURES} CACHE INTERNAL DOCSTRING)
+SET(CLITK_DATA_PATH ${PROJECT_BINARY_DIR}/tests/data/ CACHE STRING "dataTest path")
+#todo test if data test path exists
-IF (CLITK_BUILD_TESTING)
+ADD_DEFINITIONS(-DCLITK_DATA_PATH=\"${CLITK_DATA_PATH}\")
- set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/tests/bin)
-
- # default data path is searched in the project source tree
- FIND_PATH(CLITK_DATA_PATH data PATHS ${PROJECT_SOURCE_DIR})
- IF (CLITK_DATA_PATH STREQUAL "CLITK_DATA_PATH-NOTFOUND" OR CLITK_DATA_PATH STREQUAL "")
- MESSAGE("Data path must be given when tests are enabled.")
- ENDIF (CLITK_DATA_PATH STREQUAL "CLITK_DATA_PATH-NOTFOUND" OR CLITK_DATA_PATH STREQUAL "")
-
- set(CLITK_DATA_PATH ${CLITK_DATA_PATH}/data)
- ADD_DEFINITIONS(-DCLITK_DATA_PATH='"${CLITK_DATA_PATH}"')
+add_library(gtest UNKNOWN IMPORTED)
+set(GTEST_DIR ${ITK_DIR}/../gtest/ CACHE STRING "gtestDir")
+#if windows gtestLibName=gtest.dll else libgtest.a
+set(gtestLibName libgtest.a)
+set(GTEST_LIB ${GTEST_DIR}/build/${gtestLibName})
+message(gtestlib name = ${GTEST_LIB})
+set_property(TARGET gtest PROPERTY IMPORTED_LOCATION "${GTEST_LIB}")
+include_directories(${GTEST_DIR}/include/)
+IF(CLITK_BUILD_TOOLS)
ADD_SUBDIRECTORY(tools)
- #ADD_SUBDIRECTORY(segmentation)
- #ADD_SUBDIRECTORY(registration)
- #ADD_SUBDIRECTORY(common)
+ENDIF()
+IF(CLITK_BUILD_VV)
+ ADD_SUBDIRECTORY(vv)
+ENDIF()
+# ADD_SUBDIRECTORY(segmentation)
+# ADD_SUBDIRECTORY(registration)
+# ADD_SUBDIRECTORY(common)
+
-ENDIF(CLITK_BUILD_TESTING)
-# Add test apps and test executions to this part
-# Test apps are compiled as any other app in the
-# project. Test executions are run using "make test"
-#
-IF(CLITK_BUILD_TESTING)
+include_directories(
+ ${PROJECT_SOURCE_DIR}/common
+ ${PROJECT_SOURCE_DIR}/tools
+ ${GTEST_DIR}/include
+)
- # clitkImageInfo
- ADD_EXECUTABLE(clitkImageInfoTest clitkImageInfoTest.cxx)
- TARGET_LINK_LIBRARIES(clitkImageInfoTest ITKIO)
- ADD_TEST(NAME clitkImageInfoTest COMMAND clitkImageInfoTest)
+FILE(GLOB srcs *.cxx)
+ADD_EXECUTABLE(toolsTest ${srcs})
+ADD_DEFINITIONS(-DTOOLS_PATH=\"${PROJECT_BINARY_DIR}/bin/\")
+target_link_libraries(toolsTest vvLib ${vvExternalLibs} gtest)
- # clitkWriteDicomSeries
- ADD_EXECUTABLE(clitkWriteDicomSeriesTest clitkWriteDicomSeriesTest.cxx)
- TARGET_LINK_LIBRARIES(clitkWriteDicomSeriesTest ITKIO)
- ADD_TEST(NAME clitkWriteDicomSeriesTest COMMAND clitkWriteDicomSeriesTest)
-
-ENDIF(CLITK_BUILD_TESTING)
+# Add all tests found in the source code, calling the executable to run them
+add_google_tests ( ${EXECUTABLE_OUTPUT_PATH}/toolsTest ${srcs})
+SET(BUILDNAME ${BUILDNAME}_tools CACHE INTERNAL DOCSTRING)
\ No newline at end of file
- BSD See included LICENSE.txt file
- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
===========================================================================*/
-#include <cstdlib>
-#include <cstdio>
-
#include <iostream>
#include <sstream>
#include <string>
-
+#include <fstream>
+#include "gtest/gtest.h"
+#include "stdio.h"
#include <itksys/SystemTools.hxx>
-
-
-const size_t NUMTESTS=2;
-
-// test files
-const char mhd_files[NUMTESTS][128] = {
- CLITK_DATA_PATH"/4d/mhd/00.mhd",
- CLITK_DATA_PATH"/4d/mhd/bh.mhd"
-};
-
-// pre-written validation files. the idea
-// is that the output generated from the test
-// files match the verification files
-const char validation_files[NUMTESTS][128] = {
- CLITK_DATA_PATH"/tools/clitkImageInfoTestValidate3D.out",
- CLITK_DATA_PATH"/tools/clitkImageInfoTestValidate4D.out"
-};
-
-int main(int argc, char** argv)
-{
- system("pwd");
+static inline void compare(std::string mhd, std::string ref){
+ std::ostringstream cmd_line;
+ ASSERT_TRUE(itksys::SystemTools::FileExists(mhd.c_str(), true));
+ cmd_line << TOOLS_PATH<<"clitkImageInfo " << mhd << " > clitkImageInfoTest.out";
+ std::cout << "Executing " << cmd_line.str() << std::endl;
+ system(cmd_line.str().c_str());
- bool failed = false;
- for (size_t i = 0; i < NUMTESTS; i++) {
- std::ostringstream cmd_line;
- cmd_line << "clitkImageInfo " << mhd_files[i] << " > clitkImageInfoTest.out";
-
- std::cout << "Executing " << cmd_line.str() << std::endl;
- system(cmd_line.str().c_str());
-
- // compare output with validation file
- std::cout << "Validating output against " << validation_files[i] << std::endl;
- bool differ = itksys::SystemTools::FilesDiffer("clitkImageInfoTest.out", validation_files[i]);
- if (differ)
- {
- failed = true;
- std::cout << "FAILED: Program output and reference do not match." << std::endl;
- }
- else
- {
- itksys::SystemTools::RemoveFile("clitkImageInfoTest.out");
- std::cout << "PASSED" << std::endl;
- }
- }
- return failed ? -1 : 0;
+ bool differ = itksys::SystemTools::FilesDiffer("clitkImageInfoTest.out", ref.c_str());
+ remove("clitkImageInfoTest.out");
+ EXPECT_FALSE(differ);
+}
+TEST(clitkImageInfoTest, main){
+ std::string mhd1=std::string(CLITK_DATA_PATH)+"4d/mhd/00.mhd";
+ std::string ref1=std::string(CLITK_DATA_PATH)+"tools/clitkImageInfoTestValidate3D.out";
+ compare(mhd1, ref1);
+
+ std::string mhd2=std::string(CLITK_DATA_PATH)+"4d/mhd/bh.mhd";
+ std::string ref2=std::string(CLITK_DATA_PATH)+"tools/clitkImageInfoTestValidate4D.out";
+ compare(mhd2, ref2);
}
\ No newline at end of file
- BSD See included LICENSE.txt file
- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
===========================================================================*/
-#include <cstdlib>
-#include <cstdio>
-
#include <iostream>
#include <sstream>
-#include <cassert>
-
+#include "gtest/gtest.h"
#include <itksys/SystemTools.hxx>
-
-const size_t NUMTESTS=1;
-
-const char mhd_files[NUMTESTS][128] = {
- CLITK_DATA_PATH"/3d/mhd/00.mhd"
-};
-
-const char dcm_dirs[NUMTESTS][128] = {
- CLITK_DATA_PATH"/3d/dcm/1.2.840.113704.1.111.536.1248695032.26"
-};
-
-int main(int argc, char** argv)
-{
- bool failed = false;
- for (size_t i = 0; i < NUMTESTS; i++) {
- std::ostringstream cmd_line;
- cmd_line << "clitkWriteDicomSeries -i " << mhd_files[i] << " -d " << dcm_dirs[i] << " -o dcm --verbose";
-
- std::cout << "Executing " << cmd_line.str() << std::endl;
- int err = system(cmd_line.str().c_str());
- if (err != 0)
- {
- failed = true;
- std::cout << "FAILED (errno = " << err << ")" << std::endl;
- }
- else
- {
- itksys::SystemTools::RemoveADirectory("dcm");
- std::cout << "PASSED" << std::endl;
- }
- }
- return failed ? -1 : 0;
+TEST(clitkWriteDicomSeriesTest, main){
+
+ std::string fIn=std::string(CLITK_DATA_PATH)+"/3d/mhd/00.mhd";
+ std::string fOut=std::string(CLITK_DATA_PATH)+"/3d/dcm/1.2.840.113704.1.111.536.1248695032.26";
+ ASSERT_TRUE(itksys::SystemTools::FileExists(fIn.c_str(), true));
+ std::ostringstream cmd_line;
+ cmd_line << TOOLS_PATH <<"clitkWriteDicomSeries -i " << fIn << " -d " << fOut << " -o dcm --verbose";
+ EXPECT_TRUE(itksys::SystemTools::FileExists(fOut.c_str(), false));
+ EXPECT_TRUE(itksys::SystemTools::FileExists("dcm", false));
+ EXPECT_EQ(0, system(cmd_line.str().c_str()));
+ //does directory exists
+ itksys::SystemTools::RemoveADirectory("dcm");
}
\ No newline at end of file
--- /dev/null
+#include "gtest/gtest.h"
+int main(int argc, char** argv){
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+include_directories(
+ ${PROJECT_SOURCE_DIR}/vv
+ ${PROJECT_BINARY_DIR}/vv
+ ${QT_INCLUDES}
+ ${QT_INCLUDE_DIR}
+ ${QT_QTGUI_INCLUDE_DIR}
+ ${QT_QTCORE_INCLUDE_DIR}
+ ${QT_QTNETWORK_INCLUDE_DIR}
+ ${PROJECT_SOURCE_DIR}/common
+ ${PROJECT_SOURCE_DIR}/tools
+ ${PROJECT_SOURCE_DIR}/segmentation
+ ${QT_LIBRARY_DIR}
+ ${GTEST_DIR}/include
+)
+
+FILE(GLOB srcs *.cxx)
+ADD_EXECUTABLE(vvTest ${srcs})
+target_link_libraries(vvTest vvLib ${vvExternalLibs} gtest)
+
+# Add all tests found in the source code, calling the executable to run them
+add_google_tests ( ${EXECUTABLE_OUTPUT_PATH}/vvTest ${srcs})
+SET(BUILDNAME ${BUILDNAME}_vv CACHE INTERNAL DOCSTRING)
--- /dev/null
+#include "gtest/gtest.h"
+#include <iostream>
+#include <QApplication>
+int main(int argc, char** argv){
+ QApplication* q=new QApplication ( argc, argv );
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================*/
+#include "vvRegisterForm.h"
+#include <QUrl>
+#include <QSettings>
+#include "gtest/gtest.h"
+#include "vvCommon.h"
+#include <stdio.h>
+#include <fstream>
+const std::string data_path = "/home/mpech/workspace/vvSource/tests/data/";
+TEST(vvRegisterForm, canPush){
+ QUrl url;
+ //the file exists with some old lines
+ vvRegisterForm* v=new vvRegisterForm(url, QString::fromStdString(data_path+".settingsCanPush.txt"), QSettings::NativeFormat);
+ std::ifstream inFile((data_path+".settingsCanPush.txt").c_str(), std::ifstream::in);
+ ASSERT_FALSE(inFile.fail());
+ EXPECT_TRUE(v->canPush());
+
+ //the file doesn't exist
+ vvRegisterForm* v2=new vvRegisterForm(url, QString::fromStdString(data_path+".settings_notFound.txt"), QSettings::NativeFormat);
+ EXPECT_TRUE(v2->canPush());
+
+ //the current version is the same
+ QString strSettings=QString::fromStdString(data_path+".settings2.txt");
+ QSettings settings(strSettings, QSettings::NativeFormat);
+ settings.setValue("vvVersion", VV_VERSION);
+ vvRegisterForm* v3=new vvRegisterForm(url, strSettings, QSettings::NativeFormat);
+ EXPECT_FALSE(v3->canPush());
+}
+TEST(vvRegisterForm, acquitPushed){
+ QUrl url;
+ vvRegisterForm* v=new vvRegisterForm(url, QString::fromStdString(data_path+".settingsAcquit.txt"), QSettings::NativeFormat);
+ ASSERT_TRUE(v->canPush());
+ v->acquitPushed();
+ EXPECT_FALSE(v->canPush());
+ remove((data_path+".settingsAcquit.txt").c_str());
+}
endif(COMMAND cmake_policy)
#=========================================================
+
#=========================================================
#List of vv tools to compile
SET(vv_TOOLS
vvToolSimpleInputSelectorWidget
vvToolInputSelectorWidget
vvToolStructureSetManager
+ vvRegisterForm
)
# All others sources
vvStructureSetActor.h
vvROIActor.h
vvToolCreatorBase.h
+ vvRegisterForm.h
)
QT4_WRAP_UI(vv_UI_CXX
qt_ui/vvHelpDialog.ui
+ qt_ui/vvRegisterForm.ui
qt_ui/vvDocumentation.ui
qt_ui/vvDicomSeriesSelector.ui
qt_ui/vvDummyWindow.ui #For testing
QT4_WRAP_CPP(vv_SRCS ${tool}.h)
QT4_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui)
endforeach(tool)
-
#Add the common source files
foreach(tool ${vv_COMMON})
SET(vv_SRCS ${vv_SRCS} ${tool}.cxx)
QT4_WRAP_CPP(vv_SRCS ${tool}.h)
endforeach(tool)
-
# if Windows and Qt was built as a static lib then don't set QT_DLL flag
SET(QT_STATIC 0)
IF (WIN32)
ENDIF(WIN32)
LINK_DIRECTORIES(${QT_LIBRARY_DIR})
-ADD_EXECUTABLE(vv ${vv_SRCS} vv.cxx ${vv_UI_CXX} ${EXE_ICON})
-ADD_DEPENDENCIES(vv clitkSegmentationGgoLib)
-TARGET_LINK_LIBRARIES(vv clitkDicomRTStruct)
-
#=========================================================
#Add each tool's dependencies
foreach(tool ${vv_TOOLS})
- target_link_libraries(vv ${${tool}_LIBS})
+ SET(toolLibs ${toolLibs} ${${tool}_LIBS})
endforeach(tool)
-
#=========================================================
#Add Foundation Libraries (this should be after our libraries, since we depend
#on them)
-TARGET_LINK_LIBRARIES(vv
-clitkCommon ${ITK_LIBRARIES} QVTK vtkHybrid)
+SET(foundationLibraries clitkCommon ${ITK_LIBRARIES} QVTK vtkHybrid)
+#=========================================================
+#Create binary and libs for tests
+SET(vvExternalLibs clitkSegmentationGgoLib clitkDicomRTStruct ${toolLibs} ${foundationLibraries} CACHE INTERNAL DOCSTRING)
+ADD_EXECUTABLE(vv ${vv_SRCS} vv.cxx ${vv_UI_CXX} ${EXE_ICON})
+ADD_DEPENDENCIES(vv clitkSegmentationGgoLib)
+IF(BUILD_TESTING)
+ target_link_libraries(vv ${vvExternalLibs})
+ add_library(vvLib ${vv_SRCS} vv.cxx ${vv_UI_CXX} ${EXE_ICON})
+ENDIF(BUILD_TESTING)
#=========================================================
# Install options (also used by CPack)
IF(UNIX AND NOT APPLE)
ENDIF(WIN32)
INCLUDE(CPack)
#=========================================================
+#=========================================================
+configure_file(vvCommon.h.in vvCommon.h)
+#=========================================================
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvRegisterForm</class>
+ <widget class="QDialog" name="vvRegisterForm">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>389</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>260</y>
+ <width>341</width>
+ <height>32</height>
+ </rect>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="firstName">
+ <property name="geometry">
+ <rect>
+ <x>110</x>
+ <y>150</y>
+ <width>241</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>150</y>
+ <width>71</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>First name</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_2">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>170</y>
+ <width>71</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Last name</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="lastName">
+ <property name="geometry">
+ <rect>
+ <x>110</x>
+ <y>170</y>
+ <width>241</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="email">
+ <property name="geometry">
+ <rect>
+ <x>110</x>
+ <y>190</y>
+ <width>241</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="group">
+ <property name="geometry">
+ <rect>
+ <x>110</x>
+ <y>210</y>
+ <width>241</width>
+ <height>21</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_3">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>190</y>
+ <width>71</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Email</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_4">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>210</y>
+ <width>71</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Institute</string>
+ </property>
+ </widget>
+ <widget class="QTextBrowser" name="textBrowser">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>10</y>
+ <width>311</width>
+ <height>121</height>
+ </rect>
+ </property>
+ <property name="html">
+ <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Thank you for using vv!</p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">We would like to know more about our vv users. Those informations are private and will not be shared to any other society.</p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The data which will be sent are the facultative input to fill below, and the operating system name.</p></body></html></string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_5">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>240</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>OS name</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="osName">
+ <property name="geometry">
+ <rect>
+ <x>110</x>
+ <y>240</y>
+ <width>241</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>OS name</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>vvRegisterForm</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>vvRegisterForm</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
--- /dev/null
+#define VV_VERSION "v@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@"
+
\ No newline at end of file
#include <QInputDialog>
#include <QTimer>
#include "QTreePushButton.h"
+#include <QUrl>
+#include <QSettings>
// VV include
#include "vvMainWindow.h"
#include "vvHelpDialog.h"
+#include "vvRegisterForm.h"
#include "vvDocumentation.h"
#include "vvProgressDialog.h"
#include "vvQDicomSeriesSelector.h"
//Recently opened files
std::list<std::string> recent_files = GetRecentlyOpenedImages();
+ recentlyOpenedFilesMenu=NULL;
if ( !recent_files.empty() ) {
- QMenu * rmenu = new QMenu("Recently opened files...");
- rmenu->setIcon(QIcon(QString::fromUtf8(":/common/icons/open.png")));
- menuFile->insertMenu(actionOpen_Image_With_Time,rmenu);
- menuFile->insertSeparator(actionOpen_Image_With_Time);
- for (std::list<std::string>::iterator i = recent_files.begin(); i!=recent_files.end(); i++) {
- QAction* current=new QAction(QIcon(QString::fromUtf8(":/common/icons/open.png")),
- (*i).c_str(),this);
- rmenu->addAction(current);
- connect(current,SIGNAL(triggered()),this,SLOT(OpenRecentImage()));
- }
+ createRecentlyOpenedFilesMenu();
+ updateRecentlyOpenedFilesMenu(recent_files);
}
// Adding all new tools (insertion in the menu)
//timerMemory->setInterval(5);
connect(timerMemory, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage()));
timerMemory->start(2000);
-
}
//------------------------------------------------------------------------------
-
+void vvMainWindow::show(){
+ vvMainWindowBase::show();
+ vvRegisterForm* registerForm = new vvRegisterForm(QUrl("http://localhost/vvregister/write.php"), getVVSettingsPath(), getSettingsOptionFormat());
+ if(registerForm->canPush()){
+ registerForm->show();
+ registerForm->acquitPushed();//too bad if there is not internet connection anymore.
+ }
+}
//------------------------------------------------------------------------------
void vvMainWindow::UpdateMemoryUsage()
{
//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+void vvMainWindow::createRecentlyOpenedFilesMenu()
+{
+ recentlyOpenedFilesMenu = new QMenu("Recently opened files...");
+ recentlyOpenedFilesMenu->setIcon(QIcon(QString::fromUtf8(":/common/icons/open.png")));
+ menuFile->insertMenu(actionOpen_Image_With_Time,recentlyOpenedFilesMenu);
+ menuFile->insertSeparator(actionOpen_Image_With_Time);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+
+void vvMainWindow::updateRecentlyOpenedFilesMenu(const std::list<std::string> &recent_files)
+{
+ if(recentlyOpenedFilesMenu==NULL){
+ createRecentlyOpenedFilesMenu();
+ }else{
+ recentlyOpenedFilesMenu->clear();
+ }
+ for (std::list<std::string>::const_iterator i = recent_files.begin(); i!=recent_files.end(); i++) {
+ QAction* current=new QAction(QIcon(QString::fromUtf8(":/common/icons/open.png")), i->c_str(),this);
+ recentlyOpenedFilesMenu->addAction(current);
+ connect(current,SIGNAL(triggered()),this,SLOT(OpenRecentImage()));
+ }
+}
+//------------------------------------------------------------------------------
+
+
//------------------------------------------------------------------------------
void vvMainWindow::ComputeMidPosition()
{
if (files.size() == 1) {
QFileInfo finfo=tr(files[0].c_str());
AddToRecentlyOpenedImages(finfo.absoluteFilePath().toStdString());
+ updateRecentlyOpenedFilesMenu(GetRecentlyOpenedImages());
}
//init the progress events
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
}
void UpdateRenderWindows();
void UpdateMemoryUsage();
-
+ void show();
+
+protected:
+
+ void createRecentlyOpenedFilesMenu();
+ void updateRecentlyOpenedFilesMenu(const std::list<std::string> &files);
+
private:
//variables
int GetImageDuplicateFilenameNumber(std::string filename);
QMenu contextMenu;
+ QMenu* recentlyOpenedFilesMenu;
//QMenu *AddSubImageMenu;
std::vector<QAction*> contextActions;
std::vector<QSlider*> horizontalSliders;
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+#include <QApplication>
+
+#include "vvRegisterForm.h"
+#include <QNetworkRequest>
+#include <QDir>
+#include "common/globals.h"
+#include "vvCommon.h"
+#include "vvUtils.h"
+
+vvRegisterForm::vvRegisterForm(QUrl url, QString path, QSettings::Format format):url(url), settings(path, format){
+ manager = new QNetworkAccessManager(this);
+ setupUi(this);
+}
+
+void vvRegisterForm::sendData(){
+ QUrl url2(url);
+ url2.addQueryItem("name", firstName->text().toUtf8());
+ url2.addQueryItem("lastName", lastName->text().toUtf8());
+ url2.addQueryItem("email", email->text().toUtf8());
+ url2.addQueryItem("group", group->text().toUtf8());
+ url2.addQueryItem("os", osName->text().toUtf8());
+ url2.addQueryItem("vvVersion", VV_VERSION);
+ manager->get(QNetworkRequest(url2));
+}
+void vvRegisterForm::accept(){
+ sendData();
+ settings.setValue("name", firstName->text().toUtf8());
+ settings.setValue("lastName", lastName->text().toUtf8());
+ settings.setValue("email", email->text().toUtf8());
+ settings.setValue("group", group->text().toUtf8());
+ settings.setValue("os", osName->text().toUtf8());
+ QDialog::accept();
+}
+bool vvRegisterForm::canPush(){
+ ///maybe we show this dialog only for new major release, not for any patches?
+ return settings.value("vvVersion").toString().toStdString()<VV_VERSION;
+}
+void vvRegisterForm::acquitPushed(){
+ settings.setValue("vvVersion", VV_VERSION);
+}
+void vvRegisterForm::show(){
+ firstName->setText(settings.value("name").toString());
+ lastName->setText(settings.value("lastName").toString());
+ email->setText(settings.value("email").toString());
+ group->setText(settings.value("group").toString());
+
+ osName->setText(QString::fromStdString(OS_NAME));
+ QDialog::show();
+}
\ No newline at end of file
--- /dev/null
+/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
+
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://www.centreleonberard.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the copyright notices for more information.
+
+ It is distributed under dual licence
+
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
+#ifndef vvRegisterForm_h
+#define vvRegisterForm_h
+
+#include "ui_vvRegisterForm.h"
+#include <QUrl>
+#include <QSettings>
+#include <QNetworkAccessManager>
+class vvRegisterForm : public QDialog, private Ui::vvRegisterForm
+{
+ Q_OBJECT
+
+public:
+ vvRegisterForm(QUrl url, QString path, QSettings::Format format);
+ void sendData();
+ ~vvRegisterForm() {}
+ virtual bool canPush();
+ virtual void acquitPushed();
+public slots:
+ virtual void accept();
+ virtual void show();
+protected:
+ QUrl url;
+ QSettings settings;
+ QNetworkAccessManager* manager;
+};
+
+#endif
- BSD See included LICENSE.txt file
- CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
===========================================================================**/
-#include <fstream>
+#include <sstream>
#include <algorithm>
#include <QDir>
-
#include "clitkCommon.h"
#include "vvUtils.h"
const std::string vv_user_file=".vv_settings.txt";
+const std::string recentFileList="recentFiles";
typedef std::list<std::string> FileListType;
+QString getVVSettingsPath(){
+ return QDir::homePath()+QString::fromStdString("/"+vv_user_file);
+}
+
+QSettings::Format getSettingsOptionFormat(){
+ return QSettings::NativeFormat;
+}
+
///Returns the last images opened by the user
FileListType GetRecentlyOpenedImages()
{
- std::ifstream in((QDir::homePath().toStdString() + "/" + vv_user_file).c_str());
- std::string current_file;
+ QSettings settings(getVVSettingsPath(), getSettingsOptionFormat());
FileListType result;
- in >> current_file;
- while (in.good()) {
- result.push_back(current_file);
- in >> current_file;
- }
- in.close();
+ settings.beginGroup(QString::fromStdString(recentFileList));
+ QStringList keys = settings.childKeys();
+ for(int i=0; i<keys.size(); i++){
+ std::string value=settings.value(QString::fromStdString (keys[i].toStdString())).toString().toStdString();
+ result.push_back(value);
+ }
+ settings.endGroup();
return result;
}
///Adds an image to the list of recently opened images
void AddToRecentlyOpenedImages(std::string filename)
{
+ QSettings settings(getVVSettingsPath(), getSettingsOptionFormat());
FileListType file_list = GetRecentlyOpenedImages();
+
FileListType::iterator i = std::find(file_list.begin(),file_list.end(),filename);
if (i != file_list.end()) // avoid dupes
file_list.erase(i);
while (file_list.size() >= 6) //keep list to a reasonable size
file_list.pop_back();
file_list.push_front(filename);
- std::ofstream out((QDir::homePath().toStdString() + "/" + vv_user_file).c_str(),std::ios_base::out | std::ios_base::trunc);
- for (FileListType::iterator j = file_list.begin() ; j != file_list.end() ; j++)
- out << (*j) << std::endl;
- out.close();
+
+ settings.beginGroup(QString::fromStdString(recentFileList));
+ int index=0;
+ for (FileListType::iterator j = file_list.begin() ; j != file_list.end() ; j++){
+ QString s=QString(index++);
+ settings.setValue(s, QString::fromStdString ( *j ));
+ }
+ settings.endGroup();
}
+
#define vvXXX_h
#include <list>
#include <string>
+#include <QSettings>
///Returns the last images opened by the user
std::list<std::string> GetRecentlyOpenedImages();
///Adds an image to the list of recently opened images
void AddToRecentlyOpenedImages(std::string filename);
+///path to user settings
+QString getVVSettingsPath();
+
+///by default nativeFormat
+QSettings::Format getSettingsOptionFormat();
+
#endif