• R/O
  • HTTP
  • SSH
  • HTTPS

cpp: Commit

psychlops cpp


Commit MetaInfo

Revisione84165b09393ea1992e0ec2696a044eb7c4e401d (tree)
Time2016-07-04 19:21:23
AuthorHOSOKAWA Kenchi <hosokawa.kenchi@gmai...>
CommiterHOSOKAWA Kenchi

Log Message

font

Change Summary

Incremental Difference

--- a/psychlops/core/graphic/psychlops_g_font.cpp
+++ b/psychlops/core/graphic/psychlops_g_font.cpp
@@ -78,23 +78,23 @@ namespace Psychlops {
7878 Letters::Cache::Cache(APIFontProperties* id__, bool dirty__) : id(id__), dirty(dirty__) {}
7979
8080 Letters::Letters()
81- : str(), font(Font::default_font), width_(0), height_(0), vertical_align(BASELINE)
81+ : str(), font(Font::default_font), width_(0), height_(0), vertical_align(BASELINE), _zoom_cache(false)
8282 {
8383 }
8484 Letters::Letters(const char *init_str, const Font& init_font)
85- : font(init_font), width_(0), height_(0), vertical_align(BASELINE)
85+ : font(init_font), width_(0), height_(0), vertical_align(BASELINE), _zoom_cache(false)
8686 {
8787 str = LocalEncodingtoWCHAR(init_str);
8888 cache();
8989 }
9090 Letters::Letters(const char *init_str, int size_, const Font& init_font)
91- : font(init_font), width_(0), height_(0), vertical_align(BASELINE)
91+ : font(init_font), width_(0), height_(0), vertical_align(BASELINE), _zoom_cache(false)
9292 {
9393 str = LocalEncodingtoWCHAR(init_str, size_);
9494 cache();
9595 }
9696 Letters::Letters(const std::wstring &init_str, const Font& init_font)
97- : str(init_str), font(init_font), width_(0), height_(0), vertical_align(BASELINE)
97+ : str(init_str), font(init_font), width_(0), height_(0), vertical_align(BASELINE), _zoom_cache(false)
9898 {
9999 cache();
100100 }
--- a/psychlops/core/graphic/psychlops_g_font.h
+++ b/psychlops/core/graphic/psychlops_g_font.h
@@ -85,9 +85,10 @@ namespace Psychlops {
8585 typedef std::map<DrawableWithCache*, Cache> CacheID;
8686 mutable CacheID caches;
8787 // bool cached;
88- double width_, height_;
88+ double width_, height_;
8989
9090 public:
91+ bool _zoom_cache;
9192 Font font;
9293 std::wstring str;
9394 enum HorizontalAlign { NOT_SPECIFIED=-1, TEXT_ALIGN_LEFT=0, TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT };
--- a/psychlops/core/graphic/psychlops_g_image.cpp
+++ b/psychlops/core/graphic/psychlops_g_image.cpp
@@ -106,7 +106,8 @@ namespace Psychlops {
106106 width_ = 0;
107107 height_ = 0;
108108 pixcomp_ = RGB;
109- pixprec_ = BYTE;
109+ pixprec_ = BYTE;
110+ _zoom_percentage_ = 100;
110111 }
111112
112113
--- a/psychlops/core/graphic/psychlops_g_image.h
+++ b/psychlops/core/graphic/psychlops_g_image.h
@@ -174,7 +174,10 @@ namespace IMAGE_FORMATS {
174174 *(++bitmapf) = b/255.0;
175175 if(pixcomp_==Image::RGB) return; else *(++bitmapf) = a;
176176 }
177- }
177+ }
178+
179+ public:
180+ double _zoom_percentage_;
178181
179182 protected:
180183 int width_, height_;
--- a/psychlops/platform/gl/psychlops_g_cache.cpp
+++ b/psychlops/platform/gl/psychlops_g_cache.cpp
@@ -61,8 +61,14 @@ namespace Utilities {
6161 }
6262 //img.draw(outer);
6363
64+
6465 Color col(r,g,b,a);
65- Rectangle targetarea(img.getLeft(), img.getTop(), img.getRight(), img.getBottom());
66+ Rectangle targetarea;
67+ if(drawee._zoom_cache) {
68+ targetarea.set(img.getLeft(), img.getTop(), img.getRight(), img.getBottom());
69+ } else {
70+ targetarea.set(img.getLeft(), img.getTop(), img.getRight(), img.getBottom());
71+ }
6672 const Color zero_alpha(1,1,1,0,false);
6773 glPushAttrib(GL_COLOR_BUFFER_BIT);
6874 //img.move_to(posX, posY-cache_baseY);
--- a/psychlops/platform/gl/psychlops_g_cache.h
+++ b/psychlops/platform/gl/psychlops_g_cache.h
@@ -16,6 +16,7 @@ namespace Utilities {
1616 {
1717 public:
1818 bool dirty_;
19+ double font_size;
1920 Image img;
2021 CacheOnImage();
2122 ~CacheOnImage();
--- a/psychlops/platform/win32gl/psychlops_g_API_win32gl.cpp
+++ b/psychlops/platform/win32gl/psychlops_g_API_win32gl.cpp
@@ -452,6 +452,7 @@ namespace Psychlops {
452452 void APICanvasProperties::cacheText(Letters &drawee, Utilities::CacheOnImage& t)
453453 {
454454 int fontsize = (int)(drawee.font.size);
455+ t.font_size = drawee.font.size;
455456 int ix = 0, iy = 0;
456457 //std:: str = wtext(drawee.text).dup;
457458
--- a/win32gl/test/Psychlops_win32cblibtest.cbp
+++ b/win32gl/test/Psychlops_win32cblibtest.cbp
@@ -21,14 +21,14 @@
2121 </Compiler>
2222 <Linker>
2323 <Add option="-s" />
24- <Add library="..\dev\libpsychlopswin32gcc3.a" />
25- <Add library="lib\libpng_mingw.a" />
26- <Add library="lib\libfftw3.a" />
24+ <Add library="../dev/libpsychlopswin32gcc3.a" />
25+ <Add library="lib/libpng_mingw.a" />
26+ <Add library="lib/libfftw3.a" />
2727 <Add library="opengl32" />
2828 <Add library="gdi32" />
2929 <Add library="comdlg32" />
30- <Add library="C:\Program Files\National Instruments\NI-DAQmx Base\Lib\nidaqmxbase.lib" />
31- <Add library="C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\msvc\NIDAQmx.lib" />
30+ <Add library="C:/Program Files/National Instruments/NI-DAQmx Base/Lib/nidaqmxbase.lib" />
31+ <Add library="C:/Program Files/National Instruments/NI-DAQ/DAQmx ANSI C Dev/lib/msvc/NIDAQmx.lib" />
3232 </Linker>
3333 </Target>
3434 <Target title="MinGW4">
@@ -46,33 +46,31 @@
4646 </Compiler>
4747 <Linker>
4848 <Add option="-s" />
49- <Add library="..\dev\libpsychlopswin32gcc4.a" />
50- <Add library="lib\libpng_mingw.a" />
51- <Add library="lib\libfftw3.a" />
49+ <Add library="../dev/libpsychlopswin32gcc4.a" />
50+ <Add library="lib/libpng_mingw.a" />
51+ <Add library="lib/libfftw3.a" />
5252 <Add library="opengl32" />
5353 <Add library="gdi32" />
5454 <Add library="comdlg32" />
55- <Add library="C:\Program Files\National Instruments\NI-DAQmx Base\Lib\nidaqmxbase.lib" />
56- <Add library="C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\msvc\NIDAQmx.lib" />
57- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_calib3d249.dll.a" />
58- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_contrib249.dll.a" />
59- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_core249.dll.a" />
60- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_features2d249.dll.a" />
61- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_flann249.dll.a" />
62- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_gpu249.dll.a" />
63- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_haartraining_engine.a" />
64- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_highgui249.dll.a" />
65- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_imgproc249.dll.a" />
66- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_legacy249.dll.a" />
67- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_ml249.dll.a" />
68- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_nonfree249.dll.a" />
69- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_objdetect249.dll.a" />
70- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_ocl249.dll.a" />
71- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_photo249.dll.a" />
72- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_stitching249.dll.a" />
73- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_superres249.dll.a" />
74- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_video249.dll.a" />
75- <Add library="C:\Library\Frameworks\Psychlops.framework\cv\lib\mingw4\libopencv_videostab249.dll.a" />
55+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_calib3d249.dll.a" />
56+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_contrib249.dll.a" />
57+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_core249.dll.a" />
58+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_features2d249.dll.a" />
59+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_flann249.dll.a" />
60+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_gpu249.dll.a" />
61+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_haartraining_engine.a" />
62+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_highgui249.dll.a" />
63+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_imgproc249.dll.a" />
64+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_legacy249.dll.a" />
65+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_ml249.dll.a" />
66+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_nonfree249.dll.a" />
67+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_objdetect249.dll.a" />
68+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_ocl249.dll.a" />
69+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_photo249.dll.a" />
70+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_stitching249.dll.a" />
71+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_superres249.dll.a" />
72+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_video249.dll.a" />
73+ <Add library="C:/Library/Frameworks/Psychlops.framework/cv/lib/mingw4/libopencv_videostab249.dll.a" />
7674 </Linker>
7775 </Target>
7876 <Target title="BCC5.51">
@@ -91,8 +89,8 @@
9189 <Add option="-O1" />
9290 </Compiler>
9391 <Linker>
94- <Add library="..\dev\psychlopswin32bcc.lib" />
95- <Add library="lib\libpng_bcc.lib" />
92+ <Add library="../dev/psychlopswin32bcc.lib" />
93+ <Add library="lib/libpng_bcc.lib" />
9694 <Add library="import32.lib" />
9795 <Add library="cw32mt.lib" />
9896 <Add library="advapi32.lib" />
@@ -112,11 +110,11 @@
112110 <Add option="/Ox" />
113111 </Compiler>
114112 <Linker>
115- <Add library="..\dev\psychlopswin32vc9.lib" />
116- <Add library="lib\libpng_vc9.lib" />
117- <Add library="lib\glut32.lib" />
118- <Add library="C:\Program Files\National Instruments\NI-DAQmx Base\Lib\nidaqmxbase.lib" />
119- <Add library="lib\libfftw3_vc9.lib" />
113+ <Add library="../dev/psychlopswin32vc9.lib" />
114+ <Add library="lib/libpng_vc9.lib" />
115+ <Add library="lib/glut32.lib" />
116+ <Add library="C:/Program Files/National Instruments/NI-DAQmx Base/Lib/nidaqmxbase.lib" />
117+ <Add library="lib/libfftw3_vc9.lib" />
120118 </Linker>
121119 </Target>
122120 <Target title="VC10">
@@ -132,13 +130,13 @@
132130 <Add option="/Ox" />
133131 </Compiler>
134132 <Linker>
135- <Add library="..\dev\psychlopswin32vc10.lib" />
136- <Add library="lib\libpng_vc9.lib" />
137- <Add library="lib\glut32.lib" />
138- <Add library="C:\Program Files\National Instruments\NI-DAQmx Base\Lib\nidaqmxbase.lib" />
139- <Add library="lib\libfftw3_vc9.lib" />
140- <Add library="C:\Library\frameworks\opencv\build\x86\vc10\lib\opencv_core249.lib" />
141- <Add library="C:\Library\frameworks\opencv\build\x86\vc10\lib\opencv_highgui249.lib" />
133+ <Add library="../dev/psychlopswin32vc10.lib" />
134+ <Add library="lib/libpng_vc9.lib" />
135+ <Add library="lib/glut32.lib" />
136+ <Add library="C:/Program Files/National Instruments/NI-DAQmx Base/Lib/nidaqmxbase.lib" />
137+ <Add library="lib/libfftw3_vc9.lib" />
138+ <Add library="C:/Library/frameworks/opencv/build/x86/vc10/lib/opencv_core249.lib" />
139+ <Add library="C:/Library/frameworks/opencv/build/x86/vc10/lib/opencv_highgui249.lib" />
142140 </Linker>
143141 </Target>
144142 <Target title="VC12">
@@ -154,11 +152,11 @@
154152 <Add option="/Ox" />
155153 </Compiler>
156154 <Linker>
157- <Add library="..\dev\psychlopswin32vc12.lib" />
158- <Add library="lib\libpng_vc9.lib" />
159- <Add library="lib\glut32.lib" />
160- <Add library="C:\Program Files\National Instruments\NI-DAQmx Base\Lib\nidaqmxbase.lib" />
161- <Add library="lib\libfftw3_vc9.lib" />
155+ <Add library="../dev/psychlopswin32vc12.lib" />
156+ <Add library="lib/libpng_vc9.lib" />
157+ <Add library="lib/glut32.lib" />
158+ <Add library="C:/Program Files/National Instruments/NI-DAQmx Base/Lib/nidaqmxbase.lib" />
159+ <Add library="lib/libfftw3_vc9.lib" />
162160 </Linker>
163161 </Target>
164162 </Build>
@@ -192,15 +190,15 @@
192190 <Option compile="0" />
193191 <Option link="0" />
194192 </Unit>
195- <Unit filename="fftfirm.cpp" />
196- <Unit filename="inputTest.cpp">
193+ <Unit filename="fftfirm.cpp">
197194 <Option compile="0" />
198195 <Option link="0" />
199196 </Unit>
200- <Unit filename="main.cpp">
197+ <Unit filename="inputTest.cpp">
201198 <Option compile="0" />
202199 <Option link="0" />
203200 </Unit>
201+ <Unit filename="main.cpp" />
204202 <Unit filename="newfuncfirm.cpp">
205203 <Option compile="0" />
206204 <Option link="0" />
--- a/win32gl/test/main.cpp
+++ b/win32gl/test/main.cpp
@@ -1,3 +1,33 @@
1+#include <psychlops.h>
2+using namespace Psychlops;
3+
4+void psychlops_main() {
5+ Canvas cnvs(Canvas::window);
6+
7+ Font font(L"MS P Gothic", 32);
8+ Letters let(L"hoge", font);
9+ let._zoom_cache = true;
10+
11+ Clock after, before;
12+ after.update();
13+
14+ while(!Keyboard::esc.pushed()) {
15+ before = after;
16+ after.update();
17+
18+ cnvs.clear();
19+
20+ font.size = random(100);
21+ //let.setFont(font);
22+ let.font = font;
23+ let.centering().draw(Color::white);
24+
25+ cnvs.var((after-before).at_msec(), 100,100, Color::green);
26+
27+ cnvs.flip();
28+ }
29+}
30+
131 /*
232 #include <psychlops.h>
333 using namespace Psychlops;
@@ -138,7 +168,7 @@ void psychlops_main()
138168 }
139169 */
140170
141-
171+/*
142172 #include <psychlops.h>
143173 using namespace Psychlops; // Initially developed with Psychlops Win32 1.0.2 / 20080414
144174
@@ -183,4 +213,4 @@ void psychlops_main() {
183213 p.run();
184214
185215 }
186-
216+*/
Show on old repository browser