From 2bdbece75f9dcc9b98d7f9d5794c4b5e5f441b26 Mon Sep 17 00:00:00 2001 From: neoraider Date: Sun, 16 Sep 2007 12:52:01 +0000 Subject: zoomedit: Kompiliert jetzt als C++-Programm --- Makefile.am | 4 +- Makefile.in | 245 +++++------ config.h.in | 3 - configure | 1338 ++++++++++++++++++++++++++++++++++++---------------------- configure.in | 9 +- draw.c | 306 -------------- draw.cpp | 307 ++++++++++++++ edit.c | 172 -------- edit.cpp | 170 ++++++++ edit.h | 3 + geometry.c | 368 ---------------- geometry.cpp | 368 ++++++++++++++++ level.c | 51 --- level.cpp | 51 +++ level.h | 2 +- ui.c | 103 ----- ui.cpp | 103 +++++ window.c | 366 ---------------- window.cpp | 367 ++++++++++++++++ zoomedit.c | 25 -- zoomedit.cpp | 24 ++ 21 files changed, 2368 insertions(+), 2017 deletions(-) delete mode 100644 draw.c create mode 100644 draw.cpp delete mode 100644 edit.c create mode 100644 edit.cpp delete mode 100644 geometry.c create mode 100644 geometry.cpp delete mode 100644 level.c create mode 100644 level.cpp delete mode 100644 ui.c create mode 100644 ui.cpp delete mode 100644 window.c create mode 100644 window.cpp delete mode 100644 zoomedit.c create mode 100644 zoomedit.cpp diff --git a/Makefile.am b/Makefile.am index 06034df..2458ea3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ bin_PROGRAMS = zoomedit -zoomedit_SOURCES = zoomedit.c window.c ui.c draw.c level.c geometry.c edit.c -zoomedit_CFLAGS = @GTK_CFLAGS@ +zoomedit_SOURCES = zoomedit.cpp window.cpp ui.cpp draw.cpp level.cpp geometry.cpp edit.cpp +zoomedit_CPPFLAGS = @GTK_CFLAGS@ zoomedit_LDADD = @GTK_LIBS@ \ No newline at end of file diff --git a/Makefile.in b/Makefile.in index 166bcdf..e421750 100644 --- a/Makefile.in +++ b/Makefile.in @@ -54,15 +54,14 @@ am_zoomedit_OBJECTS = zoomedit-zoomedit.$(OBJEXT) \ zoomedit-geometry.$(OBJEXT) zoomedit-edit.$(OBJEXT) zoomedit_OBJECTS = $(am_zoomedit_OBJECTS) zoomedit_DEPENDENCIES = -zoomedit_LINK = $(CCLD) $(zoomedit_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ SOURCES = $(zoomedit_SOURCES) DIST_SOURCES = $(zoomedit_SOURCES) ETAGS = etags @@ -89,6 +88,9 @@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ @@ -130,6 +132,7 @@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ @@ -166,14 +169,14 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -zoomedit_SOURCES = zoomedit.c window.c ui.c draw.c level.c geometry.c edit.c -zoomedit_CFLAGS = @GTK_CFLAGS@ +zoomedit_SOURCES = zoomedit.cpp window.cpp ui.cpp draw.cpp level.cpp geometry.cpp edit.cpp +zoomedit_CPPFLAGS = @GTK_CFLAGS@ zoomedit_LDADD = @GTK_LIBS@ all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: -.SUFFIXES: .c .o .obj +.SUFFIXES: .cpp .o .obj am--refresh: @: $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) @@ -249,7 +252,7 @@ clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) zoomedit$(EXEEXT): $(zoomedit_OBJECTS) $(zoomedit_DEPENDENCIES) @rm -f zoomedit$(EXEEXT) - $(zoomedit_LINK) $(zoomedit_OBJECTS) $(zoomedit_LDADD) $(LIBS) + $(CXXLINK) $(zoomedit_OBJECTS) $(zoomedit_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -265,117 +268,117 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-window.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zoomedit-zoomedit.Po@am__quote@ -.c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -zoomedit-zoomedit.o: zoomedit.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-zoomedit.o -MD -MP -MF $(DEPDIR)/zoomedit-zoomedit.Tpo -c -o zoomedit-zoomedit.o `test -f 'zoomedit.c' || echo '$(srcdir)/'`zoomedit.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-zoomedit.Tpo $(DEPDIR)/zoomedit-zoomedit.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='zoomedit.c' object='zoomedit-zoomedit.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-zoomedit.o `test -f 'zoomedit.c' || echo '$(srcdir)/'`zoomedit.c - -zoomedit-zoomedit.obj: zoomedit.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-zoomedit.obj -MD -MP -MF $(DEPDIR)/zoomedit-zoomedit.Tpo -c -o zoomedit-zoomedit.obj `if test -f 'zoomedit.c'; then $(CYGPATH_W) 'zoomedit.c'; else $(CYGPATH_W) '$(srcdir)/zoomedit.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-zoomedit.Tpo $(DEPDIR)/zoomedit-zoomedit.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='zoomedit.c' object='zoomedit-zoomedit.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-zoomedit.obj `if test -f 'zoomedit.c'; then $(CYGPATH_W) 'zoomedit.c'; else $(CYGPATH_W) '$(srcdir)/zoomedit.c'; fi` - -zoomedit-window.o: window.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-window.o -MD -MP -MF $(DEPDIR)/zoomedit-window.Tpo -c -o zoomedit-window.o `test -f 'window.c' || echo '$(srcdir)/'`window.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-window.Tpo $(DEPDIR)/zoomedit-window.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='window.c' object='zoomedit-window.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-window.o `test -f 'window.c' || echo '$(srcdir)/'`window.c - -zoomedit-window.obj: window.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-window.obj -MD -MP -MF $(DEPDIR)/zoomedit-window.Tpo -c -o zoomedit-window.obj `if test -f 'window.c'; then $(CYGPATH_W) 'window.c'; else $(CYGPATH_W) '$(srcdir)/window.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-window.Tpo $(DEPDIR)/zoomedit-window.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='window.c' object='zoomedit-window.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-window.obj `if test -f 'window.c'; then $(CYGPATH_W) 'window.c'; else $(CYGPATH_W) '$(srcdir)/window.c'; fi` - -zoomedit-ui.o: ui.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-ui.o -MD -MP -MF $(DEPDIR)/zoomedit-ui.Tpo -c -o zoomedit-ui.o `test -f 'ui.c' || echo '$(srcdir)/'`ui.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-ui.Tpo $(DEPDIR)/zoomedit-ui.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ui.c' object='zoomedit-ui.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-ui.o `test -f 'ui.c' || echo '$(srcdir)/'`ui.c - -zoomedit-ui.obj: ui.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-ui.obj -MD -MP -MF $(DEPDIR)/zoomedit-ui.Tpo -c -o zoomedit-ui.obj `if test -f 'ui.c'; then $(CYGPATH_W) 'ui.c'; else $(CYGPATH_W) '$(srcdir)/ui.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-ui.Tpo $(DEPDIR)/zoomedit-ui.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ui.c' object='zoomedit-ui.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-ui.obj `if test -f 'ui.c'; then $(CYGPATH_W) 'ui.c'; else $(CYGPATH_W) '$(srcdir)/ui.c'; fi` - -zoomedit-draw.o: draw.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-draw.o -MD -MP -MF $(DEPDIR)/zoomedit-draw.Tpo -c -o zoomedit-draw.o `test -f 'draw.c' || echo '$(srcdir)/'`draw.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-draw.Tpo $(DEPDIR)/zoomedit-draw.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='draw.c' object='zoomedit-draw.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-draw.o `test -f 'draw.c' || echo '$(srcdir)/'`draw.c - -zoomedit-draw.obj: draw.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-draw.obj -MD -MP -MF $(DEPDIR)/zoomedit-draw.Tpo -c -o zoomedit-draw.obj `if test -f 'draw.c'; then $(CYGPATH_W) 'draw.c'; else $(CYGPATH_W) '$(srcdir)/draw.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-draw.Tpo $(DEPDIR)/zoomedit-draw.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='draw.c' object='zoomedit-draw.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-draw.obj `if test -f 'draw.c'; then $(CYGPATH_W) 'draw.c'; else $(CYGPATH_W) '$(srcdir)/draw.c'; fi` - -zoomedit-level.o: level.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-level.o -MD -MP -MF $(DEPDIR)/zoomedit-level.Tpo -c -o zoomedit-level.o `test -f 'level.c' || echo '$(srcdir)/'`level.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-level.Tpo $(DEPDIR)/zoomedit-level.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='level.c' object='zoomedit-level.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-level.o `test -f 'level.c' || echo '$(srcdir)/'`level.c - -zoomedit-level.obj: level.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-level.obj -MD -MP -MF $(DEPDIR)/zoomedit-level.Tpo -c -o zoomedit-level.obj `if test -f 'level.c'; then $(CYGPATH_W) 'level.c'; else $(CYGPATH_W) '$(srcdir)/level.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-level.Tpo $(DEPDIR)/zoomedit-level.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='level.c' object='zoomedit-level.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-level.obj `if test -f 'level.c'; then $(CYGPATH_W) 'level.c'; else $(CYGPATH_W) '$(srcdir)/level.c'; fi` - -zoomedit-geometry.o: geometry.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-geometry.o -MD -MP -MF $(DEPDIR)/zoomedit-geometry.Tpo -c -o zoomedit-geometry.o `test -f 'geometry.c' || echo '$(srcdir)/'`geometry.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-geometry.Tpo $(DEPDIR)/zoomedit-geometry.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='geometry.c' object='zoomedit-geometry.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-geometry.o `test -f 'geometry.c' || echo '$(srcdir)/'`geometry.c - -zoomedit-geometry.obj: geometry.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-geometry.obj -MD -MP -MF $(DEPDIR)/zoomedit-geometry.Tpo -c -o zoomedit-geometry.obj `if test -f 'geometry.c'; then $(CYGPATH_W) 'geometry.c'; else $(CYGPATH_W) '$(srcdir)/geometry.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-geometry.Tpo $(DEPDIR)/zoomedit-geometry.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='geometry.c' object='zoomedit-geometry.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-geometry.obj `if test -f 'geometry.c'; then $(CYGPATH_W) 'geometry.c'; else $(CYGPATH_W) '$(srcdir)/geometry.c'; fi` - -zoomedit-edit.o: edit.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-edit.o -MD -MP -MF $(DEPDIR)/zoomedit-edit.Tpo -c -o zoomedit-edit.o `test -f 'edit.c' || echo '$(srcdir)/'`edit.c -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-edit.Tpo $(DEPDIR)/zoomedit-edit.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edit.c' object='zoomedit-edit.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-edit.o `test -f 'edit.c' || echo '$(srcdir)/'`edit.c - -zoomedit-edit.obj: edit.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -MT zoomedit-edit.obj -MD -MP -MF $(DEPDIR)/zoomedit-edit.Tpo -c -o zoomedit-edit.obj `if test -f 'edit.c'; then $(CYGPATH_W) 'edit.c'; else $(CYGPATH_W) '$(srcdir)/edit.c'; fi` -@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/zoomedit-edit.Tpo $(DEPDIR)/zoomedit-edit.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='edit.c' object='zoomedit-edit.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(zoomedit_CFLAGS) $(CFLAGS) -c -o zoomedit-edit.obj `if test -f 'edit.c'; then $(CYGPATH_W) 'edit.c'; else $(CYGPATH_W) '$(srcdir)/edit.c'; fi` +.cpp.o: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +zoomedit-zoomedit.o: zoomedit.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-zoomedit.o -MD -MP -MF $(DEPDIR)/zoomedit-zoomedit.Tpo -c -o zoomedit-zoomedit.o `test -f 'zoomedit.cpp' || echo '$(srcdir)/'`zoomedit.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-zoomedit.Tpo $(DEPDIR)/zoomedit-zoomedit.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='zoomedit.cpp' object='zoomedit-zoomedit.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-zoomedit.o `test -f 'zoomedit.cpp' || echo '$(srcdir)/'`zoomedit.cpp + +zoomedit-zoomedit.obj: zoomedit.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-zoomedit.obj -MD -MP -MF $(DEPDIR)/zoomedit-zoomedit.Tpo -c -o zoomedit-zoomedit.obj `if test -f 'zoomedit.cpp'; then $(CYGPATH_W) 'zoomedit.cpp'; else $(CYGPATH_W) '$(srcdir)/zoomedit.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-zoomedit.Tpo $(DEPDIR)/zoomedit-zoomedit.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='zoomedit.cpp' object='zoomedit-zoomedit.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-zoomedit.obj `if test -f 'zoomedit.cpp'; then $(CYGPATH_W) 'zoomedit.cpp'; else $(CYGPATH_W) '$(srcdir)/zoomedit.cpp'; fi` + +zoomedit-window.o: window.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-window.o -MD -MP -MF $(DEPDIR)/zoomedit-window.Tpo -c -o zoomedit-window.o `test -f 'window.cpp' || echo '$(srcdir)/'`window.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-window.Tpo $(DEPDIR)/zoomedit-window.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='window.cpp' object='zoomedit-window.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-window.o `test -f 'window.cpp' || echo '$(srcdir)/'`window.cpp + +zoomedit-window.obj: window.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-window.obj -MD -MP -MF $(DEPDIR)/zoomedit-window.Tpo -c -o zoomedit-window.obj `if test -f 'window.cpp'; then $(CYGPATH_W) 'window.cpp'; else $(CYGPATH_W) '$(srcdir)/window.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-window.Tpo $(DEPDIR)/zoomedit-window.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='window.cpp' object='zoomedit-window.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-window.obj `if test -f 'window.cpp'; then $(CYGPATH_W) 'window.cpp'; else $(CYGPATH_W) '$(srcdir)/window.cpp'; fi` + +zoomedit-ui.o: ui.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-ui.o -MD -MP -MF $(DEPDIR)/zoomedit-ui.Tpo -c -o zoomedit-ui.o `test -f 'ui.cpp' || echo '$(srcdir)/'`ui.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-ui.Tpo $(DEPDIR)/zoomedit-ui.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ui.cpp' object='zoomedit-ui.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-ui.o `test -f 'ui.cpp' || echo '$(srcdir)/'`ui.cpp + +zoomedit-ui.obj: ui.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-ui.obj -MD -MP -MF $(DEPDIR)/zoomedit-ui.Tpo -c -o zoomedit-ui.obj `if test -f 'ui.cpp'; then $(CYGPATH_W) 'ui.cpp'; else $(CYGPATH_W) '$(srcdir)/ui.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-ui.Tpo $(DEPDIR)/zoomedit-ui.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='ui.cpp' object='zoomedit-ui.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-ui.obj `if test -f 'ui.cpp'; then $(CYGPATH_W) 'ui.cpp'; else $(CYGPATH_W) '$(srcdir)/ui.cpp'; fi` + +zoomedit-draw.o: draw.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-draw.o -MD -MP -MF $(DEPDIR)/zoomedit-draw.Tpo -c -o zoomedit-draw.o `test -f 'draw.cpp' || echo '$(srcdir)/'`draw.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-draw.Tpo $(DEPDIR)/zoomedit-draw.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='draw.cpp' object='zoomedit-draw.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-draw.o `test -f 'draw.cpp' || echo '$(srcdir)/'`draw.cpp + +zoomedit-draw.obj: draw.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-draw.obj -MD -MP -MF $(DEPDIR)/zoomedit-draw.Tpo -c -o zoomedit-draw.obj `if test -f 'draw.cpp'; then $(CYGPATH_W) 'draw.cpp'; else $(CYGPATH_W) '$(srcdir)/draw.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-draw.Tpo $(DEPDIR)/zoomedit-draw.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='draw.cpp' object='zoomedit-draw.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-draw.obj `if test -f 'draw.cpp'; then $(CYGPATH_W) 'draw.cpp'; else $(CYGPATH_W) '$(srcdir)/draw.cpp'; fi` + +zoomedit-level.o: level.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-level.o -MD -MP -MF $(DEPDIR)/zoomedit-level.Tpo -c -o zoomedit-level.o `test -f 'level.cpp' || echo '$(srcdir)/'`level.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-level.Tpo $(DEPDIR)/zoomedit-level.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='level.cpp' object='zoomedit-level.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-level.o `test -f 'level.cpp' || echo '$(srcdir)/'`level.cpp + +zoomedit-level.obj: level.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-level.obj -MD -MP -MF $(DEPDIR)/zoomedit-level.Tpo -c -o zoomedit-level.obj `if test -f 'level.cpp'; then $(CYGPATH_W) 'level.cpp'; else $(CYGPATH_W) '$(srcdir)/level.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-level.Tpo $(DEPDIR)/zoomedit-level.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='level.cpp' object='zoomedit-level.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-level.obj `if test -f 'level.cpp'; then $(CYGPATH_W) 'level.cpp'; else $(CYGPATH_W) '$(srcdir)/level.cpp'; fi` + +zoomedit-geometry.o: geometry.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-geometry.o -MD -MP -MF $(DEPDIR)/zoomedit-geometry.Tpo -c -o zoomedit-geometry.o `test -f 'geometry.cpp' || echo '$(srcdir)/'`geometry.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-geometry.Tpo $(DEPDIR)/zoomedit-geometry.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='geometry.cpp' object='zoomedit-geometry.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-geometry.o `test -f 'geometry.cpp' || echo '$(srcdir)/'`geometry.cpp + +zoomedit-geometry.obj: geometry.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-geometry.obj -MD -MP -MF $(DEPDIR)/zoomedit-geometry.Tpo -c -o zoomedit-geometry.obj `if test -f 'geometry.cpp'; then $(CYGPATH_W) 'geometry.cpp'; else $(CYGPATH_W) '$(srcdir)/geometry.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-geometry.Tpo $(DEPDIR)/zoomedit-geometry.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='geometry.cpp' object='zoomedit-geometry.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-geometry.obj `if test -f 'geometry.cpp'; then $(CYGPATH_W) 'geometry.cpp'; else $(CYGPATH_W) '$(srcdir)/geometry.cpp'; fi` + +zoomedit-edit.o: edit.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-edit.o -MD -MP -MF $(DEPDIR)/zoomedit-edit.Tpo -c -o zoomedit-edit.o `test -f 'edit.cpp' || echo '$(srcdir)/'`edit.cpp +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-edit.Tpo $(DEPDIR)/zoomedit-edit.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='edit.cpp' object='zoomedit-edit.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-edit.o `test -f 'edit.cpp' || echo '$(srcdir)/'`edit.cpp + +zoomedit-edit.obj: edit.cpp +@am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT zoomedit-edit.obj -MD -MP -MF $(DEPDIR)/zoomedit-edit.Tpo -c -o zoomedit-edit.obj `if test -f 'edit.cpp'; then $(CYGPATH_W) 'edit.cpp'; else $(CYGPATH_W) '$(srcdir)/edit.cpp'; fi` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/zoomedit-edit.Tpo $(DEPDIR)/zoomedit-edit.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='edit.cpp' object='zoomedit-edit.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(zoomedit_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o zoomedit-edit.obj `if test -f 'edit.cpp'; then $(CYGPATH_W) 'edit.cpp'; else $(CYGPATH_W) '$(srcdir)/edit.cpp'; fi` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ diff --git a/config.h.in b/config.h.in index 5348680..81d3be2 100644 --- a/config.h.in +++ b/config.h.in @@ -14,9 +14,6 @@ and to 0 otherwise. */ #undef HAVE_REALLOC -/* Define to 1 if you have the header file. */ -#undef HAVE_STDDEF_H - /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H diff --git a/configure b/configure index 782d91d..53ed2f0 100755 --- a/configure +++ b/configure @@ -578,7 +578,7 @@ PACKAGE_VERSION='0.1' PACKAGE_STRING='zoomedit 0.1' PACKAGE_BUGREPORT='matthias@gamezock.de' -ac_unique_file="zoomedit.c" +ac_unique_file="zoomedit.cpp" # Factoring default headers for most tests. ac_includes_default="\ #include @@ -677,11 +677,11 @@ am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT -CC -CFLAGS +CXX +CXXFLAGS LDFLAGS CPPFLAGS -ac_ct_CC +ac_ct_CXX EXEEXT OBJEXT DEPDIR @@ -690,6 +690,12 @@ am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH +CXXDEPMODE +am__fastdepCXX_TRUE +am__fastdepCXX_FALSE +CC +CFLAGS +ac_ct_CC CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE @@ -705,11 +711,14 @@ ac_subst_files='' ac_precious_vars='build_alias host_alias target_alias -CC -CFLAGS +CXX +CXXFLAGS LDFLAGS LIBS CPPFLAGS +CCC +CC +CFLAGS CPP' @@ -1293,13 +1302,15 @@ Optional Features: --disable-gtktest do not try to compile and run a test GTK+ program Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags + CXX C++ compiler command + CXXFLAGS C++ compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory + CC C compiler command + CFLAGS C compiler flags CPP C preprocessor Use these variables to override the choices made by `configure' or to help @@ -2244,217 +2255,27 @@ fi # Checks for programs. -ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. -set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_CC"; then - ac_ct_CC=$CC - # Extract the first word of "gcc", so it can be a program name with args. -set dummy gcc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="gcc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - if test "x$ac_ct_CC" = x; then - CC="" +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC else - case $cross_compiling:$ac_tool_warned in -yes:) -{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&5 -echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools -whose name does not start with the host triplet. If you think this -configuration is useful to you, please write to autoconf@gnu.org." >&2;} -ac_tool_warned=yes ;; -esac - CC=$ac_ct_CC - fi -else - CC="$ac_cv_prog_CC" -fi - -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. -set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="${ac_tool_prefix}cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - - fi -fi -if test -z "$CC"; then - # Extract the first word of "cc", so it can be a program name with args. -set dummy cc; ac_word=$2 -{ echo "$as_me:$LINENO: checking for $ac_word" >&5 -echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_CC+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. -else - ac_prog_rejected=no -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then - ac_prog_rejected=yes - continue - fi - ac_cv_prog_CC="cc" - echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done -done -IFS=$as_save_IFS - -if test $ac_prog_rejected = yes; then - # We found a bogon in the path, so make sure we never use it. - set dummy $ac_cv_prog_CC - shift - if test $# != 0; then - # We chose a different compiler from the bogus one. - # However, it has the same basename, so the bogon will be chosen - # first if we set CC to just the basename; use the full file name. - shift - ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" - fi -fi -fi -fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } -else - { echo "$as_me:$LINENO: result: no" >&5 -echo "${ECHO_T}no" >&6; } -fi - - -fi -if test -z "$CC"; then - if test -n "$ac_tool_prefix"; then - for ac_prog in cl.exe + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test -n "$CC"; then - ac_cv_prog_CC="$CC" # Let the user override the test. + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -2463,7 +2284,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -2473,32 +2294,32 @@ IFS=$as_save_IFS fi fi -CC=$ac_cv_prog_CC -if test -n "$CC"; then - { echo "$as_me:$LINENO: result: $CC" >&5 -echo "${ECHO_T}$CC" >&6; } +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { echo "$as_me:$LINENO: result: $CXX" >&5 +echo "${ECHO_T}$CXX" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi - test -n "$CC" && break + test -n "$CXX" && break done fi -if test -z "$CC"; then - ac_ct_CC=$CC - for ac_prog in cl.exe +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - if test -n "$ac_ct_CC"; then - ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH @@ -2507,7 +2328,7 @@ do test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then - ac_cv_prog_ac_ct_CC="$ac_prog" + ac_cv_prog_ac_ct_CXX="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi @@ -2517,21 +2338,21 @@ IFS=$as_save_IFS fi fi -ac_ct_CC=$ac_cv_prog_ac_ct_CC -if test -n "$ac_ct_CC"; then - { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 -echo "${ECHO_T}$ac_ct_CC" >&6; } +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 +echo "${ECHO_T}$ac_ct_CXX" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi - test -n "$ac_ct_CC" && break + test -n "$ac_ct_CXX" && break done - if test "x$ac_ct_CC" = x; then - CC="" + if test "x$ac_ct_CXX" = x; then + CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) @@ -2543,21 +2364,14 @@ whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac - CC=$ac_ct_CC + CXX=$ac_ct_CXX fi fi + fi fi - - -test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } - # Provide some information about the compiler. -echo "$as_me:$LINENO: checking for C compiler version" >&5 +echo "$as_me:$LINENO: checking for C++ compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in @@ -2610,8 +2424,8 @@ ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: checking for C++ compiler default output file name" >&5 +echo $ECHO_N "checking for C++ compiler default output file name... $ECHO_C" >&6; } ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # # List of possible output files, starting from the most likely. @@ -2684,9 +2498,9 @@ if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +{ { echo "$as_me:$LINENO: error: C++ compiler cannot create executables See \`config.log' for more details." >&5 -echo "$as_me: error: C compiler cannot create executables +echo "$as_me: error: C++ compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi @@ -2695,8 +2509,8 @@ ac_exeext=$ac_cv_exeext # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: checking whether the C++ compiler works" >&5 +echo $ECHO_N "checking whether the C++ compiler works... $ECHO_C" >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then @@ -2715,10 +2529,10 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 if test "$cross_compiling" = maybe; then cross_compiling=yes else - { { echo "$as_me:$LINENO: error: cannot run C compiled programs. + { { echo "$as_me:$LINENO: error: cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run C compiled programs. +echo "$as_me: error: cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } @@ -2804,35 +2618,766 @@ case "(($ac_try" in *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; } +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; } +GXX=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cxx_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CXXFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +{ echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + +depcc="$CXX" am_compiler_list= + +{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } +if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - for ac_file in conftest.o conftest.obj conftest.*; do - test -f "$ac_file" || continue; - case $ac_file in - *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; - *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` - break;; - esac -done -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; } -fi + (exit $ac_status); } -rm -f conftest.$ac_cv_objext conftest.$ac_ext -fi -{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 -echo "${ECHO_T}$ac_cv_objext" >&6; } -OBJEXT=$ac_cv_objext -ac_objext=$OBJEXT { echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then @@ -3162,68 +3707,6 @@ ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -DEPDIR="${am__leading_dot}deps" - -ac_config_commands="$ac_config_commands depfiles" - - -am_make=${MAKE-make} -cat > confinc << 'END' -am__doit: - @echo done -.PHONY: am__doit -END -# If we don't find an include directive, just comment out the code. -{ echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 -echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; } -am__include="#" -am__quote= -_am_result=none -# First try GNU make style include. -echo "include confinc" > confmf -# We grep out `Entering directory' and `Leaving directory' -# messages which can occur if `w' ends up in MAKEFLAGS. -# In particular we don't look at `^make:' because GNU make might -# be invoked under some other name (usually "gmake"), in which -# case it prints its new name instead of `make'. -if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then - am__include=include - am__quote= - _am_result=GNU -fi -# Now try BSD make style include. -if test "$am__include" = "#"; then - echo '.include "confinc"' > confmf - if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then - am__include=.include - am__quote="\"" - _am_result=BSD - fi -fi - - -{ echo "$as_me:$LINENO: result: $_am_result" >&5 -echo "${ECHO_T}$_am_result" >&6; } -rm -f confinc confmf - -# Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then - enableval=$enable_dependency_tracking; -fi - -if test "x$enable_dependency_tracking" != xno; then - am_depcomp="$ac_aux_dir/depcomp" - AMDEPBACKSLASH='\' -fi - if test "x$enable_dependency_tracking" != xno; then - AMDEP_TRUE= - AMDEP_FALSE='#' -else - AMDEP_TRUE='#' - AMDEP_FALSE= -fi - - depcc="$CC" am_compiler_list= @@ -3459,7 +3942,6 @@ if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then fi -#AC_PROG_LIBTOOL # Checks for libraries. #AC_CHECK_LIB(m, [sqrt]) @@ -3780,6 +4262,13 @@ echo "$as_me: error: zoomedit needs GTK+ 2.8.0" >&2;} # Checks for header files. +#AC_HEADER_STDC +#AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) + +# Checks for typedefs, structures, and compiler characteristics. +#AC_HEADER_TIME + +# Checks for library functions. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4417,158 +4906,6 @@ done - - -for ac_header in stddef.h stdlib.h string.h -do -as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -else - # Is the header compilable? -{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 -echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -echo "${ECHO_T}$ac_header_compiler" >&6; } - -# Is the header present? -{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 -echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -echo "${ECHO_T}$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## ----------------------------------- ## -## Report this to matthias@gamezock.de ## -## ----------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ echo "$as_me:$LINENO: checking for $ac_header" >&5 -echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval echo '${'$as_ac_Header'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } - -fi -if test `eval echo '${'$as_ac_Header'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - -# Checks for typedefs, structures, and compiler characteristics. -#AC_HEADER_TIME - -# Checks for library functions. - for ac_header in stdlib.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -5153,6 +5490,13 @@ echo "$as_me: error: conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&5 @@ -5754,11 +6098,11 @@ am__untar!$am__untar$ac_delim MAINTAINER_MODE_TRUE!$MAINTAINER_MODE_TRUE$ac_delim MAINTAINER_MODE_FALSE!$MAINTAINER_MODE_FALSE$ac_delim MAINT!$MAINT$ac_delim -CC!$CC$ac_delim -CFLAGS!$CFLAGS$ac_delim +CXX!$CXX$ac_delim +CXXFLAGS!$CXXFLAGS$ac_delim LDFLAGS!$LDFLAGS$ac_delim CPPFLAGS!$CPPFLAGS$ac_delim -ac_ct_CC!$ac_ct_CC$ac_delim +ac_ct_CXX!$ac_ct_CXX$ac_delim EXEEXT!$EXEEXT$ac_delim OBJEXT!$OBJEXT$ac_delim DEPDIR!$DEPDIR$ac_delim @@ -5767,6 +6111,12 @@ am__quote!$am__quote$ac_delim AMDEP_TRUE!$AMDEP_TRUE$ac_delim AMDEP_FALSE!$AMDEP_FALSE$ac_delim AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim +CXXDEPMODE!$CXXDEPMODE$ac_delim +am__fastdepCXX_TRUE!$am__fastdepCXX_TRUE$ac_delim +am__fastdepCXX_FALSE!$am__fastdepCXX_FALSE$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim CCDEPMODE!$CCDEPMODE$ac_delim am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim @@ -5780,7 +6130,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 86; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 92; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/configure.in b/configure.in index 0d801f2..1fd6e99 100644 --- a/configure.in +++ b/configure.in @@ -3,24 +3,23 @@ AC_PREREQ(2.59) AC_INIT(zoomedit, 0.1, matthias@gamezock.de) -AC_CONFIG_SRCDIR([zoomedit.c]) +AC_CONFIG_SRCDIR([zoomedit.cpp]) AM_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE(zoomedit, 0.1) AM_MAINTAINER_MODE # Checks for programs. -AC_PROG_CC +AC_PROG_CXX AM_PROG_CC_C_O -#AC_PROG_LIBTOOL # Checks for libraries. #AC_CHECK_LIB(m, [sqrt]) AM_PATH_GTK_2_0(2.8.0,,AC_MSG_ERROR(zoomedit needs GTK+ 2.8.0)) # Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) +#AC_HEADER_STDC +#AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) # Checks for typedefs, structures, and compiler characteristics. #AC_HEADER_TIME diff --git a/draw.c b/draw.c deleted file mode 100644 index b293e66..0000000 --- a/draw.c +++ /dev/null @@ -1,306 +0,0 @@ -#include "draw.h" -#include "edit.h" -#include "level.h" -#include "geometry.h" -#include -#include -#include - - -static double scale = 100.0; -static double xTranslate = 0.0, yTranslate = 0.0; -static gboolean repaint = FALSE; - - -static void drawGrid(cairo_t *cr, const RECTANGLE *rect) { - double depth = log10(scale)-0.75; - double depth2 = floor(depth); - double step = pow(0.1, depth2); - double d; - int i; - gchar *string; - - - cairo_set_font_size(cr, 10.0/scale); - - for(i = 0; 0.4*(depth-depth2+i-1) < 0.5; i++) { - d = MIN(0.4*(depth-depth2+i), 0.5); - cairo_set_source_rgb(cr, d, d, d); - - for(d = rect->x - fmod(rect->x, step) - step; d <= rect->x+rect->width; d+=step) { - cairo_move_to(cr, d, rect->y); - cairo_line_to(cr, d, rect->y+rect->height); - - if(step > 0.005) { - if(step > 0.5) - string = g_strdup_printf("%i", (int)rint(d)); - else - string = g_strdup_printf("%.*f", -(int)floor(log10(step*1.1)), d+step/10); - - cairo_move_to(cr, d+1/scale, rect->y+11/scale); - cairo_show_text(cr, string); - - g_free(string); - } - } - - for(d = rect->y - fmod(rect->y, step) - step; d <= rect->y+rect->height; d+=step) { - cairo_move_to(cr, rect->x, d); - cairo_line_to(cr, rect->x+rect->width, d); - - if(step > 0.005) { - if(step > 0.5) - string = g_strdup_printf("%i", (int)rint(d)); - else - string = g_strdup_printf("%.*f", -(int)floor(log10(step*1.1)), d+step/10); - - cairo_move_to(cr, rect->x+3/scale, d+11/scale); - cairo_show_text(cr, string); - - g_free(string); - } - } - - cairo_stroke(cr); - - step *= 10; - } -} - -static void polygon2path(cairo_t *cr, const POLYGON *polygon, const RECTANGLE *rect, gboolean close) { - int i; - POLYGON polygon2 = {0, NULL}; - - // no vertices - if(polygon->nVertices == 0) return; - - if(rect) - simplifyPolygon(polygon, rect, &polygon2); - else - polygon2 = *polygon; - - if(polygon2.nVertices == 0) return; - - cairo_new_sub_path(cr); - - for(i = 0; i < polygon2.nVertices; i++) { - cairo_line_to(cr, polygon2.vertices[i].x, polygon2.vertices[i].y); - } - - if(close) - cairo_close_path(cr); - - if(rect && polygon2.vertices) - free(polygon2.vertices); -} - -gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) { - cairo_t *cr; - VERTEX v1 = {-1, -1}, v2 = {widget->allocation.width+1, widget->allocation.height+1}; - RECTANGLE rect; - gboolean vertexOk; - static GdkPixmap *pixmap = NULL; - static double lastImageWidth = 0.0, lastImageHeight = 0.0; - static gint lastWidth = 0.0, lastHeight = 0.0; - static int lastEditMode = 0; - int i; - - - if(getLevel() == NULL) return FALSE; - - viewToImage(&v1); - viewToImage(&v2); - - rect.x = v1.x; - rect.y = v1.y; - rect.width = v2.x-v1.x; - rect.height = v2.y-v1.y; - - if(pixmap == NULL || fabs(lastImageWidth - getImageWidth()) >= 0.000001 || fabs(lastImageHeight - getImageHeight()) >= 0.000001 || - lastWidth != widget->allocation.width || lastHeight != widget->allocation.height || lastEditMode != getEditMode() || repaint) - { - if(pixmap != NULL) - g_object_unref(G_OBJECT(pixmap)); - - pixmap = gdk_pixmap_new(widget->window, widget->allocation.width, widget->allocation.height, -1); - - lastImageWidth = getImageWidth(); - lastImageHeight = getImageHeight(); - lastWidth = widget->allocation.width; - lastHeight = widget->allocation.height; - lastEditMode = getEditMode(); - repaint = FALSE; - - - cr = gdk_cairo_create(GDK_DRAWABLE(pixmap)); - - cairo_translate(cr, getImageWidth()/2-xTranslate, getImageHeight()/2-yTranslate); - cairo_scale(cr, scale, scale); - - cairo_set_line_width(cr, 1.0/scale); - cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND); - - cairo_set_source_rgb(cr, 0, 0, 0); - cairo_paint(cr); - - drawGrid(cr, &rect); - - for(i = 0; i < getLevel()->nRooms; i++) { - if(&getLevel()->rooms[i] != getActiveRoom()) { - polygon2path(cr, &getLevel()->rooms[i].polygon, &rect, TRUE); - } - } - - cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.3); - cairo_fill_preserve(cr); - - cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.7); - cairo_stroke(cr); - - if(getEditMode() == EDIT_MODE_SELECTED) { - polygon2path(cr, &getActiveRoom()->polygon, &rect, TRUE); - - cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.2); - cairo_fill_preserve(cr); - - cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.9); - cairo_set_line_width(cr, 2.0/scale); - cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND); - cairo_stroke(cr); - } - - cairo_destroy (cr); - } - - gdk_draw_drawable(GDK_DRAWABLE(widget->window), widget->style->fg_gc[GTK_WIDGET_STATE(widget)], GDK_DRAWABLE(pixmap), 0, 0, 0, 0, -1, -1); - - cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); - - cairo_translate(cr, getImageWidth()/2-xTranslate, getImageHeight()/2-yTranslate); - cairo_scale(cr, scale, scale); - - cairo_set_line_width(cr, 2.0/scale); - cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER); - - if(getHoveredRoom() != NULL && getHoveredRoom() != getActiveRoom() && - (getEditMode() == EDIT_MODE_VIEW || getEditMode() == EDIT_MODE_SELECTED)) - { - polygon2path(cr, &getHoveredRoom()->polygon, &rect, TRUE); - - cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.7); - cairo_stroke(cr); - } - else if(getEditMode() == EDIT_MODE_ADD) { - polygon2path(cr, &getActiveRoom()->polygon, NULL, FALSE); - - if(isPolygonOk(&getActiveRoom()->polygon)) - cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.2); - else - cairo_set_source_rgba(cr, 1.0, 0.3, 0.3, 0.2); - cairo_fill_preserve(cr); - - - if(getActiveRoom()->polygon.nVertices && getHoveredVertex()) { - vertexOk = isVertexOk(getHoveredVertex()); - - if(vertexOk) - cairo_line_to(cr, getHoveredVertex()->x, getHoveredVertex()->y); - } - - cairo_set_line_width(cr, 2.0/scale); - cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND); - cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); - cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.7); - cairo_stroke(cr); - - if(getActiveRoom()->polygon.nVertices && getHoveredVertex() && !vertexOk) { - cairo_set_source_rgba(cr, 1.0, 0.3, 0.3, 0.7); - - i = getActiveRoom()->polygon.nVertices - 1; - cairo_move_to(cr, getActiveRoom()->polygon.vertices[i].x, getActiveRoom()->polygon.vertices[i].y); - cairo_line_to(cr, getHoveredVertex()->x, getHoveredVertex()->y); - - cairo_stroke(cr); - } - } - - cairo_destroy (cr); - - return FALSE; -} - - -double getScale() { - return scale; -} - -void setScale(double s) { - scale = MAX(0.005, MIN(s, 10000)); - repaint = TRUE; -} - -void imageToView(VERTEX *v) { - v->x = v->x*scale+getImageWidth()/2-xTranslate; - v->y = v->y*scale+getImageHeight()/2-yTranslate; -} - -void viewToImage(VERTEX *v) { - v->x = (v->x-getImageWidth()/2+xTranslate)/scale; - v->y = (v->y-getImageHeight()/2+yTranslate)/scale; -} - -double getImageWidth() { - const LEVEL *level = getLevel(); - double min = 0.0, max = 0.0; - int i, j; - - if(level) { - for(i = 0; i < level->nRooms; i++) { - for(j = 0; j < level->rooms[i].polygon.nVertices; j++) { - min = MIN(min, level->rooms[i].polygon.vertices[j].x); - max = MAX(max, level->rooms[i].polygon.vertices[j].x); - } - } - } - - return (max-min+10)*scale; -} - -double getImageHeight() { - const LEVEL *level = getLevel(); - double min = 0.0, max = 0.0; - int i, j; - - if(level) { - for(i = 0; i < level->nRooms; i++) { - for(j = 0; j < level->rooms[i].polygon.nVertices; j++) { - min = MIN(min, level->rooms[i].polygon.vertices[j].y); - max = MAX(max, level->rooms[i].polygon.vertices[j].y); - } - } - } - - return (max-min+10)*scale; -} - -double getXTranslate() { - return xTranslate; -} - -void setXTranslate(double x) { - xTranslate = x; - repaint = TRUE; -} - -double getYTranslate() { - return yTranslate; -} - -void setYTranslate(double y) { - yTranslate = y; - repaint = TRUE; -} - -void redraw() { - repaint = TRUE; -} diff --git a/draw.cpp b/draw.cpp new file mode 100644 index 0000000..3a09628 --- /dev/null +++ b/draw.cpp @@ -0,0 +1,307 @@ +#include "draw.h" +#include "edit.h" +#include "level.h" +#include "geometry.h" +#include +#include +#include +#include + + +static double scale = 100.0; +static double xTranslate = 0.0, yTranslate = 0.0; +static gboolean repaint = FALSE; + + +static void drawGrid(cairo_t *cr, const RECTANGLE *rect) { + double depth = log10(scale)-0.75; + double depth2 = floor(depth); + double step = pow(0.1, depth2); + double d; + int i; + gchar *string; + + + cairo_set_font_size(cr, 10.0/scale); + + for(i = 0; 0.4*(depth-depth2+i-1) < 0.5; i++) { + d = MIN(0.4*(depth-depth2+i), 0.5); + cairo_set_source_rgb(cr, d, d, d); + + for(d = rect->x - fmod(rect->x, step) - step; d <= rect->x+rect->width; d+=step) { + cairo_move_to(cr, d, rect->y); + cairo_line_to(cr, d, rect->y+rect->height); + + if(step > 0.005) { + if(step > 0.5) + string = g_strdup_printf("%i", (int)rint(d)); + else + string = g_strdup_printf("%.*f", -(int)floor(log10(step*1.1)), d+step/10); + + cairo_move_to(cr, d+1/scale, rect->y+11/scale); + cairo_show_text(cr, string); + + g_free(string); + } + } + + for(d = rect->y - fmod(rect->y, step) - step; d <= rect->y+rect->height; d+=step) { + cairo_move_to(cr, rect->x, d); + cairo_line_to(cr, rect->x+rect->width, d); + + if(step > 0.005) { + if(step > 0.5) + string = g_strdup_printf("%i", (int)rint(d)); + else + string = g_strdup_printf("%.*f", -(int)floor(log10(step*1.1)), d+step/10); + + cairo_move_to(cr, rect->x+3/scale, d+11/scale); + cairo_show_text(cr, string); + + g_free(string); + } + } + + cairo_stroke(cr); + + step *= 10; + } +} + +static void polygon2path(cairo_t *cr, const POLYGON *polygon, const RECTANGLE *rect, gboolean close) { + int i; + POLYGON polygon2 = {0, NULL}; + + // no vertices + if(polygon->nVertices == 0) return; + + if(rect) + simplifyPolygon(polygon, rect, &polygon2); + else + polygon2 = *polygon; + + if(polygon2.nVertices == 0) return; + + cairo_new_sub_path(cr); + + for(i = 0; i < polygon2.nVertices; i++) { + cairo_line_to(cr, polygon2.vertices[i].x, polygon2.vertices[i].y); + } + + if(close) + cairo_close_path(cr); + + if(rect && polygon2.vertices) + free(polygon2.vertices); +} + +gboolean drawTopView(GtkWidget *widget, GdkEventExpose *event, gpointer data) { + cairo_t *cr; + VERTEX v1 = {-1, -1}, v2 = {widget->allocation.width+1, widget->allocation.height+1}; + RECTANGLE rect; + gboolean vertexOk; + static GdkPixmap *pixmap = NULL; + static double lastImageWidth = 0.0, lastImageHeight = 0.0; + static gint lastWidth = 0.0, lastHeight = 0.0; + static int lastEditMode = 0; + int i; + + + if(getLevel() == NULL) return FALSE; + + viewToImage(&v1); + viewToImage(&v2); + + rect.x = v1.x; + rect.y = v1.y; + rect.width = v2.x-v1.x; + rect.height = v2.y-v1.y; + + if(pixmap == NULL || fabs(lastImageWidth - getImageWidth()) >= 0.000001 || fabs(lastImageHeight - getImageHeight()) >= 0.000001 || + lastWidth != widget->allocation.width || lastHeight != widget->allocation.height || lastEditMode != getEditMode() || repaint) + { + if(pixmap != NULL) + g_object_unref(G_OBJECT(pixmap)); + + pixmap = gdk_pixmap_new(widget->window, widget->allocation.width, widget->allocation.height, -1); + + lastImageWidth = getImageWidth(); + lastImageHeight = getImageHeight(); + lastWidth = widget->allocation.width; + lastHeight = widget->allocation.height; + lastEditMode = getEditMode(); + repaint = FALSE; + + + cr = gdk_cairo_create(GDK_DRAWABLE(pixmap)); + + cairo_translate(cr, getImageWidth()/2-xTranslate, getImageHeight()/2-yTranslate); + cairo_scale(cr, scale, scale); + + cairo_set_line_width(cr, 1.0/scale); + cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND); + + cairo_set_source_rgb(cr, 0, 0, 0); + cairo_paint(cr); + + drawGrid(cr, &rect); + + for(i = 0; i < getLevel()->nRooms; i++) { + if(&getLevel()->rooms[i] != getActiveRoom()) { + polygon2path(cr, &getLevel()->rooms[i].polygon, &rect, TRUE); + } + } + + cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.3); + cairo_fill_preserve(cr); + + cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.7); + cairo_stroke(cr); + + if(getEditMode() == EDIT_MODE_SELECTED) { + polygon2path(cr, &getActiveRoom()->polygon, &rect, TRUE); + + cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.2); + cairo_fill_preserve(cr); + + cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.9); + cairo_set_line_width(cr, 2.0/scale); + cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND); + cairo_stroke(cr); + } + + cairo_destroy (cr); + } + + gdk_draw_drawable(GDK_DRAWABLE(widget->window), widget->style->fg_gc[GTK_WIDGET_STATE(widget)], GDK_DRAWABLE(pixmap), 0, 0, 0, 0, -1, -1); + + cr = gdk_cairo_create(GDK_DRAWABLE(widget->window)); + + cairo_translate(cr, getImageWidth()/2-xTranslate, getImageHeight()/2-yTranslate); + cairo_scale(cr, scale, scale); + + cairo_set_line_width(cr, 2.0/scale); + cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER); + + if(getHoveredRoom() != NULL && getHoveredRoom() != getActiveRoom() && + (getEditMode() == EDIT_MODE_VIEW || getEditMode() == EDIT_MODE_SELECTED)) + { + polygon2path(cr, &getHoveredRoom()->polygon, &rect, TRUE); + + cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.7); + cairo_stroke(cr); + } + else if(getEditMode() == EDIT_MODE_ADD) { + polygon2path(cr, &getActiveRoom()->polygon, NULL, FALSE); + + if(isPolygonOk(&getActiveRoom()->polygon)) + cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.2); + else + cairo_set_source_rgba(cr, 1.0, 0.3, 0.3, 0.2); + cairo_fill_preserve(cr); + + + if(getActiveRoom()->polygon.nVertices && getHoveredVertex()) { + vertexOk = isVertexOk(getHoveredVertex()); + + if(vertexOk) + cairo_line_to(cr, getHoveredVertex()->x, getHoveredVertex()->y); + } + + cairo_set_line_width(cr, 2.0/scale); + cairo_set_line_join(cr, CAIRO_LINE_JOIN_ROUND); + cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); + cairo_set_source_rgba(cr, 0.0, 0.7, 1.0, 0.7); + cairo_stroke(cr); + + if(getActiveRoom()->polygon.nVertices && getHoveredVertex() && !vertexOk) { + cairo_set_source_rgba(cr, 1.0, 0.3, 0.3, 0.7); + + i = getActiveRoom()->polygon.nVertices - 1; + cairo_move_to(cr, getActiveRoom()->polygon.vertices[i].x, getActiveRoom()->polygon.vertices[i].y); + cairo_line_to(cr, getHoveredVertex()->x, getHoveredVertex()->y); + + cairo_stroke(cr); + } + } + + cairo_destroy (cr); + + return FALSE; +} + + +double getScale() { + return scale; +} + +void setScale(double s) { + scale = MAX(0.005, MIN(s, 10000)); + repaint = TRUE; +} + +void imageToView(VERTEX *v) { + v->x = v->x*scale+getImageWidth()/2-xTranslate; + v->y = v->y*scale+getImageHeight()/2-yTranslate; +} + +void viewToImage(VERTEX *v) { + v->x = (v->x-getImageWidth()/2+xTranslate)/scale; + v->y = (v->y-getImageHeight()/2+yTranslate)/scale; +} + +double getImageWidth() { + const LEVEL *level = getLevel(); + double min = 0.0, max = 0.0; + int i, j; + + if(level) { + for(i = 0; i < level->nRooms; i++) { + for(j = 0; j < level->rooms[i].polygon.nVertices; j++) { + min = MIN(min, level->rooms[i].polygon.vertices[j].x); + max = MAX(max, level->rooms[i].polygon.vertices[j].x); + } + } + } + + return (max-min+10)*scale; +} + +double getImageHeight() { + const LEVEL *level = getLevel(); + double min = 0.0, max = 0.0; + int i, j; + + if(level) { + for(i = 0; i < level->nRooms; i++) { + for(j = 0; j < level->rooms[i].polygon.nVertices; j++) { + min = MIN(min, level->rooms[i].polygon.vertices[j].y); + max = MAX(max, level->rooms[i].polygon.vertices[j].y); + } + } + } + + return (max-min+10)*scale; +} + +double getXTranslate() { + return xTranslate; +} + +void setXTranslate(double x) { + xTranslate = x; + repaint = TRUE; +} + +double getYTranslate() { + return yTranslate; +} + +void setYTranslate(double y) { + yTranslate = y; + repaint = TRUE; +} + +void redraw() { + repaint = TRUE; +} diff --git a/edit.c b/edit.c deleted file mode 100644 index 0fc01aa..0000000 --- a/edit.c +++ /dev/null @@ -1,172 +0,0 @@ -#include "edit.h" -#include "level.h" -#include "geometry.h" -#include - - -static int editMode = EDIT_MODE_VIEW; - -static ROOM *activeRoom = NULL; -static ROOM *hoveredRoom = NULL; - -static VERTEX hoveredVertex; -static int hasHoveredVertex = 0; - -int getEditMode() { - return editMode; -} - -ROOM *getActiveRoom() { - return activeRoom; -} - -void setActiveRoom(ROOM *room) { - activeRoom = room; - - if(room == NULL) { - editMode = EDIT_MODE_VIEW; - } - else if(editMode == EDIT_MODE_VIEW) { - editMode = EDIT_MODE_SELECTED; - } -} - -VERTEX *getHoveredVertex() { - if(hasHoveredVertex) return &hoveredVertex; - else return NULL; -} - -void setHoveredVertex(VERTEX *v) { - int i; - LEVEL *l; - - if(v) { - hasHoveredVertex = 1; - hoveredVertex = *v; - - l = getLevel(); - hoveredRoom = NULL; - - for(i = 0; i < l->nRooms; i++) { - if(vertexInPolygon(v, &l->rooms[i].polygon)) { - hoveredRoom = &l->rooms[i]; - break; - } - } - } - else { - hasHoveredVertex = 0; - hoveredRoom = NULL; - } -} - -void startAddMode() { - ROOM room = {{0, NULL}, calloc(1, sizeof(unsigned char))}; - - activeRoom = calloc(1, sizeof(ROOM)); - activeRoom->polygon.nVertices = 0; - activeRoom->polygon.vertices = NULL; - activeRoom->name = calloc(1, sizeof(unsigned char)); - - editMode = EDIT_MODE_ADD; -} - -void endAddMode() { - editMode = activeRoom ? EDIT_MODE_SELECTED : EDIT_MODE_VIEW; -} - -ROOM *getHoveredRoom() { - return hoveredRoom; -} - -static isLineOk(LINE *l) { - LEVEL *lvl = getLevel(); - LINE l2; - int i; - - - if(activeRoom) { - for(i = 0; i+2 < activeRoom->polygon.nVertices; i++) { - l2.v1 = activeRoom->polygon.vertices[i]; - l2.v2 = activeRoom->polygon.vertices[i+1]; - - if(lineIntersection(l, &l2, NULL) == INTERSECTION_SEGMENT_SEGMENT) return 0; - } - - if(activeRoom->polygon.nVertices > 1) { - l2.v1 = activeRoom->polygon.vertices[activeRoom->polygon.nVertices-2]; - l2.v2 = activeRoom->polygon.vertices[activeRoom->polygon.nVertices-1]; - if(vertexOnLine(&l->v2, &l2)) return 0; - } - } - - for(i = 0; i < lvl->nRooms; i++) { - if(linePolygonIntersection(l, &lvl->rooms[i].polygon)) - return 0; - } - - return 1; -} - -int isVertexOk(VERTEX *v) { - LEVEL *lvl = getLevel(); - LINE l; - int i; - - for(i = 0; i < lvl->nRooms; i++) { - if(vertexInPolygon(v, &lvl->rooms[i].polygon)) return 0; - } - - if(!(getActiveRoom() && getActiveRoom()->polygon.nVertices)) - return 1; - - l.v1 = getActiveRoom()->polygon.vertices[getActiveRoom()->polygon.nVertices-1]; - l.v2 = *v; - - return isLineOk(&l); -} - - - -int isPolygonOk(POLYGON *polygon) { - LEVEL *lvl = getLevel(); - LINE l, l2; - int i, j; - - if(!polygon->nVertices) return 0; - - for(i = 0; i < lvl->nRooms; i++) { - if(!lvl->rooms[i].polygon.nVertices) continue; - - if(vertexInPolygon(&polygon->vertices[0], &lvl->rooms[i].polygon)) - return 0; - - if(vertexInPolygon(&lvl->rooms[i].polygon.vertices[0], polygon)) - return 0; - } - - if(polygon->nVertices == 1) - return 1; - - for(i = 0; i < polygon->nVertices; i++) { - l.v1 = polygon->vertices[i]; - l.v2 = polygon->vertices[(i+1)%polygon->nVertices]; - - for(j = 0; j < lvl->nRooms; j++) { - if(linePolygonIntersection(&l, &lvl->rooms[j].polygon)) - return 0; - } - - for(j = i+2; j < polygon->nVertices; j++) { - if(i == 0 && j == polygon->nVertices-1) continue; - - l2.v1 = polygon->vertices[j]; - l2.v2 = polygon->vertices[(j+1)%polygon->nVertices]; - - if(lineIntersection(&l, &l2, NULL) == INTERSECTION_SEGMENT_SEGMENT) - return 0; - } - } - - return 1; -} diff --git a/edit.cpp b/edit.cpp new file mode 100644 index 0000000..c54f308 --- /dev/null +++ b/edit.cpp @@ -0,0 +1,170 @@ +#include "edit.h" +#include "level.h" +#include "geometry.h" +#include + + +static int editMode = EDIT_MODE_VIEW; + +static ROOM *activeRoom = NULL; +static ROOM *hoveredRoom = NULL; + +static VERTEX hoveredVertex; +static int hasHoveredVertex = 0; + +int getEditMode() { + return editMode; +} + +ROOM *getActiveRoom() { + return activeRoom; +} + +void setActiveRoom(ROOM *room) { + activeRoom = room; + + if(room == NULL) { + editMode = EDIT_MODE_VIEW; + } + else if(editMode == EDIT_MODE_VIEW) { + editMode = EDIT_MODE_SELECTED; + } +} + +VERTEX *getHoveredVertex() { + if(hasHoveredVertex) return &hoveredVertex; + else return NULL; +} + +void setHoveredVertex(VERTEX *v) { + int i; + LEVEL *l; + + if(v) { + hasHoveredVertex = 1; + hoveredVertex = *v; + + l = getLevel(); + hoveredRoom = NULL; + + for(i = 0; i < l->nRooms; i++) { + if(vertexInPolygon(v, &l->rooms[i].polygon)) { + hoveredRoom = &l->rooms[i]; + break; + } + } + } + else { + hasHoveredVertex = 0; + hoveredRoom = NULL; + } +} + +void startAddMode() { + activeRoom = (ROOM*)calloc(1, sizeof(ROOM)); + activeRoom->polygon.nVertices = 0; + activeRoom->polygon.vertices = NULL; + activeRoom->name = (char*)calloc(1, sizeof(unsigned char)); + + editMode = EDIT_MODE_ADD; +} + +void endAddMode() { + editMode = activeRoom ? EDIT_MODE_SELECTED : EDIT_MODE_VIEW; +} + +ROOM *getHoveredRoom() { + return hoveredRoom; +} + +static int isLineOk(LINE *l) { + LEVEL *lvl = getLevel(); + LINE l2; + int i; + + + if(activeRoom) { + for(i = 0; i+2 < activeRoom->polygon.nVertices; i++) { + l2.v1 = activeRoom->polygon.vertices[i]; + l2.v2 = activeRoom->polygon.vertices[i+1]; + + if(lineIntersection(l, &l2, NULL) == INTERSECTION_SEGMENT_SEGMENT) return 0; + } + + if(activeRoom->polygon.nVertices > 1) { + l2.v1 = activeRoom->polygon.vertices[activeRoom->polygon.nVertices-2]; + l2.v2 = activeRoom->polygon.vertices[activeRoom->polygon.nVertices-1]; + if(vertexOnLine(&l->v2, &l2)) return 0; + } + } + + for(i = 0; i < lvl->nRooms; i++) { + if(linePolygonIntersection(l, &lvl->rooms[i].polygon)) + return 0; + } + + return 1; +} + +int isVertexOk(VERTEX *v) { + LEVEL *lvl = getLevel(); + LINE l; + int i; + + for(i = 0; i < lvl->nRooms; i++) { + if(vertexInPolygon(v, &lvl->rooms[i].polygon)) return 0; + } + + if(!(getActiveRoom() && getActiveRoom()->polygon.nVertices)) + return 1; + + l.v1 = getActiveRoom()->polygon.vertices[getActiveRoom()->polygon.nVertices-1]; + l.v2 = *v; + + return isLineOk(&l); +} + + + +int isPolygonOk(POLYGON *polygon) { + LEVEL *lvl = getLevel(); + LINE l, l2; + int i, j; + + if(!polygon->nVertices) return 0; + + for(i = 0; i < lvl->nRooms; i++) { + if(!lvl->rooms[i].polygon.nVertices) continue; + + if(vertexInPolygon(&polygon->vertices[0], &lvl->rooms[i].polygon)) + return 0; + + if(vertexInPolygon(&lvl->rooms[i].polygon.vertices[0], polygon)) + return 0; + } + + if(polygon->nVertices == 1) + return 1; + + for(i = 0; i < polygon->nVertices; i++) { + l.v1 = polygon->vertices[i]; + l.v2 = polygon->vertices[(i+1)%polygon->nVertices]; + + for(j = 0; j < lvl->nRooms; j++) { + if(linePolygonIntersection(&l, &lvl->rooms[j].polygon)) + return 0; + } + + for(j = i+2; j < polygon->nVertices; j++) { + if(i == 0 && j == polygon->nVertices-1) continue; + + l2.v1 = polygon->vertices[j]; + l2.v2 = polygon->vertices[(j+1)%polygon->nVertices]; + + if(lineIntersection(&l, &l2, NULL) == INTERSECTION_SEGMENT_SEGMENT) + return 0; + } + } + + return 1; +} diff --git a/edit.h b/edit.h index 663ba45..fd12454 100644 --- a/edit.h +++ b/edit.h @@ -13,6 +13,9 @@ int getEditMode(); ROOM *getActiveRoom(); void setActiveRoom(ROOM *room); +void startAddMode(); +void endAddMode(); + ROOM *getHoveredRoom(); VERTEX *getHoveredVertex(); diff --git a/geometry.c b/geometry.c deleted file mode 100644 index d54348f..0000000 --- a/geometry.c +++ /dev/null @@ -1,368 +0,0 @@ -#include "geometry.h" -#include -#include -#include - - -void addVertex(VERTEX_LIST *list, const VERTEX *v) { - list->nVertices++; - list->vertices = realloc(list->vertices, list->nVertices*sizeof(VERTEX)); - list->vertices[list->nVertices-1] = *v; -} - -void insertVertex(VERTEX_LIST *list, const VERTEX *v, unsigned int n) { - int i; - - if(n > list->nVertices) - n = list->nVertices; - - list->nVertices++; - list->vertices = realloc(list->vertices, list->nVertices*sizeof(VERTEX)); - - for(i = list->nVertices-1; i > n; i--) - list->vertices[i] = list->vertices[i-1]; - - list->vertices[n] = *v; -} - -void deleteVertex(VERTEX_LIST *list, unsigned int n) { - int i; - - list->nVertices--; - - for(i = n; i < list->nVertices; i++) - list->vertices[i] = list->vertices[i+1]; - - list->vertices = realloc(list->vertices, list->nVertices*sizeof(VERTEX)); -} - -double vertexDistanceSquare(const VERTEX *v1, const VERTEX *v2) { - return (v1->x-v2->x)*(v1->x-v2->x) + (v1->y-v2->y)*(v1->y-v2->y); -} - -double vertexDistance(const VERTEX *v1, const VERTEX *v2) { - return sqrt(vertexDistanceSquare(v1, v2)); -} - -int vertexOnLine(const VERTEX *v, const LINE *l) { - if(l->v1.x == l->v2.x && l->v1.y == l->v2.y) { - if(l->v1.x == v->x && l->v1.y == v->y) return 1; - else return 0; - } - - if(l->v1.x == l->v2.x) { - if(l->v1.x != v->x) return 0; - else if(v->y >= MIN(l->v1.y, l->v2.y) && v->y <= MAX(l->v1.y, l->v2.y)) return 1; - else return 1; - } - - if(l->v1.y == l->v2.y) { - if(l->v1.y != v->y) return 0; - else if(v->x >= MIN(l->v1.x, l->v2.x) && v->x <= MAX(l->v1.x, l->v2.x)) return 1; - else return 1; - } - if((v->x-l->v1.x)/(l->v2.x-l->v1.x) - (v->y-l->v1.y)/(l->v2.y-l->v1.y) == 0) return 1; - else return 0; -} - -int vertexInRect(const VERTEX *v, const RECTANGLE *rect) { - int ret = EDGE_NONE; - - if(v->x < rect->x) ret |= EDGE_LEFT; - else if(v->x >= rect->x+rect->width) ret |= EDGE_RIGHT; - - if(v->y < rect->y) ret |= EDGE_TOP; - else if(v->y >= rect->y+rect->height) ret |= EDGE_BOTTOM; - - return ret; -} - -static int quadrant(VERTEX *v) { - if(v->x > 0 && v->y >= 0) return 1; - if(v->x >= 0 && v->y < 0) return 2; - if(v->x < 0 && v->y <= 0) return 3; - if(v->x <= 0 && v->y > 0) return 4; - - return 0; -} - -gboolean vertexInPolygon(const VERTEX *v, const POLYGON *p) { - int d = 0, i, li; - int q, ql, q2; - LINE d1 = {{-1, -1}, {1, 1}}; - LINE d2 = {{-1, 1}, {1, -1}}; - LINE l; - VERTEX v2; - - - if(p->nVertices == 0) return FALSE; - - v2.x = p->vertices[p->nVertices-1].x - v->x; - v2.y = p->vertices[p->nVertices-1].y - v->y; - q = quadrant(&v2); - - if(q == 0) return TRUE; - - for(i = 0; i < p->nVertices; i++) { - ql = q; - - v2.x = p->vertices[i].x - v->x; - v2.y = p->vertices[i].y - v->y; - q = quadrant(&v2); - - if(q == 0) return TRUE; - - switch(q-ql) { - case 0: - break; - case 1: - case -3: - d++; - break; - case 3: - case -1: - d--; - break; - default: - l.v1.x = p->vertices[(i>0)?i-1:p->nVertices-1].x - v->x; - l.v1.y = p->vertices[(i>0)?i-1:p->nVertices-1].y - v->y; - - l.v2 = v2; - - if(q == 1 || q == 3) { - if(!(lineIntersection(&l, &d2, &v2) & INTERSECTION_LINE)) return FALSE; - - q2 = quadrant(&v2); - if(q2 == 0) return TRUE; - - if((q == 1 && q2 == 2) || (q == 3 && q2 == 4)) d -= 2; - else d += 2; - } - else { - if(!(lineIntersection(&l, &d1, &v2) & INTERSECTION_LINE)) return FALSE; - - q2 = quadrant(&v2); - if(q2 == 0) return TRUE; - - if((q == 2 && q2 == 3) || (q == 4 && q2 == 1)) d -= 2; - else d += 2; - } - } - } - - return (d == 0) ? FALSE : TRUE; -} - -double polygonPerimeter(const POLYGON *p) { - int i; - double d = 0.0; - - for(i = 0; i < p->nVertices; i++) - d += vertexDistance(&p->vertices[i], &p->vertices[(i+1)%p->nVertices]); - - return d; -} - -double polygonArea(const POLYGON *p) { - int i; - double d = 0.0; - - for(i = 0; i < p->nVertices; i++) - d += (p->vertices[(i+1)%p->nVertices].x+p->vertices[i].x)*(p->vertices[(i+1)%p->nVertices].y-p->vertices[i].y); - - return fabs(d/2); -} - -int lineIntersection(const LINE *la, const LINE *lb, VERTEX *v) { - double xa1 = la->v1.x, ya1 = la->v1.y; - double xa2 = la->v2.x, ya2 = la->v2.y; - double xb1 = lb->v1.x, yb1 = lb->v1.y; - double xb2 = lb->v2.x, yb2 = lb->v2.y; - double temp; - int switched = 0; - VERTEX v2; - - - if(v == NULL) v = &v2; - - if(xa1 == xa2 && ya1 == ya2) return INTERSECTION_ERROR; - if(xb1 == xb2 && yb1 == yb2) return INTERSECTION_ERROR; - - if(xa1 == xa2 || xb1 == xb2) { - temp = xa1; xa1 = ya1; ya1 = temp; - temp = xa2; xa2 = ya2; ya2 = temp; - temp = xb1; xb1 = yb1; yb1 = temp; - temp = xb2; xb2 = yb2; yb2 = temp; - - switched = 1; - } - - if(xa1 == xa2 && xb1 == xb2) - return (xa1 == xb1) ? INTERSECTION_IDENTICAL : INTERSECTION_NONE; - - if(xa1 == xa2) { - v->x = xa1; - v->y = yb1; - } - else if(xb1 == xb2) { - v->x = xb1; - v->y = ya1; - } - else { - double ma = (ya2-ya1)/(xa2-xa1); - double mb = (yb2-yb1)/(xb2-xb1); - double ba = ya1 - ma*xa1; - double bb = yb1 - mb*xb1; - - if(ma == mb) return (ba == bb) ? INTERSECTION_IDENTICAL : INTERSECTION_NONE; - - v->x = (bb-ba)/(ma-mb); - v->y = ma*v->x + ba; - } - - if(switched) { - temp = v->x; v->x = v->y; v->y = temp; - - //switch back everything for segment tests - temp = xa1; xa1 = ya1; ya1 = temp; - temp = xa2; xa2 = ya2; ya2 = temp; - temp = xb1; xb1 = yb1; yb1 = temp; - temp = xb2; xb2 = yb2; yb2 = temp; - } - - if(v->x < MIN(xa1,xa2) || v->x > MAX(xa1, xa2) || v->y < MIN(ya1,ya2) || v->y > MAX(ya1, ya2)) { - if(v->x < MIN(xb1,xb2) || v->x > MAX(xb1, xb2) || v->y < MIN(yb1,yb2) || v->y > MAX(yb1, yb2)) - return INTERSECTION_LINE_LINE; - else - return INTERSECTION_LINE_SEGMENT; - } - else if(v->x < MIN(xb1,xb2) || v->x > MAX(xb1, xb2) || v->y < MIN(yb1,yb2) || v->y > MAX(yb1, yb2)) - return INTERSECTION_SEGMENT_LINE; - else - return INTERSECTION_SEGMENT_SEGMENT; -} - -int lineRectIntersection(const LINE *l, const RECTANGLE *rect, int edge, VERTEX *v) { - const double minX = rect->x, maxX = rect->x+rect->width; - const double minY = rect->y, maxY = rect->y+rect->height; - const LINE top = {{minX, minY}, {maxX, minY}}; - const LINE bottom = {{minX, maxY}, {maxX, maxY}}; - const LINE left = {{minX, minY}, {minX, maxY}}; - const LINE right = {{maxX, minY}, {maxX, maxY}}; - - if((edge & EDGE_TOP) && (lineIntersection(&top, l, v) == INTERSECTION_SEGMENT_SEGMENT)) - return EDGE_TOP; - if((edge & EDGE_BOTTOM) && (lineIntersection(&bottom, l, v) == INTERSECTION_SEGMENT_SEGMENT)) - return EDGE_BOTTOM; - if((edge & EDGE_LEFT) && (lineIntersection(&left, l, v) == INTERSECTION_SEGMENT_SEGMENT)) - return EDGE_LEFT; - if((edge & EDGE_RIGHT) && (lineIntersection(&right, l, v) == INTERSECTION_SEGMENT_SEGMENT)) - return EDGE_RIGHT; - - v->x = v->y = 0; - - return EDGE_NONE; -} - -int lineRectIntersections(const LINE *line, const RECTANGLE *rect, int edge, VERTEX *v1, VERTEX *v2) { - int ret = EDGE_NONE; - - ret |= lineRectIntersection(line, rect, edge, v1); - ret |= lineRectIntersection(line, rect, EDGE_ALL^edge, v2); - - return ret; -} - -gboolean linePolygonIntersection(const LINE *l, const POLYGON *p) { - int i; - LINE line; - - for(i = 0; i < p->nVertices; i++) { - line.v1 = p->vertices[i]; - line.v2 = p->vertices[(i+1)%p->nVertices]; - - if(lineIntersection(l, &line, NULL) == INTERSECTION_SEGMENT_SEGMENT) - return TRUE; - } - - return FALSE; -} - - -static void edgeVertex(VERTEX *v, int edge, const RECTANGLE *rect) { - if(edge == EDGE_NONE) - edge = vertexInRect(v, rect); - - if(edge & EDGE_LEFT) v->x = rect->x; - else if(edge & EDGE_RIGHT) v->x = rect->x+rect->width; - - if(edge & EDGE_TOP) v->y = rect->y; - else if(edge & EDGE_BOTTOM) v->y = rect->y+rect->height; -} - -static int simplifyVertex(VERTEX *v, const VERTEX *to, const RECTANGLE *rect) { - LINE l = {*v, *to}; - int edge, edge2; - - - edge = vertexInRect(v, rect); - if(edge == EDGE_NONE) return EDGE_NONE; - - edge2 = lineRectIntersection(&l, rect, edge, v); - if(edge2 != EDGE_NONE) return edge2; - - edgeVertex(v, edge, rect); - return edge; -} - - - -static void addSimplifiedLine(const VERTEX *v1, const VERTEX *v2, const RECTANGLE *rect, int last, POLYGON *out) { - const LINE d1 = {{rect->x, rect->y}, {rect->x+rect->width, rect->y+rect->height}}; - const LINE d2 = {{rect->x, rect->y+rect->height}, {rect->x+rect->width, rect->y}}; - - LINE l = {*v1, *v2}; - VERTEX v, vi; - int edge1, edge2; - - - v = *v1; - if((edge1 = simplifyVertex(&v, v2, rect)) != EDGE_NONE) - addVertex(out, &v); - - v = *v2; - edge2 = simplifyVertex(&v, v1, rect); - - if(edge1 != EDGE_NONE && edge2 != EDGE_NONE && !(edge1 & edge2)) { - if(lineIntersection(&l, &d1, &vi) == INTERSECTION_SEGMENT_LINE) { - edgeVertex(&vi, 0, rect); - addVertex(out, &vi); - } - else if(lineIntersection(&l, &d2, &vi) == INTERSECTION_SEGMENT_LINE) { - edgeVertex(&vi, 0, rect); - addVertex(out, &vi); - } - } - - if(!last) - addVertex(out, &v); -} - -void simplifyPolygon(const POLYGON *in, const RECTANGLE *rect, POLYGON *out) { - VERTEX v; - int i; - - if(in->nVertices == 0) return; - else if(in->nVertices == 1) { - addVertex(out, &in->vertices[0]); - return; - } - - v = in->vertices[0]; - simplifyVertex(&v, &in->vertices[in->nVertices-1], rect); - addVertex(out, &v); - - for(i = 0; i < in->nVertices; i++) { - addSimplifiedLine(&in->vertices[i], &in->vertices[(i+1)%in->nVertices], rect, (i == in->nVertices-1), out); - } -} diff --git a/geometry.cpp b/geometry.cpp new file mode 100644 index 0000000..ef5acfd --- /dev/null +++ b/geometry.cpp @@ -0,0 +1,368 @@ +#include "geometry.h" +#include +#include +#include + + +void addVertex(VERTEX_LIST *list, const VERTEX *v) { + list->nVertices++; + list->vertices = (VERTEX*)realloc(list->vertices, list->nVertices*sizeof(VERTEX)); + list->vertices[list->nVertices-1] = *v; +} + +void insertVertex(VERTEX_LIST *list, const VERTEX *v, unsigned int n) { + int i; + + if(n > list->nVertices) + n = list->nVertices; + + list->nVertices++; + list->vertices = (VERTEX*)realloc(list->vertices, list->nVertices*sizeof(VERTEX)); + + for(i = list->nVertices-1; i > n; i--) + list->vertices[i] = list->vertices[i-1]; + + list->vertices[n] = *v; +} + +void deleteVertex(VERTEX_LIST *list, unsigned int n) { + int i; + + list->nVertices--; + + for(i = n; i < list->nVertices; i++) + list->vertices[i] = list->vertices[i+1]; + + list->vertices = (VERTEX*)realloc(list->vertices, list->nVertices*sizeof(VERTEX)); +} + +double vertexDistanceSquare(const VERTEX *v1, const VERTEX *v2) { + return (v1->x-v2->x)*(v1->x-v2->x) + (v1->y-v2->y)*(v1->y-v2->y); +} + +double vertexDistance(const VERTEX *v1, const VERTEX *v2) { + return sqrt(vertexDistanceSquare(v1, v2)); +} + +int vertexOnLine(const VERTEX *v, const LINE *l) { + if(l->v1.x == l->v2.x && l->v1.y == l->v2.y) { + if(l->v1.x == v->x && l->v1.y == v->y) return 1; + else return 0; + } + + if(l->v1.x == l->v2.x) { + if(l->v1.x != v->x) return 0; + else if(v->y >= MIN(l->v1.y, l->v2.y) && v->y <= MAX(l->v1.y, l->v2.y)) return 1; + else return 1; + } + + if(l->v1.y == l->v2.y) { + if(l->v1.y != v->y) return 0; + else if(v->x >= MIN(l->v1.x, l->v2.x) && v->x <= MAX(l->v1.x, l->v2.x)) return 1; + else return 1; + } + if((v->x-l->v1.x)/(l->v2.x-l->v1.x) - (v->y-l->v1.y)/(l->v2.y-l->v1.y) == 0) return 1; + else return 0; +} + +int vertexInRect(const VERTEX *v, const RECTANGLE *rect) { + int ret = EDGE_NONE; + + if(v->x < rect->x) ret |= EDGE_LEFT; + else if(v->x >= rect->x+rect->width) ret |= EDGE_RIGHT; + + if(v->y < rect->y) ret |= EDGE_TOP; + else if(v->y >= rect->y+rect->height) ret |= EDGE_BOTTOM; + + return ret; +} + +static int quadrant(VERTEX *v) { + if(v->x > 0 && v->y >= 0) return 1; + if(v->x >= 0 && v->y < 0) return 2; + if(v->x < 0 && v->y <= 0) return 3; + if(v->x <= 0 && v->y > 0) return 4; + + return 0; +} + +gboolean vertexInPolygon(const VERTEX *v, const POLYGON *p) { + int d = 0, i, li; + int q, ql, q2; + LINE d1 = {{-1, -1}, {1, 1}}; + LINE d2 = {{-1, 1}, {1, -1}}; + LINE l; + VERTEX v2; + + + if(p->nVertices == 0) return FALSE; + + v2.x = p->vertices[p->nVertices-1].x - v->x; + v2.y = p->vertices[p->nVertices-1].y - v->y; + q = quadrant(&v2); + + if(q == 0) return TRUE; + + for(i = 0; i < p->nVertices; i++) { + ql = q; + + v2.x = p->vertices[i].x - v->x; + v2.y = p->vertices[i].y - v->y; + q = quadrant(&v2); + + if(q == 0) return TRUE; + + switch(q-ql) { + case 0: + break; + case 1: + case -3: + d++; + break; + case 3: + case -1: + d--; + break; + default: + l.v1.x = p->vertices[(i>0)?i-1:p->nVertices-1].x - v->x; + l.v1.y = p->vertices[(i>0)?i-1:p->nVertices-1].y - v->y; + + l.v2 = v2; + + if(q == 1 || q == 3) { + if(!(lineIntersection(&l, &d2, &v2) & INTERSECTION_LINE)) return FALSE; + + q2 = quadrant(&v2); + if(q2 == 0) return TRUE; + + if((q == 1 && q2 == 2) || (q == 3 && q2 == 4)) d -= 2; + else d += 2; + } + else { + if(!(lineIntersection(&l, &d1, &v2) & INTERSECTION_LINE)) return FALSE; + + q2 = quadrant(&v2); + if(q2 == 0) return TRUE; + + if((q == 2 && q2 == 3) || (q == 4 && q2 == 1)) d -= 2; + else d += 2; + } + } + } + + return (d == 0) ? FALSE : TRUE; +} + +double polygonPerimeter(const POLYGON *p) { + int i; + double d = 0.0; + + for(i = 0; i < p->nVertices; i++) + d += vertexDistance(&p->vertices[i], &p->vertices[(i+1)%p->nVertices]); + + return d; +} + +double polygonArea(const POLYGON *p) { + int i; + double d = 0.0; + + for(i = 0; i < p->nVertices; i++) + d += (p->vertices[(i+1)%p->nVertices].x+p->vertices[i].x)*(p->vertices[(i+1)%p->nVertices].y-p->vertices[i].y); + + return fabs(d/2); +} + +int lineIntersection(const LINE *la, const LINE *lb, VERTEX *v) { + double xa1 = la->v1.x, ya1 = la->v1.y; + double xa2 = la->v2.x, ya2 = la->v2.y; + double xb1 = lb->v1.x, yb1 = lb->v1.y; + double xb2 = lb->v2.x, yb2 = lb->v2.y; + double temp; + int switched = 0; + VERTEX v2; + + + if(v == NULL) v = &v2; + + if(xa1 == xa2 && ya1 == ya2) return INTERSECTION_ERROR; + if(xb1 == xb2 && yb1 == yb2) return INTERSECTION_ERROR; + + if(xa1 == xa2 || xb1 == xb2) { + temp = xa1; xa1 = ya1; ya1 = temp; + temp = xa2; xa2 = ya2; ya2 = temp; + temp = xb1; xb1 = yb1; yb1 = temp; + temp = xb2; xb2 = yb2; yb2 = temp; + + switched = 1; + } + + if(xa1 == xa2 && xb1 == xb2) + return (xa1 == xb1) ? INTERSECTION_IDENTICAL : INTERSECTION_NONE; + + if(xa1 == xa2) { + v->x = xa1; + v->y = yb1; + } + else if(xb1 == xb2) { + v->x = xb1; + v->y = ya1; + } + else { + double ma = (ya2-ya1)/(xa2-xa1); + double mb = (yb2-yb1)/(xb2-xb1); + double ba = ya1 - ma*xa1; + double bb = yb1 - mb*xb1; + + if(ma == mb) return (ba == bb) ? INTERSECTION_IDENTICAL : INTERSECTION_NONE; + + v->x = (bb-ba)/(ma-mb); + v->y = ma*v->x + ba; + } + + if(switched) { + temp = v->x; v->x = v->y; v->y = temp; + + //switch back everything for segment tests + temp = xa1; xa1 = ya1; ya1 = temp; + temp = xa2; xa2 = ya2; ya2 = temp; + temp = xb1; xb1 = yb1; yb1 = temp; + temp = xb2; xb2 = yb2; yb2 = temp; + } + + if(v->x < MIN(xa1,xa2) || v->x > MAX(xa1, xa2) || v->y < MIN(ya1,ya2) || v->y > MAX(ya1, ya2)) { + if(v->x < MIN(xb1,xb2) || v->x > MAX(xb1, xb2) || v->y < MIN(yb1,yb2) || v->y > MAX(yb1, yb2)) + return INTERSECTION_LINE_LINE; + else + return INTERSECTION_LINE_SEGMENT; + } + else if(v->x < MIN(xb1,xb2) || v->x > MAX(xb1, xb2) || v->y < MIN(yb1,yb2) || v->y > MAX(yb1, yb2)) + return INTERSECTION_SEGMENT_LINE; + else + return INTERSECTION_SEGMENT_SEGMENT; +} + +int lineRectIntersection(const LINE *l, const RECTANGLE *rect, int edge, VERTEX *v) { + const double minX = rect->x, maxX = rect->x+rect->width; + const double minY = rect->y, maxY = rect->y+rect->height; + const LINE top = {{minX, minY}, {maxX, minY}}; + const LINE bottom = {{minX, maxY}, {maxX, maxY}}; + const LINE left = {{minX, minY}, {minX, maxY}}; + const LINE right = {{maxX, minY}, {maxX, maxY}}; + + if((edge & EDGE_TOP) && (lineIntersection(&top, l, v) == INTERSECTION_SEGMENT_SEGMENT)) + return EDGE_TOP; + if((edge & EDGE_BOTTOM) && (lineIntersection(&bottom, l, v) == INTERSECTION_SEGMENT_SEGMENT)) + return EDGE_BOTTOM; + if((edge & EDGE_LEFT) && (lineIntersection(&left, l, v) == INTERSECTION_SEGMENT_SEGMENT)) + return EDGE_LEFT; + if((edge & EDGE_RIGHT) && (lineIntersection(&right, l, v) == INTERSECTION_SEGMENT_SEGMENT)) + return EDGE_RIGHT; + + v->x = v->y = 0; + + return EDGE_NONE; +} + +int lineRectIntersections(const LINE *line, const RECTANGLE *rect, int edge, VERTEX *v1, VERTEX *v2) { + int ret = EDGE_NONE; + + ret |= lineRectIntersection(line, rect, edge, v1); + ret |= lineRectIntersection(line, rect, EDGE_ALL^edge, v2); + + return ret; +} + +gboolean linePolygonIntersection(const LINE *l, const POLYGON *p) { + int i; + LINE line; + + for(i = 0; i < p->nVertices; i++) { + line.v1 = p->vertices[i]; + line.v2 = p->vertices[(i+1)%p->nVertices]; + + if(lineIntersection(l, &line, NULL) == INTERSECTION_SEGMENT_SEGMENT) + return TRUE; + } + + return FALSE; +} + + +static void edgeVertex(VERTEX *v, int edge, const RECTANGLE *rect) { + if(edge == EDGE_NONE) + edge = vertexInRect(v, rect); + + if(edge & EDGE_LEFT) v->x = rect->x; + else if(edge & EDGE_RIGHT) v->x = rect->x+rect->width; + + if(edge & EDGE_TOP) v->y = rect->y; + else if(edge & EDGE_BOTTOM) v->y = rect->y+rect->height; +} + +static int simplifyVertex(VERTEX *v, const VERTEX *to, const RECTANGLE *rect) { + LINE l = {*v, *to}; + int edge, edge2; + + + edge = vertexInRect(v, rect); + if(edge == EDGE_NONE) return EDGE_NONE; + + edge2 = lineRectIntersection(&l, rect, edge, v); + if(edge2 != EDGE_NONE) return edge2; + + edgeVertex(v, edge, rect); + return edge; +} + + + +static void addSimplifiedLine(const VERTEX *v1, const VERTEX *v2, const RECTANGLE *rect, int last, POLYGON *out) { + const LINE d1 = {{rect->x, rect->y}, {rect->x+rect->width, rect->y+rect->height}}; + const LINE d2 = {{rect->x, rect->y+rect->height}, {rect->x+rect->width, rect->y}}; + + LINE l = {*v1, *v2}; + VERTEX v, vi; + int edge1, edge2; + + + v = *v1; + if((edge1 = simplifyVertex(&v, v2, rect)) != EDGE_NONE) + addVertex(out, &v); + + v = *v2; + edge2 = simplifyVertex(&v, v1, rect); + + if(edge1 != EDGE_NONE && edge2 != EDGE_NONE && !(edge1 & edge2)) { + if(lineIntersection(&l, &d1, &vi) == INTERSECTION_SEGMENT_LINE) { + edgeVertex(&vi, 0, rect); + addVertex(out, &vi); + } + else if(lineIntersection(&l, &d2, &vi) == INTERSECTION_SEGMENT_LINE) { + edgeVertex(&vi, 0, rect); + addVertex(out, &vi); + } + } + + if(!last) + addVertex(out, &v); +} + +void simplifyPolygon(const POLYGON *in, const RECTANGLE *rect, POLYGON *out) { + VERTEX v; + int i; + + if(in->nVertices == 0) return; + else if(in->nVertices == 1) { + addVertex(out, &in->vertices[0]); + return; + } + + v = in->vertices[0]; + simplifyVertex(&v, &in->vertices[in->nVertices-1], rect); + addVertex(out, &v); + + for(i = 0; i < in->nVertices; i++) { + addSimplifiedLine(&in->vertices[i], &in->vertices[(i+1)%in->nVertices], rect, (i == in->nVertices-1), out); + } +} diff --git a/level.c b/level.c deleted file mode 100644 index e78dfb7..0000000 --- a/level.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "level.h" -#include - - -static LEVEL *level = NULL; - - -LEVEL *getLevel() { - return level; -} - -void setLevel(LEVEL *l) { - level = l; -} - -void addRoom(LEVEL *lvl, const ROOM *room) { - lvl->nRooms++; - lvl->rooms = realloc(lvl->rooms, lvl->nRooms*sizeof(ROOM)); - lvl->rooms[lvl->nRooms-1] = *room; -} - -void deleteRoom(LEVEL *lvl, unsigned int n) { - int i; - - lvl->nRooms--; - - for(i = n; i < lvl->nRooms; i++) - lvl->rooms[i] = lvl->rooms[i+1]; - - lvl->rooms = realloc(lvl->rooms, lvl->nRooms*sizeof(ROOM)); -} - -void freeLevel(LEVEL *lvl) { - int i; - - if(lvl) { - if(lvl->rooms) { - for(i = 0; i < lvl->nRooms; i++) { - if(lvl->rooms[i].polygon.vertices) - free(lvl->rooms[i].polygon.vertices); - - if(lvl->rooms[i].name) - free(lvl->rooms[i].name); - } - - free(lvl->rooms); - } - - free(lvl); - } -} diff --git a/level.cpp b/level.cpp new file mode 100644 index 0000000..6483066 --- /dev/null +++ b/level.cpp @@ -0,0 +1,51 @@ +#include "level.h" +#include + + +static LEVEL *level = NULL; + + +LEVEL *getLevel() { + return level; +} + +void setLevel(LEVEL *l) { + level = l; +} + +void addRoom(LEVEL *lvl, const ROOM *room) { + lvl->nRooms++; + lvl->rooms = (ROOM*)realloc(lvl->rooms, lvl->nRooms*sizeof(ROOM)); + lvl->rooms[lvl->nRooms-1] = *room; +} + +void deleteRoom(LEVEL *lvl, unsigned int n) { + int i; + + lvl->nRooms--; + + for(i = n; i < lvl->nRooms; i++) + lvl->rooms[i] = lvl->rooms[i+1]; + + lvl->rooms = (ROOM*)realloc(lvl->rooms, lvl->nRooms*sizeof(ROOM)); +} + +void freeLevel(LEVEL *lvl) { + int i; + + if(lvl) { + if(lvl->rooms) { + for(i = 0; i < lvl->nRooms; i++) { + if(lvl->rooms[i].polygon.vertices) + free(lvl->rooms[i].polygon.vertices); + + if(lvl->rooms[i].name) + free(lvl->rooms[i].name); + } + + free(lvl->rooms); + } + + free(lvl); + } +} diff --git a/level.h b/level.h index e647509..8b098d8 100644 --- a/level.h +++ b/level.h @@ -5,7 +5,7 @@ typedef struct _ROOM { POLYGON polygon; - unsigned char *name; + char *name; } ROOM; typedef struct _LEVEL { diff --git a/ui.c b/ui.c deleted file mode 100644 index d0fc58b..0000000 --- a/ui.c +++ /dev/null @@ -1,103 +0,0 @@ -#include "ui.h" -#include "draw.h" -#include "window.h" -#include -#include - - -static const gchar *uiData = -"" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" - "" -""; - - -static void handleAction(GtkAction *action, gpointer user_data) { - const gchar* name = gtk_action_get_name(action); - - if(!strcmp(name, "zoomIn")) - zoomInCentered(1.2); - else if(!strcmp(name, "zoomOut")) - zoomOutCentered(1.2); -} - -static GtkActionGroup *createActions() { - GtkActionGroup *actionGroup = gtk_action_group_new("actions"); - GtkAction *action; - - action = gtk_action_new("fileMenu", "_File", NULL, NULL); - gtk_action_group_add_action(actionGroup, action); - - action = gtk_action_new("toolbar1", "Toolbar", NULL, NULL); - gtk_action_group_add_action(actionGroup, action); - - action = gtk_action_new("new", "_New", NULL, GTK_STOCK_NEW); - gtk_action_group_add_action_with_accel(actionGroup, action, NULL); - - action = gtk_action_new("open", "_Open", NULL, GTK_STOCK_OPEN); - gtk_action_group_add_action_with_accel(actionGroup, action, NULL); - - action = gtk_action_new("save", "_Save", NULL, GTK_STOCK_SAVE); - gtk_action_group_add_action_with_accel(actionGroup, action, NULL); - - action = gtk_action_new("saveAs", "Save _As", NULL, NULL); - gtk_action_group_add_action(actionGroup, action); - - action = gtk_action_new("zoomIn", "Zoom _in", NULL, GTK_STOCK_ZOOM_IN); - g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(handleAction), NULL); - gtk_action_group_add_action_with_accel(actionGroup, action, NULL); - - action = gtk_action_new("zoomOut", "Zoom _out", NULL, GTK_STOCK_ZOOM_OUT); - g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(handleAction), NULL); - gtk_action_group_add_action_with_accel(actionGroup, action, NULL); - - action = gtk_action_new("quit", "_Quit", NULL, GTK_STOCK_QUIT); - g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(gtk_main_quit), NULL); - gtk_action_group_add_action_with_accel(actionGroup, action, NULL); - - return actionGroup; -} - -static GtkUIManager* getUIManager() { - static GtkUIManager *uiManager = NULL; - - if(!uiManager) { - - - uiManager = gtk_ui_manager_new(); - gtk_ui_manager_add_ui_from_string(uiManager, uiData, -1, NULL); - - gtk_ui_manager_insert_action_group(uiManager, createActions(), 0); - - gtk_ui_manager_ensure_update(uiManager); - } - - return uiManager; -} - - -GtkWidget* getMenu() { - return gtk_ui_manager_get_widget(getUIManager(), "/ui/menubar"); -} - -GtkWidget* getToolbar() { - return gtk_ui_manager_get_widget(getUIManager(), "/ui/toolbar1"); -} - -GtkAccelGroup *getAccels() { - return gtk_ui_manager_get_accel_group(getUIManager()); -} diff --git a/ui.cpp b/ui.cpp new file mode 100644 index 0000000..d0fc58b --- /dev/null +++ b/ui.cpp @@ -0,0 +1,103 @@ +#include "ui.h" +#include "draw.h" +#include "window.h" +#include +#include + + +static const gchar *uiData = +"" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" +""; + + +static void handleAction(GtkAction *action, gpointer user_data) { + const gchar* name = gtk_action_get_name(action); + + if(!strcmp(name, "zoomIn")) + zoomInCentered(1.2); + else if(!strcmp(name, "zoomOut")) + zoomOutCentered(1.2); +} + +static GtkActionGroup *createActions() { + GtkActionGroup *actionGroup = gtk_action_group_new("actions"); + GtkAction *action; + + action = gtk_action_new("fileMenu", "_File", NULL, NULL); + gtk_action_group_add_action(actionGroup, action); + + action = gtk_action_new("toolbar1", "Toolbar", NULL, NULL); + gtk_action_group_add_action(actionGroup, action); + + action = gtk_action_new("new", "_New", NULL, GTK_STOCK_NEW); + gtk_action_group_add_action_with_accel(actionGroup, action, NULL); + + action = gtk_action_new("open", "_Open", NULL, GTK_STOCK_OPEN); + gtk_action_group_add_action_with_accel(actionGroup, action, NULL); + + action = gtk_action_new("save", "_Save", NULL, GTK_STOCK_SAVE); + gtk_action_group_add_action_with_accel(actionGroup, action, NULL); + + action = gtk_action_new("saveAs", "Save _As", NULL, NULL); + gtk_action_group_add_action(actionGroup, action); + + action = gtk_action_new("zoomIn", "Zoom _in", NULL, GTK_STOCK_ZOOM_IN); + g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(handleAction), NULL); + gtk_action_group_add_action_with_accel(actionGroup, action, NULL); + + action = gtk_action_new("zoomOut", "Zoom _out", NULL, GTK_STOCK_ZOOM_OUT); + g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(handleAction), NULL); + gtk_action_group_add_action_with_accel(actionGroup, action, NULL); + + action = gtk_action_new("quit", "_Quit", NULL, GTK_STOCK_QUIT); + g_signal_connect(G_OBJECT(action), "activate", G_CALLBACK(gtk_main_quit), NULL); + gtk_action_group_add_action_with_accel(actionGroup, action, NULL); + + return actionGroup; +} + +static GtkUIManager* getUIManager() { + static GtkUIManager *uiManager = NULL; + + if(!uiManager) { + + + uiManager = gtk_ui_manager_new(); + gtk_ui_manager_add_ui_from_string(uiManager, uiData, -1, NULL); + + gtk_ui_manager_insert_action_group(uiManager, createActions(), 0); + + gtk_ui_manager_ensure_update(uiManager); + } + + return uiManager; +} + + +GtkWidget* getMenu() { + return gtk_ui_manager_get_widget(getUIManager(), "/ui/menubar"); +} + +GtkWidget* getToolbar() { + return gtk_ui_manager_get_widget(getUIManager(), "/ui/toolbar1"); +} + +GtkAccelGroup *getAccels() { + return gtk_ui_manager_get_accel_group(getUIManager()); +} diff --git a/window.c b/window.c deleted file mode 100644 index 38cf0cc..0000000 --- a/window.c +++ /dev/null @@ -1,366 +0,0 @@ -#include "window.h" -#include "ui.h" -#include "edit.h" -#include "draw.h" -#include "geometry.h" -#include "level.h" -#include -#include - - -static GtkWidget *drawingArea = NULL, *sidebarView = NULL, *sidebarAdd = NULL; -static GtkAdjustment *hAdjustment = NULL, *vAdjustment = NULL; - -static GtkWidget *entryName, *labelArea = NULL, *labelPerimeter = NULL, *buttonAdd = NULL, *buttonAddDo = NULL; - - -static gboolean deleteEvent(GtkWidget *widget, GdkEvent *event, gpointer data) { - return FALSE; -} - -static gboolean scrollEvent(GtkWidget *widget, GdkEventScroll *event, gpointer user_data) { - const gdouble x = event->x/widget->allocation.width, y = event->y/widget->allocation.height; - - switch(event->direction) { - case GDK_SCROLL_UP: - zoomIn(1.1, x, y); - break; - case GDK_SCROLL_DOWN: - zoomOut(1.1, x, y); - } -} - -static gboolean buttonEvent(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { - VERTEX v = {event->x, event->y}; - - switch(event->type) { - case GDK_BUTTON_PRESS: - switch(event->button) { - case 1: - switch(getEditMode()) { - case EDIT_MODE_VIEW: - case EDIT_MODE_SELECTED: - setActiveRoom(getHoveredRoom()); - - updateSidebar(); - - redraw(); - - break; - case EDIT_MODE_ADD: - viewToImage(&v); - - if(isVertexOk(&v)) { - addVertex(&getActiveRoom()->polygon, &v); - updateSidebar(); - } - } - - gtk_widget_queue_draw(drawingArea); - } - } - - return FALSE; -} - -gboolean crossingNotifyEvent(GtkWidget *widget, GdkEventCrossing *event, gpointer user_data) { - VERTEX v; - - - switch(event->type) { - case GDK_ENTER_NOTIFY: - v.x = event->x; - v.y = event->y; - - viewToImage(&v); - - setHoveredVertex(&v); - - break; - case GDK_LEAVE_NOTIFY: - setHoveredVertex(NULL); - } - - - gtk_widget_queue_draw(drawingArea); -} - -gboolean motionNotifyEvent(GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { - VERTEX v; - ROOM *last = getHoveredRoom(); - - v.x = event->x; - v.y = event->y; - - viewToImage(&v); - - setHoveredVertex(&v); - - if(getHoveredRoom() != last || getEditMode() == EDIT_MODE_ADD) - gtk_widget_queue_draw(drawingArea); -} - -static void destroy(GtkWidget *widget, gpointer data) { - gtk_main_quit(); -} - -static void refreshScrolling() { - if(getImageWidth() < drawingArea->allocation.width) - setXTranslate((getImageWidth()-drawingArea->allocation.width)/2); - else - setXTranslate(gtk_adjustment_get_value(hAdjustment)); - - if(getImageHeight() < drawingArea->allocation.height) - setYTranslate((getImageHeight()-drawingArea->allocation.height)/2); - else - setYTranslate(gtk_adjustment_get_value(vAdjustment)); - - gtk_widget_queue_draw(drawingArea); -} - -static void updateScrollbars(double x, double y) { - const gdouble imageWidth = getImageWidth(), imageHeight = getImageHeight(); - const gdouble width = drawingArea->allocation.width, height = drawingArea->allocation.height; - gdouble upper, pageSize, value; - - gdk_window_freeze_updates(drawingArea->window); - - g_object_get(G_OBJECT(hAdjustment), "upper", &upper, "page_size", &pageSize, NULL); - g_object_set(G_OBJECT(hAdjustment), "upper", imageWidth, "page_size", width, NULL); - gtk_adjustment_changed(hAdjustment); - - if((pageSize > upper && width < imageWidth) || upper == 0) - value = (imageWidth-width)/2; - else - value = (gtk_adjustment_get_value(hAdjustment)+pageSize*x)/upper*imageWidth-width*x; - gtk_adjustment_set_value(hAdjustment, MAX(MIN(value, imageWidth-width), 0)); - - g_object_get(G_OBJECT(vAdjustment), "upper", &upper, "page_size", &pageSize, NULL); - g_object_set(G_OBJECT(vAdjustment), "upper", imageHeight, "page_size", height, NULL); - gtk_adjustment_changed(vAdjustment); - - if((pageSize > upper && height < imageHeight) || upper == 0) - value = (imageHeight-height)/2; - else - value = (gtk_adjustment_get_value(vAdjustment)+pageSize*y)/upper*imageHeight-height*y; - gtk_adjustment_set_value(vAdjustment, MAX(MIN(value, imageHeight-height), 0)); - - gdk_window_thaw_updates(drawingArea->window); - - refreshScrolling(); -} - -static void updateScrollbarsCentered() { - updateScrollbars(0.5, 0.5); -} - -static void sidebarNameChanged(GtkEditable *editable, gpointer user_data) { - if(getActiveRoom() == NULL) return; - - free(getActiveRoom()->name); - getActiveRoom()->name = strdup(gtk_entry_get_text(GTK_ENTRY(entryName))); -} - -static void sidebarButtonClicked(GtkButton *button, gpointer user_data) { - if(button == GTK_BUTTON(buttonAdd)) { - startAddMode(); - updateSidebar(); - - gtk_widget_queue_draw(drawingArea); - } - else if(button == GTK_BUTTON(buttonAddDo)) { - if(getActiveRoom() &&getActiveRoom()->polygon.nVertices > 2 && isPolygonOk(&getActiveRoom()->polygon)) { - addRoom(getLevel(), getActiveRoom()); - setActiveRoom(&getLevel()->rooms[getLevel()->nRooms-1]); - } - - endAddMode(); - updateSidebar(); - - gtk_widget_queue_draw(drawingArea); - } -} - -static GtkWidget* createSidebar() { - GtkWidget *sidebar, *labelRoomInfo, *labelName; - GtkWidget *tableRoomData, *labelAreaLabel, *labelPerimeterLabel; - - sidebar = gtk_hbox_new(FALSE, 0); - - // View sidebar - sidebarView = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(sidebar), sidebarView, FALSE, FALSE, 5); - - labelRoomInfo = gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(labelRoomInfo), "Room info:"); - gtk_misc_set_alignment(GTK_MISC(labelRoomInfo), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(sidebarView), labelRoomInfo, FALSE, FALSE, 5); - - gtk_box_pack_start(GTK_BOX(sidebarView), gtk_hseparator_new(), FALSE, FALSE, 5); - - labelName = gtk_label_new("Name:"); - gtk_misc_set_alignment(GTK_MISC(labelName), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(sidebarView), labelName, FALSE, FALSE, 0); - - entryName = gtk_entry_new(); - gtk_widget_set_sensitive(entryName, FALSE); - g_signal_connect(G_OBJECT(entryName), "changed", G_CALLBACK(sidebarNameChanged), NULL); - gtk_box_pack_start(GTK_BOX(sidebarView), entryName, FALSE, FALSE, 0); - - tableRoomData = gtk_table_new(2, 2, FALSE); - gtk_table_set_row_spacings(GTK_TABLE(tableRoomData), 5); - gtk_table_set_col_spacings(GTK_TABLE(tableRoomData), 10); - gtk_box_pack_start(GTK_BOX(sidebarView), tableRoomData, FALSE, FALSE, 5); - - labelAreaLabel = gtk_label_new("Room area:"); - gtk_misc_set_alignment(GTK_MISC(labelAreaLabel), 0.0, 0.5); - gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelAreaLabel, 0, 1, 0, 1); - - labelArea = gtk_label_new(NULL); - gtk_misc_set_alignment(GTK_MISC(labelArea), 1.0, 0.5); - gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelArea, 1, 2, 0, 1); - - labelPerimeterLabel = gtk_label_new("Room perimeter:"); - gtk_misc_set_alignment(GTK_MISC(labelPerimeterLabel), 0.0, 0.5); - gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelPerimeterLabel, 0, 1, 1, 2); - - labelPerimeter = gtk_label_new(NULL); - gtk_misc_set_alignment(GTK_MISC(labelPerimeter), 1.0, 0.5); - gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelPerimeter, 1, 2, 1, 2); - - buttonAdd = gtk_button_new_with_label("Add room"); - g_signal_connect(G_OBJECT(buttonAdd), "clicked", G_CALLBACK(sidebarButtonClicked), NULL); - gtk_box_pack_end(GTK_BOX(sidebarView), buttonAdd, FALSE, FALSE, 0); - - // Add sidebar - sidebarAdd = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(sidebar), sidebarAdd, FALSE, FALSE, 5); - - labelRoomInfo = gtk_label_new(NULL); - gtk_label_set_markup(GTK_LABEL(labelRoomInfo), "Add room"); - gtk_misc_set_alignment(GTK_MISC(labelRoomInfo), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(sidebarAdd), labelRoomInfo, FALSE, FALSE, 5); - - buttonAddDo = gtk_button_new_with_label("Add room"); - g_signal_connect(G_OBJECT(buttonAddDo), "clicked", G_CALLBACK(sidebarButtonClicked), NULL); - gtk_box_pack_end(GTK_BOX(sidebarAdd), buttonAddDo, FALSE, FALSE, 0); - - return sidebar; -} - -GtkWidget* createMainWindow() { - GtkWidget *window, *hPaned, *vbox, *table, *vScroll, *hScroll, *sidebar; - GdkColor color = {0, 0, 0, 0}; - - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_default_size(GTK_WINDOW(window), 640, 480); - g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(deleteEvent), NULL); - g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL); - - vbox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(window), vbox); - - gtk_box_pack_start(GTK_BOX(vbox), getMenu(), FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), getToolbar(), FALSE, FALSE, 0); - - gtk_window_add_accel_group(GTK_WINDOW(window), getAccels()); - - hPaned = gtk_hpaned_new(); - gtk_box_pack_end(GTK_BOX(vbox), hPaned, TRUE, TRUE, 0); - - table = gtk_table_new(2, 2, FALSE); - gtk_paned_pack1(GTK_PANED(hPaned), table, TRUE, TRUE); - - drawingArea = gtk_drawing_area_new(); - gtk_widget_modify_bg(drawingArea, GTK_WIDGET_STATE(drawingArea), &color); - g_signal_connect(G_OBJECT(drawingArea), "configure-event", G_CALLBACK(updateScrollbarsCentered), NULL); - g_signal_connect(G_OBJECT(drawingArea), "expose-event", G_CALLBACK(drawTopView), NULL); - g_signal_connect(G_OBJECT(drawingArea), "button-press-event", G_CALLBACK(buttonEvent), NULL); - g_signal_connect(G_OBJECT(drawingArea), "button-release-event", G_CALLBACK(buttonEvent), NULL); - g_signal_connect(G_OBJECT(drawingArea), "enter-notify-event", G_CALLBACK(crossingNotifyEvent), NULL); - g_signal_connect(G_OBJECT(drawingArea), "leave-notify-event", G_CALLBACK(crossingNotifyEvent), NULL); - g_signal_connect(G_OBJECT(drawingArea), "motion-notify-event", G_CALLBACK(motionNotifyEvent), NULL); - g_signal_connect(G_OBJECT(drawingArea), "scroll-event", G_CALLBACK(scrollEvent), NULL); - gtk_widget_add_events(drawingArea, GDK_SCROLL_MASK | GDK_POINTER_MOTION_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - gtk_table_attach(GTK_TABLE(table), drawingArea, 0, 1, 0, 1, GTK_FILL|GTK_EXPAND|GTK_SHRINK, GTK_FILL|GTK_EXPAND|GTK_SHRINK, 0, 0); - - hAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 0, 10, 100, 100)); - hScroll = gtk_hscrollbar_new(hAdjustment); - g_signal_connect(G_OBJECT(hScroll), "value-changed", G_CALLBACK(refreshScrolling), NULL); - gtk_table_attach(GTK_TABLE(table), hScroll, 0, 1, 1, 2, GTK_FILL|GTK_EXPAND|GTK_SHRINK, 0, 0, 0); - - vAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 0, 10, 100, 100)); - vScroll = gtk_vscrollbar_new(vAdjustment); - g_signal_connect(G_OBJECT(vScroll), "value-changed", G_CALLBACK(refreshScrolling), NULL); - gtk_table_attach(GTK_TABLE(table), vScroll, 1, 2, 0, 1, 0, GTK_FILL|GTK_EXPAND|GTK_SHRINK, 0, 0); - - sidebar = createSidebar(); - gtk_paned_pack2(GTK_PANED(hPaned), sidebar, FALSE, TRUE); - - gtk_widget_show_all(vbox); - gtk_widget_hide(sidebarAdd); - - return window; -} - -void updateSidebar() { - gchar *string; - - switch(getEditMode()) { - case EDIT_MODE_VIEW: - case EDIT_MODE_SELECTED: - gtk_widget_hide(sidebarAdd); - gtk_widget_show(sidebarView); - - if(getActiveRoom()) { - gtk_entry_set_text(GTK_ENTRY(entryName), getActiveRoom()->name); - gtk_widget_set_sensitive(entryName, TRUE); - - string = g_strdup_printf("%.2f", polygonArea(&getActiveRoom()->polygon)); - gtk_label_set_text(GTK_LABEL(labelArea), string); - g_free(string); - - string = g_strdup_printf("%.2f", polygonPerimeter(&getActiveRoom()->polygon)); - gtk_label_set_text(GTK_LABEL(labelPerimeter), string); - g_free(string); - } - else { - gtk_entry_set_text(GTK_ENTRY(entryName), ""); - gtk_widget_set_sensitive(entryName, FALSE); - - gtk_label_set_text(GTK_LABEL(labelArea), NULL); - gtk_label_set_text(GTK_LABEL(labelPerimeter), NULL); - } - - break; - case EDIT_MODE_ADD: - gtk_widget_hide(sidebarView); - gtk_widget_show(sidebarAdd); - - if(getActiveRoom()) { - if(getActiveRoom()->polygon.nVertices > 2 && isPolygonOk(&getActiveRoom()->polygon)) - gtk_widget_set_sensitive(buttonAddDo, TRUE); - else - gtk_widget_set_sensitive(buttonAddDo, FALSE); - } - } -} - -void zoomIn(double factor, double x, double y) { - setScale(getScale()*factor); - updateScrollbars(x, y); -} - -void zoomOut(double factor, double x, double y) { - setScale(getScale()/factor); - updateScrollbars(x, y); -} - -void zoomInCentered(double factor) { - zoomIn(factor, 0.5, 0.5); -} - -void zoomOutCentered(double factor) { - zoomOut(factor, 0.5, 0.5); -} diff --git a/window.cpp b/window.cpp new file mode 100644 index 0000000..39c7ebc --- /dev/null +++ b/window.cpp @@ -0,0 +1,367 @@ +#include "window.h" +#include "ui.h" +#include "edit.h" +#include "draw.h" +#include "geometry.h" +#include "level.h" +#include +#include +#include + + +static GtkWidget *drawingArea = NULL, *sidebarView = NULL, *sidebarAdd = NULL; +static GtkAdjustment *hAdjustment = NULL, *vAdjustment = NULL; + +static GtkWidget *entryName, *labelArea = NULL, *labelPerimeter = NULL, *buttonAdd = NULL, *buttonAddDo = NULL; + + +static gboolean deleteEvent(GtkWidget *widget, GdkEvent *event, gpointer data) { + return FALSE; +} + +static gboolean scrollEvent(GtkWidget *widget, GdkEventScroll *event, gpointer user_data) { + const gdouble x = event->x/widget->allocation.width, y = event->y/widget->allocation.height; + + switch(event->direction) { + case GDK_SCROLL_UP: + zoomIn(1.1, x, y); + break; + case GDK_SCROLL_DOWN: + zoomOut(1.1, x, y); + } +} + +static gboolean buttonEvent(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { + VERTEX v = {event->x, event->y}; + + switch(event->type) { + case GDK_BUTTON_PRESS: + switch(event->button) { + case 1: + switch(getEditMode()) { + case EDIT_MODE_VIEW: + case EDIT_MODE_SELECTED: + setActiveRoom(getHoveredRoom()); + + updateSidebar(); + + redraw(); + + break; + case EDIT_MODE_ADD: + viewToImage(&v); + + if(isVertexOk(&v)) { + addVertex(&getActiveRoom()->polygon, &v); + updateSidebar(); + } + } + + gtk_widget_queue_draw(drawingArea); + } + } + + return FALSE; +} + +gboolean crossingNotifyEvent(GtkWidget *widget, GdkEventCrossing *event, gpointer user_data) { + VERTEX v; + + + switch(event->type) { + case GDK_ENTER_NOTIFY: + v.x = event->x; + v.y = event->y; + + viewToImage(&v); + + setHoveredVertex(&v); + + break; + case GDK_LEAVE_NOTIFY: + setHoveredVertex(NULL); + } + + + gtk_widget_queue_draw(drawingArea); +} + +gboolean motionNotifyEvent(GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { + VERTEX v; + ROOM *last = getHoveredRoom(); + + v.x = event->x; + v.y = event->y; + + viewToImage(&v); + + setHoveredVertex(&v); + + if(getHoveredRoom() != last || getEditMode() == EDIT_MODE_ADD) + gtk_widget_queue_draw(drawingArea); +} + +static void destroy(GtkWidget *widget, gpointer data) { + gtk_main_quit(); +} + +static void refreshScrolling() { + if(getImageWidth() < drawingArea->allocation.width) + setXTranslate((getImageWidth()-drawingArea->allocation.width)/2); + else + setXTranslate(gtk_adjustment_get_value(hAdjustment)); + + if(getImageHeight() < drawingArea->allocation.height) + setYTranslate((getImageHeight()-drawingArea->allocation.height)/2); + else + setYTranslate(gtk_adjustment_get_value(vAdjustment)); + + gtk_widget_queue_draw(drawingArea); +} + +static void updateScrollbars(double x, double y) { + const gdouble imageWidth = getImageWidth(), imageHeight = getImageHeight(); + const gdouble width = drawingArea->allocation.width, height = drawingArea->allocation.height; + gdouble upper, pageSize, value; + + gdk_window_freeze_updates(drawingArea->window); + + g_object_get(G_OBJECT(hAdjustment), "upper", &upper, "page_size", &pageSize, NULL); + g_object_set(G_OBJECT(hAdjustment), "upper", imageWidth, "page_size", width, NULL); + gtk_adjustment_changed(hAdjustment); + + if((pageSize > upper && width < imageWidth) || upper == 0) + value = (imageWidth-width)/2; + else + value = (gtk_adjustment_get_value(hAdjustment)+pageSize*x)/upper*imageWidth-width*x; + gtk_adjustment_set_value(hAdjustment, MAX(MIN(value, imageWidth-width), 0)); + + g_object_get(G_OBJECT(vAdjustment), "upper", &upper, "page_size", &pageSize, NULL); + g_object_set(G_OBJECT(vAdjustment), "upper", imageHeight, "page_size", height, NULL); + gtk_adjustment_changed(vAdjustment); + + if((pageSize > upper && height < imageHeight) || upper == 0) + value = (imageHeight-height)/2; + else + value = (gtk_adjustment_get_value(vAdjustment)+pageSize*y)/upper*imageHeight-height*y; + gtk_adjustment_set_value(vAdjustment, MAX(MIN(value, imageHeight-height), 0)); + + gdk_window_thaw_updates(drawingArea->window); + + refreshScrolling(); +} + +static void updateScrollbarsCentered() { + updateScrollbars(0.5, 0.5); +} + +static void sidebarNameChanged(GtkEditable *editable, gpointer user_data) { + if(getActiveRoom() == NULL) return; + + free(getActiveRoom()->name); + getActiveRoom()->name = strdup(gtk_entry_get_text(GTK_ENTRY(entryName))); +} + +static void sidebarButtonClicked(GtkButton *button, gpointer user_data) { + if(button == GTK_BUTTON(buttonAdd)) { + startAddMode(); + updateSidebar(); + + gtk_widget_queue_draw(drawingArea); + } + else if(button == GTK_BUTTON(buttonAddDo)) { + if(getActiveRoom() &&getActiveRoom()->polygon.nVertices > 2 && isPolygonOk(&getActiveRoom()->polygon)) { + addRoom(getLevel(), getActiveRoom()); + setActiveRoom(&getLevel()->rooms[getLevel()->nRooms-1]); + } + + endAddMode(); + updateSidebar(); + + gtk_widget_queue_draw(drawingArea); + } +} + +static GtkWidget* createSidebar() { + GtkWidget *sidebar, *labelRoomInfo, *labelName; + GtkWidget *tableRoomData, *labelAreaLabel, *labelPerimeterLabel; + + sidebar = gtk_hbox_new(FALSE, 0); + + // View sidebar + sidebarView = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(sidebar), sidebarView, FALSE, FALSE, 5); + + labelRoomInfo = gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(labelRoomInfo), "Room info:"); + gtk_misc_set_alignment(GTK_MISC(labelRoomInfo), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(sidebarView), labelRoomInfo, FALSE, FALSE, 5); + + gtk_box_pack_start(GTK_BOX(sidebarView), gtk_hseparator_new(), FALSE, FALSE, 5); + + labelName = gtk_label_new("Name:"); + gtk_misc_set_alignment(GTK_MISC(labelName), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(sidebarView), labelName, FALSE, FALSE, 0); + + entryName = gtk_entry_new(); + gtk_widget_set_sensitive(entryName, FALSE); + g_signal_connect(G_OBJECT(entryName), "changed", G_CALLBACK(sidebarNameChanged), NULL); + gtk_box_pack_start(GTK_BOX(sidebarView), entryName, FALSE, FALSE, 0); + + tableRoomData = gtk_table_new(2, 2, FALSE); + gtk_table_set_row_spacings(GTK_TABLE(tableRoomData), 5); + gtk_table_set_col_spacings(GTK_TABLE(tableRoomData), 10); + gtk_box_pack_start(GTK_BOX(sidebarView), tableRoomData, FALSE, FALSE, 5); + + labelAreaLabel = gtk_label_new("Room area:"); + gtk_misc_set_alignment(GTK_MISC(labelAreaLabel), 0.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelAreaLabel, 0, 1, 0, 1); + + labelArea = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(labelArea), 1.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelArea, 1, 2, 0, 1); + + labelPerimeterLabel = gtk_label_new("Room perimeter:"); + gtk_misc_set_alignment(GTK_MISC(labelPerimeterLabel), 0.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelPerimeterLabel, 0, 1, 1, 2); + + labelPerimeter = gtk_label_new(NULL); + gtk_misc_set_alignment(GTK_MISC(labelPerimeter), 1.0, 0.5); + gtk_table_attach_defaults(GTK_TABLE(tableRoomData), labelPerimeter, 1, 2, 1, 2); + + buttonAdd = gtk_button_new_with_label("Add room"); + g_signal_connect(G_OBJECT(buttonAdd), "clicked", G_CALLBACK(sidebarButtonClicked), NULL); + gtk_box_pack_end(GTK_BOX(sidebarView), buttonAdd, FALSE, FALSE, 0); + + // Add sidebar + sidebarAdd = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(sidebar), sidebarAdd, FALSE, FALSE, 5); + + labelRoomInfo = gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(labelRoomInfo), "Add room"); + gtk_misc_set_alignment(GTK_MISC(labelRoomInfo), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(sidebarAdd), labelRoomInfo, FALSE, FALSE, 5); + + buttonAddDo = gtk_button_new_with_label("Add room"); + g_signal_connect(G_OBJECT(buttonAddDo), "clicked", G_CALLBACK(sidebarButtonClicked), NULL); + gtk_box_pack_end(GTK_BOX(sidebarAdd), buttonAddDo, FALSE, FALSE, 0); + + return sidebar; +} + +GtkWidget* createMainWindow() { + GtkWidget *window, *hPaned, *vbox, *table, *vScroll, *hScroll, *sidebar; + GdkColor color = {0, 0, 0, 0}; + + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(window), 640, 480); + g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(deleteEvent), NULL); + g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL); + + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(window), vbox); + + gtk_box_pack_start(GTK_BOX(vbox), getMenu(), FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), getToolbar(), FALSE, FALSE, 0); + + gtk_window_add_accel_group(GTK_WINDOW(window), getAccels()); + + hPaned = gtk_hpaned_new(); + gtk_box_pack_end(GTK_BOX(vbox), hPaned, TRUE, TRUE, 0); + + table = gtk_table_new(2, 2, FALSE); + gtk_paned_pack1(GTK_PANED(hPaned), table, TRUE, TRUE); + + drawingArea = gtk_drawing_area_new(); + gtk_widget_modify_bg(drawingArea, (GtkStateType)GTK_WIDGET_STATE(drawingArea), &color); + g_signal_connect(G_OBJECT(drawingArea), "configure-event", G_CALLBACK(updateScrollbarsCentered), NULL); + g_signal_connect(G_OBJECT(drawingArea), "expose-event", G_CALLBACK(drawTopView), NULL); + g_signal_connect(G_OBJECT(drawingArea), "button-press-event", G_CALLBACK(buttonEvent), NULL); + g_signal_connect(G_OBJECT(drawingArea), "button-release-event", G_CALLBACK(buttonEvent), NULL); + g_signal_connect(G_OBJECT(drawingArea), "enter-notify-event", G_CALLBACK(crossingNotifyEvent), NULL); + g_signal_connect(G_OBJECT(drawingArea), "leave-notify-event", G_CALLBACK(crossingNotifyEvent), NULL); + g_signal_connect(G_OBJECT(drawingArea), "motion-notify-event", G_CALLBACK(motionNotifyEvent), NULL); + g_signal_connect(G_OBJECT(drawingArea), "scroll-event", G_CALLBACK(scrollEvent), NULL); + gtk_widget_add_events(drawingArea, GDK_SCROLL_MASK | GDK_POINTER_MOTION_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); + gtk_table_attach(GTK_TABLE(table), drawingArea, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL|GTK_EXPAND|GTK_SHRINK), (GtkAttachOptions)(GTK_FILL|GTK_EXPAND|GTK_SHRINK), 0, 0); + + hAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 0, 10, 100, 100)); + hScroll = gtk_hscrollbar_new(hAdjustment); + g_signal_connect(G_OBJECT(hScroll), "value-changed", G_CALLBACK(refreshScrolling), NULL); + gtk_table_attach(GTK_TABLE(table), hScroll, 0, 1, 1, 2, (GtkAttachOptions)(GTK_FILL|GTK_EXPAND|GTK_SHRINK), (GtkAttachOptions)0, 0, 0); + + vAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 0, 10, 100, 100)); + vScroll = gtk_vscrollbar_new(vAdjustment); + g_signal_connect(G_OBJECT(vScroll), "value-changed", G_CALLBACK(refreshScrolling), NULL); + gtk_table_attach(GTK_TABLE(table), vScroll, 1, 2, 0, 1, (GtkAttachOptions)0, (GtkAttachOptions)(GTK_FILL|GTK_EXPAND|GTK_SHRINK), 0, 0); + + sidebar = createSidebar(); + gtk_paned_pack2(GTK_PANED(hPaned), sidebar, FALSE, TRUE); + + gtk_widget_show_all(vbox); + gtk_widget_hide(sidebarAdd); + + return window; +} + +void updateSidebar() { + gchar *string; + + switch(getEditMode()) { + case EDIT_MODE_VIEW: + case EDIT_MODE_SELECTED: + gtk_widget_hide(sidebarAdd); + gtk_widget_show(sidebarView); + + if(getActiveRoom()) { + gtk_entry_set_text(GTK_ENTRY(entryName), getActiveRoom()->name); + gtk_widget_set_sensitive(entryName, TRUE); + + string = g_strdup_printf("%.2f", polygonArea(&getActiveRoom()->polygon)); + gtk_label_set_text(GTK_LABEL(labelArea), string); + g_free(string); + + string = g_strdup_printf("%.2f", polygonPerimeter(&getActiveRoom()->polygon)); + gtk_label_set_text(GTK_LABEL(labelPerimeter), string); + g_free(string); + } + else { + gtk_entry_set_text(GTK_ENTRY(entryName), ""); + gtk_widget_set_sensitive(entryName, FALSE); + + gtk_label_set_text(GTK_LABEL(labelArea), NULL); + gtk_label_set_text(GTK_LABEL(labelPerimeter), NULL); + } + + break; + case EDIT_MODE_ADD: + gtk_widget_hide(sidebarView); + gtk_widget_show(sidebarAdd); + + if(getActiveRoom()) { + if(getActiveRoom()->polygon.nVertices > 2 && isPolygonOk(&getActiveRoom()->polygon)) + gtk_widget_set_sensitive(buttonAddDo, TRUE); + else + gtk_widget_set_sensitive(buttonAddDo, FALSE); + } + } +} + +void zoomIn(double factor, double x, double y) { + setScale(getScale()*factor); + updateScrollbars(x, y); +} + +void zoomOut(double factor, double x, double y) { + setScale(getScale()/factor); + updateScrollbars(x, y); +} + +void zoomInCentered(double factor) { + zoomIn(factor, 0.5, 0.5); +} + +void zoomOutCentered(double factor) { + zoomOut(factor, 0.5, 0.5); +} diff --git a/zoomedit.c b/zoomedit.c deleted file mode 100644 index 5cce048..0000000 --- a/zoomedit.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include "level.h" -#include "window.h" - - -int main(int argc, char *argv[]) { - LEVEL *lvl = calloc(1, sizeof(LEVEL)); - GtkWidget *window; - - - setLevel(lvl); - - gtk_init(&argc, &argv); - - window = createMainWindow(); - - gtk_widget_show(window); - - gtk_main(); - - freeLevel(lvl); - - return 0; -} diff --git a/zoomedit.cpp b/zoomedit.cpp new file mode 100644 index 0000000..a38dc3b --- /dev/null +++ b/zoomedit.cpp @@ -0,0 +1,24 @@ +#include +#include +#include "level.h" +#include "window.h" + + +int main(int argc, char *argv[]) { + LEVEL *lvl = (LEVEL*)calloc(1, sizeof(LEVEL)); + GtkWidget *window; + + setLevel(lvl); + + gtk_init(&argc, &argv); + + window = createMainWindow(); + + gtk_widget_show(window); + + gtk_main(); + + freeLevel(lvl); + + return 0; +} -- cgit v1.2.3