diff --git a/.gitignore b/.gitignore index 81b959f1..af55cb7a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,8 @@ *.vtg *.out *.log +*.sdf +*.pdb +*.opensdf +*.suo *~ \ No newline at end of file diff --git a/Projects/Cortex_test/cortex_test/ReadMe.txt b/Projects/Cortex_test/ReadMe.txt similarity index 97% rename from Projects/Cortex_test/cortex_test/ReadMe.txt rename to Projects/Cortex_test/ReadMe.txt index f645b350..d232049f 100644 --- a/Projects/Cortex_test/cortex_test/ReadMe.txt +++ b/Projects/Cortex_test/ReadMe.txt @@ -1,40 +1,40 @@ -======================================================================== - CONSOLE APPLICATION : cortex_test Project Overview -======================================================================== - -AppWizard has created this cortex_test application for you. - -This file contains a summary of what you will find in each of the files that -make up your cortex_test application. - - -cortex_test.vcxproj - This is the main project file for VC++ projects generated using an Application Wizard. - It contains information about the version of Visual C++ that generated the file, and - information about the platforms, configurations, and project features selected with the - Application Wizard. - -cortex_test.vcxproj.filters - This is the filters file for VC++ projects generated using an Application Wizard. - It contains information about the association between the files in your project - and the filters. This association is used in the IDE to show grouping of files with - similar extensions under a specific node (for e.g. ".cpp" files are associated with the - "Source Files" filter). - -cortex_test.cpp - This is the main application source file. - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named cortex_test.pch and a precompiled types file named StdAfx.obj. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" comments to indicate parts of the source code you -should add to or customize. - -///////////////////////////////////////////////////////////////////////////// +======================================================================== + CONSOLE APPLICATION : cortex_test Project Overview +======================================================================== + +AppWizard has created this cortex_test application for you. + +This file contains a summary of what you will find in each of the files that +make up your cortex_test application. + + +cortex_test.vcxproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +cortex_test.vcxproj.filters + This is the filters file for VC++ projects generated using an Application Wizard. + It contains information about the association between the files in your project + and the filters. This association is used in the IDE to show grouping of files with + similar extensions under a specific node (for e.g. ".cpp" files are associated with the + "Source Files" filter). + +cortex_test.cpp + This is the main application source file. + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named cortex_test.pch and a precompiled types file named StdAfx.obj. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" comments to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Projects/Cortex_test/cortex_test/cortex_test.cpp b/Projects/Cortex_test/cortex_test.cpp similarity index 97% rename from Projects/Cortex_test/cortex_test/cortex_test.cpp rename to Projects/Cortex_test/cortex_test.cpp index aebf2458..ef4d324e 100644 --- a/Projects/Cortex_test/cortex_test/cortex_test.cpp +++ b/Projects/Cortex_test/cortex_test.cpp @@ -1,38 +1,38 @@ -// cortex_test.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" - - -int _tmain(int argc, _TCHAR* argv[]){ - objectConsoleLoggingService CL; - cortexLayersFactory * mFACTORY; - classGUI_SDL * mGUI; - sdlProgressBar * mPBar; - sdlLog * mLog; - basicLogCollection::getInstance()->addHandler(&CL); - mGUI = classGUI_SDL::getInstance(); - mLog = new sdlLog( 10,300,600,200); - basicLogCollection::getInstance()->addHandler(mLog); - - mFACTORY = cortexLayersFactory::getInstance(); - mPBar = new sdlProgressBar(120, 120, 500, 40); - mPBar->attachStatusProvider(mFACTORY); - mFACTORY->setGpuUsageMode(false); - mFACTORY->setPushPullMode(true); - float detectionThreshold = 0.5f; - basicCortex * Net; - Net = mFACTORY->parseConfigCustom("C:\\FruchtSystems\\darknet-master\\cfg\\tiny-yolo.cfg", 1 ); - //Net = mFACTORY->parseConfig("C:\\FruchtSystems\\dn_vs13\\x64\\Debug\\cfg\\yolo-obj.cfg"); - //Net = mFACTORY->parseConfig("C:\\FruchtSystems\\darknet-master\\cfg\\darknet.cfg"); - if( Net != NULL ){ - //delete(mPBar); - Net->loadWeights("C:\\FruchtSystems\\dn_vs13\\x64\\Debug\\yolo-obj.backup"); - Net->setBatch(1); - - regionLayer *RL; - RL = (regionLayer*)Net->getLayer(Net->getLayersCount() - 1); - +// cortex_test.cpp : Defines the entry point for the console application. +// + +#include "stdafx.h" + + +int _tmain(int argc, _TCHAR* argv[]){ + objectConsoleLoggingService CL; + cortexLayersFactory * mFACTORY; + classGUI_SDL * mGUI; + sdlProgressBar * mPBar; + sdlLog * mLog; + basicLogCollection::getInstance()->addHandler(&CL); + mGUI = classGUI_SDL::getInstance(); + mLog = new sdlLog( 10,300,600,200); + basicLogCollection::getInstance()->addHandler(mLog); + + mFACTORY = cortexLayersFactory::getInstance(); + mPBar = new sdlProgressBar(120, 120, 500, 40); + mPBar->attachStatusProvider(mFACTORY); + mFACTORY->setGpuUsageMode(false); + mFACTORY->setPushPullMode(true); + float detectionThreshold = 0.5f; + basicCortex * Net; + Net = mFACTORY->parseConfigCustom("C:\\FruchtSystems\\darknet-master\\cfg\\tiny-yolo.cfg", 1 ); + //Net = mFACTORY->parseConfig("C:\\FruchtSystems\\dn_vs13\\x64\\Debug\\cfg\\yolo-obj.cfg"); + //Net = mFACTORY->parseConfig("C:\\FruchtSystems\\darknet-master\\cfg\\darknet.cfg"); + if( Net != NULL ){ + //delete(mPBar); + Net->loadWeights("C:\\FruchtSystems\\dn_vs13\\x64\\Debug\\yolo-obj.backup"); + Net->setBatch(1); + + regionLayer *RL; + RL = (regionLayer*)Net->getLayer(Net->getLayersCount() - 1); + float nms = .4f; uint32_t box_cnt; uint32_t cls_cnt; @@ -40,31 +40,31 @@ int _tmain(int argc, _TCHAR* argv[]){ cls_cnt = RL->getClassesCount(); cortexBOXLABEL *boxes = (cortexBOXLABEL*)calloc(box_cnt, sizeof(cortexBOXLABEL)); float **probs = (float**)calloc(box_cnt, sizeof(float*)); - for (uint32_t j = 0; j < box_cnt; ++j){ - memset(boxes, 0, box_cnt*sizeof(cortexBOXLABEL)); - probs[j] = (float*)calloc(cls_cnt, sizeof(float)); - memset(probs[j], 0, cls_cnt*sizeof(float)); - }; - cv::Mat img; - cv::Mat r_img; - char *tPath = "C:\\FruchtSystems\\darknet-master\\data\\dog.jpg"; - img = cv::imread(tPath, CV_LOAD_IMAGE_COLOR);//CV_LOAD_IMAGE_GRAYSCALE - basicLogCollection::getInstance()->Log("Main", NULL, tPath ); - // Check for invalid input - if( !img.data ){ - basicLogCollection::getInstance()->Log("Main", NULL, "Could not open or find the image!"); - } else { - cv::resize(img, r_img, cv::Size(Net->getInputWidth(), Net->getInputHeight()), 0, 0, CV_INTER_LINEAR); - cortexImage image(&r_img); - Net->predict(image.data); - RL->get_region_boxes(1, 1, detectionThreshold, probs, boxes, 0, 0 ); - - }; - mGUI->waitThreadEnd(); - delete(Net); - } else { - basicLogCollection::getInstance()->Log("Main", NULL, "Error Loading Network Configuration!"); - }; - return 0; -} - + for (uint32_t j = 0; j < box_cnt; ++j){ + memset(boxes, 0, box_cnt*sizeof(cortexBOXLABEL)); + probs[j] = (float*)calloc(cls_cnt, sizeof(float)); + memset(probs[j], 0, cls_cnt*sizeof(float)); + }; + cv::Mat img; + cv::Mat r_img; + char *tPath = "C:\\FruchtSystems\\darknet-master\\data\\dog.jpg"; + img = cv::imread(tPath, CV_LOAD_IMAGE_COLOR);//CV_LOAD_IMAGE_GRAYSCALE + basicLogCollection::getInstance()->Log("Main", NULL, tPath ); + // Check for invalid input + if( !img.data ){ + basicLogCollection::getInstance()->Log("Main", NULL, "Could not open or find the image!"); + } else { + cv::resize(img, r_img, cv::Size(Net->getInputWidth(), Net->getInputHeight()), 0, 0, CV_INTER_LINEAR); + cortexImage image(&r_img); + Net->predict(image.data); + RL->get_region_boxes(1, 1, detectionThreshold, probs, boxes, 0, 0 ); + + }; + mGUI->waitThreadEnd(); + delete(Net); + } else { + basicLogCollection::getInstance()->Log("Main", NULL, "Error Loading Network Configuration!"); + }; + return 0; +} + diff --git a/Projects/Cortex_test/cortex_test.sln b/Projects/Cortex_test/cortex_test.sln deleted file mode 100644 index ee99ef25..00000000 --- a/Projects/Cortex_test/cortex_test.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cortex_test", "cortex_test\cortex_test.vcxproj", "{CB0601AE-A104-40CF-83D1-DA66736E8322}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CB0601AE-A104-40CF-83D1-DA66736E8322}.Debug|Win32.ActiveCfg = Debug|Win32 - {CB0601AE-A104-40CF-83D1-DA66736E8322}.Debug|Win32.Build.0 = Debug|Win32 - {CB0601AE-A104-40CF-83D1-DA66736E8322}.Release|Win32.ActiveCfg = Release|Win32 - {CB0601AE-A104-40CF-83D1-DA66736E8322}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/Projects/Cortex_test/cortex_test.vcxproj b/Projects/Cortex_test/cortex_test.vcxproj new file mode 100644 index 00000000..a73b6355 --- /dev/null +++ b/Projects/Cortex_test/cortex_test.vcxproj @@ -0,0 +1,247 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {CB0601AE-A104-40CF-83D1-DA66736E8322} + Win32Proj + cortex_test + + + + Application + true + v120 + + + Application + false + true + Unicode + v120 + + + + + + + + + + + + + + true + c:\boost_1_68_0;c:\FruchtSystems\W32LIBS\include;c:\FruchtSystems\W32LIBS\CUDAToolkit_x86_6.5\include;c:\SDL\include;$(IncludePath) + c:\boost_1_68_0\lib32-msvc-12.0;c:\FruchtSystems\W32LIBS\lib;c:\FruchtSystems\W32LIBS\CUDAToolkit_x86_6.5\lib\Win32;c:\SDL\lib\x86;$(LibraryPath) + + + false + c:\boost_1_68_0;c:\FruchtSystems\W32LIBS\include;c:\FruchtSystems\W32LIBS\CUDAToolkit_x86_6.5\include;$(IncludePath) + c:\boost_1_68_0\lib32-msvc-12.0;c:\FruchtSystems\W32LIBS\lib;c:\FruchtSystems\W32LIBS\CUDAToolkit_x86_6.5\lib\Win32;$(LibraryPath) + + + + NotUsing + Level3 + Disabled + WIN32;GPU;_DEBUG;DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + -Zm121 %(AdditionalOptions) + + + Console + true + C:\MS_LIBS\cv2\x86\vc10\lib;%(AdditionalLibraryDirectories) + cublas.lib;cublas_device.lib;cuda.lib;cudadevrt.lib;cudart.lib;cudart_static.lib;cufft.lib;cufftw.lib;curand.lib;cusparse.lib;nppc.lib;nppi.lib;npps.lib;nvcuvid.lib;OpenCL.lib;opencv_calib3d249d.lib;opencv_contrib249d.lib;opencv_core249d.lib;opencv_features2d249d.lib;opencv_flann249d.lib;opencv_gpu249d.lib;opencv_highgui249d.lib;opencv_imgproc249d.lib;opencv_legacy249d.lib;opencv_ml249d.lib;opencv_nonfree249d.lib;opencv_objdetect249d.lib;opencv_ocl249d.lib;opencv_photo249d.lib;opencv_stitching249d.lib;opencv_superres249d.lib;opencv_ts249d.lib;opencv_video249d.lib;opencv_videostab249d.lib;SDL2.lib;SDL2_image.lib;SDL2_mixer.lib;SDL2_net.lib;SDL2_ttf.lib;SDL2main.lib;%(AdditionalDependencies) + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;GPU;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + Console + true + true + true + cublas.lib;cublas_device.lib;cuda.lib;cudadevrt.lib;cudart.lib;cudart_static.lib;cufft.lib;cufftw.lib;curand.lib;cusparse.lib;nppc.lib;nppi.lib;npps.lib;nvcuvid.lib;OpenCL.lib;opencv_calib3d249.lib;opencv_calib3d249d.lib;opencv_contrib249.lib;opencv_contrib249d.lib;opencv_core249.lib;opencv_core249d.lib;opencv_features2d249.lib;opencv_features2d249d.lib;opencv_flann249.lib;opencv_flann249d.lib;opencv_gpu249.lib;opencv_gpu249d.lib;opencv_highgui249.lib;opencv_highgui249d.lib;opencv_imgproc249.lib;opencv_imgproc249d.lib;opencv_legacy249.lib;opencv_legacy249d.lib;opencv_ml249.lib;opencv_ml249d.lib;opencv_nonfree249.lib;opencv_nonfree249d.lib;opencv_objdetect249.lib;opencv_objdetect249d.lib;opencv_ocl249.lib;opencv_ocl249d.lib;opencv_photo249.lib;opencv_photo249d.lib;opencv_stitching249.lib;opencv_stitching249d.lib;opencv_superres249.lib;opencv_superres249d.lib;opencv_ts249.lib;opencv_ts249d.lib;opencv_video249.lib;opencv_video249d.lib;opencv_videostab249.lib;opencv_videostab249d.lib;%(AdditionalDependencies) + + + + + Document + + + Document + + + + + + + Document + + + Document + + + Document + + + Document + + + Document + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Create + Create + + + + + + + \ No newline at end of file diff --git a/Projects/Cortex_test/cortex_test.vcxproj.filters b/Projects/Cortex_test/cortex_test.vcxproj.filters new file mode 100644 index 00000000..c8be8a7d --- /dev/null +++ b/Projects/Cortex_test/cortex_test.vcxproj.filters @@ -0,0 +1,450 @@ + + + + + Sources\CUDA modules + + + Sources\CUDA modules + + + Sources\CUDA modules + + + Sources\CUDA modules + + + Sources\CUDA modules + + + Sources\CUDA modules + + + Sources\CUDA modules + + + Sources\CUDA modules + + + Sources\CUDA modules + + + Sources\CUDA modules + + + Sources\Cortex\Cuda + + + + + Sources + + + Sources + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Cortex\Base + + + Sources\Cortex\Base + + + Sources\Cortex\Base + + + Sources\Cortex\Base + + + Sources\Cortex\Base + + + Sources\Cortex\Base + + + Sources\Cortex\Base + + + Sources\Cortex\Base + + + Sources\Cortex\Base + + + Sources\Base + + + Sources\Base + + + Sources\Base + + + Sources\Cortex\Base + + + Sources\Cortex\Base + + + Sources\Base + + + Sources\Base + + + Sources\Cortex\Base + + + Sources\Cortex\Base + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\SDL + + + Sources\SDL + + + Sources\Cortex\Layers + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\CPU + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Cortex\Cuda + + + Sources\Cortex\Cuda + + + Sources\Cortex\Cuda + + + Sources\Cortex\Cuda + + + Sources\Cortex\Cuda + + + Sources\Cortex\Cuda + + + Sources\Cortex\Cuda + + + Sources\Cortex\Cuda + + + Sources\Cortex\Cuda + + + Sources\Cortex\Cuda + + + Sources\Cortex\Cuda + + + Sources\Cortex\Cuda + + + Sources\Cortex\Cuda + + + Sources\Cortex\Cuda + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\SDL + + + Sources\SDL + + + Sources\SDL + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Cortex\Layers + + + Sources\Base + + + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + Headers + + + + + + + + {4e95beec-3da5-4485-adaf-c28c4f488cd9} + + + {5157f098-ee01-4c3c-afef-8b8b35bb4b06} + *.h + + + {2f027295-8bd2-4f77-9eda-1ce84cb72421} + + + {1c870a70-4ccb-4d04-a715-0a11132a4f70} + + + {5a93c20c-c7a7-4ab8-8064-64de4a658f6e} + + + {c1ee37cf-2f1c-412b-bffc-5abee9b38edf} + + + {43b34290-5182-4314-ba47-7cade3bc2c64} + + + {1f757de4-a7d7-494c-982f-e9b4cbbf12f9} + + + {3264e393-ee44-46e1-b7cc-0a22ce55f5cd} + + + {a6b8cbd6-f36c-4a92-8c98-94956bf25b22} + + + \ No newline at end of file diff --git a/Projects/Cortex_test/cortex_test/stdafx.cpp b/Projects/Cortex_test/stdafx.cpp similarity index 97% rename from Projects/Cortex_test/cortex_test/stdafx.cpp rename to Projects/Cortex_test/stdafx.cpp index 6c62e2f6..d3cb6681 100644 --- a/Projects/Cortex_test/cortex_test/stdafx.cpp +++ b/Projects/Cortex_test/stdafx.cpp @@ -1,8 +1,8 @@ -// stdafx.cpp : source file that includes just the standard includes -// cortex_test.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file +// stdafx.cpp : source file that includes just the standard includes +// cortex_test.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/Projects/Cortex_test/cortex_test/stdafx.h b/Projects/Cortex_test/stdafx.h similarity index 96% rename from Projects/Cortex_test/cortex_test/stdafx.h rename to Projects/Cortex_test/stdafx.h index 902b447f..37489160 100644 --- a/Projects/Cortex_test/cortex_test/stdafx.h +++ b/Projects/Cortex_test/stdafx.h @@ -1,30 +1,30 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -#include -#include - -//#include -//#include -//#include -//#include - -//#include - -#include "../../lib/data/cortex/cpu/cpu.h" -#include "../../lib/data/cortex/cuda/cuda.h" -#include "../../lib/components/object/objectConsoleLoggingService.h" -#include "../../lib/data/cortex/layers/layersFactory.h" -#include "../../lib/data/cortex/layers/regionLayer.h" -//#include "../../lib/sdl/gui_sdl.h" -#include "../../lib/sdl/widgets/progressBar.h" -#include "../../lib/sdl/widgets/logWidget.h" - - -// TODO: reference additional headers your program requires here +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#include +#include + +//#include +//#include +//#include +//#include + +//#include + +#include "../../lib/data/cortex/cpu/cpu.h" +#include "../../lib/data/cortex/cuda/cuda.h" +#include "../../lib/components/object/objectConsoleLoggingService.h" +#include "../../lib/data/cortex/layers/layersFactory.h" +#include "../../lib/data/cortex/layers/regionLayer.h" +//#include "../../lib/sdl/gui_sdl.h" +#include "../../lib/sdl/widgets/progressBar.h" +#include "../../lib/sdl/widgets/logWidget.h" + + +// TODO: reference additional headers your program requires here diff --git a/Projects/Cortex_test/cortex_test/targetver.h b/Projects/Cortex_test/targetver.h similarity index 97% rename from Projects/Cortex_test/cortex_test/targetver.h rename to Projects/Cortex_test/targetver.h index 87c0086d..90e767bf 100644 --- a/Projects/Cortex_test/cortex_test/targetver.h +++ b/Projects/Cortex_test/targetver.h @@ -1,8 +1,8 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include diff --git a/Projects/QT-Gui-App/Win32-QT-gui-application.sln b/Windows_Workspace.sln similarity index 58% rename from Projects/QT-Gui-App/Win32-QT-gui-application.sln rename to Windows_Workspace.sln index 193d34e2..167ebd3e 100644 --- a/Projects/QT-Gui-App/Win32-QT-gui-application.sln +++ b/Windows_Workspace.sln @@ -1,25 +1,31 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29102.190 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Win32-QT-gui-application", "Win32-QT-gui-application.vcxproj", "{5F60E152-44A4-44FF-8B0E-5CECE9454C2F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5F60E152-44A4-44FF-8B0E-5CECE9454C2F}.Debug|x86.ActiveCfg = Debug|Win32 - {5F60E152-44A4-44FF-8B0E-5CECE9454C2F}.Debug|x86.Build.0 = Debug|Win32 - {5F60E152-44A4-44FF-8B0E-5CECE9454C2F}.Release|x86.ActiveCfg = Release|Win32 - {5F60E152-44A4-44FF-8B0E-5CECE9454C2F}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {9261EC15-9830-4F88-A73B-8FD5F7390495} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cortex_test", "Projects\Cortex_test\cortex_test.vcxproj", "{CB0601AE-A104-40CF-83D1-DA66736E8322}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Win32-QT-gui-application", "Projects\QT-Gui-App\Win32-QT-gui-application.vcxproj", "{5F60E152-44A4-44FF-8B0E-5CECE9454C2F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CB0601AE-A104-40CF-83D1-DA66736E8322}.Debug|x86.ActiveCfg = Debug|Win32 + {CB0601AE-A104-40CF-83D1-DA66736E8322}.Debug|x86.Build.0 = Debug|Win32 + {CB0601AE-A104-40CF-83D1-DA66736E8322}.Release|x86.ActiveCfg = Release|Win32 + {CB0601AE-A104-40CF-83D1-DA66736E8322}.Release|x86.Build.0 = Release|Win32 + {5F60E152-44A4-44FF-8B0E-5CECE9454C2F}.Debug|x86.ActiveCfg = Debug|Win32 + {5F60E152-44A4-44FF-8B0E-5CECE9454C2F}.Debug|x86.Build.0 = Debug|Win32 + {5F60E152-44A4-44FF-8B0E-5CECE9454C2F}.Release|x86.ActiveCfg = Release|Win32 + {5F60E152-44A4-44FF-8B0E-5CECE9454C2F}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9261EC15-9830-4F88-A73B-8FD5F7390495} + EndGlobalSection +EndGlobal diff --git a/lib/components/base/basicStatusProvider.h b/lib/components/base/basicStatusProvider.h new file mode 100644 index 00000000..bbc9cceb --- /dev/null +++ b/lib/components/base/basicStatusProvider.h @@ -0,0 +1,13 @@ +#ifndef __BASIC_STATUS_PROVIDER_HEADER__ +#define __BASIC_STATUS_PROVIDER_HEADER__ + +#include "basicStatus.h" + +class basicStatusProvider{ + public: + basicStatusProvider(){}; + virtual ~basicStatusProvider(){}; + virtual uint8_t getStatus(CSTR msg = NULL){ return 0; }; +}; + +#endif \ No newline at end of file diff --git a/lib/data/cortex/cuda/cudaAvgpoolLayer.cu b/lib/data/cortex/cuda/cudaAvgpoolLayer.cu index d800647f..5bdbb4dc 100644 --- a/lib/data/cortex/cuda/cudaAvgpoolLayer.cu +++ b/lib/data/cortex/cuda/cudaAvgpoolLayer.cu @@ -1,9 +1,9 @@ #include "cuda_runtime.h" #include "curand.h" -#include "cublas_v2.h" -#include "cuda.h" -#include "../layers/avgpoolLayer.h" - +#include "cublas_v2.h" +#include "cuda.h" +#include "../layers/avgpoolLayer.h" + __global__ void forward_avgpool_layer_kernel(int n, int w, int h, int c, float *input, float *output) { int id = (blockIdx.x + blockIdx.y*gridDim.x) * blockDim.x + threadIdx.x; diff --git a/lib/data/cortex/layers/crnnLayer.cpp b/lib/data/cortex/layers/crnnLayer.cpp index 269a0c7c..0de21e39 100644 --- a/lib/data/cortex/layers/crnnLayer.cpp +++ b/lib/data/cortex/layers/crnnLayer.cpp @@ -81,8 +81,8 @@ void crnnLayer::backward(cortexSTATE state){ }; void crnnLayer::loadWeights(FILE *fp, bool trans){ - m_pInputLayer->loadWeights(fp, trans); - m_pSelfLayer->loadWeights(fp, trans); + m_pInputLayer->loadWeights(fp, trans); + m_pSelfLayer->loadWeights(fp, trans); m_pOutputLayer->loadWeights(fp, trans); }; diff --git a/lib/sdl/core/coreLabel.cpp b/lib/sdl/core/coreLabel.cpp index cc0a1cd9..8231352a 100644 --- a/lib/sdl/core/coreLabel.cpp +++ b/lib/sdl/core/coreLabel.cpp @@ -1,105 +1,105 @@ -#include "coreLabel.h" -sdlLabel::sdlLabel(int x, int y, int w, int h, sdlCoreWidget *wPtr, int fsize, CSTR fontName) :sdlCoreWidget(x,y,w,h,wPtr){ - m_sColorStyle = DEFAULT_COLOR_STYLE; - m_pFontTexture = NULL; - m_pFont = NULL; - m_sRect.x = x; - m_sRect.y = y; - m_sRect.w = w; - m_sRect.h = h; - setDecoraion(false); - m_bTextAlign = ALIGN_CENTER; - memset( m_pText, 0, SDL_DEFAULT_TEXT_SIZE ); - if (fontName != NULL){ - m_pFont = TTF_OpenFont(fontName, fsize); - } else { - m_pFont = TTF_OpenFont("C:\\FruchtSystems\\cortex_test\\cortex_test\\Fonts\\Ubuntu-L.ttf", fsize); - }; - m_bRedraw = true; -}; - -sdlLabel::~sdlLabel(){ - if (m_pFont != NULL){ - TTF_CloseFont(m_pFont); - m_pFont = NULL; - }; - if (m_pFontTexture != NULL){ - SDL_DestroyTexture(m_pFontTexture); - m_pFontTexture = NULL; - }; -}; - -void sdlLabel::draw(SDL_Renderer *pRenderer){ - if (m_bRedraw){ - if (m_pFont == NULL) return; - SDL_Surface *pSurface; - pSurface = TTF_RenderText_Solid(m_pFont, m_pText, m_sColor); - if (pSurface != NULL){ - m_nLabelWidth = pSurface->w; - m_nLabelHeight = pSurface->h; - m_pFontTexture = SDL_CreateTextureFromSurface(pRenderer, pSurface); - if (m_pFontTexture != NULL) m_bRedraw = false; - }; - }; - if( m_pFontTexture != NULL ){ - SDL_Rect tRect; - switch (m_bTextAlign){ - case ALIGN_LEFT: tRect.x = 0; break; - case ALIGN_CENTER: tRect.x = (m_sRect.w - m_nLabelWidth) / 2; break; - case ALIGN_RIGHT: tRect.x = m_sRect.w - m_nLabelWidth; break; - }; - tRect.y = m_sRect.y + (m_sRect.h - m_nLabelHeight) / 2; - //tRect.y = (m_sRect.h - m_pSurface->h) / 2; - tRect.w = m_nLabelWidth; - tRect.h = m_nLabelHeight; - //SDL_RenderCopyEx(pRenderer, m_pTexture, clip, &m_sRect, angle, center, flip); - SDL_RenderCopyEx(pRenderer, m_pFontTexture, NULL, &tRect, 0, 0, SDL_FLIP_NONE); - }; -}; - -void sdlLabel::setText(CSTR pStr){ - if (pStr != NULL){ - sprintf(m_pText, "%s", pStr); - } else { - memset(m_pText, 0, SDL_DEFAULT_TEXT_SIZE ); - }; - m_bRedraw = true; -}; - -void sdlLabel::setFont(TTF_Font *tPtr){ - if (m_pFont != NULL){ - TTF_CloseFont(m_pFont); - m_pFont = NULL; - }; - m_pFont = tPtr; - m_bRedraw = true; -}; - -void sdlLabel::setColor(SDL_Color *tC){ - if (tC == NULL){ - m_sColor = m_sColorStyle.font; - } else { - memcpy(&m_sColor, tC, sizeof(SDL_Color)); - }; - m_bRedraw = true; -}; -void sdlLabel::setColor(Uint8 red, Uint8 green, Uint8 blue){ - //Modulate texture rgb - if (m_pFontTexture != NULL){ - SDL_SetTextureColorMod(m_pFontTexture, red, green, blue); - }; -}; - -void sdlLabel::setBlendMode(SDL_BlendMode blending){ - //Set blending function - if (m_pFontTexture != NULL){ - SDL_SetTextureBlendMode(m_pFontTexture, blending); - }; -}; - -void sdlLabel::setAlpha(Uint8 alpha){ - //Modulate texture alpha - if (m_pFontTexture != NULL){ - SDL_SetTextureAlphaMod(m_pFontTexture, alpha); - }; -}; +#include "coreLabel.h" +sdlLabel::sdlLabel(int x, int y, int w, int h, sdlCoreWidget *wPtr, int fsize, CSTR fontName) :sdlCoreWidget(x,y,w,h,wPtr){ + m_sColorStyle = DEFAULT_COLOR_STYLE; + m_pFontTexture = NULL; + m_pFont = NULL; + m_sRect.x = x; + m_sRect.y = y; + m_sRect.w = w; + m_sRect.h = h; + setDecoraion(false); + m_bTextAlign = ALIGN_CENTER; + memset( m_pText, 0, SDL_DEFAULT_TEXT_SIZE ); + if (fontName != NULL){ + m_pFont = TTF_OpenFont(fontName, fsize); + } else { + m_pFont = TTF_OpenFont("C:\\FruchtSystems\\cortex_test\\cortex_test\\Fonts\\Ubuntu-L.ttf", fsize); + }; + m_bRedraw = true; +}; + +sdlLabel::~sdlLabel(){ + if (m_pFont != NULL){ + TTF_CloseFont(m_pFont); + m_pFont = NULL; + }; + if (m_pFontTexture != NULL){ + SDL_DestroyTexture(m_pFontTexture); + m_pFontTexture = NULL; + }; +}; + +void sdlLabel::draw(SDL_Renderer *pRenderer){ + if (m_bRedraw){ + if (m_pFont == NULL) return; + SDL_Surface *pSurface; + pSurface = TTF_RenderText_Solid(m_pFont, m_pText, m_sColor); + if (pSurface != NULL){ + m_nLabelWidth = pSurface->w; + m_nLabelHeight = pSurface->h; + m_pFontTexture = SDL_CreateTextureFromSurface(pRenderer, pSurface); + if (m_pFontTexture != NULL) m_bRedraw = false; + }; + }; + if( m_pFontTexture != NULL ){ + SDL_Rect tRect; + switch (m_bTextAlign){ + case ALIGN_LEFT: tRect.x = 0; break; + case ALIGN_CENTER: tRect.x = (m_sRect.w - m_nLabelWidth) / 2; break; + case ALIGN_RIGHT: tRect.x = m_sRect.w - m_nLabelWidth; break; + }; + tRect.y = m_sRect.y + (m_sRect.h - m_nLabelHeight) / 2; + //tRect.y = (m_sRect.h - m_pSurface->h) / 2; + tRect.w = m_nLabelWidth; + tRect.h = m_nLabelHeight; + //SDL_RenderCopyEx(pRenderer, m_pTexture, clip, &m_sRect, angle, center, flip); + SDL_RenderCopyEx(pRenderer, m_pFontTexture, NULL, &tRect, 0, 0, SDL_FLIP_NONE); + }; +}; + +void sdlLabel::setText(CSTR pStr){ + if (pStr != NULL){ + sprintf(m_pText, "%s", pStr); + } else { + memset(m_pText, 0, SDL_DEFAULT_TEXT_SIZE ); + }; + m_bRedraw = true; +}; + +void sdlLabel::setFont(TTF_Font *tPtr){ + if (m_pFont != NULL){ + TTF_CloseFont(m_pFont); + m_pFont = NULL; + }; + m_pFont = tPtr; + m_bRedraw = true; +}; + +void sdlLabel::setColor(SDL_Color *tC){ + if (tC == NULL){ + m_sColor = m_sColorStyle.font; + } else { + memcpy(&m_sColor, tC, sizeof(SDL_Color)); + }; + m_bRedraw = true; +}; +void sdlLabel::setColor(Uint8 red, Uint8 green, Uint8 blue){ + //Modulate texture rgb + if (m_pFontTexture != NULL){ + SDL_SetTextureColorMod(m_pFontTexture, red, green, blue); + }; +}; + +void sdlLabel::setBlendMode(SDL_BlendMode blending){ + //Set blending function + if (m_pFontTexture != NULL){ + SDL_SetTextureBlendMode(m_pFontTexture, blending); + }; +}; + +void sdlLabel::setAlpha(Uint8 alpha){ + //Modulate texture alpha + if (m_pFontTexture != NULL){ + SDL_SetTextureAlphaMod(m_pFontTexture, alpha); + }; +}; diff --git a/lib/sdl/core/coreLabel.h b/lib/sdl/core/coreLabel.h index 0697bd28..5843c81d 100644 --- a/lib/sdl/core/coreLabel.h +++ b/lib/sdl/core/coreLabel.h @@ -1,43 +1,43 @@ -#ifndef __SDL_CORE_LABEL_HEADERS__ -#define __SDL_CORE_LABEL_HEADERS__ - -#include "../../components/base/basicMutex.h" -#include "../gui_sdl.h" -#include "coreWidget.h" - -#define SDL_DEFAULT_TEXT_SIZE 1024 -#define SDL_DEFAULT_FONT_SIZE 12 -typedef enum E_TEXT_ALIGN{ - ALIGN_LEFT = 0, - ALIGN_CENTER = 1, - ALIGN_RIGHT -} TEXT_ALIGN; - -class sdlLabel :public sdlCoreWidget{ - private: - char m_pText[SDL_DEFAULT_TEXT_SIZE]; - TTF_Font * m_pFont; - SDL_Texture * m_pFontTexture; - SDL_Color m_sColor; - SDL_Rect m_sRect; - int m_nLabelWidth; - int m_nLabelHeight; - sdlColorStyle m_sColorStyle; - TEXT_ALIGN m_bTextAlign; - protected: - virtual void draw(SDL_Renderer *pRenderer); - public: - explicit sdlLabel(int x, int y, int w, int h, sdlCoreWidget *wPtr=NULL, int fsize = SDL_DEFAULT_FONT_SIZE, CSTR fontName = NULL); - virtual ~sdlLabel(); - void setText( CSTR pStr ); - void setFont( TTF_Font *tPtr ); - void setColor( SDL_Color *tC ); - void setColor( Uint8 red, Uint8 green, Uint8 blue ); - void setBlendMode(SDL_BlendMode blending ); - void setAlpha( Uint8 alpha ); - void setAlign(TEXT_ALIGN tA){ m_bTextAlign = tA; }; - CSTR getText(void){ return m_pText; }; -}; - - +#ifndef __SDL_CORE_LABEL_HEADERS__ +#define __SDL_CORE_LABEL_HEADERS__ + +#include "../../components/base/basicMutex.h" +#include "../gui_sdl.h" +#include "coreWidget.h" + +#define SDL_DEFAULT_TEXT_SIZE 1024 +#define SDL_DEFAULT_FONT_SIZE 12 +typedef enum E_TEXT_ALIGN{ + ALIGN_LEFT = 0, + ALIGN_CENTER = 1, + ALIGN_RIGHT +} TEXT_ALIGN; + +class sdlLabel :public sdlCoreWidget{ + private: + char m_pText[SDL_DEFAULT_TEXT_SIZE]; + TTF_Font * m_pFont; + SDL_Texture * m_pFontTexture; + SDL_Color m_sColor; + SDL_Rect m_sRect; + int m_nLabelWidth; + int m_nLabelHeight; + sdlColorStyle m_sColorStyle; + TEXT_ALIGN m_bTextAlign; + protected: + virtual void draw(SDL_Renderer *pRenderer); + public: + explicit sdlLabel(int x, int y, int w, int h, sdlCoreWidget *wPtr=NULL, int fsize = SDL_DEFAULT_FONT_SIZE, CSTR fontName = NULL); + virtual ~sdlLabel(); + void setText( CSTR pStr ); + void setFont( TTF_Font *tPtr ); + void setColor( SDL_Color *tC ); + void setColor( Uint8 red, Uint8 green, Uint8 blue ); + void setBlendMode(SDL_BlendMode blending ); + void setAlpha( Uint8 alpha ); + void setAlign(TEXT_ALIGN tA){ m_bTextAlign = tA; }; + CSTR getText(void){ return m_pText; }; +}; + + #endif \ No newline at end of file diff --git a/lib/sdl/core/coreStyleTemplate.h b/lib/sdl/core/coreStyleTemplate.h index 635534a7..91716aec 100644 --- a/lib/sdl/core/coreStyleTemplate.h +++ b/lib/sdl/core/coreStyleTemplate.h @@ -1,32 +1,32 @@ -#ifndef __SDL_CORE_STYLE_TEMPLATE_HEADER__ -#define __SDL_CORE_STYLE_TEMPLATE_HEADER__ -#include - -typedef struct S_sdlColorStyle{ - SDL_Color panelBG; - SDL_Color borderTOP; - SDL_Color borderBOTTOM; - SDL_Color borderLEFT; - SDL_Color borderRIGHT; - SDL_Color borderBODY; - SDL_Color body; - SDL_Color font; - SDL_Color disabledFont; - SDL_Color activeSelector; - SDL_Color passiveSelector; -} sdlColorStyle; - -#define DEFAULT_COLOR_STYLE { \ - {0x20, 0x20, 0x20, 0xFF}, \ - {0xF0, 0xF0, 0xF0, 0xFF}, \ - {0xF0, 0xF0, 0xF0, 0xFF}, \ - {0xF0, 0xF0, 0xF0, 0xFF}, \ - {0xF0, 0xF0, 0xF0, 0xFF}, \ - {0xF0, 0xF0, 0xF0, 0xFF}, \ - {0x70, 0x70, 0x70, 0xFF}, \ - {0x0, 0x0, 0x0, 0xFF}, \ - {0x10, 0x10, 0x10, 0xFF}, \ - {0x10, 0x10, 0xF0, 0xFF}, \ - {0x0, 0x0, 0x20, 0xFF} \ -} +#ifndef __SDL_CORE_STYLE_TEMPLATE_HEADER__ +#define __SDL_CORE_STYLE_TEMPLATE_HEADER__ +#include + +typedef struct S_sdlColorStyle{ + SDL_Color panelBG; + SDL_Color borderTOP; + SDL_Color borderBOTTOM; + SDL_Color borderLEFT; + SDL_Color borderRIGHT; + SDL_Color borderBODY; + SDL_Color body; + SDL_Color font; + SDL_Color disabledFont; + SDL_Color activeSelector; + SDL_Color passiveSelector; +} sdlColorStyle; + +#define DEFAULT_COLOR_STYLE { \ + {0x20, 0x20, 0x20, 0xFF}, \ + {0xF0, 0xF0, 0xF0, 0xFF}, \ + {0xF0, 0xF0, 0xF0, 0xFF}, \ + {0xF0, 0xF0, 0xF0, 0xFF}, \ + {0xF0, 0xF0, 0xF0, 0xFF}, \ + {0xF0, 0xF0, 0xF0, 0xFF}, \ + {0x70, 0x70, 0x70, 0xFF}, \ + {0x0, 0x0, 0x0, 0xFF}, \ + {0x10, 0x10, 0x10, 0xFF}, \ + {0x10, 0x10, 0xF0, 0xFF}, \ + {0x0, 0x0, 0x20, 0xFF} \ +} #endif \ No newline at end of file diff --git a/lib/sdl/core/coreWidget.cpp b/lib/sdl/core/coreWidget.cpp index bbb3f8da..c8f36ebe 100644 --- a/lib/sdl/core/coreWidget.cpp +++ b/lib/sdl/core/coreWidget.cpp @@ -1,53 +1,53 @@ -#include "coreWidget.h" - -sdlCoreWidget::sdlCoreWidget(int x, int y, int width, int height, sdlCoreWidget * pParent){ - m_sRect.x = x; - m_sRect.y = y; - m_sRect.w = width; - m_sRect.h = height; - m_pParent = pParent; - m_bRedraw = true; - m_sColorStyle = DEFAULT_COLOR_STYLE; - m_pWidgetTexture = NULL; - m_bNoDecoration = false; - m_pGUI = classGUI_SDL::getInstance(); - if (m_pGUI != NULL) m_pGUI->registerWidget(this); -}; - -sdlCoreWidget::~sdlCoreWidget(){ - if (m_pGUI != NULL) m_pGUI->removeWidget(this); - if (m_pWidgetTexture != NULL) SDL_DestroyTexture(m_pWidgetTexture); -}; - -void sdlCoreWidget::render(SDL_Renderer *pRenderer){ - if (pRenderer == NULL) return; - if (m_pWidgetTexture == NULL) m_pWidgetTexture = SDL_CreateTexture(pRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, m_sRect.w, m_sRect.h); - if (m_pWidgetTexture == NULL) return; - if (m_bRedraw){ - SDL_SetRenderTarget(pRenderer, m_pWidgetTexture); - SDL_SetRenderDrawColor(pRenderer, 0x00, 0x00, 0x00, 0x00); - SDL_RenderFillRect(pRenderer, &m_sRect); - if (!m_bNoDecoration){ - SDL_SetRenderDrawColor(pRenderer, m_sColorStyle.panelBG.r, m_sColorStyle.panelBG.g, m_sColorStyle.panelBG.b, m_sColorStyle.panelBG.a); - SDL_RenderClear(pRenderer); - SDL_Rect r; - r.x = 0; r.y = 0; r.w = m_sRect.w; r.h = m_sRect.h; - SDL_SetRenderDrawColor(pRenderer, m_sColorStyle.borderBODY.r, m_sColorStyle.borderBODY.g, m_sColorStyle.borderBODY.b, m_sColorStyle.borderBODY.a); - SDL_RenderDrawRect(pRenderer, &r); - }; - draw( pRenderer ); - if (m_vWidgets.size()){ - for (pWidgetVector::iterator index = m_vWidgets.begin(); index < m_vWidgets.end(); index++) (*index)->render(pRenderer); - }; - }; - if (m_pParent == NULL){ - SDL_SetRenderTarget(pRenderer, NULL); - } else { - SDL_SetRenderTarget(pRenderer, m_pParent->getWidgetTexture()); - }; - SDL_RenderCopy(pRenderer, m_pWidgetTexture, NULL, &m_sRect); -}; - -void sdlCoreWidget::setColorStyle(sdlColorStyle style){ - m_sColorStyle = style; +#include "coreWidget.h" + +sdlCoreWidget::sdlCoreWidget(int x, int y, int width, int height, sdlCoreWidget * pParent){ + m_sRect.x = x; + m_sRect.y = y; + m_sRect.w = width; + m_sRect.h = height; + m_pParent = pParent; + m_bRedraw = true; + m_sColorStyle = DEFAULT_COLOR_STYLE; + m_pWidgetTexture = NULL; + m_bNoDecoration = false; + m_pGUI = classGUI_SDL::getInstance(); + if (m_pGUI != NULL) m_pGUI->registerWidget(this); +}; + +sdlCoreWidget::~sdlCoreWidget(){ + if (m_pGUI != NULL) m_pGUI->removeWidget(this); + if (m_pWidgetTexture != NULL) SDL_DestroyTexture(m_pWidgetTexture); +}; + +void sdlCoreWidget::render(SDL_Renderer *pRenderer){ + if (pRenderer == NULL) return; + if (m_pWidgetTexture == NULL) m_pWidgetTexture = SDL_CreateTexture(pRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, m_sRect.w, m_sRect.h); + if (m_pWidgetTexture == NULL) return; + if (m_bRedraw){ + SDL_SetRenderTarget(pRenderer, m_pWidgetTexture); + SDL_SetRenderDrawColor(pRenderer, 0x00, 0x00, 0x00, 0x00); + SDL_RenderFillRect(pRenderer, &m_sRect); + if (!m_bNoDecoration){ + SDL_SetRenderDrawColor(pRenderer, m_sColorStyle.panelBG.r, m_sColorStyle.panelBG.g, m_sColorStyle.panelBG.b, m_sColorStyle.panelBG.a); + SDL_RenderClear(pRenderer); + SDL_Rect r; + r.x = 0; r.y = 0; r.w = m_sRect.w; r.h = m_sRect.h; + SDL_SetRenderDrawColor(pRenderer, m_sColorStyle.borderBODY.r, m_sColorStyle.borderBODY.g, m_sColorStyle.borderBODY.b, m_sColorStyle.borderBODY.a); + SDL_RenderDrawRect(pRenderer, &r); + }; + draw( pRenderer ); + if (m_vWidgets.size()){ + for (pWidgetVector::iterator index = m_vWidgets.begin(); index < m_vWidgets.end(); index++) (*index)->render(pRenderer); + }; + }; + if (m_pParent == NULL){ + SDL_SetRenderTarget(pRenderer, NULL); + } else { + SDL_SetRenderTarget(pRenderer, m_pParent->getWidgetTexture()); + }; + SDL_RenderCopy(pRenderer, m_pWidgetTexture, NULL, &m_sRect); +}; + +void sdlCoreWidget::setColorStyle(sdlColorStyle style){ + m_sColorStyle = style; }; \ No newline at end of file diff --git a/lib/sdl/core/coreWidget.h b/lib/sdl/core/coreWidget.h index 44765749..b425250a 100644 --- a/lib/sdl/core/coreWidget.h +++ b/lib/sdl/core/coreWidget.h @@ -1,33 +1,33 @@ -#ifndef __SDL_CORE_WIDGET_HEADER__ -#define __SDL_CORE_WIDGET_HEADER__ - -#include "../gui_sdl.h" -#include "coreStyleTemplate.h" - -class sdlCoreWidget{ - protected: - sdlCoreWidget * m_pParent; - classGUI_SDL * m_pGUI; - SDL_Rect m_sRect; - sdlColorStyle m_sColorStyle; - pWidgetVector m_vWidgets; - SDL_Texture * m_pWidgetTexture; - bool m_bNoDecoration; - bool m_bRedraw; - void requerstUpdate(void); - virtual void draw(SDL_Renderer *pRenderer){}; - SDL_Texture * getWidgetTexture(void){ return m_pWidgetTexture; }; - public: - explicit sdlCoreWidget(int x, int y, int width, int height, sdlCoreWidget * pParent = NULL); - virtual ~sdlCoreWidget(); - void render(SDL_Renderer *pRenderer); - SDL_Rect * getBoundRect(void){ return &m_sRect; }; - virtual void dispatch(SDL_Event *pEvt){}; - void setColorStyle(sdlColorStyle style); - virtual void hide(){}; - void addWidget(sdlCoreWidget *tPtr); - void setDecoraion(bool A){ m_bNoDecoration = !A; }; -}; - - +#ifndef __SDL_CORE_WIDGET_HEADER__ +#define __SDL_CORE_WIDGET_HEADER__ + +#include "../gui_sdl.h" +#include "coreStyleTemplate.h" + +class sdlCoreWidget{ + protected: + sdlCoreWidget * m_pParent; + classGUI_SDL * m_pGUI; + SDL_Rect m_sRect; + sdlColorStyle m_sColorStyle; + pWidgetVector m_vWidgets; + SDL_Texture * m_pWidgetTexture; + bool m_bNoDecoration; + bool m_bRedraw; + void requerstUpdate(void); + virtual void draw(SDL_Renderer *pRenderer){}; + SDL_Texture * getWidgetTexture(void){ return m_pWidgetTexture; }; + public: + explicit sdlCoreWidget(int x, int y, int width, int height, sdlCoreWidget * pParent = NULL); + virtual ~sdlCoreWidget(); + void render(SDL_Renderer *pRenderer); + SDL_Rect * getBoundRect(void){ return &m_sRect; }; + virtual void dispatch(SDL_Event *pEvt){}; + void setColorStyle(sdlColorStyle style); + virtual void hide(){}; + void addWidget(sdlCoreWidget *tPtr); + void setDecoraion(bool A){ m_bNoDecoration = !A; }; +}; + + #endif \ No newline at end of file diff --git a/lib/sdl/gui_sdl.cpp b/lib/sdl/gui_sdl.cpp index b2a416e3..8dc5448c 100644 --- a/lib/sdl/gui_sdl.cpp +++ b/lib/sdl/gui_sdl.cpp @@ -1,193 +1,193 @@ -#include "gui_sdl.h" -#include "core/coreWidget.h" - -classGUI_SDL * classGUI_SDL::m_pInstance = NULL; -classGUI_SDL * classGUI_SDL::getInstance(void){ - if (m_pInstance == NULL){ - m_pInstance = new classGUI_SDL(); - }; - return m_pInstance; -}; - -classGUI_SDL::classGUI_SDL(): basicThread(){ - m_pWindow = NULL; - m_pScreenSurface = NULL; - m_pTexture = NULL; - m_pRenderer = NULL; - m_bWindowSystemOk = false; - m_bInitOk = false; - m_pProtector = SDL_CreateMutex(); - int display_count = 0, display_index = 0, mode_index = 0; - SDL_DisplayMode mode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 }; - if ((display_count = SDL_GetNumVideoDisplays()) < 1) { - SDL_Log("SDL_GetNumVideoDisplays returned: %i", display_count); - }; - SDL_Log("SDL_GetNumVideoDisplays returned: %i", display_count); - if (SDL_GetDisplayMode(display_index, mode_index, &mode) != 0) { - SDL_Log("SDL_GetDisplayMode failed: %s", SDL_GetError()); - }; - SDL_Log("SDL_GetDisplayMode(0, 0, &mode):\t\t%i bpp\t%i x %i", SDL_BITSPERPIXEL(mode.format), mode.w, mode.h ); - m_bInitOk = basicThread::init(); - while ( ( m_bWindowSystemOk == false ) && ( m_bThreadStatus < TH_ENDED ) ) SLEEP(1); -}; - -classGUI_SDL::~classGUI_SDL(){ - m_bWindowSystemOk = false; - m_bInitOk = false; - SDL_DestroyMutex( m_pProtector ); - if (m_pRenderer!=NULL){ - SDL_DestroyRenderer(m_pRenderer); - }; - if (m_pScreenSurface != NULL){ - //Deallocate surface - SDL_FreeSurface(m_pScreenSurface); - m_pScreenSurface = NULL; - }; - if ( m_pWindow!= NULL ){ - //Destroy window - SDL_DestroyWindow(m_pWindow); - m_pWindow = NULL; - }; - //Quit SDL subsystems - SDL_Quit(); -}; - - - -//https://www.facebook.com/missing.person.3158 -//https://www.facebook.com/guga.wereteli.90 -//https://www.facebook.com/mentul.ohmentul -//https://www.facebook.com/profile.php?id=100001772172980 -//https://www.facebook.com/egagua -/* Collect Confirmation Codes -Contact your friends and ask them for their help. -1. Call three of these friends or talk to them in person. -Raphael LlamadoChantebis SamkaroMentul OhmentulEstrada Irish PotchEvgeny Gagua -2. Ask them to visit : -https ://www.facebook.com/recover -3. Each friend will give you a code.Enter them below : -*/ -void classGUI_SDL::m_fThreadProc(void){ - if( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ){ - m_bInitOk = false; - m_bThreadStatus = TH_ENDED; - return; - }; - if (!(IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG)){ - //printf("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError()); - m_bInitOk = false; - m_bThreadStatus = TH_ENDED; - return; - }; - - //Initialize SDL_ttf - if( TTF_Init() == -1 ){ - //printf("SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError()); - m_bInitOk = false; - m_bThreadStatus = TH_ENDED; - return; - } else { - m_bInitOk = true; - if (SDL_CreateWindowAndRenderer(SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_RESIZABLE, &m_pWindow, &m_pRenderer)){ - printf("Window could not be created! SDL_Error: %s\n", SDL_GetError()); - m_bThreadStatus = TH_ENDED; - m_bWindowSystemOk = false; - return; - } else { - //SDL_SetWindowOpacity(m_pWindow, 0.5); - //Get window surface - //m_pScreenSurface = SDL_GetWindowSurface(m_pWindow); - m_bThreadStatus = TH_WORKING; - m_bWindowSystemOk = true; - }; - }; - while( m_bThreadStatus < TH_ENDED ){ - //Event handler - SDL_Event mEvent; - //Handle events on queue - if( SDL_PollEvent(&mEvent) != 0 ){ - //m_mProtector.lock(); - SDL_LockMutex(m_pProtector); - if (m_vWidgets.size()){ - for (pWidgetVector::iterator index = m_vWidgets.begin(); index < m_vWidgets.end(); index++) (*index)->dispatch(&mEvent); - }; - //m_mProtector.unlock(); - SDL_UnlockMutex(m_pProtector); - // Global Window Event handler - if( mEvent.type == SDL_QUIT ){ - m_bThreadStatus = TH_ENDED; - } else if (mEvent.type == SDL_KEYDOWN){ //User presses a key - //Select surfaces based on key press - switch( mEvent.key.keysym.sym ){ - case SDLK_UP: - //gCurrentSurface = gKeyPressSurfaces[KEY_PRESS_SURFACE_UP]; - break; - case SDLK_DOWN: - //gCurrentSurface = gKeyPressSurfaces[KEY_PRESS_SURFACE_DOWN]; - break; - case SDLK_LEFT: - //gCurrentSurface = gKeyPressSurfaces[KEY_PRESS_SURFACE_LEFT]; - break; - case SDLK_RIGHT: - //gCurrentSurface = gKeyPressSurfaces[KEY_PRESS_SURFACE_RIGHT]; - break; - default: - //gCurrentSurface = gKeyPressSurfaces[KEY_PRESS_SURFACE_DEFAULT]; - break; - }; - }; - }; - //m_mProtector.lock(); - SDL_LockMutex(m_pProtector); - if (m_vWidgets.size()){ - for (pWidgetVector::iterator index = m_vWidgets.begin(); index < m_vWidgets.end(); index++) (*index)->render(m_pRenderer); - SDL_RenderPresent(m_pRenderer); - }; - //m_mProtector.unlock(); - SDL_UnlockMutex(m_pProtector); - //Apply the image - //SDL_BlitSurface(gXOut, NULL, m_pScreenSurface, NULL); - //Update the surface - //SDL_UpdateWindowSurface(m_pWindow); - //SLEEP(150); - }; -}; -//FOXCONN PVB120G12H-P01 -//AVC MD413 BA13733B12H - -void classGUI_SDL::registerWidget(sdlCoreWidget * tPtr){ - while( !m_bWindowSystemOk ) SLEEP(1); - if( tPtr != NULL ){ - //m_mProtector.lock(); - SDL_LockMutex(m_pProtector); - m_vWidgets.push_back(tPtr); - //m_mProtector.unlock(); - SDL_UnlockMutex(m_pProtector); - }; -}; - -void classGUI_SDL::removeWidget(sdlCoreWidget * tPtr){ - if (tPtr != NULL){ - //m_mProtector.lock(); - SDL_LockMutex(m_pProtector); - for (pWidgetVector::iterator index = m_vWidgets.begin(); index < m_vWidgets.end(); index++){ - if ((*index) == tPtr){ - (*index)->hide(); - m_vWidgets.erase(index); - break; - }; - }; - //m_mProtector.unlock(); - SDL_UnlockMutex(m_pProtector); - }; -}; - -bool classGUI_SDL::setFullScreen( bool status ){ - if (m_pWindow == NULL) return false; - if (status){ - SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN ); - } else { - SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN_DESKTOP); - }; - return true; +#include "gui_sdl.h" +#include "core/coreWidget.h" + +classGUI_SDL * classGUI_SDL::m_pInstance = NULL; +classGUI_SDL * classGUI_SDL::getInstance(void){ + if (m_pInstance == NULL){ + m_pInstance = new classGUI_SDL(); + }; + return m_pInstance; +}; + +classGUI_SDL::classGUI_SDL(): basicThread(){ + m_pWindow = NULL; + m_pScreenSurface = NULL; + m_pTexture = NULL; + m_pRenderer = NULL; + m_bWindowSystemOk = false; + m_bInitOk = false; + m_pProtector = SDL_CreateMutex(); + int display_count = 0, display_index = 0, mode_index = 0; + SDL_DisplayMode mode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 }; + if ((display_count = SDL_GetNumVideoDisplays()) < 1) { + SDL_Log("SDL_GetNumVideoDisplays returned: %i", display_count); + }; + SDL_Log("SDL_GetNumVideoDisplays returned: %i", display_count); + if (SDL_GetDisplayMode(display_index, mode_index, &mode) != 0) { + SDL_Log("SDL_GetDisplayMode failed: %s", SDL_GetError()); + }; + SDL_Log("SDL_GetDisplayMode(0, 0, &mode):\t\t%i bpp\t%i x %i", SDL_BITSPERPIXEL(mode.format), mode.w, mode.h ); + m_bInitOk = basicThread::init(); + while ( ( m_bWindowSystemOk == false ) && ( m_bThreadStatus < TH_ENDED ) ) SLEEP(1); +}; + +classGUI_SDL::~classGUI_SDL(){ + m_bWindowSystemOk = false; + m_bInitOk = false; + SDL_DestroyMutex( m_pProtector ); + if (m_pRenderer!=NULL){ + SDL_DestroyRenderer(m_pRenderer); + }; + if (m_pScreenSurface != NULL){ + //Deallocate surface + SDL_FreeSurface(m_pScreenSurface); + m_pScreenSurface = NULL; + }; + if ( m_pWindow!= NULL ){ + //Destroy window + SDL_DestroyWindow(m_pWindow); + m_pWindow = NULL; + }; + //Quit SDL subsystems + SDL_Quit(); +}; + + + +//https://www.facebook.com/missing.person.3158 +//https://www.facebook.com/guga.wereteli.90 +//https://www.facebook.com/mentul.ohmentul +//https://www.facebook.com/profile.php?id=100001772172980 +//https://www.facebook.com/egagua +/* Collect Confirmation Codes +Contact your friends and ask them for their help. +1. Call three of these friends or talk to them in person. +Raphael LlamadoChantebis SamkaroMentul OhmentulEstrada Irish PotchEvgeny Gagua +2. Ask them to visit : +https ://www.facebook.com/recover +3. Each friend will give you a code.Enter them below : +*/ +void classGUI_SDL::m_fThreadProc(void){ + if( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ){ + m_bInitOk = false; + m_bThreadStatus = TH_ENDED; + return; + }; + if (!(IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG)){ + //printf("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError()); + m_bInitOk = false; + m_bThreadStatus = TH_ENDED; + return; + }; + + //Initialize SDL_ttf + if( TTF_Init() == -1 ){ + //printf("SDL_ttf could not initialize! SDL_ttf Error: %s\n", TTF_GetError()); + m_bInitOk = false; + m_bThreadStatus = TH_ENDED; + return; + } else { + m_bInitOk = true; + if (SDL_CreateWindowAndRenderer(SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_RESIZABLE, &m_pWindow, &m_pRenderer)){ + printf("Window could not be created! SDL_Error: %s\n", SDL_GetError()); + m_bThreadStatus = TH_ENDED; + m_bWindowSystemOk = false; + return; + } else { + //SDL_SetWindowOpacity(m_pWindow, 0.5); + //Get window surface + //m_pScreenSurface = SDL_GetWindowSurface(m_pWindow); + m_bThreadStatus = TH_WORKING; + m_bWindowSystemOk = true; + }; + }; + while( m_bThreadStatus < TH_ENDED ){ + //Event handler + SDL_Event mEvent; + //Handle events on queue + if( SDL_PollEvent(&mEvent) != 0 ){ + //m_mProtector.lock(); + SDL_LockMutex(m_pProtector); + if (m_vWidgets.size()){ + for (pWidgetVector::iterator index = m_vWidgets.begin(); index < m_vWidgets.end(); index++) (*index)->dispatch(&mEvent); + }; + //m_mProtector.unlock(); + SDL_UnlockMutex(m_pProtector); + // Global Window Event handler + if( mEvent.type == SDL_QUIT ){ + m_bThreadStatus = TH_ENDED; + } else if (mEvent.type == SDL_KEYDOWN){ //User presses a key + //Select surfaces based on key press + switch( mEvent.key.keysym.sym ){ + case SDLK_UP: + //gCurrentSurface = gKeyPressSurfaces[KEY_PRESS_SURFACE_UP]; + break; + case SDLK_DOWN: + //gCurrentSurface = gKeyPressSurfaces[KEY_PRESS_SURFACE_DOWN]; + break; + case SDLK_LEFT: + //gCurrentSurface = gKeyPressSurfaces[KEY_PRESS_SURFACE_LEFT]; + break; + case SDLK_RIGHT: + //gCurrentSurface = gKeyPressSurfaces[KEY_PRESS_SURFACE_RIGHT]; + break; + default: + //gCurrentSurface = gKeyPressSurfaces[KEY_PRESS_SURFACE_DEFAULT]; + break; + }; + }; + }; + //m_mProtector.lock(); + SDL_LockMutex(m_pProtector); + if (m_vWidgets.size()){ + for (pWidgetVector::iterator index = m_vWidgets.begin(); index < m_vWidgets.end(); index++) (*index)->render(m_pRenderer); + SDL_RenderPresent(m_pRenderer); + }; + //m_mProtector.unlock(); + SDL_UnlockMutex(m_pProtector); + //Apply the image + //SDL_BlitSurface(gXOut, NULL, m_pScreenSurface, NULL); + //Update the surface + //SDL_UpdateWindowSurface(m_pWindow); + //SLEEP(150); + }; +}; +//FOXCONN PVB120G12H-P01 +//AVC MD413 BA13733B12H + +void classGUI_SDL::registerWidget(sdlCoreWidget * tPtr){ + while( !m_bWindowSystemOk ) SLEEP(1); + if( tPtr != NULL ){ + //m_mProtector.lock(); + SDL_LockMutex(m_pProtector); + m_vWidgets.push_back(tPtr); + //m_mProtector.unlock(); + SDL_UnlockMutex(m_pProtector); + }; +}; + +void classGUI_SDL::removeWidget(sdlCoreWidget * tPtr){ + if (tPtr != NULL){ + //m_mProtector.lock(); + SDL_LockMutex(m_pProtector); + for (pWidgetVector::iterator index = m_vWidgets.begin(); index < m_vWidgets.end(); index++){ + if ((*index) == tPtr){ + (*index)->hide(); + m_vWidgets.erase(index); + break; + }; + }; + //m_mProtector.unlock(); + SDL_UnlockMutex(m_pProtector); + }; +}; + +bool classGUI_SDL::setFullScreen( bool status ){ + if (m_pWindow == NULL) return false; + if (status){ + SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN ); + } else { + SDL_SetWindowFullscreen(m_pWindow, SDL_WINDOW_FULLSCREEN_DESKTOP); + }; + return true; }; \ No newline at end of file diff --git a/lib/sdl/gui_sdl.h b/lib/sdl/gui_sdl.h index 58af5a50..67314661 100644 --- a/lib/sdl/gui_sdl.h +++ b/lib/sdl/gui_sdl.h @@ -1,42 +1,42 @@ -#ifndef __GUI_SDL_HEADER__ -#define __GUI_SDL_HEADER__ - -#include -#include -#include "../components/base/basicMutex.h" -#include "../components/base/basicThread.h" -#include -#include -#include - -#define SCREEN_WIDTH 800 -#define SCREEN_HEIGHT 600 - -class sdlCoreWidget; - -typedef std::vector pWidgetVector; - -class classGUI_SDL: public basicThread{ - private: - bool m_bInitOk; - bool m_bWindowSystemOk; - SDL_Window * m_pWindow; - SDL_Renderer * m_pRenderer; - SDL_Surface * m_pScreenSurface; - SDL_Texture * m_pTexture; - //basicMutex m_mProtector; - SDL_mutex * m_pProtector; - pWidgetVector m_vWidgets; - public: - static classGUI_SDL * getInstance(); - virtual void m_fThreadProc(void); - void registerWidget(sdlCoreWidget * tPtr); - void removeWidget( sdlCoreWidget * tPtr); - bool setFullScreen( bool status ); - protected: - classGUI_SDL(); - ~classGUI_SDL(); - static classGUI_SDL * m_pInstance; -}; - +#ifndef __GUI_SDL_HEADER__ +#define __GUI_SDL_HEADER__ + +#include +#include +#include "../components/base/basicMutex.h" +#include "../components/base/basicThread.h" +#include +#include +#include + +#define SCREEN_WIDTH 800 +#define SCREEN_HEIGHT 600 + +class sdlCoreWidget; + +typedef std::vector pWidgetVector; + +class classGUI_SDL: public basicThread{ + private: + bool m_bInitOk; + bool m_bWindowSystemOk; + SDL_Window * m_pWindow; + SDL_Renderer * m_pRenderer; + SDL_Surface * m_pScreenSurface; + SDL_Texture * m_pTexture; + //basicMutex m_mProtector; + SDL_mutex * m_pProtector; + pWidgetVector m_vWidgets; + public: + static classGUI_SDL * getInstance(); + virtual void m_fThreadProc(void); + void registerWidget(sdlCoreWidget * tPtr); + void removeWidget( sdlCoreWidget * tPtr); + bool setFullScreen( bool status ); + protected: + classGUI_SDL(); + ~classGUI_SDL(); + static classGUI_SDL * m_pInstance; +}; + #endif \ No newline at end of file diff --git a/lib/sdl/widgets/logWidget.cpp b/lib/sdl/widgets/logWidget.cpp index 0191e344..de9189a0 100644 --- a/lib/sdl/widgets/logWidget.cpp +++ b/lib/sdl/widgets/logWidget.cpp @@ -1,59 +1,59 @@ -#include "logWidget.h" - -sdlLog::sdlLog(int x, int y, int width, int height, sdlCoreWidget * pWnd) :sdlCoreWidget(x, y, width, height, pWnd){ - m_nLines = height / SDL_DEFAULT_LOG_ROW_SIZE; - m_nCurrentLine = 0; - m_ppLines = (sdlLabel**)calloc( m_nLines, sizeof(sdlLabel*) ); - memset( m_ppLines, 0, m_nLines * sizeof(sdlLabel*) ); -}; - -sdlLog::~sdlLog(){ - if (m_ppLines != NULL){ - for (int index = 0; index < m_nLines; index++) delete(m_ppLines[index]); - free(m_ppLines); - }; -}; - -void sdlLog::logMessage(const char *Msg){ - if (m_ppLines != NULL){ - //m_mProtector.lock(); - if (m_nCurrentLine < m_nLines){ - m_ppLines[m_nCurrentLine] = new sdlLabel( - 1, - 1 + (m_nCurrentLine*SDL_DEFAULT_LOG_ROW_SIZE), - m_sRect.w - 2, - SDL_DEFAULT_LOG_ROW_SIZE, - this, - SDL_DEFAULT_LOG_FONT_SIZE - ); - if( m_ppLines[m_nCurrentLine] != NULL ){ - m_ppLines[m_nCurrentLine]->setAlign(ALIGN_LEFT); - m_nCurrentLine++; - }; - for (int index = m_nCurrentLine - 1; index > 0; index--){ - char tBuf[SDL_DEFAULT_TEXT_SIZE]; - memcpy(tBuf, m_ppLines[index - 1]->getText(), SDL_DEFAULT_TEXT_SIZE); - m_ppLines[index]->setText(tBuf); - }; - m_ppLines[0]->setText((CSTR)Msg); - } else { - for (int index = m_nLines - 1; index > 0; index-- ){ - char tBuf[SDL_DEFAULT_TEXT_SIZE]; - memcpy(tBuf, m_ppLines[index-1]->getText(), SDL_DEFAULT_TEXT_SIZE); - m_ppLines[index]->setText(tBuf); - }; - m_ppLines[0]->setText((CSTR)Msg); - }; - //m_mProtector.unlock(); - }; -}; - -void sdlLog::logMessage(CSTR Msg){ - logMessage((const char*)Msg); -}; - -void sdlLog::draw(SDL_Renderer *pRenderer){ - for (int index = 0; index < m_nLines; index++){ - if (m_ppLines[index] != NULL) m_ppLines[index]->render(pRenderer); - }; +#include "logWidget.h" + +sdlLog::sdlLog(int x, int y, int width, int height, sdlCoreWidget * pWnd) :sdlCoreWidget(x, y, width, height, pWnd){ + m_nLines = height / SDL_DEFAULT_LOG_ROW_SIZE; + m_nCurrentLine = 0; + m_ppLines = (sdlLabel**)calloc( m_nLines, sizeof(sdlLabel*) ); + memset( m_ppLines, 0, m_nLines * sizeof(sdlLabel*) ); +}; + +sdlLog::~sdlLog(){ + if (m_ppLines != NULL){ + for (int index = 0; index < m_nLines; index++) delete(m_ppLines[index]); + free(m_ppLines); + }; +}; + +void sdlLog::logMessage(const char *Msg){ + if (m_ppLines != NULL){ + //m_mProtector.lock(); + if (m_nCurrentLine < m_nLines){ + m_ppLines[m_nCurrentLine] = new sdlLabel( + 1, + 1 + (m_nCurrentLine*SDL_DEFAULT_LOG_ROW_SIZE), + m_sRect.w - 2, + SDL_DEFAULT_LOG_ROW_SIZE, + this, + SDL_DEFAULT_LOG_FONT_SIZE + ); + if( m_ppLines[m_nCurrentLine] != NULL ){ + m_ppLines[m_nCurrentLine]->setAlign(ALIGN_LEFT); + m_nCurrentLine++; + }; + for (int index = m_nCurrentLine - 1; index > 0; index--){ + char tBuf[SDL_DEFAULT_TEXT_SIZE]; + memcpy(tBuf, m_ppLines[index - 1]->getText(), SDL_DEFAULT_TEXT_SIZE); + m_ppLines[index]->setText(tBuf); + }; + m_ppLines[0]->setText((CSTR)Msg); + } else { + for (int index = m_nLines - 1; index > 0; index-- ){ + char tBuf[SDL_DEFAULT_TEXT_SIZE]; + memcpy(tBuf, m_ppLines[index-1]->getText(), SDL_DEFAULT_TEXT_SIZE); + m_ppLines[index]->setText(tBuf); + }; + m_ppLines[0]->setText((CSTR)Msg); + }; + //m_mProtector.unlock(); + }; +}; + +void sdlLog::logMessage(CSTR Msg){ + logMessage((const char*)Msg); +}; + +void sdlLog::draw(SDL_Renderer *pRenderer){ + for (int index = 0; index < m_nLines; index++){ + if (m_ppLines[index] != NULL) m_ppLines[index]->render(pRenderer); + }; }; \ No newline at end of file diff --git a/lib/sdl/widgets/logWidget.h b/lib/sdl/widgets/logWidget.h index 24be8068..70dccd85 100644 --- a/lib/sdl/widgets/logWidget.h +++ b/lib/sdl/widgets/logWidget.h @@ -1,29 +1,29 @@ -#ifndef __SDL_LOG_WIDGET_HEADER__ -#define __SDL_LOG_WIDGET_HEADER__ -#include "../core/coreWidget.h" -#include "../core/coreLabel.h" -#include "../../components/base/basicMutex.h" -#include "../../components/base/basicLoggingService.h" - -#define SDL_DEFAULT_LOG_FONT_SIZE 10 -#define SDL_DEFAULT_LOG_ROW_SIZE 12 - -class sdlLog :public basicLoggingService, public sdlCoreWidget { - private: - sdlLabel ** m_ppLines; - int m_nLines; - int m_nCurrentLine; - basicMutex m_mProtector; - protected: - virtual void draw(SDL_Renderer *pRenderer); - public: - explicit sdlLog(int x, int y, int width, int height, sdlCoreWidget * pWnd = NULL); - virtual ~sdlLog(); +#ifndef __SDL_LOG_WIDGET_HEADER__ +#define __SDL_LOG_WIDGET_HEADER__ +#include "../core/coreWidget.h" +#include "../core/coreLabel.h" +#include "../../components/base/basicMutex.h" +#include "../../components/base/basicLoggingService.h" + +#define SDL_DEFAULT_LOG_FONT_SIZE 10 +#define SDL_DEFAULT_LOG_ROW_SIZE 12 + +class sdlLog :public basicLoggingService, public sdlCoreWidget { + private: + sdlLabel ** m_ppLines; + int m_nLines; + int m_nCurrentLine; + basicMutex m_mProtector; + protected: + virtual void draw(SDL_Renderer *pRenderer); + public: + explicit sdlLog(int x, int y, int width, int height, sdlCoreWidget * pWnd = NULL); + virtual ~sdlLog(); virtual void logMessage(CSTR Msg); - virtual void logMessage(const char *Msg); -}; - - - - + virtual void logMessage(const char *Msg); +}; + + + + #endif \ No newline at end of file diff --git a/lib/sdl/widgets/progressBar.cpp b/lib/sdl/widgets/progressBar.cpp index 959682c7..80b7664f 100644 --- a/lib/sdl/widgets/progressBar.cpp +++ b/lib/sdl/widgets/progressBar.cpp @@ -1,59 +1,59 @@ -#include "progressBar.h" -sdlProgressBar::sdlProgressBar(int x, int y, int width, int height, sdlCoreWidget * pWnd) :sdlCoreWidget(x, y, width, height, pWnd){ - m_pStatusProvider = NULL; - m_pLabel = NULL; -}; - -sdlProgressBar::~sdlProgressBar(){ - -}; - -void sdlProgressBar::draw(SDL_Renderer *pRenderer){ - m_mStatusProtecter.lock(); - if( m_pStatusProvider ){ - SDL_Rect r; - char tBuff[256]; - uint8_t bStatus; - bStatus = m_pStatusProvider->getStatus(tBuff); - if (tBuff[0]!=(char)0)setText(tBuff); - if (bStatus > 0){ - SDL_SetRenderDrawColor(pRenderer, m_sColorStyle.activeSelector.r, m_sColorStyle.activeSelector.g, m_sColorStyle.activeSelector.b, m_sColorStyle.activeSelector.a); - if (bStatus < 100){ - r.x = 1; r.y = 1; r.w = ( m_sRect.w * bStatus ) / 100 -2; r.h = m_sRect.h - 2; - } else { - r.x = 1; r.y = 1; r.w = m_sRect.w - 2; r.h = m_sRect.h - 2; - }; - //SDL_RenderDrawRect(pRenderer, &r); - SDL_RenderFillRect(pRenderer, &r); - - if (m_pLabel != NULL) m_pLabel->render(pRenderer); - //SDL_SetRenderDrawColor(pRenderer, m_sColorStyle.borderBODY.r, m_sColorStyle.borderBODY.g, m_sColorStyle.borderBODY.b, m_sColorStyle.borderBODY.a); - //r.x = 0; r.y = 0; r.w = m_sRect.w; r.h = m_sRect.h; - //SDL_RenderDrawRect(pRenderer, &r); - }; - }; - m_mStatusProtecter.unlock(); -}; - -void sdlProgressBar::dispatch(SDL_Event *pEvt){ - if (pEvt->type == SDL_MOUSEMOTION || pEvt->type == SDL_MOUSEBUTTONDOWN || pEvt->type == SDL_MOUSEBUTTONUP){ - //Get mouse position - int x, y; - SDL_GetMouseState(&x, &y); - }; -}; - -void sdlProgressBar::attachStatusProvider(basicStatusProvider *tPtr){ - m_mStatusProtecter.lock(); - m_pStatusProvider = tPtr; - m_mStatusProtecter.unlock(); -}; - -void sdlProgressBar::setText(CSTR tPtr){ - if (m_pLabel == NULL){ - m_pLabel = new sdlLabel( 1, 1, m_sRect.w - 2, m_sRect.h - 2, this, 12 ); - }; - if (m_pLabel != NULL){ - m_pLabel->setText(tPtr); - }; +#include "progressBar.h" +sdlProgressBar::sdlProgressBar(int x, int y, int width, int height, sdlCoreWidget * pWnd) :sdlCoreWidget(x, y, width, height, pWnd){ + m_pStatusProvider = NULL; + m_pLabel = NULL; +}; + +sdlProgressBar::~sdlProgressBar(){ + +}; + +void sdlProgressBar::draw(SDL_Renderer *pRenderer){ + m_mStatusProtecter.lock(); + if( m_pStatusProvider ){ + SDL_Rect r; + char tBuff[256]; + uint8_t bStatus; + bStatus = m_pStatusProvider->getStatus(tBuff); + if (tBuff[0]!=(char)0)setText(tBuff); + if (bStatus > 0){ + SDL_SetRenderDrawColor(pRenderer, m_sColorStyle.activeSelector.r, m_sColorStyle.activeSelector.g, m_sColorStyle.activeSelector.b, m_sColorStyle.activeSelector.a); + if (bStatus < 100){ + r.x = 1; r.y = 1; r.w = ( m_sRect.w * bStatus ) / 100 -2; r.h = m_sRect.h - 2; + } else { + r.x = 1; r.y = 1; r.w = m_sRect.w - 2; r.h = m_sRect.h - 2; + }; + //SDL_RenderDrawRect(pRenderer, &r); + SDL_RenderFillRect(pRenderer, &r); + + if (m_pLabel != NULL) m_pLabel->render(pRenderer); + //SDL_SetRenderDrawColor(pRenderer, m_sColorStyle.borderBODY.r, m_sColorStyle.borderBODY.g, m_sColorStyle.borderBODY.b, m_sColorStyle.borderBODY.a); + //r.x = 0; r.y = 0; r.w = m_sRect.w; r.h = m_sRect.h; + //SDL_RenderDrawRect(pRenderer, &r); + }; + }; + m_mStatusProtecter.unlock(); +}; + +void sdlProgressBar::dispatch(SDL_Event *pEvt){ + if (pEvt->type == SDL_MOUSEMOTION || pEvt->type == SDL_MOUSEBUTTONDOWN || pEvt->type == SDL_MOUSEBUTTONUP){ + //Get mouse position + int x, y; + SDL_GetMouseState(&x, &y); + }; +}; + +void sdlProgressBar::attachStatusProvider(basicStatusProvider *tPtr){ + m_mStatusProtecter.lock(); + m_pStatusProvider = tPtr; + m_mStatusProtecter.unlock(); +}; + +void sdlProgressBar::setText(CSTR tPtr){ + if (m_pLabel == NULL){ + m_pLabel = new sdlLabel( 1, 1, m_sRect.w - 2, m_sRect.h - 2, this, 12 ); + }; + if (m_pLabel != NULL){ + m_pLabel->setText(tPtr); + }; }; \ No newline at end of file diff --git a/lib/sdl/widgets/progressBar.h b/lib/sdl/widgets/progressBar.h index 715edcf6..30802931 100644 --- a/lib/sdl/widgets/progressBar.h +++ b/lib/sdl/widgets/progressBar.h @@ -1,23 +1,23 @@ -#ifndef __GUI_SDL_WIDGET_PROGRESS_BAR_HEADER__ -#define __GUI_SDL_WIDGET_PROGRESS_BAR_HEADER__ -#include "../core/coreWidget.h" -#include "../core/coreLabel.h" -#include "../../components/base/basicMutex.h" -#include "../../components/base/basicStatusProvider.h" - -class sdlProgressBar : public sdlCoreWidget{ - private: - basicStatusProvider * m_pStatusProvider; - sdlLabel * m_pLabel; - basicMutex m_mStatusProtecter; - protected: - virtual void draw(SDL_Renderer *pRenderer); - public: - explicit sdlProgressBar(int x, int y, int width, int height, sdlCoreWidget * pWnd = NULL); - virtual ~sdlProgressBar(); - void attachStatusProvider(basicStatusProvider *tPtr); - virtual void dispatch(SDL_Event *pEvt); - void setText( CSTR tPtr ); -}; - +#ifndef __GUI_SDL_WIDGET_PROGRESS_BAR_HEADER__ +#define __GUI_SDL_WIDGET_PROGRESS_BAR_HEADER__ +#include "../core/coreWidget.h" +#include "../core/coreLabel.h" +#include "../../components/base/basicMutex.h" +#include "../../components/base/basicStatusProvider.h" + +class sdlProgressBar : public sdlCoreWidget{ + private: + basicStatusProvider * m_pStatusProvider; + sdlLabel * m_pLabel; + basicMutex m_mStatusProtecter; + protected: + virtual void draw(SDL_Renderer *pRenderer); + public: + explicit sdlProgressBar(int x, int y, int width, int height, sdlCoreWidget * pWnd = NULL); + virtual ~sdlProgressBar(); + void attachStatusProvider(basicStatusProvider *tPtr); + virtual void dispatch(SDL_Event *pEvt); + void setText( CSTR tPtr ); +}; + #endif \ No newline at end of file