From 365c3a2ae92fa2746f52678220c0864be4814d20 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Wed, 7 Oct 2020 23:15:10 +0200 Subject: [PATCH] Revert "Get rid of unused wxTransformMatrix" wxTransformMatrix is undocumented but it is appartently in use so it has to be present in the library. This reverts commit 3e88df56f5afa2d0de4c4a563788f8476d749eb8. --- Makefile.in | 21 + build/bakefiles/files.bkl | 2 + build/cmake/files.cmake | 2 + build/files | 2 + build/msw/makefile.bcc | 28 + build/msw/makefile.gcc | 28 + build/msw/makefile.vc | 28 + build/msw/wx_core.vcxproj | 2 + build/msw/wx_core.vcxproj.filters | 6 + build/msw/wx_vc7_core.vcproj | 6 + build/msw/wx_vc8_core.vcproj | 8 + build/msw/wx_vc9_core.vcproj | 8 + build/osx/wxcocoa.xcodeproj/project.pbxproj | 8 + build/osx/wxiphone.xcodeproj/project.pbxproj | 4 + include/wx/matrix.h | 234 ++++++++ src/common/matrix.cpp | 600 +++++++++++++++++++ tests/allheaders.h | 1 + 17 files changed, 988 insertions(+) create mode 100644 include/wx/matrix.h create mode 100644 src/common/matrix.cpp diff --git a/Makefile.in b/Makefile.in index 83f5f3489d..62beaa8482 100644 --- a/Makefile.in +++ b/Makefile.in @@ -3879,6 +3879,7 @@ COND_USE_GUI_1_ALL_GUI_HEADERS = \ wx/listbase.h \ wx/listbook.h \ wx/listctrl.h \ + wx/matrix.h \ wx/menuitem.h \ wx/metafile.h \ wx/minifram.h \ @@ -4515,6 +4516,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS = \ monodll_lboxcmn.o \ monodll_listctrlcmn.o \ monodll_markupparser.o \ + monodll_matrix.o \ monodll_menucmn.o \ monodll_modalhook.o \ monodll_mousemanager.o \ @@ -4775,6 +4777,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS = \ monodll_lboxcmn.o \ monodll_listctrlcmn.o \ monodll_markupparser.o \ + monodll_matrix.o \ monodll_menucmn.o \ monodll_modalhook.o \ monodll_mousemanager.o \ @@ -6500,6 +6503,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_1 = \ monolib_lboxcmn.o \ monolib_listctrlcmn.o \ monolib_markupparser.o \ + monolib_matrix.o \ monolib_menucmn.o \ monolib_modalhook.o \ monolib_mousemanager.o \ @@ -6760,6 +6764,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_1 = \ monolib_lboxcmn.o \ monolib_listctrlcmn.o \ monolib_markupparser.o \ + monolib_matrix.o \ monolib_menucmn.o \ monolib_modalhook.o \ monolib_mousemanager.o \ @@ -8631,6 +8636,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_2 = \ coredll_lboxcmn.o \ coredll_listctrlcmn.o \ coredll_markupparser.o \ + coredll_matrix.o \ coredll_menucmn.o \ coredll_modalhook.o \ coredll_mousemanager.o \ @@ -8891,6 +8897,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_2 = \ coredll_lboxcmn.o \ coredll_listctrlcmn.o \ coredll_markupparser.o \ + coredll_matrix.o \ coredll_menucmn.o \ coredll_modalhook.o \ coredll_mousemanager.o \ @@ -10352,6 +10359,7 @@ COND_USE_GUI_1_WXUNIV_0___CORE_SRC_OBJECTS_3 = \ corelib_lboxcmn.o \ corelib_listctrlcmn.o \ corelib_markupparser.o \ + corelib_matrix.o \ corelib_menucmn.o \ corelib_modalhook.o \ corelib_mousemanager.o \ @@ -10612,6 +10620,7 @@ COND_USE_GUI_1_WXUNIV_1___CORE_SRC_OBJECTS_3 = \ corelib_lboxcmn.o \ corelib_listctrlcmn.o \ corelib_markupparser.o \ + corelib_matrix.o \ corelib_menucmn.o \ corelib_modalhook.o \ corelib_mousemanager.o \ @@ -20463,6 +20472,9 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@monodll_markupparser.o: $(srcdir)/src/common/markupparser.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/markupparser.cpp +@COND_USE_GUI_1@monodll_matrix.o: $(srcdir)/src/common/matrix.cpp $(MONODLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/matrix.cpp + @COND_USE_GUI_1@monodll_menucmn.o: $(srcdir)/src/common/menucmn.cpp $(MONODLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/menucmn.cpp @@ -25728,6 +25740,9 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@monolib_markupparser.o: $(srcdir)/src/common/markupparser.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/markupparser.cpp +@COND_USE_GUI_1@monolib_matrix.o: $(srcdir)/src/common/matrix.cpp $(MONOLIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/matrix.cpp + @COND_USE_GUI_1@monolib_menucmn.o: $(srcdir)/src/common/menucmn.cpp $(MONOLIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/common/menucmn.cpp @@ -31074,6 +31089,9 @@ coredll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@coredll_markupparser.o: $(srcdir)/src/common/markupparser.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/markupparser.cpp +@COND_USE_GUI_1@coredll_matrix.o: $(srcdir)/src/common/matrix.cpp $(COREDLL_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/matrix.cpp + @COND_USE_GUI_1@coredll_menucmn.o: $(srcdir)/src/common/menucmn.cpp $(COREDLL_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $(srcdir)/src/common/menucmn.cpp @@ -35328,6 +35346,9 @@ corelib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@corelib_markupparser.o: $(srcdir)/src/common/markupparser.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/markupparser.cpp +@COND_USE_GUI_1@corelib_matrix.o: $(srcdir)/src/common/matrix.cpp $(CORELIB_ODEP) +@COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/matrix.cpp + @COND_USE_GUI_1@corelib_menucmn.o: $(srcdir)/src/common/menucmn.cpp $(CORELIB_ODEP) @COND_USE_GUI_1@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $(srcdir)/src/common/menucmn.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 7752bbe117..6b906206a4 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -883,6 +883,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/common/lboxcmn.cpp src/common/listctrlcmn.cpp src/common/markupparser.cpp + src/common/matrix.cpp src/common/menucmn.cpp src/common/modalhook.cpp src/common/mousemanager.cpp @@ -1187,6 +1188,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/listbase.h wx/listbook.h wx/listctrl.h + wx/matrix.h wx/menuitem.h wx/metafile.h wx/minifram.h diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 3d76134938..8165d51792 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -787,6 +787,7 @@ set(GUI_CMN_SRC src/common/lboxcmn.cpp src/common/listctrlcmn.cpp src/common/markupparser.cpp + src/common/matrix.cpp src/common/menucmn.cpp src/common/modalhook.cpp src/common/mousemanager.cpp @@ -1096,6 +1097,7 @@ set(GUI_CMN_HDR wx/listbase.h wx/listbook.h wx/listctrl.h + wx/matrix.h wx/menuitem.h wx/metafile.h wx/minifram.h diff --git a/build/files b/build/files index cf9a6341c1..39a49b19c6 100644 --- a/build/files +++ b/build/files @@ -806,6 +806,7 @@ GUI_CMN_SRC = src/common/lboxcmn.cpp src/common/listctrlcmn.cpp src/common/markupparser.cpp + src/common/matrix.cpp src/common/menucmn.cpp src/common/modalhook.cpp src/common/mousemanager.cpp @@ -1100,6 +1101,7 @@ GUI_CMN_HDR = wx/listbook.h wx/listbox.h wx/listctrl.h + wx/matrix.h wx/mdi.h wx/menu.h wx/menuitem.h diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc index fb0f397081..1ca436dce3 100644 --- a/build/msw/makefile.bcc +++ b/build/msw/makefile.bcc @@ -2028,6 +2028,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_lboxcmn.obj \ $(OBJS)\monodll_listctrlcmn.obj \ $(OBJS)\monodll_markupparser.obj \ + $(OBJS)\monodll_matrix.obj \ $(OBJS)\monodll_menucmn.obj \ $(OBJS)\monodll_modalhook.obj \ $(OBJS)\monodll_mousemanager.obj \ @@ -2354,6 +2355,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_lboxcmn.obj \ $(OBJS)\monodll_listctrlcmn.obj \ $(OBJS)\monodll_markupparser.obj \ + $(OBJS)\monodll_matrix.obj \ $(OBJS)\monodll_menucmn.obj \ $(OBJS)\monodll_modalhook.obj \ $(OBJS)\monodll_mousemanager.obj \ @@ -2860,6 +2862,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_lboxcmn.obj \ $(OBJS)\monolib_listctrlcmn.obj \ $(OBJS)\monolib_markupparser.obj \ + $(OBJS)\monolib_matrix.obj \ $(OBJS)\monolib_menucmn.obj \ $(OBJS)\monolib_modalhook.obj \ $(OBJS)\monolib_mousemanager.obj \ @@ -3186,6 +3189,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_lboxcmn.obj \ $(OBJS)\monolib_listctrlcmn.obj \ $(OBJS)\monolib_markupparser.obj \ + $(OBJS)\monolib_matrix.obj \ $(OBJS)\monolib_menucmn.obj \ $(OBJS)\monolib_modalhook.obj \ $(OBJS)\monolib_mousemanager.obj \ @@ -3565,6 +3569,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_lboxcmn.obj \ $(OBJS)\coredll_listctrlcmn.obj \ $(OBJS)\coredll_markupparser.obj \ + $(OBJS)\coredll_matrix.obj \ $(OBJS)\coredll_menucmn.obj \ $(OBJS)\coredll_modalhook.obj \ $(OBJS)\coredll_mousemanager.obj \ @@ -3891,6 +3896,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_lboxcmn.obj \ $(OBJS)\coredll_listctrlcmn.obj \ $(OBJS)\coredll_markupparser.obj \ + $(OBJS)\coredll_matrix.obj \ $(OBJS)\coredll_menucmn.obj \ $(OBJS)\coredll_modalhook.obj \ $(OBJS)\coredll_mousemanager.obj \ @@ -4236,6 +4242,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_lboxcmn.obj \ $(OBJS)\corelib_listctrlcmn.obj \ $(OBJS)\corelib_markupparser.obj \ + $(OBJS)\corelib_matrix.obj \ $(OBJS)\corelib_menucmn.obj \ $(OBJS)\corelib_modalhook.obj \ $(OBJS)\corelib_mousemanager.obj \ @@ -4562,6 +4569,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_lboxcmn.obj \ $(OBJS)\corelib_listctrlcmn.obj \ $(OBJS)\corelib_markupparser.obj \ + $(OBJS)\corelib_matrix.obj \ $(OBJS)\corelib_menucmn.obj \ $(OBJS)\corelib_modalhook.obj \ $(OBJS)\corelib_mousemanager.obj \ @@ -8395,6 +8403,11 @@ $(OBJS)\monodll_markupparser.obj: ..\..\src\common\markupparser.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\markupparser.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_matrix.obj: ..\..\src\common\matrix.cpp + $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\matrix.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monodll_menucmn.obj: ..\..\src\common\menucmn.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) ..\..\src\common\menucmn.cpp @@ -10944,6 +10957,11 @@ $(OBJS)\monolib_markupparser.obj: ..\..\src\common\markupparser.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\markupparser.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_matrix.obj: ..\..\src\common\matrix.cpp + $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\matrix.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monolib_menucmn.obj: ..\..\src\common\menucmn.cpp $(CXX) -q -c -P -o$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\menucmn.cpp @@ -13451,6 +13469,11 @@ $(OBJS)\coredll_markupparser.obj: ..\..\src\common\markupparser.cpp $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\common\markupparser.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\coredll_matrix.obj: ..\..\src\common\matrix.cpp + $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\common\matrix.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\coredll_menucmn.obj: ..\..\src\common\menucmn.cpp $(CXX) -q -c -P -o$@ $(COREDLL_CXXFLAGS) ..\..\src\common\menucmn.cpp @@ -15181,6 +15204,11 @@ $(OBJS)\corelib_markupparser.obj: ..\..\src\common\markupparser.cpp $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\common\markupparser.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\corelib_matrix.obj: ..\..\src\common\matrix.cpp + $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\common\matrix.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\corelib_menucmn.obj: ..\..\src\common\menucmn.cpp $(CXX) -q -c -P -o$@ $(CORELIB_CXXFLAGS) ..\..\src\common\menucmn.cpp diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index bda89b0f3b..a5488e00a1 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -2053,6 +2053,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_lboxcmn.o \ $(OBJS)\monodll_listctrlcmn.o \ $(OBJS)\monodll_markupparser.o \ + $(OBJS)\monodll_matrix.o \ $(OBJS)\monodll_menucmn.o \ $(OBJS)\monodll_modalhook.o \ $(OBJS)\monodll_mousemanager.o \ @@ -2381,6 +2382,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_lboxcmn.o \ $(OBJS)\monodll_listctrlcmn.o \ $(OBJS)\monodll_markupparser.o \ + $(OBJS)\monodll_matrix.o \ $(OBJS)\monodll_menucmn.o \ $(OBJS)\monodll_modalhook.o \ $(OBJS)\monodll_mousemanager.o \ @@ -2891,6 +2893,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_lboxcmn.o \ $(OBJS)\monolib_listctrlcmn.o \ $(OBJS)\monolib_markupparser.o \ + $(OBJS)\monolib_matrix.o \ $(OBJS)\monolib_menucmn.o \ $(OBJS)\monolib_modalhook.o \ $(OBJS)\monolib_mousemanager.o \ @@ -3219,6 +3222,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_lboxcmn.o \ $(OBJS)\monolib_listctrlcmn.o \ $(OBJS)\monolib_markupparser.o \ + $(OBJS)\monolib_matrix.o \ $(OBJS)\monolib_menucmn.o \ $(OBJS)\monolib_modalhook.o \ $(OBJS)\monolib_mousemanager.o \ @@ -3612,6 +3616,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_lboxcmn.o \ $(OBJS)\coredll_listctrlcmn.o \ $(OBJS)\coredll_markupparser.o \ + $(OBJS)\coredll_matrix.o \ $(OBJS)\coredll_menucmn.o \ $(OBJS)\coredll_modalhook.o \ $(OBJS)\coredll_mousemanager.o \ @@ -3940,6 +3945,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_lboxcmn.o \ $(OBJS)\coredll_listctrlcmn.o \ $(OBJS)\coredll_markupparser.o \ + $(OBJS)\coredll_matrix.o \ $(OBJS)\coredll_menucmn.o \ $(OBJS)\coredll_modalhook.o \ $(OBJS)\coredll_mousemanager.o \ @@ -4291,6 +4297,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_lboxcmn.o \ $(OBJS)\corelib_listctrlcmn.o \ $(OBJS)\corelib_markupparser.o \ + $(OBJS)\corelib_matrix.o \ $(OBJS)\corelib_menucmn.o \ $(OBJS)\corelib_modalhook.o \ $(OBJS)\corelib_mousemanager.o \ @@ -4619,6 +4626,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_lboxcmn.o \ $(OBJS)\corelib_listctrlcmn.o \ $(OBJS)\corelib_markupparser.o \ + $(OBJS)\corelib_matrix.o \ $(OBJS)\corelib_menucmn.o \ $(OBJS)\corelib_modalhook.o \ $(OBJS)\corelib_mousemanager.o \ @@ -8699,6 +8707,11 @@ $(OBJS)\monodll_markupparser.o: ../../src/common/markupparser.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monodll_matrix.o: ../../src/common/matrix.cpp + $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\monodll_menucmn.o: ../../src/common/menucmn.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< @@ -11248,6 +11261,11 @@ $(OBJS)\monolib_markupparser.o: ../../src/common/markupparser.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\monolib_matrix.o: ../../src/common/matrix.cpp + $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\monolib_menucmn.o: ../../src/common/menucmn.cpp $(CXX) -c -o $@ $(MONOLIB_CXXFLAGS) $(CPPDEPS) $< @@ -13755,6 +13773,11 @@ $(OBJS)\coredll_markupparser.o: ../../src/common/markupparser.cpp $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\coredll_matrix.o: ../../src/common/matrix.cpp + $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\coredll_menucmn.o: ../../src/common/menucmn.cpp $(CXX) -c -o $@ $(COREDLL_CXXFLAGS) $(CPPDEPS) $< @@ -15485,6 +15508,11 @@ $(OBJS)\corelib_markupparser.o: ../../src/common/markupparser.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< endif +ifeq ($(USE_GUI),1) +$(OBJS)\corelib_matrix.o: ../../src/common/matrix.cpp + $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< +endif + ifeq ($(USE_GUI),1) $(OBJS)\corelib_menucmn.o: ../../src/common/menucmn.cpp $(CXX) -c -o $@ $(CORELIB_CXXFLAGS) $(CPPDEPS) $< diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index 72bc753c29..2852105611 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -2365,6 +2365,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_lboxcmn.obj \ $(OBJS)\monodll_listctrlcmn.obj \ $(OBJS)\monodll_markupparser.obj \ + $(OBJS)\monodll_matrix.obj \ $(OBJS)\monodll_menucmn.obj \ $(OBJS)\monodll_modalhook.obj \ $(OBJS)\monodll_mousemanager.obj \ @@ -2691,6 +2692,7 @@ ____CORE_SRC_FILENAMES_OBJECTS = \ $(OBJS)\monodll_lboxcmn.obj \ $(OBJS)\monodll_listctrlcmn.obj \ $(OBJS)\monodll_markupparser.obj \ + $(OBJS)\monodll_matrix.obj \ $(OBJS)\monodll_menucmn.obj \ $(OBJS)\monodll_modalhook.obj \ $(OBJS)\monodll_mousemanager.obj \ @@ -3203,6 +3205,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_lboxcmn.obj \ $(OBJS)\monolib_listctrlcmn.obj \ $(OBJS)\monolib_markupparser.obj \ + $(OBJS)\monolib_matrix.obj \ $(OBJS)\monolib_menucmn.obj \ $(OBJS)\monolib_modalhook.obj \ $(OBJS)\monolib_mousemanager.obj \ @@ -3529,6 +3532,7 @@ ____CORE_SRC_FILENAMES_1_OBJECTS = \ $(OBJS)\monolib_lboxcmn.obj \ $(OBJS)\monolib_listctrlcmn.obj \ $(OBJS)\monolib_markupparser.obj \ + $(OBJS)\monolib_matrix.obj \ $(OBJS)\monolib_menucmn.obj \ $(OBJS)\monolib_modalhook.obj \ $(OBJS)\monolib_mousemanager.obj \ @@ -3974,6 +3978,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_lboxcmn.obj \ $(OBJS)\coredll_listctrlcmn.obj \ $(OBJS)\coredll_markupparser.obj \ + $(OBJS)\coredll_matrix.obj \ $(OBJS)\coredll_menucmn.obj \ $(OBJS)\coredll_modalhook.obj \ $(OBJS)\coredll_mousemanager.obj \ @@ -4300,6 +4305,7 @@ ____CORE_SRC_FILENAMES_2_OBJECTS = \ $(OBJS)\coredll_lboxcmn.obj \ $(OBJS)\coredll_listctrlcmn.obj \ $(OBJS)\coredll_markupparser.obj \ + $(OBJS)\coredll_matrix.obj \ $(OBJS)\coredll_menucmn.obj \ $(OBJS)\coredll_modalhook.obj \ $(OBJS)\coredll_mousemanager.obj \ @@ -4651,6 +4657,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_lboxcmn.obj \ $(OBJS)\corelib_listctrlcmn.obj \ $(OBJS)\corelib_markupparser.obj \ + $(OBJS)\corelib_matrix.obj \ $(OBJS)\corelib_menucmn.obj \ $(OBJS)\corelib_modalhook.obj \ $(OBJS)\corelib_mousemanager.obj \ @@ -4977,6 +4984,7 @@ ____CORE_SRC_FILENAMES_3_OBJECTS = \ $(OBJS)\corelib_lboxcmn.obj \ $(OBJS)\corelib_listctrlcmn.obj \ $(OBJS)\corelib_markupparser.obj \ + $(OBJS)\corelib_matrix.obj \ $(OBJS)\corelib_menucmn.obj \ $(OBJS)\corelib_modalhook.obj \ $(OBJS)\corelib_mousemanager.obj \ @@ -9130,6 +9138,11 @@ $(OBJS)\monodll_markupparser.obj: ..\..\src\common\markupparser.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\markupparser.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monodll_matrix.obj: ..\..\src\common\matrix.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\matrix.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monodll_menucmn.obj: ..\..\src\common\menucmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) ..\..\src\common\menucmn.cpp @@ -11679,6 +11692,11 @@ $(OBJS)\monolib_markupparser.obj: ..\..\src\common\markupparser.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\markupparser.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\monolib_matrix.obj: ..\..\src\common\matrix.cpp + $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\matrix.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\monolib_menucmn.obj: ..\..\src\common\menucmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONOLIB_CXXFLAGS) ..\..\src\common\menucmn.cpp @@ -14186,6 +14204,11 @@ $(OBJS)\coredll_markupparser.obj: ..\..\src\common\markupparser.cpp $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\common\markupparser.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\coredll_matrix.obj: ..\..\src\common\matrix.cpp + $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\common\matrix.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\coredll_menucmn.obj: ..\..\src\common\menucmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(COREDLL_CXXFLAGS) ..\..\src\common\menucmn.cpp @@ -15916,6 +15939,11 @@ $(OBJS)\corelib_markupparser.obj: ..\..\src\common\markupparser.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\common\markupparser.cpp !endif +!if "$(USE_GUI)" == "1" +$(OBJS)\corelib_matrix.obj: ..\..\src\common\matrix.cpp + $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\common\matrix.cpp +!endif + !if "$(USE_GUI)" == "1" $(OBJS)\corelib_menucmn.obj: ..\..\src\common\menucmn.cpp $(CXX) /c /nologo /TP /Fo$@ $(CORELIB_CXXFLAGS) ..\..\src\common\menucmn.cpp diff --git a/build/msw/wx_core.vcxproj b/build/msw/wx_core.vcxproj index 2d84caa37c..8089f36d7b 100644 --- a/build/msw/wx_core.vcxproj +++ b/build/msw/wx_core.vcxproj @@ -541,6 +541,7 @@ + @@ -1337,6 +1338,7 @@ + diff --git a/build/msw/wx_core.vcxproj.filters b/build/msw/wx_core.vcxproj.filters index 57bc68602c..83c265118a 100644 --- a/build/msw/wx_core.vcxproj.filters +++ b/build/msw/wx_core.vcxproj.filters @@ -294,6 +294,9 @@ Common Sources + + Common Sources + Common Sources @@ -1615,6 +1618,9 @@ Common Headers + + Common Headers + Common Headers diff --git a/build/msw/wx_vc7_core.vcproj b/build/msw/wx_vc7_core.vcproj index ef9520b43f..ad378068ce 100644 --- a/build/msw/wx_vc7_core.vcproj +++ b/build/msw/wx_vc7_core.vcproj @@ -567,6 +567,9 @@ + + @@ -2474,6 +2477,9 @@ + + diff --git a/build/msw/wx_vc8_core.vcproj b/build/msw/wx_vc8_core.vcproj index a25ffbdd55..e956ab6df8 100644 --- a/build/msw/wx_vc8_core.vcproj +++ b/build/msw/wx_vc8_core.vcproj @@ -1161,6 +1161,10 @@ RelativePath="..\..\src\common\markupparser.cpp" > + + @@ -3800,6 +3804,10 @@ RelativePath="..\..\include\wx\propgrid\manager.h" > + + diff --git a/build/msw/wx_vc9_core.vcproj b/build/msw/wx_vc9_core.vcproj index f8d4cc4439..a6d3ec7b1d 100644 --- a/build/msw/wx_vc9_core.vcproj +++ b/build/msw/wx_vc9_core.vcproj @@ -1157,6 +1157,10 @@ RelativePath="..\..\src\common\markupparser.cpp" > + + @@ -3796,6 +3800,10 @@ RelativePath="..\..\include\wx\propgrid\manager.h" > + + diff --git a/build/osx/wxcocoa.xcodeproj/project.pbxproj b/build/osx/wxcocoa.xcodeproj/project.pbxproj index 771d6ce9fe..5ce91d315a 100644 --- a/build/osx/wxcocoa.xcodeproj/project.pbxproj +++ b/build/osx/wxcocoa.xcodeproj/project.pbxproj @@ -1766,6 +1766,9 @@ 9A178ED42D96329D8CBF9B89 /* tif_predict.c in Sources */ = {isa = PBXBuildFile; fileRef = 2FA01C426EAF38D3B9ED35AC /* tif_predict.c */; }; 9A178ED42D96329D8CBF9B8A /* tif_predict.c in Sources */ = {isa = PBXBuildFile; fileRef = 2FA01C426EAF38D3B9ED35AC /* tif_predict.c */; }; 9A178ED42D96329D8CBF9B8B /* tif_predict.c in Sources */ = {isa = PBXBuildFile; fileRef = 2FA01C426EAF38D3B9ED35AC /* tif_predict.c */; }; + 9A83D365AD1F37FA9C7030C2 /* matrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EF330EAACFA53877BE289896 /* matrix.cpp */; }; + 9A83D365AD1F37FA9C7030C3 /* matrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EF330EAACFA53877BE289896 /* matrix.cpp */; }; + 9A83D365AD1F37FA9C7030C4 /* matrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EF330EAACFA53877BE289896 /* matrix.cpp */; }; 9B3F9D04FB533D99B58BD519 /* jfdctfst.c in Sources */ = {isa = PBXBuildFile; fileRef = 029486D6A2EC3DE0902A6A24 /* jfdctfst.c */; }; 9B3F9D04FB533D99B58BD51A /* jfdctfst.c in Sources */ = {isa = PBXBuildFile; fileRef = 029486D6A2EC3DE0902A6A24 /* jfdctfst.c */; }; 9B3F9D04FB533D99B58BD51B /* jfdctfst.c in Sources */ = {isa = PBXBuildFile; fileRef = 029486D6A2EC3DE0902A6A24 /* jfdctfst.c */; }; @@ -4754,6 +4757,7 @@ EEADAA811BBF3CBBB9E254FD /* xh_split.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = xh_split.cpp; path = ../../src/xrc/xh_split.cpp; sourceTree = ""; }; EED7C691150139EFA35E8EBD /* utils_osx.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = utils_osx.cpp; path = ../../src/osx/utils_osx.cpp; sourceTree = ""; }; EEE82083BFA430D5B58F8A04 /* regfree.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = regfree.c; path = ../../src/regex/regfree.c; sourceTree = ""; }; + EF330EAACFA53877BE289896 /* matrix.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = matrix.cpp; path = ../../src/common/matrix.cpp; sourceTree = ""; }; F01DDE448E4C3983ACCE67FD /* appcmn.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = appcmn.cpp; path = ../../src/common/appcmn.cpp; sourceTree = ""; }; F0905A1EBD653F6D82395602 /* xh_combo.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = xh_combo.cpp; path = ../../src/xrc/xh_combo.cpp; sourceTree = ""; }; F175D6E8E5723FC797701275 /* menucmn.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = menucmn.cpp; path = ../../src/common/menucmn.cpp; sourceTree = ""; }; @@ -5529,6 +5533,7 @@ 9660AE8FEB7B3EDB857B9238 /* lboxcmn.cpp */, E1B1FBB2BCC43BA7A45E9438 /* listctrlcmn.cpp */, DA7F7633279936EFA0B9C5CF /* markupparser.cpp */, + EF330EAACFA53877BE289896 /* matrix.cpp */, F175D6E8E5723FC797701275 /* menucmn.cpp */, 58E7C516E2453A269280A404 /* modalhook.cpp */, D037EA567C253DEEA17E822B /* mousemanager.cpp */, @@ -7743,6 +7748,7 @@ CFF73578F04D357E83D1D832 /* lboxcmn.cpp in Sources */, 164010B26D363F5FA09785B8 /* listctrlcmn.cpp in Sources */, 2F7F5B9BBCD83D90B237A1A2 /* markupparser.cpp in Sources */, + 9A83D365AD1F37FA9C7030C4 /* matrix.cpp in Sources */, E3A4615870B139D29FE727C3 /* menucmn.cpp in Sources */, 171F09F8DD553FA5B4B3FAE4 /* modalhook.cpp in Sources */, BD49EC50CB363642BDBF25CA /* mousemanager.cpp in Sources */, @@ -8420,6 +8426,7 @@ CFF73578F04D357E83D1D831 /* lboxcmn.cpp in Sources */, 164010B26D363F5FA09785B7 /* listctrlcmn.cpp in Sources */, 2F7F5B9BBCD83D90B237A1A1 /* markupparser.cpp in Sources */, + 9A83D365AD1F37FA9C7030C3 /* matrix.cpp in Sources */, E3A4615870B139D29FE727C2 /* menucmn.cpp in Sources */, 171F09F8DD553FA5B4B3FAE3 /* modalhook.cpp in Sources */, BD49EC50CB363642BDBF25C9 /* mousemanager.cpp in Sources */, @@ -9650,6 +9657,7 @@ CFF73578F04D357E83D1D830 /* lboxcmn.cpp in Sources */, 164010B26D363F5FA09785B6 /* listctrlcmn.cpp in Sources */, 2F7F5B9BBCD83D90B237A1A0 /* markupparser.cpp in Sources */, + 9A83D365AD1F37FA9C7030C2 /* matrix.cpp in Sources */, E3A4615870B139D29FE727C1 /* menucmn.cpp in Sources */, 171F09F8DD553FA5B4B3FAE2 /* modalhook.cpp in Sources */, BD49EC50CB363642BDBF25C8 /* mousemanager.cpp in Sources */, diff --git a/build/osx/wxiphone.xcodeproj/project.pbxproj b/build/osx/wxiphone.xcodeproj/project.pbxproj index c13eba02f4..5f78a8530d 100644 --- a/build/osx/wxiphone.xcodeproj/project.pbxproj +++ b/build/osx/wxiphone.xcodeproj/project.pbxproj @@ -514,6 +514,7 @@ 99E7A46106C03484BA70D29E /* tif_unix.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D2F8259CC99380CB8217DEF /* tif_unix.c */; }; 99F7D7BFBB543A04AB728375 /* m_hline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ECA4A44BEC2F3AED8CF0C911 /* m_hline.cpp */; }; 9A178ED42D96329D8CBF9B89 /* tif_predict.c in Sources */ = {isa = PBXBuildFile; fileRef = 2FA01C426EAF38D3B9ED35AC /* tif_predict.c */; }; + 9A83D365AD1F37FA9C7030C2 /* matrix.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EF330EAACFA53877BE289896 /* matrix.cpp */; }; 9B3F9D04FB533D99B58BD519 /* jfdctfst.c in Sources */ = {isa = PBXBuildFile; fileRef = 029486D6A2EC3DE0902A6A24 /* jfdctfst.c */; }; 9B6A35E706543CDAA6A5014A /* LexGui4Cli.cxx in Sources */ = {isa = PBXBuildFile; fileRef = FFB767BD2C7235F293F45796 /* LexGui4Cli.cxx */; }; 9B8E5690A6103FC1BDC6C47E /* pngread.c in Sources */ = {isa = PBXBuildFile; fileRef = 29D6506AEA5A323B8735F126 /* pngread.c */; }; @@ -1663,6 +1664,7 @@ EEADAA811BBF3CBBB9E254FD /* xh_split.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = xh_split.cpp; path = ../../src/xrc/xh_split.cpp; sourceTree = ""; }; EED7C691150139EFA35E8EBD /* utils_osx.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = utils_osx.cpp; path = ../../src/osx/utils_osx.cpp; sourceTree = ""; }; EEE82083BFA430D5B58F8A04 /* regfree.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = regfree.c; path = ../../src/regex/regfree.c; sourceTree = ""; }; + EF330EAACFA53877BE289896 /* matrix.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = matrix.cpp; path = ../../src/common/matrix.cpp; sourceTree = ""; }; F01DDE448E4C3983ACCE67FD /* appcmn.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = appcmn.cpp; path = ../../src/common/appcmn.cpp; sourceTree = ""; }; F0905A1EBD653F6D82395602 /* xh_combo.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = xh_combo.cpp; path = ../../src/xrc/xh_combo.cpp; sourceTree = ""; }; F175D6E8E5723FC797701275 /* menucmn.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = menucmn.cpp; path = ../../src/common/menucmn.cpp; sourceTree = ""; }; @@ -2119,6 +2121,7 @@ 9660AE8FEB7B3EDB857B9238 /* lboxcmn.cpp */, E1B1FBB2BCC43BA7A45E9438 /* listctrlcmn.cpp */, DA7F7633279936EFA0B9C5CF /* markupparser.cpp */, + EF330EAACFA53877BE289896 /* matrix.cpp */, F175D6E8E5723FC797701275 /* menucmn.cpp */, 58E7C516E2453A269280A404 /* modalhook.cpp */, D037EA567C253DEEA17E822B /* mousemanager.cpp */, @@ -3169,6 +3172,7 @@ CFF73578F04D357E83D1D830 /* lboxcmn.cpp in Sources */, 164010B26D363F5FA09785B6 /* listctrlcmn.cpp in Sources */, 2F7F5B9BBCD83D90B237A1A0 /* markupparser.cpp in Sources */, + 9A83D365AD1F37FA9C7030C2 /* matrix.cpp in Sources */, E3A4615870B139D29FE727C1 /* menucmn.cpp in Sources */, 171F09F8DD553FA5B4B3FAE2 /* modalhook.cpp in Sources */, BD49EC50CB363642BDBF25C8 /* mousemanager.cpp in Sources */, diff --git a/include/wx/matrix.h b/include/wx/matrix.h new file mode 100644 index 0000000000..b45473e3ee --- /dev/null +++ b/include/wx/matrix.h @@ -0,0 +1,234 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: wx/matrix.h +// Purpose: wxTransformMatrix class. NOT YET USED +// Author: Chris Breeze, Julian Smart +// Modified by: Klaas Holwerda +// Created: 01/02/97 +// Copyright: (c) Julian Smart, Chris Breeze +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_MATRIXH__ +#define _WX_MATRIXH__ + +//! headerfiles="matrix.h wx/object.h" +#include "wx/object.h" +#include "wx/math.h" + +//! codefiles="matrix.cpp" + +// A simple 3x3 matrix. This may be replaced by a more general matrix +// class some day. +// +// Note: this is intended to be used in wxDC at some point to replace +// the current system of scaling/translation. It is not yet used. + +//:definition +// A 3x3 matrix to do 2D transformations. +// It can be used to map data to window coordinates, +// and also for manipulating your own data. +// For example drawing a picture (composed of several primitives) +// at a certain coordinate and angle within another parent picture. +// At all times m_isIdentity is set if the matrix itself is an Identity matrix. +// It is used where possible to optimize calculations. +class WXDLLIMPEXP_CORE wxTransformMatrix: public wxObject +{ +public: + wxTransformMatrix(); + wxTransformMatrix(const wxTransformMatrix& mat); + + //get the value in the matrix at col,row + //rows are horizontal (second index of m_matrix member) + //columns are vertical (first index of m_matrix member) + double GetValue(int col, int row) const; + + //set the value in the matrix at col,row + //rows are horizontal (second index of m_matrix member) + //columns are vertical (first index of m_matrix member) + void SetValue(int col, int row, double value); + + void operator = (const wxTransformMatrix& mat); + bool operator == (const wxTransformMatrix& mat) const; + bool operator != (const wxTransformMatrix& mat) const; + + //multiply every element by t + wxTransformMatrix& operator*=(const double& t); + //divide every element by t + wxTransformMatrix& operator/=(const double& t); + //add matrix m to this t + wxTransformMatrix& operator+=(const wxTransformMatrix& m); + //subtract matrix m from this + wxTransformMatrix& operator-=(const wxTransformMatrix& m); + //multiply matrix m with this + wxTransformMatrix& operator*=(const wxTransformMatrix& m); + + // constant operators + + //multiply every element by t and return result + wxTransformMatrix operator*(const double& t) const; + //divide this matrix by t and return result + wxTransformMatrix operator/(const double& t) const; + //add matrix m to this and return result + wxTransformMatrix operator+(const wxTransformMatrix& m) const; + //subtract matrix m from this and return result + wxTransformMatrix operator-(const wxTransformMatrix& m) const; + //multiply this by matrix m and return result + wxTransformMatrix operator*(const wxTransformMatrix& m) const; + wxTransformMatrix operator-() const; + + //rows are horizontal (second index of m_matrix member) + //columns are vertical (first index of m_matrix member) + double& operator()(int col, int row); + + //rows are horizontal (second index of m_matrix member) + //columns are vertical (first index of m_matrix member) + double operator()(int col, int row) const; + + // Invert matrix + bool Invert(); + + // Make into identity matrix + bool Identity(); + + // Is the matrix the identity matrix? + // Only returns a flag, which is set whenever an operation + // is done. + inline bool IsIdentity() const { return m_isIdentity; } + + // This does an actual check. + inline bool IsIdentity1() const ; + + //Scale by scale (isotropic scaling i.e. the same in x and y): + //!ex: + //!code: | scale 0 0 | + //!code: matrix' = | 0 scale 0 | x matrix + //!code: | 0 0 scale | + bool Scale(double scale); + + //Scale with center point and x/y scale + // + //!ex: + //!code: | xs 0 xc(1-xs) | + //!code: matrix' = | 0 ys yc(1-ys) | x matrix + //!code: | 0 0 1 | + wxTransformMatrix& Scale(const double &xs, const double &ys,const double &xc, const double &yc); + + // mirror a matrix in x, y + //!ex: + //!code: | -1 0 0 | + //!code: matrix' = | 0 -1 0 | x matrix + //!code: | 0 0 1 | + wxTransformMatrix& Mirror(bool x=true, bool y=false); + // Translate by dx, dy: + //!ex: + //!code: | 1 0 dx | + //!code: matrix' = | 0 1 dy | x matrix + //!code: | 0 0 1 | + bool Translate(double x, double y); + + // Rotate clockwise by the given number of degrees: + //!ex: + //!code: | cos sin 0 | + //!code: matrix' = | -sin cos 0 | x matrix + //!code: | 0 0 1 | + bool Rotate(double angle); + + //Rotate counter clockwise with point of rotation + // + //!ex: + //!code: | cos(r) -sin(r) x(1-cos(r))+y(sin(r)| + //!code: matrix' = | sin(r) cos(r) y(1-cos(r))-x(sin(r)| x matrix + //!code: | 0 0 1 | + wxTransformMatrix& Rotate(const double &r, const double &x, const double &y); + + // Transform X value from logical to device + inline double TransformX(double x) const; + + // Transform Y value from logical to device + inline double TransformY(double y) const; + + // Transform a point from logical to device coordinates + bool TransformPoint(double x, double y, double& tx, double& ty) const; + + // Transform a point from device to logical coordinates. + // Example of use: + // wxTransformMatrix mat = dc.GetTransformation(); + // mat.Invert(); + // mat.InverseTransformPoint(x, y, x1, y1); + // OR (shorthand:) + // dc.LogicalToDevice(x, y, x1, y1); + // The latter is slightly less efficient if we're doing several + // conversions, since the matrix is inverted several times. + // N.B. 'this' matrix is the inverse at this point + bool InverseTransformPoint(double x, double y, double& tx, double& ty) const; + + double Get_scaleX(); + double Get_scaleY(); + double GetRotation(); + void SetRotation(double rotation); + + +public: + double m_matrix[3][3]; + bool m_isIdentity; +}; + + +/* +Chris Breeze reported, that +some functions of wxTransformMatrix cannot work because it is not +known if he matrix has been inverted. Be careful when using it. +*/ + +// Transform X value from logical to device +// warning: this function can only be used for this purpose +// because no rotation is involved when mapping logical to device coordinates +// mirror and scaling for x and y will be part of the matrix +// if you have a matrix that is rotated, eg a shape containing a matrix to place +// it in the logical coordinate system, use TransformPoint +inline double wxTransformMatrix::TransformX(double x) const +{ + //normally like this, but since no rotation is involved (only mirror and scale) + //we can do without Y -> m_matrix[1]{0] is -sin(rotation angle) and therefore zero + //(x * m_matrix[0][0] + y * m_matrix[1][0] + m_matrix[2][0])) + return (m_isIdentity ? x : (x * m_matrix[0][0] + m_matrix[2][0])); +} + +// Transform Y value from logical to device +// warning: this function can only be used for this purpose +// because no rotation is involved when mapping logical to device coordinates +// mirror and scaling for x and y will be part of the matrix +// if you have a matrix that is rotated, eg a shape containing a matrix to place +// it in the logical coordinate system, use TransformPoint +inline double wxTransformMatrix::TransformY(double y) const +{ + //normally like this, but since no rotation is involved (only mirror and scale) + //we can do without X -> m_matrix[0]{1] is sin(rotation angle) and therefore zero + //(x * m_matrix[0][1] + y * m_matrix[1][1] + m_matrix[2][1])) + return (m_isIdentity ? y : (y * m_matrix[1][1] + m_matrix[2][1])); +} + + +// Is the matrix the identity matrix? +// Each operation checks whether the result is still the identity matrix and sets a flag. +inline bool wxTransformMatrix::IsIdentity1() const +{ + return + ( wxIsSameDouble(m_matrix[0][0], 1.0) && + wxIsSameDouble(m_matrix[1][1], 1.0) && + wxIsSameDouble(m_matrix[2][2], 1.0) && + wxIsSameDouble(m_matrix[1][0], 0.0) && + wxIsSameDouble(m_matrix[2][0], 0.0) && + wxIsSameDouble(m_matrix[0][1], 0.0) && + wxIsSameDouble(m_matrix[2][1], 0.0) && + wxIsSameDouble(m_matrix[0][2], 0.0) && + wxIsSameDouble(m_matrix[1][2], 0.0) ); +} + +// Calculates the determinant of a 2 x 2 matrix +inline double wxCalculateDet(double a11, double a21, double a12, double a22) +{ + return a11 * a22 - a12 * a21; +} + +#endif // _WX_MATRIXH__ diff --git a/src/common/matrix.cpp b/src/common/matrix.cpp new file mode 100644 index 0000000000..69ef92cc2d --- /dev/null +++ b/src/common/matrix.cpp @@ -0,0 +1,600 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: src/common/matrix.cpp +// Purpose: wxTransformMatrix class +// Author: Chris Breeze, Julian Smart +// Modified by: Klaas Holwerda +// Created: 01/02/97 +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// Note: this is intended to be used in wxDC at some point to replace +// the current system of scaling/translation. It is not yet used. + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#include "wx/matrix.h" + +#ifndef WX_PRECOMP + #include "wx/math.h" +#endif + +static const double pi = M_PI; + +wxTransformMatrix::wxTransformMatrix() +{ + m_isIdentity = false; + + Identity(); +} + +wxTransformMatrix::wxTransformMatrix(const wxTransformMatrix& mat) + : wxObject() +{ + (*this) = mat; +} + +double wxTransformMatrix::GetValue(int col, int row) const +{ + if (row < 0 || row > 2 || col < 0 || col > 2) + return 0.0; + + return m_matrix[col][row]; +} + +void wxTransformMatrix::SetValue(int col, int row, double value) +{ + if (row < 0 || row > 2 || col < 0 || col > 2) + return; + + m_matrix[col][row] = value; + m_isIdentity = IsIdentity1(); +} + +void wxTransformMatrix::operator = (const wxTransformMatrix& mat) +{ + int i, j; + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { + m_matrix[i][j] = mat.m_matrix[i][j]; + } + } + m_isIdentity = mat.m_isIdentity; +} + +bool wxTransformMatrix::operator == (const wxTransformMatrix& mat) const +{ + if (m_isIdentity && mat.m_isIdentity) + return true; + + int i, j; + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { + if ( !wxIsSameDouble(m_matrix[i][j], mat.m_matrix[i][j]) ) + return false; + } + } + return true; +} + +bool wxTransformMatrix::operator != (const wxTransformMatrix& mat) const +{ + return (! ((*this) == mat)); +} + +double& wxTransformMatrix::operator()(int col, int row) +{ + if (row < 0 || row > 2 || col < 0 || col > 2) + return m_matrix[0][0]; + + return m_matrix[col][row]; +} + +double wxTransformMatrix::operator()(int col, int row) const +{ + if (row < 0 || row > 2 || col < 0 || col > 2) + return 0.0; + + return m_matrix[col][row]; +} + +// Invert matrix +bool wxTransformMatrix::Invert() +{ + double inverseMatrix[3][3]; + + // calculate the adjoint + inverseMatrix[0][0] = wxCalculateDet(m_matrix[1][1],m_matrix[2][1],m_matrix[1][2],m_matrix[2][2]); + inverseMatrix[0][1] = -wxCalculateDet(m_matrix[0][1],m_matrix[2][1],m_matrix[0][2],m_matrix[2][2]); + inverseMatrix[0][2] = wxCalculateDet(m_matrix[0][1],m_matrix[1][1],m_matrix[0][2],m_matrix[1][2]); + + inverseMatrix[1][0] = -wxCalculateDet(m_matrix[1][0],m_matrix[2][0],m_matrix[1][2],m_matrix[2][2]); + inverseMatrix[1][1] = wxCalculateDet(m_matrix[0][0],m_matrix[2][0],m_matrix[0][2],m_matrix[2][2]); + inverseMatrix[1][2] = -wxCalculateDet(m_matrix[0][0],m_matrix[1][0],m_matrix[0][2],m_matrix[1][2]); + + inverseMatrix[2][0] = wxCalculateDet(m_matrix[1][0],m_matrix[2][0],m_matrix[1][1],m_matrix[2][1]); + inverseMatrix[2][1] = -wxCalculateDet(m_matrix[0][0],m_matrix[2][0],m_matrix[0][1],m_matrix[2][1]); + inverseMatrix[2][2] = wxCalculateDet(m_matrix[0][0],m_matrix[1][0],m_matrix[0][1],m_matrix[1][1]); + + // now divide by the determinant + double det = m_matrix[0][0] * inverseMatrix[0][0] + m_matrix[0][1] * inverseMatrix[1][0] + m_matrix[0][2] * inverseMatrix[2][0]; + if ( wxIsNullDouble(det) ) + return false; + + inverseMatrix[0][0] /= det; inverseMatrix[1][0] /= det; inverseMatrix[2][0] /= det; + inverseMatrix[0][1] /= det; inverseMatrix[1][1] /= det; inverseMatrix[2][1] /= det; + inverseMatrix[0][2] /= det; inverseMatrix[1][2] /= det; inverseMatrix[2][2] /= det; + + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + m_matrix[i][j] = inverseMatrix[i][j]; + } + } + m_isIdentity = IsIdentity1(); + return true; +} + +// Make into identity matrix +bool wxTransformMatrix::Identity() +{ + m_matrix[0][0] = m_matrix[1][1] = m_matrix[2][2] = 1.0; + m_matrix[1][0] = m_matrix[2][0] = m_matrix[0][1] = m_matrix[2][1] = m_matrix[0][2] = m_matrix[1][2] = 0.0; + m_isIdentity = true; + + return true; +} + +// Scale by scale (isotropic scaling i.e. the same in x and y): +// | scale 0 0 | +// matrix' = | 0 scale 0 | x matrix +// | 0 0 scale | +// +bool wxTransformMatrix::Scale(double scale) +{ + int i, j; + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { + m_matrix[i][j] *= scale; + } + } + m_isIdentity = IsIdentity1(); + + return true; +} + + +// scale a matrix in 2D +// +// xs 0 xc(1-xs) +// 0 ys yc(1-ys) +// 0 0 1 +// +wxTransformMatrix& wxTransformMatrix::Scale(const double &xs, const double &ys,const double &xc, const double &yc) +{ + double r00,r10,r20,r01,r11,r21; + + if (m_isIdentity) + { + double tx = xc*(1-xs); + double ty = yc*(1-ys); + r00 = xs; + r10 = 0; + r20 = tx; + r01 = 0; + r11 = ys; + r21 = ty; + } + else if ( !wxIsNullDouble(xc) || !wxIsNullDouble(yc) ) + { + double tx = xc*(1-xs); + double ty = yc*(1-ys); + r00 = xs * m_matrix[0][0]; + r10 = xs * m_matrix[1][0]; + r20 = xs * m_matrix[2][0] + tx; + r01 = ys * m_matrix[0][1]; + r11 = ys * m_matrix[1][1]; + r21 = ys * m_matrix[2][1] + ty; + } + else + { + r00 = xs * m_matrix[0][0]; + r10 = xs * m_matrix[1][0]; + r20 = xs * m_matrix[2][0]; + r01 = ys * m_matrix[0][1]; + r11 = ys * m_matrix[1][1]; + r21 = ys * m_matrix[2][1]; + } + + m_matrix[0][0] = r00; + m_matrix[1][0] = r10; + m_matrix[2][0] = r20; + m_matrix[0][1] = r01; + m_matrix[1][1] = r11; + m_matrix[2][1] = r21; + +/* or like this + // first translate to origin O + (*this).Translate(-x_cen, -y_cen); + + // now do the scaling + wxTransformMatrix scale; + scale.m_matrix[0][0] = x_fac; + scale.m_matrix[1][1] = y_fac; + scale.m_isIdentity = IsIdentity1(); + + *this = scale * (*this); + + // translate back from origin to x_cen, y_cen + (*this).Translate(x_cen, y_cen); +*/ + + m_isIdentity = IsIdentity1(); + + return *this; +} + + +// mirror a matrix in x, y +// +// -1 0 0 Y-mirror +// 0 -1 0 X-mirror +// 0 0 -1 Z-mirror +wxTransformMatrix& wxTransformMatrix::Mirror(bool x, bool y) +{ + wxTransformMatrix temp; + if (x) + { + temp.m_matrix[1][1] = -1; + temp.m_isIdentity=false; + } + if (y) + { + temp.m_matrix[0][0] = -1; + temp.m_isIdentity=false; + } + + *this = temp * (*this); + m_isIdentity = IsIdentity1(); + return *this; +} + +// Translate by dx, dy: +// | 1 0 dx | +// matrix' = | 0 1 dy | x matrix +// | 0 0 1 | +// +bool wxTransformMatrix::Translate(double dx, double dy) +{ + int i; + for (i = 0; i < 3; i++) + m_matrix[i][0] += dx * m_matrix[i][2]; + for (i = 0; i < 3; i++) + m_matrix[i][1] += dy * m_matrix[i][2]; + + m_isIdentity = IsIdentity1(); + + return true; +} + +// Rotate clockwise by the given number of degrees: +// | cos sin 0 | +// matrix' = | -sin cos 0 | x matrix +// | 0 0 1 | +bool wxTransformMatrix::Rotate(double degrees) +{ + Rotate(-degrees,0,0); + return true; +} + +// counter clockwise rotate around a point +// +// cos(r) -sin(r) x(1-cos(r))+y(sin(r) +// sin(r) cos(r) y(1-cos(r))-x(sin(r) +// 0 0 1 +wxTransformMatrix& wxTransformMatrix::Rotate(const double °rees, const double &x, const double &y) +{ + double angle = degrees * pi / 180.0; + double c = cos(angle); + double s = sin(angle); + double r00,r10,r20,r01,r11,r21; + + if (m_isIdentity) + { + double tx = x*(1-c)+y*s; + double ty = y*(1-c)-x*s; + r00 = c ; + r10 = -s; + r20 = tx; + r01 = s; + r11 = c; + r21 = ty; + } + else if ( !wxIsNullDouble(x) || !wxIsNullDouble(y) ) + { + double tx = x*(1-c)+y*s; + double ty = y*(1-c)-x*s; + r00 = c * m_matrix[0][0] - s * m_matrix[0][1] + tx * m_matrix[0][2]; + r10 = c * m_matrix[1][0] - s * m_matrix[1][1] + tx * m_matrix[1][2]; + r20 = c * m_matrix[2][0] - s * m_matrix[2][1] + tx;// * m_matrix[2][2]; + r01 = c * m_matrix[0][1] + s * m_matrix[0][0] + ty * m_matrix[0][2]; + r11 = c * m_matrix[1][1] + s * m_matrix[1][0] + ty * m_matrix[1][2]; + r21 = c * m_matrix[2][1] + s * m_matrix[2][0] + ty;// * m_matrix[2][2]; + } + else + { + r00 = c * m_matrix[0][0] - s * m_matrix[0][1]; + r10 = c * m_matrix[1][0] - s * m_matrix[1][1]; + r20 = c * m_matrix[2][0] - s * m_matrix[2][1]; + r01 = c * m_matrix[0][1] + s * m_matrix[0][0]; + r11 = c * m_matrix[1][1] + s * m_matrix[1][0]; + r21 = c * m_matrix[2][1] + s * m_matrix[2][0]; + } + + m_matrix[0][0] = r00; + m_matrix[1][0] = r10; + m_matrix[2][0] = r20; + m_matrix[0][1] = r01; + m_matrix[1][1] = r11; + m_matrix[2][1] = r21; + +/* or like this + wxTransformMatrix rotate; + rotate.m_matrix[2][0] = tx; + rotate.m_matrix[2][1] = ty; + + rotate.m_matrix[0][0] = c; + rotate.m_matrix[0][1] = s; + + rotate.m_matrix[1][0] = -s; + rotate.m_matrix[1][1] = c; + + rotate.m_isIdentity=false; + *this = rotate * (*this); +*/ + m_isIdentity = IsIdentity1(); + + return *this; +} + +// Transform a point from logical to device coordinates +bool wxTransformMatrix::TransformPoint(double x, double y, double& tx, double& ty) const +{ + if (IsIdentity()) + { + tx = x; ty = y; return true; + } + + tx = x * m_matrix[0][0] + y * m_matrix[1][0] + m_matrix[2][0]; + ty = x * m_matrix[0][1] + y * m_matrix[1][1] + m_matrix[2][1]; + + return true; +} + +// Transform a point from device to logical coordinates. + +// Example of use: +// wxTransformMatrix mat = dc.GetTransformation(); +// mat.Invert(); +// mat.InverseTransformPoint(x, y, x1, y1); +// OR (shorthand:) +// dc.LogicalToDevice(x, y, x1, y1); +// The latter is slightly less efficient if we're doing several +// conversions, since the matrix is inverted several times. +bool wxTransformMatrix::InverseTransformPoint(double x, double y, double& tx, double& ty) const +{ + if (IsIdentity()) + { + tx = x; + ty = y; + return true; + } + + const double z = (1.0 - m_matrix[0][2] * x - m_matrix[1][2] * y) / m_matrix[2][2]; + if ( wxIsNullDouble(z) ) + return false; + + tx = x * m_matrix[0][0] + y * m_matrix[1][0] + z * m_matrix[2][0]; + ty = x * m_matrix[0][1] + y * m_matrix[1][1] + z * m_matrix[2][1]; + return true; +} + +wxTransformMatrix& wxTransformMatrix::operator*=(const double& t) +{ + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + m_matrix[i][j]*= t; + m_isIdentity = IsIdentity1(); + return *this; +} + +wxTransformMatrix& wxTransformMatrix::operator/=(const double& t) +{ + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + m_matrix[i][j]/= t; + m_isIdentity = IsIdentity1(); + return *this; +} + +wxTransformMatrix& wxTransformMatrix::operator+=(const wxTransformMatrix& mat) +{ + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + m_matrix[i][j] += mat.m_matrix[i][j]; + m_isIdentity = IsIdentity1(); + return *this; +} + +wxTransformMatrix& wxTransformMatrix::operator-=(const wxTransformMatrix& mat) +{ + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + m_matrix[i][j] -= mat.m_matrix[i][j]; + m_isIdentity = IsIdentity1(); + return *this; +} + +wxTransformMatrix& wxTransformMatrix::operator*=(const wxTransformMatrix& mat) +{ + + if (mat.m_isIdentity) + return *this; + if (m_isIdentity) + { + *this = mat; + return *this; + } + else + { + wxTransformMatrix result; + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + double sum = 0; + for (int k = 0; k < 3; k++) + sum += m_matrix[k][i] * mat.m_matrix[j][k]; + result.m_matrix[j][i] = sum; + } + } + *this = result; + } + + m_isIdentity = IsIdentity1(); + return *this; +} + + +// constant operators +wxTransformMatrix wxTransformMatrix::operator*(const double& t) const +{ + wxTransformMatrix result = *this; + result *= t; + result.m_isIdentity = result.IsIdentity1(); + return result; +} + +wxTransformMatrix wxTransformMatrix::operator/(const double& t) const +{ + wxTransformMatrix result = *this; +// wxASSERT(t!=0); + result /= t; + result.m_isIdentity = result.IsIdentity1(); + return result; +} + +wxTransformMatrix wxTransformMatrix::operator+(const wxTransformMatrix& m) const +{ + wxTransformMatrix result = *this; + result += m; + result.m_isIdentity = result.IsIdentity1(); + return result; +} + +wxTransformMatrix wxTransformMatrix::operator-(const wxTransformMatrix& m) const +{ + wxTransformMatrix result = *this; + result -= m; + result.m_isIdentity = result.IsIdentity1(); + return result; +} + + +wxTransformMatrix wxTransformMatrix::operator*(const wxTransformMatrix& m) const +{ + wxTransformMatrix result = *this; + result *= m; + result.m_isIdentity = result.IsIdentity1(); + return result; +} + + +wxTransformMatrix wxTransformMatrix::operator-() const +{ + wxTransformMatrix result = *this; + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + result.m_matrix[i][j] = -(this->m_matrix[i][j]); + result.m_isIdentity = result.IsIdentity1(); + return result; +} + +static double CheckInt(double getal) +{ + // check if the number is very close to an integer + if ( (ceil(getal) - getal) < 0.0001) + return ceil(getal); + + else if ( (getal - floor(getal)) < 0.0001) + return floor(getal); + + return getal; + +} + +double wxTransformMatrix::Get_scaleX() +{ + double scale_factor; + double rot_angle = CheckInt(atan2(m_matrix[1][0],m_matrix[0][0])*180/pi); + if ( !wxIsSameDouble(rot_angle, 90) && !wxIsSameDouble(rot_angle, -90) ) + scale_factor = m_matrix[0][0]/cos((rot_angle/180)*pi); + else + scale_factor = m_matrix[0][0]/sin((rot_angle/180)*pi); // er kan nl. niet door 0 gedeeld worden ! + + scale_factor = CheckInt(scale_factor); + if (scale_factor < 0) + scale_factor = -scale_factor; + + return scale_factor; +} + +double wxTransformMatrix::Get_scaleY() +{ + double scale_factor; + double rot_angle = CheckInt(atan2(m_matrix[1][0],m_matrix[0][0])*180/pi); + if ( !wxIsSameDouble(rot_angle, 90) && !wxIsSameDouble(rot_angle, -90) ) + scale_factor = m_matrix[1][1]/cos((rot_angle/180)*pi); + else + scale_factor = m_matrix[1][1]/sin((rot_angle/180)*pi); // er kan nl. niet door 0 gedeeld worden ! + + scale_factor = CheckInt(scale_factor); + if (scale_factor < 0) + + scale_factor = -scale_factor; + + return scale_factor; + +} + +double wxTransformMatrix::GetRotation() +{ + double temp1 = GetValue(0,0); // for angle calculation + double temp2 = GetValue(0,1); // + + // Rotation + double rot_angle = atan2(temp2,temp1)*180/pi; + + rot_angle = CheckInt(rot_angle); + return rot_angle; +} + +void wxTransformMatrix::SetRotation(double rotation) +{ + double x=GetValue(2,0); + double y=GetValue(2,1); + Rotate(-GetRotation(), x, y); + Rotate(rotation, x, y); +} diff --git a/tests/allheaders.h b/tests/allheaders.h index 4915ad7efb..7da480582a 100644 --- a/tests/allheaders.h +++ b/tests/allheaders.h @@ -217,6 +217,7 @@ #include #include #include +#include #include #include #include