Fixed compilation errors (cannot convert const char * to const wchar *) with UNICODE projects (when "-DUNICODE" is set).
Fixed control bar showing -2 when webcam is used. git-svn-id: http://find-object.googlecode.com/svn/trunk/find_object@174 620bd6b2-0a58-f614-fd9a-1bd335dccda9
This commit is contained in:
parent
817f861b63
commit
597a137854
@ -6,6 +6,7 @@ SET(PROJECT_PREFIX find_object)
|
|||||||
ADD_DEFINITIONS(-DPROJECT_PREFIX="${PROJECT_PREFIX}")
|
ADD_DEFINITIONS(-DPROJECT_PREFIX="${PROJECT_PREFIX}")
|
||||||
ADD_DEFINITIONS(-DPROJECT_NAME="${PROJECT_NAME}")
|
ADD_DEFINITIONS(-DPROJECT_NAME="${PROJECT_NAME}")
|
||||||
ADD_DEFINITIONS( "-Wall" )
|
ADD_DEFINITIONS( "-Wall" )
|
||||||
|
#ADD_DEFINITIONS("-DUNICODE") # to test with UNICODE projects
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
# VERSION
|
# VERSION
|
||||||
|
|||||||
@ -130,6 +130,7 @@ connect(ui_->toolBox, SIGNAL(parametersChanged(const QStringList &)), this, SLOT
|
|||||||
ui_->pushButton_pause->setVisible(false);
|
ui_->pushButton_pause->setVisible(false);
|
||||||
ui_->pushButton_stop->setEnabled(true);
|
ui_->pushButton_stop->setEnabled(true);
|
||||||
ui_->horizontalSlider_frames->setEnabled(false);
|
ui_->horizontalSlider_frames->setEnabled(false);
|
||||||
|
ui_->label_frame->setVisible(false);
|
||||||
|
|
||||||
ui_->objects_area->addAction(ui_->actionAdd_object_from_scene);
|
ui_->objects_area->addAction(ui_->actionAdd_object_from_scene);
|
||||||
ui_->objects_area->addAction(ui_->actionAdd_objects_from_files);
|
ui_->objects_area->addAction(ui_->actionAdd_objects_from_files);
|
||||||
@ -693,7 +694,7 @@ void MainWindow::startProcessing()
|
|||||||
ui_->pushButton_pause->setVisible(true);
|
ui_->pushButton_pause->setVisible(true);
|
||||||
ui_->pushButton_stop->setEnabled(true);
|
ui_->pushButton_stop->setEnabled(true);
|
||||||
int totalFrames = camera_->getTotalFrames();
|
int totalFrames = camera_->getTotalFrames();
|
||||||
if(totalFrames)
|
if(totalFrames>0)
|
||||||
{
|
{
|
||||||
ui_->label_frame->setVisible(true);
|
ui_->label_frame->setVisible(true);
|
||||||
ui_->horizontalSlider_frames->setEnabled(true);
|
ui_->horizontalSlider_frames->setEnabled(true);
|
||||||
|
|||||||
@ -103,6 +103,26 @@ void UDirectory::setPath(const std::string & path, const std::string & extension
|
|||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
// returned whar_t * must be deleted : delete [] wText;
|
||||||
|
wchar_t * createWCharFromChar(const char * text)
|
||||||
|
{
|
||||||
|
DWORD length = MultiByteToWideChar (CP_ACP, 0, text, -1, NULL, 0);
|
||||||
|
wchar_t * wText = new wchar_t[length];
|
||||||
|
MultiByteToWideChar (CP_ACP, 0, text, -1, wText, length );
|
||||||
|
return wText;
|
||||||
|
}
|
||||||
|
|
||||||
|
// returned char * must be deleted : delete [] text;
|
||||||
|
char * createCharFromWChar(const wchar_t * wText)
|
||||||
|
{
|
||||||
|
DWORD length = WideCharToMultiByte (CP_ACP, 0, wText, -1, NULL, 0, NULL, NULL);
|
||||||
|
char * text = new char[length];
|
||||||
|
WideCharToMultiByte (CP_ACP, 0, wText, -1, text, length, NULL, NULL);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void UDirectory::update()
|
void UDirectory::update()
|
||||||
{
|
{
|
||||||
if(exists(path_))
|
if(exists(path_))
|
||||||
@ -122,12 +142,24 @@ void UDirectory::update()
|
|||||||
fileNames_.clear();
|
fileNames_.clear();
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
WIN32_FIND_DATA fileInformation;
|
WIN32_FIND_DATA fileInformation;
|
||||||
|
#ifdef UNICODE
|
||||||
|
wchar_t * pathAll = createWCharFromChar((path_+"\\*").c_str());
|
||||||
|
HANDLE hFile = ::FindFirstFile(pathAll, &fileInformation);
|
||||||
|
delete [] pathAll;
|
||||||
|
#else
|
||||||
HANDLE hFile = ::FindFirstFile((path_+"\\*").c_str(), &fileInformation);
|
HANDLE hFile = ::FindFirstFile((path_+"\\*").c_str(), &fileInformation);
|
||||||
|
#endif
|
||||||
if(hFile != INVALID_HANDLE_VALUE)
|
if(hFile != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
#ifdef UNICODE
|
||||||
|
char * fileName = createCharFromWChar(fileInformation.cFileName);
|
||||||
|
fileNames_.push_back(fileName);
|
||||||
|
delete [] fileName;
|
||||||
|
#else
|
||||||
fileNames_.push_back(fileInformation.cFileName);
|
fileNames_.push_back(fileInformation.cFileName);
|
||||||
|
#endif
|
||||||
} while(::FindNextFile(hFile, &fileInformation) == TRUE);
|
} while(::FindNextFile(hFile, &fileInformation) == TRUE);
|
||||||
::FindClose(hFile);
|
::FindClose(hFile);
|
||||||
std::vector<std::string> vFileNames = uListToVector(fileNames_);
|
std::vector<std::string> vFileNames = uListToVector(fileNames_);
|
||||||
@ -229,7 +261,13 @@ bool UDirectory::exists(const std::string & dirPath)
|
|||||||
{
|
{
|
||||||
bool r = false;
|
bool r = false;
|
||||||
#if WIN32
|
#if WIN32
|
||||||
|
#ifdef UNICODE
|
||||||
|
wchar_t * wDirPath = createWCharFromChar(dirPath.c_str());
|
||||||
|
DWORD dwAttrib = GetFileAttributes(wDirPath);
|
||||||
|
delete [] wDirPath;
|
||||||
|
#else
|
||||||
DWORD dwAttrib = GetFileAttributes(dirPath.c_str());
|
DWORD dwAttrib = GetFileAttributes(dirPath.c_str());
|
||||||
|
#endif
|
||||||
r = (dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
|
r = (dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||||
#else
|
#else
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
@ -329,9 +367,17 @@ std::string UDirectory::homeDir()
|
|||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
#if WIN32
|
#if WIN32
|
||||||
|
#ifdef UNICODE
|
||||||
|
wchar_t wProfilePath[250];
|
||||||
|
ExpandEnvironmentStrings(L"%userprofile%",wProfilePath,250);
|
||||||
|
char * profilePath = createCharFromWChar(wProfilePath);
|
||||||
|
path = profilePath;
|
||||||
|
delete [] profilePath;
|
||||||
|
#else
|
||||||
char profilePath[250];
|
char profilePath[250];
|
||||||
ExpandEnvironmentStrings("%userprofile%",profilePath,250);
|
ExpandEnvironmentStrings("%userprofile%",profilePath,250);
|
||||||
path = profilePath;
|
path = profilePath;
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
path = getenv("HOME");
|
path = getenv("HOME");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user