From 0e5d4c38a3881ac290689af3ddf2a96623d97683 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 17 Apr 2011 00:09:56 +0000 Subject: [PATCH] Add wxAffineMatrix2D and related classes. This class represents an affine 2D transformation and will be used in wxDC for now and maybe in wxGC later. Closes #13143. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67520 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 22 ++++ build/bakefiles/files.bkl | 3 + build/msw/makefile.bcc | 28 +++++ build/msw/makefile.gcc | 28 +++++ build/msw/makefile.vc | 28 +++++ build/msw/makefile.wat | 28 +++++ build/msw/wx_core.dsp | 20 +++- build/msw/wx_vc7_core.vcproj | 15 ++- build/msw/wx_vc8_core.vcproj | 20 +++- build/msw/wx_vc9_core.vcproj | 20 +++- docs/changes.txt | 1 + include/wx/affinematrix2d.h | 45 ++++++++ include/wx/affinematrix2dbase.h | 121 ++++++++++++++++++++ interface/wx/affinematrix2d.h | 161 +++++++++++++++++++++++++++ interface/wx/affinematrix2dbase.h | 34 ++++++ src/common/affinematrix2d.cpp | 179 ++++++++++++++++++++++++++++++ 16 files changed, 738 insertions(+), 15 deletions(-) create mode 100644 include/wx/affinematrix2d.h create mode 100644 include/wx/affinematrix2dbase.h create mode 100644 interface/wx/affinematrix2d.h create mode 100644 interface/wx/affinematrix2dbase.h create mode 100644 src/common/affinematrix2d.cpp diff --git a/Makefile.in b/Makefile.in index 091d58b580..5893c26553 100644 --- a/Makefile.in +++ b/Makefile.in @@ -3833,6 +3833,8 @@ COND_USE_GUI_1_WXUNIV_1_GUI_CORE_HEADERS = \ wx/univ/window.h @COND_USE_GUI_1_WXUNIV_1@GUI_CORE_HEADERS = $(COND_USE_GUI_1_WXUNIV_1_GUI_CORE_HEADERS) COND_USE_GUI_1_ALL_GUI_HEADERS = \ + wx/affinematrix2dbase.h \ + wx/affinematrix2d.h \ wx/bmpbuttn.h \ wx/brush.h \ wx/button.h \ @@ -4482,6 +4484,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS = \ monodll_accelcmn.o \ monodll_accesscmn.o \ monodll_anidecod.o \ + monodll_affinematrix2d.o \ monodll_appcmn.o \ monodll_artprov.o \ monodll_artstd.o \ @@ -4698,6 +4701,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS = \ monodll_accelcmn.o \ monodll_accesscmn.o \ monodll_anidecod.o \ + monodll_affinematrix2d.o \ monodll_appcmn.o \ monodll_artprov.o \ monodll_artstd.o \ @@ -6402,6 +6406,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_1 = \ monolib_accelcmn.o \ monolib_accesscmn.o \ monolib_anidecod.o \ + monolib_affinematrix2d.o \ monolib_appcmn.o \ monolib_artprov.o \ monolib_artstd.o \ @@ -6618,6 +6623,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_1 = \ monolib_accelcmn.o \ monolib_accesscmn.o \ monolib_anidecod.o \ + monolib_affinematrix2d.o \ monolib_appcmn.o \ monolib_artprov.o \ monolib_artstd.o \ @@ -8506,6 +8512,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_2 = \ coredll_accelcmn.o \ coredll_accesscmn.o \ coredll_anidecod.o \ + coredll_affinematrix2d.o \ coredll_appcmn.o \ coredll_artprov.o \ coredll_artstd.o \ @@ -8722,6 +8729,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_2 = \ coredll_accelcmn.o \ coredll_accesscmn.o \ coredll_anidecod.o \ + coredll_affinematrix2d.o \ coredll_appcmn.o \ coredll_artprov.o \ coredll_artstd.o \ @@ -10088,6 +10096,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_3 = \ corelib_accelcmn.o \ corelib_accesscmn.o \ corelib_anidecod.o \ + corelib_affinematrix2d.o \ corelib_appcmn.o \ corelib_artprov.o \ corelib_artstd.o \ @@ -10304,6 +10313,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_3 = \ corelib_accelcmn.o \ corelib_accesscmn.o \ corelib_anidecod.o \ + corelib_affinematrix2d.o \ corelib_appcmn.o \ corelib_artprov.o \ corelib_artstd.o \ @@ -19765,6 +19775,9 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@monodll_anidecod.o: $(srcdir)/src/common/anidecod.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/anidecod.cpp +@COND_USE_GUI_1@monodll_affinematrix2d.o: $(srcdir)/src/common/affinematrix2d.cpp $(MONODLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/affinematrix2d.cpp + @COND_USE_GUI_1@monodll_appcmn.o: $(srcdir)/src/common/appcmn.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/appcmn.cpp @@ -25060,6 +25073,9 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@monolib_anidecod.o: $(srcdir)/src/common/anidecod.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/anidecod.cpp +@COND_USE_GUI_1@monolib_affinematrix2d.o: $(srcdir)/src/common/affinematrix2d.cpp $(MONOLIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/affinematrix2d.cpp + @COND_USE_GUI_1@monolib_appcmn.o: $(srcdir)/src/common/appcmn.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/appcmn.cpp @@ -30535,6 +30551,9 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@coredll_anidecod.o: $(srcdir)/src/common/anidecod.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/anidecod.cpp +@COND_USE_GUI_1@coredll_affinematrix2d.o: $(srcdir)/src/common/affinematrix2d.cpp $(COREDLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/affinematrix2d.cpp + @COND_USE_GUI_1@coredll_appcmn.o: $(srcdir)/src/common/appcmn.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/appcmn.cpp @@ -34513,6 +34532,9 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@corelib_anidecod.o: $(srcdir)/src/common/anidecod.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/anidecod.cpp +@COND_USE_GUI_1@corelib_affinematrix2d.o: $(srcdir)/src/common/affinematrix2d.cpp $(CORELIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/affinematrix2d.cpp + @COND_USE_GUI_1@corelib_appcmn.o: $(srcdir)/src/common/appcmn.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/appcmn.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index fca4e9bb37..3c575fa16c 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -651,6 +651,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/common/accelcmn.cpp src/common/accesscmn.cpp src/common/anidecod.cpp + src/common/affinematrix2d.cpp src/common/appcmn.cpp src/common/artprov.cpp src/common/artstd.cpp @@ -809,6 +810,8 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/generic/vscroll.cpp + wx/affinematrix2dbase.h + wx/affinematrix2d.h wx/bmpbuttn.h wx/brush.h wx/button.h diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc index 17575beec3..94b908a501 100644 --- a/build/msw/makefile.bcc +++ b/build/msw/makefile.bcc @@ -1791,6 +1791,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_accelcmn.obj \ $(OBJS)\monodll_accesscmn.obj \ $(OBJS)\monodll_anidecod.obj \ + $(OBJS)\monodll_affinematrix2d.obj \ $(OBJS)\monodll_appcmn.obj \ $(OBJS)\monodll_artprov.obj \ $(OBJS)\monodll_artstd.obj \ @@ -2056,6 +2057,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_accelcmn.obj \ $(OBJS)\monodll_accesscmn.obj \ $(OBJS)\monodll_anidecod.obj \ + $(OBJS)\monodll_affinematrix2d.obj \ $(OBJS)\monodll_appcmn.obj \ $(OBJS)\monodll_artprov.obj \ $(OBJS)\monodll_artstd.obj \ @@ -2553,6 +2555,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_accelcmn.obj \ $(OBJS)\monolib_accesscmn.obj \ $(OBJS)\monolib_anidecod.obj \ + $(OBJS)\monolib_affinematrix2d.obj \ $(OBJS)\monolib_appcmn.obj \ $(OBJS)\monolib_artprov.obj \ $(OBJS)\monolib_artstd.obj \ @@ -2818,6 +2821,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_accelcmn.obj \ $(OBJS)\monolib_accesscmn.obj \ $(OBJS)\monolib_anidecod.obj \ + $(OBJS)\monolib_affinematrix2d.obj \ $(OBJS)\monolib_appcmn.obj \ $(OBJS)\monolib_artprov.obj \ $(OBJS)\monolib_artstd.obj \ @@ -3203,6 +3207,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_accelcmn.obj \ $(OBJS)\coredll_accesscmn.obj \ $(OBJS)\coredll_anidecod.obj \ + $(OBJS)\coredll_affinematrix2d.obj \ $(OBJS)\coredll_appcmn.obj \ $(OBJS)\coredll_artprov.obj \ $(OBJS)\coredll_artstd.obj \ @@ -3468,6 +3473,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_accelcmn.obj \ $(OBJS)\coredll_accesscmn.obj \ $(OBJS)\coredll_anidecod.obj \ + $(OBJS)\coredll_affinematrix2d.obj \ $(OBJS)\coredll_appcmn.obj \ $(OBJS)\coredll_artprov.obj \ $(OBJS)\coredll_artstd.obj \ @@ -3742,6 +3748,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_accelcmn.obj \ $(OBJS)\corelib_accesscmn.obj \ $(OBJS)\corelib_anidecod.obj \ + $(OBJS)\corelib_affinematrix2d.obj \ $(OBJS)\corelib_appcmn.obj \ $(OBJS)\corelib_artprov.obj \ $(OBJS)\corelib_artstd.obj \ @@ -4007,6 +4014,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_accelcmn.obj \ $(OBJS)\corelib_accesscmn.obj \ $(OBJS)\corelib_anidecod.obj \ + $(OBJS)\corelib_affinematrix2d.obj \ $(OBJS)\corelib_appcmn.obj \ $(OBJS)\corelib_artprov.obj \ $(OBJS)\corelib_artstd.obj \ @@ -7277,6 +7285,11 @@ $(OBJS)\monodll_anidecod.obj: ..\..\src\common\anidecod.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\anidecod.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_affinematrix2d.obj: ..\..\src\common\affinematrix2d.cpp + $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\affinematrix2d.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monodll_appcmn.obj: ..\..\src\common\appcmn.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\appcmn.cpp @@ -9622,6 +9635,11 @@ $(OBJS)\monolib_anidecod.obj: ..\..\src\common\anidecod.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\anidecod.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_affinematrix2d.obj: ..\..\src\common\affinematrix2d.cpp + $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\affinematrix2d.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monolib_appcmn.obj: ..\..\src\common\appcmn.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\appcmn.cpp @@ -11961,6 +11979,11 @@ $(OBJS)\coredll_anidecod.obj: ..\..\src\common\anidecod.cpp $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\common\anidecod.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\coredll_affinematrix2d.obj: ..\..\src\common\affinematrix2d.cpp + $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\common\affinematrix2d.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\coredll_appcmn.obj: ..\..\src\common\appcmn.cpp $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\common\appcmn.cpp @@ -13361,6 +13384,11 @@ $(OBJS)\corelib_anidecod.obj: ..\..\src\common\anidecod.cpp $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\common\anidecod.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\corelib_affinematrix2d.obj: ..\..\src\common\affinematrix2d.cpp + $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\common\affinematrix2d.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\corelib_appcmn.obj: ..\..\src\common\appcmn.cpp $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\common\appcmn.cpp diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index b72ed0429e..6b6d3b121a 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -1802,6 +1802,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_accelcmn.o \ $(OBJS)\monodll_accesscmn.o \ $(OBJS)\monodll_anidecod.o \ + $(OBJS)\monodll_affinematrix2d.o \ $(OBJS)\monodll_appcmn.o \ $(OBJS)\monodll_artprov.o \ $(OBJS)\monodll_artstd.o \ @@ -2069,6 +2070,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_accelcmn.o \ $(OBJS)\monodll_accesscmn.o \ $(OBJS)\monodll_anidecod.o \ + $(OBJS)\monodll_affinematrix2d.o \ $(OBJS)\monodll_appcmn.o \ $(OBJS)\monodll_artprov.o \ $(OBJS)\monodll_artstd.o \ @@ -2570,6 +2572,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_accelcmn.o \ $(OBJS)\monolib_accesscmn.o \ $(OBJS)\monolib_anidecod.o \ + $(OBJS)\monolib_affinematrix2d.o \ $(OBJS)\monolib_appcmn.o \ $(OBJS)\monolib_artprov.o \ $(OBJS)\monolib_artstd.o \ @@ -2837,6 +2840,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_accelcmn.o \ $(OBJS)\monolib_accesscmn.o \ $(OBJS)\monolib_anidecod.o \ + $(OBJS)\monolib_affinematrix2d.o \ $(OBJS)\monolib_appcmn.o \ $(OBJS)\monolib_artprov.o \ $(OBJS)\monolib_artstd.o \ @@ -3236,6 +3240,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_accelcmn.o \ $(OBJS)\coredll_accesscmn.o \ $(OBJS)\coredll_anidecod.o \ + $(OBJS)\coredll_affinematrix2d.o \ $(OBJS)\coredll_appcmn.o \ $(OBJS)\coredll_artprov.o \ $(OBJS)\coredll_artstd.o \ @@ -3503,6 +3508,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_accelcmn.o \ $(OBJS)\coredll_accesscmn.o \ $(OBJS)\coredll_anidecod.o \ + $(OBJS)\coredll_affinematrix2d.o \ $(OBJS)\coredll_appcmn.o \ $(OBJS)\coredll_artprov.o \ $(OBJS)\coredll_artstd.o \ @@ -3783,6 +3789,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_accelcmn.o \ $(OBJS)\corelib_accesscmn.o \ $(OBJS)\corelib_anidecod.o \ + $(OBJS)\corelib_affinematrix2d.o \ $(OBJS)\corelib_appcmn.o \ $(OBJS)\corelib_artprov.o \ $(OBJS)\corelib_artstd.o \ @@ -4050,6 +4057,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_accelcmn.o \ $(OBJS)\corelib_accesscmn.o \ $(OBJS)\corelib_anidecod.o \ + $(OBJS)\corelib_affinematrix2d.o \ $(OBJS)\corelib_appcmn.o \ $(OBJS)\corelib_artprov.o \ $(OBJS)\corelib_artstd.o \ @@ -7427,6 +7435,11 @@ $(OBJS)\monodll_anidecod.o: ../../src/common/anidecod.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monodll_affinematrix2d.o: ../../src/common/affinematrix2d.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\monodll_appcmn.o: ../../src/common/appcmn.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< @@ -9772,6 +9785,11 @@ $(OBJS)\monolib_anidecod.o: ../../src/common/anidecod.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monolib_affinematrix2d.o: ../../src/common/affinematrix2d.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\monolib_appcmn.o: ../../src/common/appcmn.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< @@ -12111,6 +12129,11 @@ $(OBJS)\coredll_anidecod.o: ../../src/common/anidecod.cpp $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\coredll_affinematrix2d.o: ../../src/common/affinematrix2d.cpp + $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\coredll_appcmn.o: ../../src/common/appcmn.cpp $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< @@ -13511,6 +13534,11 @@ $(OBJS)\corelib_anidecod.o: ../../src/common/anidecod.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\corelib_affinematrix2d.o: ../../src/common/affinematrix2d.cpp + $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\corelib_appcmn.o: ../../src/common/appcmn.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index aff93420b8..79802123e4 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -1999,6 +1999,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_accelcmn.obj \ $(OBJS)\monodll_accesscmn.obj \ $(OBJS)\monodll_anidecod.obj \ + $(OBJS)\monodll_affinematrix2d.obj \ $(OBJS)\monodll_appcmn.obj \ $(OBJS)\monodll_artprov.obj \ $(OBJS)\monodll_artstd.obj \ @@ -2264,6 +2265,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_accelcmn.obj \ $(OBJS)\monodll_accesscmn.obj \ $(OBJS)\monodll_anidecod.obj \ + $(OBJS)\monodll_affinematrix2d.obj \ $(OBJS)\monodll_appcmn.obj \ $(OBJS)\monodll_artprov.obj \ $(OBJS)\monodll_artstd.obj \ @@ -2767,6 +2769,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_accelcmn.obj \ $(OBJS)\monolib_accesscmn.obj \ $(OBJS)\monolib_anidecod.obj \ + $(OBJS)\monolib_affinematrix2d.obj \ $(OBJS)\monolib_appcmn.obj \ $(OBJS)\monolib_artprov.obj \ $(OBJS)\monolib_artstd.obj \ @@ -3032,6 +3035,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_accelcmn.obj \ $(OBJS)\monolib_accesscmn.obj \ $(OBJS)\monolib_anidecod.obj \ + $(OBJS)\monolib_affinematrix2d.obj \ $(OBJS)\monolib_appcmn.obj \ $(OBJS)\monolib_artprov.obj \ $(OBJS)\monolib_artstd.obj \ @@ -3483,6 +3487,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_accelcmn.obj \ $(OBJS)\coredll_accesscmn.obj \ $(OBJS)\coredll_anidecod.obj \ + $(OBJS)\coredll_affinematrix2d.obj \ $(OBJS)\coredll_appcmn.obj \ $(OBJS)\coredll_artprov.obj \ $(OBJS)\coredll_artstd.obj \ @@ -3748,6 +3753,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_accelcmn.obj \ $(OBJS)\coredll_accesscmn.obj \ $(OBJS)\coredll_anidecod.obj \ + $(OBJS)\coredll_affinematrix2d.obj \ $(OBJS)\coredll_appcmn.obj \ $(OBJS)\coredll_artprov.obj \ $(OBJS)\coredll_artstd.obj \ @@ -4028,6 +4034,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_accelcmn.obj \ $(OBJS)\corelib_accesscmn.obj \ $(OBJS)\corelib_anidecod.obj \ + $(OBJS)\corelib_affinematrix2d.obj \ $(OBJS)\corelib_appcmn.obj \ $(OBJS)\corelib_artprov.obj \ $(OBJS)\corelib_artstd.obj \ @@ -4293,6 +4300,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_accelcmn.obj \ $(OBJS)\corelib_accesscmn.obj \ $(OBJS)\corelib_anidecod.obj \ + $(OBJS)\corelib_affinematrix2d.obj \ $(OBJS)\corelib_appcmn.obj \ $(OBJS)\corelib_artprov.obj \ $(OBJS)\corelib_artstd.obj \ @@ -7857,6 +7865,11 @@ $(OBJS)\monodll_anidecod.obj: ..\..\src\common\anidecod.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\anidecod.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_affinematrix2d.obj: ..\..\src\common\affinematrix2d.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\affinematrix2d.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monodll_appcmn.obj: ..\..\src\common\appcmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\appcmn.cpp @@ -10202,6 +10215,11 @@ $(OBJS)\monolib_anidecod.obj: ..\..\src\common\anidecod.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\anidecod.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_affinematrix2d.obj: ..\..\src\common\affinematrix2d.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\affinematrix2d.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monolib_appcmn.obj: ..\..\src\common\appcmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\appcmn.cpp @@ -12541,6 +12559,11 @@ $(OBJS)\coredll_anidecod.obj: ..\..\src\common\anidecod.cpp $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\common\anidecod.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\coredll_affinematrix2d.obj: ..\..\src\common\affinematrix2d.cpp + $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\common\affinematrix2d.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\coredll_appcmn.obj: ..\..\src\common\appcmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\common\appcmn.cpp @@ -13941,6 +13964,11 @@ $(OBJS)\corelib_anidecod.obj: ..\..\src\common\anidecod.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\common\anidecod.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\corelib_affinematrix2d.obj: ..\..\src\common\affinematrix2d.cpp + $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\common\affinematrix2d.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\corelib_appcmn.obj: ..\..\src\common\appcmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\common\appcmn.cpp diff --git a/build/msw/makefile.wat b/build/msw/makefile.wat index 1445bfec72..618c7f8c0a 100644 --- a/build/msw/makefile.wat +++ b/build/msw/makefile.wat @@ -353,6 +353,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = & $(OBJS)\monodll_accelcmn.obj & $(OBJS)\monodll_accesscmn.obj & $(OBJS)\monodll_anidecod.obj & + $(OBJS)\monodll_affinematrix2d.obj & $(OBJS)\monodll_appcmn.obj & $(OBJS)\monodll_artprov.obj & $(OBJS)\monodll_artstd.obj & @@ -620,6 +621,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = & $(OBJS)\monodll_accelcmn.obj & $(OBJS)\monodll_accesscmn.obj & $(OBJS)\monodll_anidecod.obj & + $(OBJS)\monodll_affinematrix2d.obj & $(OBJS)\monodll_appcmn.obj & $(OBJS)\monodll_artprov.obj & $(OBJS)\monodll_artstd.obj & @@ -1126,6 +1128,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = & $(OBJS)\monolib_accelcmn.obj & $(OBJS)\monolib_accesscmn.obj & $(OBJS)\monolib_anidecod.obj & + $(OBJS)\monolib_affinematrix2d.obj & $(OBJS)\monolib_appcmn.obj & $(OBJS)\monolib_artprov.obj & $(OBJS)\monolib_artstd.obj & @@ -1393,6 +1396,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = & $(OBJS)\monolib_accelcmn.obj & $(OBJS)\monolib_accesscmn.obj & $(OBJS)\monolib_anidecod.obj & + $(OBJS)\monolib_affinematrix2d.obj & $(OBJS)\monolib_appcmn.obj & $(OBJS)\monolib_artprov.obj & $(OBJS)\monolib_artstd.obj & @@ -1803,6 +1807,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = & $(OBJS)\coredll_accelcmn.obj & $(OBJS)\coredll_accesscmn.obj & $(OBJS)\coredll_anidecod.obj & + $(OBJS)\coredll_affinematrix2d.obj & $(OBJS)\coredll_appcmn.obj & $(OBJS)\coredll_artprov.obj & $(OBJS)\coredll_artstd.obj & @@ -2070,6 +2075,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = & $(OBJS)\coredll_accelcmn.obj & $(OBJS)\coredll_accesscmn.obj & $(OBJS)\coredll_anidecod.obj & + $(OBJS)\coredll_affinematrix2d.obj & $(OBJS)\coredll_appcmn.obj & $(OBJS)\coredll_artprov.obj & $(OBJS)\coredll_artstd.obj & @@ -2352,6 +2358,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = & $(OBJS)\corelib_accelcmn.obj & $(OBJS)\corelib_accesscmn.obj & $(OBJS)\corelib_anidecod.obj & + $(OBJS)\corelib_affinematrix2d.obj & $(OBJS)\corelib_appcmn.obj & $(OBJS)\corelib_artprov.obj & $(OBJS)\corelib_artstd.obj & @@ -2619,6 +2626,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = & $(OBJS)\corelib_accelcmn.obj & $(OBJS)\corelib_accesscmn.obj & $(OBJS)\corelib_anidecod.obj & + $(OBJS)\corelib_affinematrix2d.obj & $(OBJS)\corelib_appcmn.obj & $(OBJS)\corelib_artprov.obj & $(OBJS)\corelib_artstd.obj & @@ -7686,6 +7694,11 @@ $(OBJS)\monodll_anidecod.obj : .AUTODEPEND ..\..\src\common\anidecod.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< !endif +!ifeq USE_GUI 1 +$(OBJS)\monodll_affinematrix2d.obj : .AUTODEPEND ..\..\src\common\affinematrix2d.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< +!endif + !ifeq USE_GUI 1 $(OBJS)\monodll_appcmn.obj : .AUTODEPEND ..\..\src\common\appcmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< @@ -10031,6 +10044,11 @@ $(OBJS)\monolib_anidecod.obj : .AUTODEPEND ..\..\src\common\anidecod.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< !endif +!ifeq USE_GUI 1 +$(OBJS)\monolib_affinematrix2d.obj : .AUTODEPEND ..\..\src\common\affinematrix2d.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< +!endif + !ifeq USE_GUI 1 $(OBJS)\monolib_appcmn.obj : .AUTODEPEND ..\..\src\common\appcmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONOLIB_CXXFLAGS) $< @@ -12370,6 +12388,11 @@ $(OBJS)\coredll_anidecod.obj : .AUTODEPEND ..\..\src\common\anidecod.cpp $(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $< !endif +!ifeq USE_GUI 1 +$(OBJS)\coredll_affinematrix2d.obj : .AUTODEPEND ..\..\src\common\affinematrix2d.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $< +!endif + !ifeq USE_GUI 1 $(OBJS)\coredll_appcmn.obj : .AUTODEPEND ..\..\src\common\appcmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(COREDLL_CXXFLAGS) $< @@ -13770,6 +13793,11 @@ $(OBJS)\corelib_anidecod.obj : .AUTODEPEND ..\..\src\common\anidecod.cpp $(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $< !endif +!ifeq USE_GUI 1 +$(OBJS)\corelib_affinematrix2d.obj : .AUTODEPEND ..\..\src\common\affinematrix2d.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $< +!endif + !ifeq USE_GUI 1 $(OBJS)\corelib_appcmn.obj : .AUTODEPEND ..\..\src\common\appcmn.cpp $(CXX) -bt=nt -zq -fo=$^@ $(CORELIB_CXXFLAGS) $< diff --git a/build/msw/wx_core.dsp b/build/msw/wx_core.dsp index d66a99bcc0..7d3bbbddbb 100644 --- a/build/msw/wx_core.dsp +++ b/build/msw/wx_core.dsp @@ -252,6 +252,10 @@ SOURCE=..\..\src\common\accesscmn.cpp # End Source File # Begin Source File +SOURCE=..\..\src\common\affinematrix2d.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\common\anidecod.cpp # End Source File # Begin Source File @@ -5893,6 +5897,14 @@ SOURCE=..\..\include\wx\propgrid\advprops.h # End Source File # Begin Source File +SOURCE=..\..\include\wx\affinematrix2d.h +# End Source File +# Begin Source File + +SOURCE=..\..\include\wx\affinematrix2dbase.h +# End Source File +# Begin Source File + SOURCE=..\..\include\wx\anidecod.h # End Source File # Begin Source File @@ -6741,10 +6753,10 @@ SOURCE=..\..\include\wx\tbarbase.h # End Source File # Begin Source File -SOURCE=..\..\include\wx\textcompleter.h -# End Source File -# Begin Source File - +SOURCE=..\..\include\wx\textcompleter.h +# End Source File +# Begin Source File + SOURCE=..\..\include\wx\textctrl.h # End Source File # Begin Source File diff --git a/build/msw/wx_vc7_core.vcproj b/build/msw/wx_vc7_core.vcproj index 511e2a8640..7692e09a3f 100644 --- a/build/msw/wx_vc7_core.vcproj +++ b/build/msw/wx_vc7_core.vcproj @@ -534,6 +534,9 @@ + + @@ -5006,6 +5009,12 @@ + + + + @@ -5643,9 +5652,9 @@ RelativePath="..\..\include\wx\tbarbase.h"> - - + + + + @@ -6695,6 +6699,14 @@ RelativePath="..\..\include\wx\propgrid\advprops.h" > + + + + @@ -7544,10 +7556,10 @@ > - - + + diff --git a/build/msw/wx_vc9_core.vcproj b/build/msw/wx_vc9_core.vcproj index c4ed51456b..8fd9dbb6ba 100644 --- a/build/msw/wx_vc9_core.vcproj +++ b/build/msw/wx_vc9_core.vcproj @@ -742,6 +742,10 @@ RelativePath="..\..\src\common\accesscmn.cpp" > + + @@ -6691,6 +6695,14 @@ RelativePath="..\..\include\wx\propgrid\advprops.h" > + + + + @@ -7540,10 +7552,10 @@ > - - + + diff --git a/docs/changes.txt b/docs/changes.txt index 63441b056d..7fb9a23609 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -502,6 +502,7 @@ All (GUI): - Add WXK_CONTROL_A..WXK_CONTROL_Z constants (Jan van Dijk). - Add support for alpha channel in colours in wxSVGFileDC (snowleopard). - Allow customizing AUI tab colours in wxAuiTabArt (snowleopard). +- Added wxAffineMatrix2D class (Catalin Raceanu). GTK: diff --git a/include/wx/affinematrix2d.h b/include/wx/affinematrix2d.h new file mode 100644 index 0000000000..dfd4969614 --- /dev/null +++ b/include/wx/affinematrix2d.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/affinematrix2d.h +// Purpose: wxAffineMatrix2D class. +// Author: Based on wxTransformMatrix by Chris Breeze, Julian Smart +// Created: 2011-04-05 +// Copyright: (c) wxWidgets team +// Licence: wxWidgets licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_AFFINEMATRIX2D_H_ +#define _WX_AFFINEMATRIX2D_H_ + +#include "wx/affinematrix2dbase.h" + +// A simple implementation of wxAffineMatrix2DBase interface done entirely in +// wxWidgets. +class WXDLLIMPEXP_CORE wxAffineMatrix2D : public wxAffineMatrix2DBase +{ +public: + wxAffineMatrix2D() : m_11(1), m_12(0), + m_21(0), m_22(1), + m_tx(0), m_ty(0) + { + } + + // Implement base class pure virtual methods. + virtual void Set(const wxMatrix2D& mat2D, const wxPoint2DDouble& tr); + virtual void Get(wxMatrix2D* mat2D, wxPoint2DDouble* tr) const; + virtual void Concat(const wxAffineMatrix2DBase& t); + virtual bool Invert(); + virtual bool IsIdentity() const; + virtual bool IsEqual(const wxAffineMatrix2DBase& t) const; + virtual void Translate(wxDouble dx, wxDouble dy); + virtual void Scale(wxDouble xScale, wxDouble yScale); + virtual void Rotate(wxDouble ccRadians); + +protected: + virtual wxPoint2DDouble DoTransformPoint(const wxPoint2DDouble& p) const; + virtual wxPoint2DDouble DoTransformDistance(const wxPoint2DDouble& p) const; + +private: + wxDouble m_11, m_12, m_21, m_22, m_tx, m_ty; +}; + +#endif // _WX_AFFINEMATRIX2D_H_ diff --git a/include/wx/affinematrix2dbase.h b/include/wx/affinematrix2dbase.h new file mode 100644 index 0000000000..a28bafa130 --- /dev/null +++ b/include/wx/affinematrix2dbase.h @@ -0,0 +1,121 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/affinematrix2dbase.h +// Purpose: Common interface for 2D transformation matrices. +// Author: Catalin Raceanu +// Created: 2011-04-06 +// Copyright: (c) wxWidgets team +// Licence: wxWidgets licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_AFFINEMATRIX2DBASE_H_ +#define _WX_AFFINEMATRIX2DBASE_H_ + +#include "wx/defs.h" +#include "wx/geometry.h" + +struct wxMatrix2D +{ + wxMatrix2D(wxDouble v11 = 1, + wxDouble v12 = 0, + wxDouble v21 = 0, + wxDouble v22 = 1) + { + m_11 = v11; m_12 = v12; + m_21 = v21; m_22 = v22; + } + + wxDouble m_11, m_12, m_21, m_22; +}; + +// A 2x3 matrix representing an affine 2D transformation. +// +// This is an abstract base class implemented by wxAffineMatrix2D only so far, +// but in the future we also plan to derive wxGraphicsMatrix from it (it should +// also be documented then as currently only wxAffineMatrix2D itself is). +class WXDLLIMPEXP_CORE wxAffineMatrix2DBase +{ +public: + wxAffineMatrix2DBase() {} + + // sets the matrix to the respective values + virtual void Set(const wxMatrix2D& mat2D, const wxPoint2DDouble& tr) = 0; + + // gets the component valuess of the matrix + virtual void Get(wxMatrix2D* mat2D, wxPoint2DDouble* tr) const = 0; + + // concatenates the matrix + virtual void Concat(const wxAffineMatrix2DBase& t) = 0; + + // makes this the inverse matrix + virtual bool Invert() = 0; + + // return true if this is the identity matrix + virtual bool IsIdentity() const = 0; + + // returns true if the elements of the transformation matrix are equal ? + virtual bool IsEqual(const wxAffineMatrix2DBase& t) const = 0; + bool operator==(const wxAffineMatrix2DBase& t) const { return IsEqual(t); } + bool operator!=(const wxAffineMatrix2DBase& t) const { return !IsEqual(t); } + + + // + // transformations + // + + // add the translation to this matrix + virtual void Translate(wxDouble dx, wxDouble dy) = 0; + + // add the scale to this matrix + virtual void Scale(wxDouble xScale, wxDouble yScale) = 0; + + // add the rotation to this matrix (counter clockwise, radians) + virtual void Rotate(wxDouble ccRadians) = 0; + + // add mirroring to this matrix + void Mirror(int direction = wxHORIZONTAL) + { + wxDouble x = (direction & wxHORIZONTAL) ? -1 : 1; + wxDouble y = (direction & wxVERTICAL) ? -1 : 1; + Scale(x, y); + } + + + // applies that matrix to the point + wxPoint2DDouble TransformPoint(const wxPoint2DDouble& src) const + { + return DoTransformPoint(src); + } + + void TransformPoint(wxDouble* x, wxDouble* y) const + { + wxCHECK_RET( x && y, "Can't be NULL" ); + + const wxPoint2DDouble dst = DoTransformPoint(wxPoint2DDouble(*x, *y)); + *x = dst.m_x; + *y = dst.m_y; + } + + // applies the matrix except for translations + wxPoint2DDouble TransformDistance(const wxPoint2DDouble& src) const + { + return DoTransformDistance(src); + } + + void TransformDistance(wxDouble* dx, wxDouble* dy) const + { + wxCHECK_RET( dx && dy, "Can't be NULL" ); + + const wxPoint2DDouble + dst = DoTransformDistance(wxPoint2DDouble(*dx, *dy)); + *dx = dst.m_x; + *dy = dst.m_y; + } + +protected: + virtual + wxPoint2DDouble DoTransformPoint(const wxPoint2DDouble& p) const = 0; + virtual + wxPoint2DDouble DoTransformDistance(const wxPoint2DDouble& p) const = 0; +}; + +#endif // _WX_AFFINEMATRIX2DBASE_H_ diff --git a/interface/wx/affinematrix2d.h b/interface/wx/affinematrix2d.h new file mode 100644 index 0000000000..b5117d4ad5 --- /dev/null +++ b/interface/wx/affinematrix2d.h @@ -0,0 +1,161 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: affinematrix2d.h +// Purpose: interface of wxAffineMatrix2D +// Author: wxWidgets team +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +/** + @class wxAffineMatrix2D + + A 3x2 matrix representing an affine 2D transformation. + + @library{wxcore} + @category{misc} + + @since 2.9.2 +*/ +class wxAffineMatrix2D +{ +public: + /** + Default constructor. + + The matrix elements are initialize to the identity matrix. + */ + wxAffineMatrix2D(); + + /** + Get the component values of the matrix. + + @param mat2D + The rotational components of the matrix (upper 2 x 2), must be + non-@NULL. + @param tr + The translational components of the matrix, may be @NULL. + */ + void Get(wxMatrix2D* mat2D, wxPoint2DDouble* tr) const; + + /** + Set all elements of this matrix. + + @param mat2D + The rotational components of the matrix (upper 2 x 2). + @param tr + The translational components of the matrix. + */ + void Set(const wxMatrix2D& mat2D, const wxPoint2DDouble& tr); + + /** + Concatenate this matrix with another one. + + The parameter matrix is the multiplicand. + + @param wxAffineMatrix2DBase + The multiplicand. + + @code + // | t.m_11 t.m_12 0 | | m_11 m_12 0 | + // matrix' = | t.m_21 t.m_22 0 | x | m_21 m_22 0 | + // | t.m_tx t.m_ty 1 | | m_tx m_ty 1 | + @endcode + */ + void Concat(const wxAffineMatrix2DBase& t); + + /** + Invert this matrix. + + If the matrix is not invertible, i.e. if its determinant is 0, returns + false and doesn't modify it. + + @code + // | m_11 m_12 0 | + // Invert | m_21 m_22 0 | + // | m_tx m_ty 1 | + @endcode + */ + bool Invert(); + + /** + Check if this is the identity matrix. + */ + bool IsIdentity() const; + + //@{ + /** + Check that this matrix is identical with @t. + + @param wxAffineMatrix2DBase + The matrix compared with this. + */ + void IsEqual(const wxAffineMatrix2DBase& t); + bool operator==(const wxAffineMatrix2DBase& t) const; + //@} + + /** + Check that this matrix differs from @t. + + @param wxAffineMatrix2DBase + The matrix compared with this. + */ + bool operator!=(const wxAffineMatrix2DBase& t) const; + + /** + Add the translation to this matrix. + + @param dx + The translation in x direction. + @param dy + The translation in y direction. + */ + void Translate(wxDouble dx, wxDouble dy); + + /** + Add scaling to this matrix. + + @param xScale + Scaling in x direction. + @param yScale + Scaling in y direction. + */ + void Scale(wxDouble xScale, wxDouble yScale); + + /** + Add mirroring to this matrix. + + @param direction + The direction(s) used for mirroring. One of wxHORIZONTAL, + wxVERTICAL or their combination wxBOTH. + */ + void Mirror(int direction = wxHORIZONTAL); + + /** + Add counter clockwise rotation to this matrix. + + @param ccRadians + Rotation angle in radians. + */ + void Rotate(wxDouble ccRadians); + + /** + Applies this matrix to the point. + + @param src + The point receiving the transformations. + + @return The point with the transformations applied. + */ + wxPoint2DDouble TransformPoint(const wxPoint2DDouble& p) const; + void TransformPoint(wxDouble* x, wxDouble* y) const; + + /** + Applies the linear part of this matrix, i.e. without translation. + + @param src + The source receiving the transformations. + + @return The source with the transformations applied. + */ + wxPoint2DDouble TransformDistance(const wxPoint2DDouble& p) const; + void TransformDistance(wxDouble* dx, wxDouble* dy) const; +}; diff --git a/interface/wx/affinematrix2dbase.h b/interface/wx/affinematrix2dbase.h new file mode 100644 index 0000000000..8845c96584 --- /dev/null +++ b/interface/wx/affinematrix2dbase.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: affinematrix2dbase.h +// Purpose: wxMatrix2D documentation +// Author: wxWidgets team +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +/** + @class wxMatrix2D + + A simple container for 2x2 matrix. + + This simple structure is used with wxAffineMatrix2D. + + @library{wxcore} + @category{misc} + + @since 2.9.2 + */ +struct wxMatrix2D +{ + /** + Default constructor. + + Initializes the matrix elements to the identity. + */ + wxMatrix2D(wxDouble v11 = 1, + wxDouble v12 = 0, + wxDouble v21 = 0, + wxDouble v22 = 1); + + /// The matrix elements in the usual mathematical notation. + wxDouble m_11, m_12, m_21, m_22; +}; diff --git a/src/common/affinematrix2d.cpp b/src/common/affinematrix2d.cpp new file mode 100644 index 0000000000..977f6834ad --- /dev/null +++ b/src/common/affinematrix2d.cpp @@ -0,0 +1,179 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: affinematrix2d.cpp +// Purpose: implementation of wxAffineMatrix2D +// Author: Based on wxTransformMatrix by Chris Breeze, Julian Smart +// Created: 2011-04-05 +// Copyright: (c) wxWidgets team +// Licence: wxWidgets licence +/////////////////////////////////////////////////////////////////////////////// + +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/affinematrix2d.h" +#include "wx/math.h" + +// sets the matrix to the respective values +void wxAffineMatrix2D::Set(const wxMatrix2D &mat2D, const wxPoint2DDouble &tr) +{ + m_11 = mat2D.m_11; + m_12 = mat2D.m_12; + m_21 = mat2D.m_21; + m_22 = mat2D.m_22; + m_tx = tr.m_x; + m_ty = tr.m_y; +} + +// gets the component valuess of the matrix +void wxAffineMatrix2D::Get(wxMatrix2D *mat2D, wxPoint2DDouble *tr) const +{ + mat2D->m_11 = m_11; + mat2D->m_12 = m_12; + mat2D->m_21 = m_21; + mat2D->m_22 = m_22; + + if ( tr ) + { + tr->m_x = m_tx; + tr->m_y = m_ty; + } +} + +// concatenates the matrix +// | t.m_11 t.m_12 0 | | m_11 m_12 0 | +// | t.m_21 t.m_22 0 | x | m_21 m_22 0 | +// | t.m_tx t.m_ty 1 | | m_tx m_ty 1 | +void wxAffineMatrix2D::Concat(const wxAffineMatrix2DBase &t) +{ + wxMatrix2D mat; + wxPoint2DDouble tr; + t.Get(&mat, &tr); + + m_tx += tr.m_x*m_11 + tr.m_y*m_21; + m_ty += tr.m_x*m_12 + tr.m_y*m_22; + wxDouble e11 = mat.m_11*m_11 + mat.m_12*m_21; + wxDouble e12 = mat.m_11*m_12 + mat.m_12*m_22; + wxDouble e21 = mat.m_21*m_11 + mat.m_22*m_21; + m_22 = mat.m_21*m_12 + mat.m_22*m_22; + m_11 = e11; + m_12 = e12; + m_21 = e21; +} + +// makes this its inverse matrix. +// Invert +// | m_11 m_12 0 | +// | m_21 m_22 0 | +// | m_tx m_ty 1 | +bool wxAffineMatrix2D::Invert() +{ + const wxDouble det = m_11*m_22 - m_12*m_21; + + if ( !det ) + return false; + + wxDouble ex = (m_21*m_ty - m_22*m_tx) / det; + m_ty = (-m_11*m_ty + m_12*m_tx) / det; + m_tx = ex; + wxDouble e11 = m_22 / det; + m_12 = -m_12 / det; + m_21 = -m_21 / det; + m_22 = m_11 / det; + m_11 = e11; + + return true; +} + +// returns true if the elements of the transformation matrix are equal +bool wxAffineMatrix2D::IsEqual(const wxAffineMatrix2DBase& t) const +{ + wxMatrix2D mat; + wxPoint2DDouble tr; + t.Get(&mat, &tr); + + return m_11 == mat.m_11 && m_12 == mat.m_12 && + m_21 == mat.m_21 && m_22 == mat.m_22 && + m_tx == tr.m_x && m_ty == tr.m_y; +} + +// +// transformations +// + +// add the translation to this matrix +void wxAffineMatrix2D::Translate(wxDouble dx, wxDouble dy) +{ + m_tx += dx; + m_ty += dy; +} + +// add the scale to this matrix +// | xScale 0 0 | | m_11 m_12 0 | +// | 0 yScale 0 | x | m_21 m_22 0 | +// | 0 0 1 | | m_tx m_ty 1 | +void wxAffineMatrix2D::Scale(wxDouble xScale, wxDouble yScale) +{ + m_11 *= xScale; + m_12 *= xScale; + m_21 *= yScale; + m_22 *= yScale; +} + +// add the rotation to this matrix (counter clockwise, radians) +// | cos -sin 0 | | m_11 m_12 0 | +// | sin cos 0 | x | m_21 m_22 0 | +// | 0 0 1 | | m_tx m_ty 1 | +void wxAffineMatrix2D::Rotate(wxDouble ccRadians) +{ + wxDouble c = cos(ccRadians); + wxDouble s = sin(ccRadians); + + wxDouble e11 = c*m_11 - s*m_21; + wxDouble e12 = c*m_12 - s*m_22; + m_21 = s*m_11 + c*m_21; + m_22 = s*m_12 + c*m_22; + m_11 = e11; + m_12 = e12; +} + +// +// apply the transforms +// + +// applies that matrix to the point +// | m_11 m_12 0 | +// | src.m_x src._my 1 | x | m_21 m_22 0 | +// | m_tx m_ty 1 | +wxPoint2DDouble +wxAffineMatrix2D::DoTransformPoint(const wxPoint2DDouble& src) const +{ + if ( IsIdentity() ) + return src; + + return wxPoint2DDouble(src.m_x * m_11 + src.m_y * m_21 + m_tx, + src.m_y * m_12 + src.m_y * m_22 + m_ty); +} + +// applies the matrix except for translations +// | m_11 m_12 0 | +// | src.m_x src._my 0 | x | m_21 m_22 0 | +// | m_tx m_ty 1 | +wxPoint2DDouble +wxAffineMatrix2D::DoTransformDistance(const wxPoint2DDouble& src) const +{ + if ( IsIdentity() ) + return src; + + return wxPoint2DDouble(src.m_x * m_11 + src.m_y * m_21, + src.m_y * m_12 + src.m_y * m_22); +} + +bool wxAffineMatrix2D::IsIdentity() const +{ + return m_11 == 1 && m_12 == 0 && + m_21 == 0 && m_22 == 1 && + m_tx == 0 && m_ty == 0; +} -- 2.45.2