#=========================================================
# 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
*
* This filter is implemented using the propagation algorithm
*/
-
+
+#if ITK_VERSION_MAJOR == 4
+ template <class TInputImage, class TOutputImage, class TtNorm=Functor::Minimum<
+ typename TOutputImage::PixelType,
+ typename TOutputImage::PixelType,
+ typename TOutputImage::PixelType> >
+#else
template <class TInputImage, class TOutputImage, class TtNorm=Function::Minimum<
typename TOutputImage::PixelType,
typename TOutputImage::PixelType,
typename TOutputImage::PixelType> >
+#endif
class ITK_EXPORT RelativePositionPropImageFilter :
public ImageToImageFilter< TInputImage, TOutputImage >
{
#include <itkBinaryErodeImageFilter.h>
#include <itkBinaryBallStructuringElement.h>
#include <itkAddImageFilter.h>
-#include <itkDivideByConstantImageFilter.h>
+#if ITK_VERSION_MAJOR >= 4
+ #include <itkDivideImageFilter.h>
+#else
+ #include <itkDivideByConstantImageFilter.h>
+#endif
// itk [Bloch et al]
#include "RelativePositionPropImageFilter.h"
// Divide by the number of relpos
if (GetNumberOfAngles() != 1) {
+#if ITK_VERSION_MAJOR >= 4
+ typedef itk::DivideImageFilter<FloatImageType, FloatImageType, FloatImageType> DivideFilter;
+ typename DivideFilter::Pointer divideFilter = DivideFilter::New();
+ divideFilter->SetConstant2(GetNumberOfAngles());
+#else
typedef itk::DivideByConstantImageFilter<FloatImageType, float, FloatImageType> DivideFilter;
typename DivideFilter::Pointer divideFilter = DivideFilter::New();
- divideFilter->SetInput(m_FuzzyMap);
divideFilter->SetConstant(GetNumberOfAngles());
+#endif
+ divideFilter->SetInput(m_FuzzyMap);
divideFilter->Update();
m_FuzzyMap = divideFilter->GetOutput();
}
#include "itkImageRegion.h"
#include "itkSpatialObject.h"
#include "itkPasteImageFilter.h"
-#include "itkMultiplyByConstantImageFilter.h"
namespace clitk
{
typedef itk::PasteImageFilter<CoefficientImageType, CoefficientImageType, CoefficientImageType> PasteImageFilterType;
typedef clitk::ExtractImageFilter<CoefficientImageType, CoefficientImageType> ExtractImageFilterType;
typedef clitk::LinearCombinationImageFilter<CoefficientImageType, CoefficientImageType> LinearCombinationFilterType;
- typedef itk::MultiplyByConstantImageFilter<CoefficientImageType, double, CoefficientImageType> MultiplicationFilterType;
// Regions
typename CoefficientImageType::RegionType sourceRegion=m_PaddedCoefficientImage->GetLargestPossibleRegion();
-# 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 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)
../segmentation
)
-IF(WIN32)
- SET(EXE_ICON vvIcon.rc)
-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})
+
+ADD_LIBRARY(vvLib ${vv_SRCS} ${vv_UI_CXX})
+TARGET_LINK_LIBRARIES(vvLib ${vvExternalLibs})
+
+IF(WIN32)
+ ADD_EXECUTABLE(vv WIN32 vv.cxx vvIcon.rc)
+ELSE(WIN32)
+ ADD_EXECUTABLE(vv vv.cxx)
+ENDIF(WIN32)
+
+TARGET_LINK_LIBRARIES(vv vvLib)
+
#=========================================================
# Install options (also used by CPack)
ENDIF(WIN32)
INCLUDE(CPack)
#=========================================================
+#=========================================================
+configure_file(vvCommon.h.in vvCommon.h)
+#=========================================================
</property>
<addaction name="actionNavigation_Help"/>
<addaction name="actionDocumentation"/>
+ <addaction name="actionRegister_vv"/>
</widget>
<widget class="QMenu" name="menuOverlay">
<property name="title">
<string>Experimental...</string>
</property>
</action>
+ <action name="actionRegister_vv">
+ <property name="text">
+ <string>Register vv</string>
+ </property>
+ </action>
</widget>
<customwidgets>
<customwidget>
--- /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>371</width>
+ <height>413</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <widget class="QWidget" name="">
+ <property name="geometry">
+ <rect>
+ <x>4</x>
+ <y>4</y>
+ <width>361</width>
+ <height>401</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTextBrowser" name="textBrowser">
+ <property name="contextMenuPolicy">
+ <enum>Qt::DefaultContextMenu</enum>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </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;">
+<img src=":/common/icons/weNeedYou.jpg" style="float:right;" />
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Welcome to VV !</p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">We wish to keep an estimate of the number of persons using VV. This is</p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">really important for us to justify the ressources spent in developing this software.</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;">Please, take a few seconds to fill in the following fields and send us</p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">the information by clicking OK. If you still prefer to remain </p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">anonymous, simply click &quot;No, thanks&quot; (you can still register afterwards using the help menu).</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;">Privacy: the collected information is for internal and non-commercial</p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">use only. We will only use your email for vv release announcements.</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;"><br /></p></body></html></string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>First name</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="firstName"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Last name</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="lastName"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Email</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="email"/>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Institute</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="group"/>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>OS name</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLabel" name="osName">
+ <property name="text">
+ <string>OS name</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <resources>
+ <include location="../vvIcons.qrc"/>
+ </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>
#include <sys/types.h>
#include <sys/stat.h>
-#include <errno.h>
+#include <errno.h>
void load_image_first_error()
{
}
//------------------------------------------------------------------------------
+#ifdef _WIN32\r
+int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, LPSTR lpCmdLine, int nShowCmd)
+{
+ int argc = __argc;
+ char **argv = __argv;
+#else
int main( int argc, char** argv )
{
+#endif
+
CLITK_INIT;
QApplication app( argc, argv );
Q_INIT_RESOURCE(vvIcons);
- //QPixmap pixmap(":/splashscreen.PNG");
- QSplashScreen *splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/new/prefix1/splashscreen.PNG")));
- /*splash->showMessage("VV 1.0 developped by Léon Bérard c`ancer center http://www.centreleonberard.fr and CREATIS-LRMN http://www.creatis.insa-lyon.fr",(Qt::AlignRight | Qt::AlignBottom));*/
- // splash->show();
- QTimer::singleShot(2000, splash, SLOT(close()));
- while (!splash->isHidden())
- app.processEvents();
vvMainWindow window;
if(itksys::SystemTools::FileExists(log_dir.c_str()) &&
!itksys::SystemTools::FileIsDirectory(log_dir.c_str())) {
- itkGenericExceptionMacro(<< "Error creating log directory, file exists and is not a directory.");
+ std::cerr << "Error creating log directory, file exists and is not a directory." << std::endl;
+ exit(1);
} else if(!itksys::SystemTools::MakeDirectory(log_dir.c_str())) {
- itkGenericExceptionMacro(<< "Error creating log directory.");
+ std::cerr << "Error creating log directory." << std::endl;
+ exit(1);
}
std::string log_file = log_dir + "/" + create_timed_string() + ".log";
--- /dev/null
+#define VV_VERSION "v@CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@"
+
\ No newline at end of file
<RCC>
<qresource prefix="common">
+ <file>icons/weNeedYou.jpg</file>
<file>icons/mip.png</file>
<file>icons/tool-roi.png</file>
<file>icons/plastimatch.png</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"
connect(actionAdd_VF_to_current_Image,SIGNAL(triggered()),this,SLOT(OpenField()));
connect(actionNavigation_Help,SIGNAL(triggered()),this,SLOT(ShowHelpDialog()));
connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation()));
+ connect(actionRegister_vv,SIGNAL(triggered()),this,SLOT(PopupRegisterForm()));
///////////////////////////////////////////////
connect(actionSegmentation,SIGNAL(triggered()),this,SLOT(SegmentationOnCurrentImage()));
//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();
+ PopupRegisterForm(true);
+}
//------------------------------------------------------------------------------
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));
{
documentation->show();
}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvMainWindow::PopupRegisterForm(bool checkCanPush)
+{
+ vvRegisterForm* registerForm = new vvRegisterForm(QUrl("http://www.creatis.insa-lyon.fr/~dsarrut/vvregister/write.php"), getVVSettingsPath(), getSettingsOptionFormat());
+ if(!checkCanPush){
+ registerForm->show();
+ }else{
+ if(registerForm->canPush()){
+ registerForm->show();
+ registerForm->acquitPushed();//too bad if there is not internet connection anymore.
+ }
+ }
+}
+//------------------------------------------------------------------------------
+
//------------------------------------------------------------------------------
void vvMainWindow::ShowHelpDialog()
{
//------------------------------------------------------------------------------
void vvMainWindow::ChangeViewMode()
{
- QListIterator<int> it0(splitter_3->sizes());
- QListIterator<int> it1(splitter_3->sizes());
- int max0 = 0;
- int max1 = 1;
- while (it0.hasNext()) {
- max0 += it0.next();
- }
- while (it1.hasNext()) {
- max1 += it1.next();
- }
- QList<int> size0;
- QList<int> size1;
+ QList<int> size;
if (viewMode == 1) {
viewMode = 0;
- size0.push_back(max0);
- size0.push_back(0);
- size1.push_back(max1);
- size1.push_back(0);
- splitter_3->setSizes(size0);
- OSplitter->setSizes(size1);
+ size.push_back(1);
+ size.push_back(0);
+ splitter_3->setSizes(size);
+ OSplitter->setSizes(size);
DataTree->setColumnHidden(2,1);
DataTree->setColumnHidden(3,1);
DataTree->setColumnHidden(4,1);
} else {
viewMode = 1;
- size0.push_back(int(max0/2));
- size0.push_back(int(max0/2));
- size1.push_back(int(max1/2));
- size1.push_back(int(max1/2));
- splitter_3->setSizes(size0);
- OSplitter->setSizes(size1);
+ size.push_back(1);
+ size.push_back(1);
+ splitter_3->setSizes(size);
+ OSplitter->setSizes(size);
DataTree->setColumnHidden(2,0);
DataTree->setColumnHidden(3,0);
DataTree->setColumnHidden(4,0);
}
+ UpdateRenderWindows();
}
//------------------------------------------------------------------------------
void ImageInfoChanged();
void ShowHelpDialog();
void ShowDocumentation();
+ void PopupRegisterForm(bool checkCanPush=false);
void ComputeDeformableRegistration();
void WarpImage();
void ChangeViewMode();
}
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 <QPalette>
+#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);
+ textBrowser->viewport()->setAutoFillBackground(false);
+}
+
+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::IniFormat;
+}
+
///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