diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile.am | 19 | ||||
-rw-r--r-- | Makefile.in | 131 | ||||
-rw-r--r-- | data/geomatic.ui | 28 | ||||
-rw-r--r-- | data/hdfsee.ui (renamed from data/displaywindow.ui) | 0 | ||||
-rw-r--r-- | src/cell.c | 60 | ||||
-rw-r--r-- | src/cell.h | 2 | ||||
-rw-r--r-- | src/detector.c | 20 | ||||
-rw-r--r-- | src/detector.h | 1 | ||||
-rw-r--r-- | src/displaywindow.c | 2 | ||||
-rw-r--r-- | src/dw-geomatic.c | 801 | ||||
-rw-r--r-- | src/dw-geomatic.h | 68 | ||||
-rw-r--r-- | src/geomatic.c | 81 | ||||
-rw-r--r-- | src/indexamajig.c | 10 | ||||
-rw-r--r-- | src/templates.c | 60 |
15 files changed, 1139 insertions, 145 deletions
@@ -21,5 +21,6 @@ src/reintegrate src/estimate_background src/check_hkl src/sum_stack +src/geomatic src/.dirstamp *~ diff --git a/Makefile.am b/Makefile.am index 8ecce78b..52b842b1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,7 +12,7 @@ noinst_PROGRAMS = tests/list_check TESTS = tests/list_check if HAVE_GTK -bin_PROGRAMS += src/hdfsee +bin_PROGRAMS += src/hdfsee src/geomatic endif if HAVE_CAIRO @@ -53,6 +53,11 @@ if HAVE_GTK src_hdfsee_SOURCES = src/hdfsee.c src/displaywindow.c src/render.c \ src/hdf5-file.c src/utils.c src/image.c src/filters.c \ src/thread-pool.c + +src_geomatic_SOURCES = src/geomatic.c src/dw-geomatic.c src/render.c \ + src/hdf5-file.c src/utils.c src/image.c src/filters.c \ + src/thread-pool.c src/cell.c src/reflist.c src/geometry.c \ + src/peaks.c src/detector.c endif src_get_hkl_SOURCES = src/get_hkl.c src/sfac.c src/cell.c src/utils.c \ @@ -117,21 +122,21 @@ EXTRA_DIST += src/cell.h src/hdf5-file.h src/image.h src/utils.h \ src/index.h src/filters.h src/diffraction-gpu.h src/cl-utils.h \ src/symmetry.h src/povray.h src/index-priv.h src/geometry.h \ src/templates.h src/render_hkl.h src/stream.h src/thread-pool.h \ - src/beam-parameters.h src/post-refinement.h src/hrs-scaling.h - -hdfseedir = $(datadir)/hdfsee -hdfsee_DATA = data/displaywindow.ui + src/beam-parameters.h src/post-refinement.h src/hrs-scaling.h \ + src/dw-geomatic.h crystfeldir = $(datadir)/crystfel crystfel_DATA = data/diffraction.cl data/defs.h data/sfac/Ca.nff \ data/sfac/C.nff data/sfac/Fe.nff data/sfac/H.nff \ data/sfac/Mg.nff data/sfac/N.nff data/sfac/O.nff \ - data/sfac/P.nff data/sfac/S.nff data/sfac/f0_WaasKirf.dat + data/sfac/P.nff data/sfac/S.nff data/sfac/f0_WaasKirf.dat \ + data/hdfsee.ui data/geomatic.ui EXTRA_DIST += data/sfac/Ca.nff data/sfac/C.nff data/sfac/Fe.nff \ data/sfac/H.nff data/sfac/Mg.nff data/sfac/N.nff data/sfac/O.nff \ data/sfac/P.nff data/sfac/S.nff data/sfac/f0_WaasKirf.dat \ - data/defs.h data/diffraction.cl data/displaywindow.ui + data/defs.h data/diffraction.cl data/hdfsee.ui \ + data/geomatic.ui crystfeldocdir = $(docdir) crystfeldoc_DATA = doc/geometry.txt doc/indexamajig.txt doc/pattern_sim.txt \ diff --git a/Makefile.in b/Makefile.in index e1f68a5c..588c3418 100644 --- a/Makefile.in +++ b/Makefile.in @@ -44,7 +44,7 @@ bin_PROGRAMS = src/pattern_sim$(EXEEXT) src/process_hkl$(EXEEXT) \ src/sum_stack$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2) noinst_PROGRAMS = tests/list_check$(EXEEXT) TESTS = tests/list_check$(EXEEXT) -@HAVE_GTK_TRUE@am__append_1 = src/hdfsee +@HAVE_GTK_TRUE@am__append_1 = src/hdfsee src/geomatic @HAVE_CAIRO_TRUE@am__append_2 = src/cubeit @HAVE_OPENCL_TRUE@am__append_3 = src/diffraction-gpu.c src/cl-utils.c @HAVE_OPENCL_TRUE@am__append_4 = src/diffraction-gpu.c src/cl-utils.c @@ -74,11 +74,11 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -@HAVE_GTK_TRUE@am__EXEEXT_1 = src/hdfsee$(EXEEXT) +@HAVE_GTK_TRUE@am__EXEEXT_1 = src/hdfsee$(EXEEXT) \ +@HAVE_GTK_TRUE@ src/geomatic$(EXEEXT) @HAVE_CAIRO_TRUE@am__EXEEXT_2 = src/cubeit$(EXEEXT) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(crystfeldir)" \ - "$(DESTDIR)$(crystfeldocdir)" "$(DESTDIR)$(hdfseedir)" \ - "$(DESTDIR)$(scriptdir)" + "$(DESTDIR)$(crystfeldocdir)" "$(DESTDIR)$(scriptdir)" PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) am__dirstamp = $(am__leading_dot)dirstamp am_src_calibrate_detector_OBJECTS = src/calibrate_detector.$(OBJEXT) \ @@ -123,6 +123,20 @@ src_estimate_background_OBJECTS = \ $(am_src_estimate_background_OBJECTS) src_estimate_background_LDADD = $(LDADD) src_estimate_background_DEPENDENCIES = $(top_builddir)/lib/libgnu.a +am__src_geomatic_SOURCES_DIST = src/geomatic.c src/dw-geomatic.c \ + src/render.c src/hdf5-file.c src/utils.c src/image.c \ + src/filters.c src/thread-pool.c src/cell.c src/reflist.c \ + src/geometry.c src/peaks.c src/detector.c +@HAVE_GTK_TRUE@am_src_geomatic_OBJECTS = src/geomatic.$(OBJEXT) \ +@HAVE_GTK_TRUE@ src/dw-geomatic.$(OBJEXT) src/render.$(OBJEXT) \ +@HAVE_GTK_TRUE@ src/hdf5-file.$(OBJEXT) src/utils.$(OBJEXT) \ +@HAVE_GTK_TRUE@ src/image.$(OBJEXT) src/filters.$(OBJEXT) \ +@HAVE_GTK_TRUE@ src/thread-pool.$(OBJEXT) src/cell.$(OBJEXT) \ +@HAVE_GTK_TRUE@ src/reflist.$(OBJEXT) src/geometry.$(OBJEXT) \ +@HAVE_GTK_TRUE@ src/peaks.$(OBJEXT) src/detector.$(OBJEXT) +src_geomatic_OBJECTS = $(am_src_geomatic_OBJECTS) +src_geomatic_LDADD = $(LDADD) +src_geomatic_DEPENDENCIES = $(top_builddir)/lib/libgnu.a am_src_get_hkl_OBJECTS = src/get_hkl.$(OBJEXT) src/sfac.$(OBJEXT) \ src/cell.$(OBJEXT) src/utils.$(OBJEXT) \ src/reflections.$(OBJEXT) src/symmetry.$(OBJEXT) \ @@ -259,16 +273,18 @@ am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(src_calibrate_detector_SOURCES) $(src_check_hkl_SOURCES) \ $(src_compare_hkl_SOURCES) $(src_cubeit_SOURCES) \ - $(src_estimate_background_SOURCES) $(src_get_hkl_SOURCES) \ - $(src_hdfsee_SOURCES) $(src_indexamajig_SOURCES) \ - $(src_partialator_SOURCES) $(src_pattern_sim_SOURCES) \ - $(src_powder_plot_SOURCES) $(src_process_hkl_SOURCES) \ - $(src_reintegrate_SOURCES) $(src_render_hkl_SOURCES) \ - $(src_sum_stack_SOURCES) $(tests_list_check_SOURCES) + $(src_estimate_background_SOURCES) $(src_geomatic_SOURCES) \ + $(src_get_hkl_SOURCES) $(src_hdfsee_SOURCES) \ + $(src_indexamajig_SOURCES) $(src_partialator_SOURCES) \ + $(src_pattern_sim_SOURCES) $(src_powder_plot_SOURCES) \ + $(src_process_hkl_SOURCES) $(src_reintegrate_SOURCES) \ + $(src_render_hkl_SOURCES) $(src_sum_stack_SOURCES) \ + $(tests_list_check_SOURCES) DIST_SOURCES = $(src_calibrate_detector_SOURCES) \ $(src_check_hkl_SOURCES) $(src_compare_hkl_SOURCES) \ $(am__src_cubeit_SOURCES_DIST) \ - $(src_estimate_background_SOURCES) $(src_get_hkl_SOURCES) \ + $(src_estimate_background_SOURCES) \ + $(am__src_geomatic_SOURCES_DIST) $(src_get_hkl_SOURCES) \ $(am__src_hdfsee_SOURCES_DIST) \ $(am__src_indexamajig_SOURCES_DIST) $(src_partialator_SOURCES) \ $(am__src_pattern_sim_SOURCES_DIST) $(src_powder_plot_SOURCES) \ @@ -303,8 +319,7 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -DATA = $(crystfel_DATA) $(crystfeldoc_DATA) $(hdfsee_DATA) \ - $(script_DATA) +DATA = $(crystfel_DATA) $(crystfeldoc_DATA) $(script_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ @@ -559,13 +574,14 @@ EXTRA_DIST = configure m4/gnulib-cache.m4 src/cell.h src/hdf5-file.h \ src/povray.h src/index-priv.h src/geometry.h src/templates.h \ src/render_hkl.h src/stream.h src/thread-pool.h \ src/beam-parameters.h src/post-refinement.h src/hrs-scaling.h \ - data/sfac/Ca.nff data/sfac/C.nff data/sfac/Fe.nff \ - data/sfac/H.nff data/sfac/Mg.nff data/sfac/N.nff \ - data/sfac/O.nff data/sfac/P.nff data/sfac/S.nff \ - data/sfac/f0_WaasKirf.dat data/defs.h data/diffraction.cl \ - data/displaywindow.ui doc/geometry.txt doc/indexamajig.txt \ - doc/pattern_sim.txt doc/process_hkl.txt doc/symmetry.txt \ - doc/twin-calculator.pdf doc/0-INDEX doc/examples/lcls-dec.geom \ + src/dw-geomatic.h data/sfac/Ca.nff data/sfac/C.nff \ + data/sfac/Fe.nff data/sfac/H.nff data/sfac/Mg.nff \ + data/sfac/N.nff data/sfac/O.nff data/sfac/P.nff \ + data/sfac/S.nff data/sfac/f0_WaasKirf.dat data/defs.h \ + data/diffraction.cl data/hdfsee.ui data/geomatic.ui \ + doc/geometry.txt doc/indexamajig.txt doc/pattern_sim.txt \ + doc/process_hkl.txt doc/symmetry.txt doc/twin-calculator.pdf \ + doc/0-INDEX doc/examples/lcls-dec.geom \ doc/examples/lcls-june-r0013-r0128.geom \ doc/examples/lcls-xpp-estimate.geom doc/examples/simple.geom \ scripts/check-near-bragg scripts/double-hit \ @@ -602,6 +618,11 @@ src_indexamajig_SOURCES = src/indexamajig.c src/hdf5-file.c \ @HAVE_GTK_TRUE@ src/hdf5-file.c src/utils.c src/image.c src/filters.c \ @HAVE_GTK_TRUE@ src/thread-pool.c +@HAVE_GTK_TRUE@src_geomatic_SOURCES = src/geomatic.c src/dw-geomatic.c src/render.c \ +@HAVE_GTK_TRUE@ src/hdf5-file.c src/utils.c src/image.c src/filters.c \ +@HAVE_GTK_TRUE@ src/thread-pool.c src/cell.c src/reflist.c src/geometry.c \ +@HAVE_GTK_TRUE@ src/peaks.c src/detector.c + src_get_hkl_SOURCES = src/get_hkl.c src/sfac.c src/cell.c src/utils.c \ src/reflections.c src/symmetry.c src/beam-parameters.c \ src/thread-pool.c @@ -654,13 +675,12 @@ tests_list_check_SOURCES = tests/list_check.c src/reflist.c src/thread-pool.c \ src/utils.c INCLUDES = "-I$(top_srcdir)/data" -hdfseedir = $(datadir)/hdfsee -hdfsee_DATA = data/displaywindow.ui crystfeldir = $(datadir)/crystfel crystfel_DATA = data/diffraction.cl data/defs.h data/sfac/Ca.nff \ data/sfac/C.nff data/sfac/Fe.nff data/sfac/H.nff \ data/sfac/Mg.nff data/sfac/N.nff data/sfac/O.nff \ - data/sfac/P.nff data/sfac/S.nff data/sfac/f0_WaasKirf.dat + data/sfac/P.nff data/sfac/S.nff data/sfac/f0_WaasKirf.dat \ + data/hdfsee.ui data/geomatic.ui crystfeldocdir = $(docdir) crystfeldoc_DATA = doc/geometry.txt doc/indexamajig.txt doc/pattern_sim.txt \ @@ -834,6 +854,18 @@ src/estimate_background.$(OBJEXT): src/$(am__dirstamp) \ src/estimate_background$(EXEEXT): $(src_estimate_background_OBJECTS) $(src_estimate_background_DEPENDENCIES) src/$(am__dirstamp) @rm -f src/estimate_background$(EXEEXT) $(AM_V_CCLD)$(LINK) $(src_estimate_background_OBJECTS) $(src_estimate_background_LDADD) $(LIBS) +src/geomatic.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/dw-geomatic.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/reflist.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/geometry.$(OBJEXT): src/$(am__dirstamp) \ + src/$(DEPDIR)/$(am__dirstamp) +src/peaks.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/geomatic$(EXEEXT): $(src_geomatic_OBJECTS) $(src_geomatic_DEPENDENCIES) src/$(am__dirstamp) + @rm -f src/geomatic$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(src_geomatic_OBJECTS) $(src_geomatic_LDADD) $(LIBS) src/get_hkl.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/beam-parameters.$(OBJEXT): src/$(am__dirstamp) \ @@ -850,7 +882,6 @@ src/hdfsee$(EXEEXT): $(src_hdfsee_OBJECTS) $(src_hdfsee_DEPENDENCIES) src/$(am__ $(AM_V_CCLD)$(LINK) $(src_hdfsee_OBJECTS) $(src_hdfsee_LDADD) $(LIBS) src/indexamajig.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) -src/peaks.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/index.$(OBJEXT): src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/diffraction.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) @@ -859,10 +890,6 @@ src/mosflm.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/templates.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) -src/geometry.$(OBJEXT): src/$(am__dirstamp) \ - src/$(DEPDIR)/$(am__dirstamp) -src/reflist.$(OBJEXT): src/$(am__dirstamp) \ - src/$(DEPDIR)/$(am__dirstamp) src/diffraction-gpu.$(OBJEXT): src/$(am__dirstamp) \ src/$(DEPDIR)/$(am__dirstamp) src/cl-utils.$(OBJEXT): src/$(am__dirstamp) \ @@ -937,8 +964,10 @@ mostlyclean-compile: -rm -f src/diffraction.$(OBJEXT) -rm -f src/dirax.$(OBJEXT) -rm -f src/displaywindow.$(OBJEXT) + -rm -f src/dw-geomatic.$(OBJEXT) -rm -f src/estimate_background.$(OBJEXT) -rm -f src/filters.$(OBJEXT) + -rm -f src/geomatic.$(OBJEXT) -rm -f src/geometry.$(OBJEXT) -rm -f src/get_hkl.$(OBJEXT) -rm -f src/hdf5-file.$(OBJEXT) @@ -985,8 +1014,10 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/diffraction.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dirax.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/displaywindow.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/dw-geomatic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/estimate_background.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/filters.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/geomatic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/geometry.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/get_hkl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/hdf5-file.Po@am__quote@ @@ -1075,26 +1106,6 @@ uninstall-crystfeldocDATA: test -n "$$files" || exit 0; \ echo " ( cd '$(DESTDIR)$(crystfeldocdir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(crystfeldocdir)" && rm -f $$files -install-hdfseeDATA: $(hdfsee_DATA) - @$(NORMAL_INSTALL) - test -z "$(hdfseedir)" || $(MKDIR_P) "$(DESTDIR)$(hdfseedir)" - @list='$(hdfsee_DATA)'; test -n "$(hdfseedir)" || list=; \ - for p in $$list; do \ - if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; \ - done | $(am__base_list) | \ - while read files; do \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(hdfseedir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(hdfseedir)" || exit $$?; \ - done - -uninstall-hdfseeDATA: - @$(NORMAL_UNINSTALL) - @list='$(hdfsee_DATA)'; test -n "$(hdfseedir)" || list=; \ - files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ - test -n "$$files" || exit 0; \ - echo " ( cd '$(DESTDIR)$(hdfseedir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(hdfseedir)" && rm -f $$files install-scriptDATA: $(script_DATA) @$(NORMAL_INSTALL) test -z "$(scriptdir)" || $(MKDIR_P) "$(DESTDIR)$(scriptdir)" @@ -1524,7 +1535,7 @@ check: check-recursive all-am: Makefile $(PROGRAMS) $(DATA) config.h installdirs: installdirs-recursive installdirs-am: - for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(crystfeldir)" "$(DESTDIR)$(crystfeldocdir)" "$(DESTDIR)$(hdfseedir)" "$(DESTDIR)$(scriptdir)"; do \ + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(crystfeldir)" "$(DESTDIR)$(crystfeldocdir)" "$(DESTDIR)$(scriptdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive @@ -1581,7 +1592,7 @@ info: info-recursive info-am: install-data-am: install-crystfelDATA install-crystfeldocDATA \ - install-hdfseeDATA install-scriptDATA + install-scriptDATA install-dvi: install-dvi-recursive @@ -1629,8 +1640,7 @@ ps: ps-recursive ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-crystfelDATA \ - uninstall-crystfeldocDATA uninstall-hdfseeDATA \ - uninstall-scriptDATA + uninstall-crystfeldocDATA uninstall-scriptDATA .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check-am \ ctags-recursive install-am install-strip tags-recursive @@ -1646,15 +1656,14 @@ uninstall-am: uninstall-binPROGRAMS uninstall-crystfelDATA \ install-binPROGRAMS install-crystfelDATA \ install-crystfeldocDATA install-data install-data-am \ install-dvi install-dvi-am install-exec install-exec-am \ - install-hdfseeDATA install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-scriptDATA install-strip \ - installcheck installcheck-am installdirs installdirs-am \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ - tags tags-recursive uninstall uninstall-am \ - uninstall-binPROGRAMS uninstall-crystfelDATA \ - uninstall-crystfeldocDATA uninstall-hdfseeDATA \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-scriptDATA install-strip installcheck \ + installcheck-am installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am uninstall-binPROGRAMS \ + uninstall-crystfelDATA uninstall-crystfeldocDATA \ uninstall-scriptDATA diff --git a/data/geomatic.ui b/data/geomatic.ui new file mode 100644 index 00000000..e35b0973 --- /dev/null +++ b/data/geomatic.ui @@ -0,0 +1,28 @@ +<ui> + <menubar name="displaywindow"> + + <menu name="file" action="FileAction"> + <menuitem name="loadgeom" action="LoadGeomAction" /> + <separator /> + <menuitem name="close" action="CloseAction" /> + </menu> + + <menu name="view" action="ViewAction"> + <menuitem name="images" action="ImagesAction" /> + <separator /> + <menuitem name="boostint" action="BoostIntAction" /> + <separator /> + <menuitem name="col" action="ColAction" /> + <menuitem name="monoscale" action="MonoAction" /> + <menuitem name="invmonoscale" action="InvMonoAction" /> + <separator /> + <menuitem name="colscale" action="ColScaleAction" /> + </menu> + + <menu name="help" action="HelpAction"> + <menuitem name="about" action="AboutAction" /> + </menu> + + </menubar> + +</ui> diff --git a/data/displaywindow.ui b/data/hdfsee.ui index 7975ad4f..7975ad4f 100644 --- a/data/displaywindow.ui +++ b/data/hdfsee.ui @@ -938,3 +938,63 @@ void cell_fudge_gslcblas() STATUS("%p\n", cblas_sgemm); } #endif + + +UnitCell *rotate_cell(UnitCell *in, double omega, double phi, double rot) +{ + UnitCell *out; + double asx, asy, asz; + double bsx, bsy, bsz; + double csx, csy, csz; + double xnew, ynew, znew; + + cell_get_reciprocal(in, &asx, &asy, &asz, &bsx, &bsy, + &bsz, &csx, &csy, &csz); + + /* Rotate by "omega" about +z (parallel to c* and c unless triclinic) */ + xnew = asx*cos(omega) + asy*sin(omega); + ynew = -asx*sin(omega) + asy*cos(omega); + znew = asz; + asx = xnew; asy = ynew; asz = znew; + xnew = bsx*cos(omega) + bsy*sin(omega); + ynew = -bsx*sin(omega) + bsy*cos(omega); + znew = bsz; + bsx = xnew; bsy = ynew; bsz = znew; + xnew = csx*cos(omega) + csy*sin(omega); + ynew = -csx*sin(omega) + csy*cos(omega); + znew = csz; + csx = xnew; csy = ynew; csz = znew; + + /* Rotate by "phi" about +x (not parallel to anything specific) */ + xnew = asx; + ynew = asy*cos(phi) + asz*sin(phi); + znew = -asy*sin(phi) + asz*cos(phi); + asx = xnew; asy = ynew; asz = znew; + xnew = bsx; + ynew = bsy*cos(phi) + bsz*sin(phi); + znew = -bsy*sin(phi) + bsz*cos(phi); + bsx = xnew; bsy = ynew; bsz = znew; + xnew = csx; + ynew = csy*cos(phi) + csz*sin(phi); + znew = -csy*sin(phi) + csz*cos(phi); + csx = xnew; csy = ynew; csz = znew; + + /* Rotate by "rot" about the new +z (in-plane rotation) */ + xnew = asx*cos(rot) + asy*sin(rot); + ynew = -asx*sin(rot) + asy*cos(rot); + znew = asz; + asx = xnew; asy = ynew; asz = znew; + xnew = bsx*cos(rot) + bsy*sin(rot); + ynew = -bsx*sin(rot) + bsy*cos(rot); + znew = bsz; + bsx = xnew; bsy = ynew; bsz = znew; + xnew = csx*cos(rot) + csy*sin(rot); + ynew = -csx*sin(rot) + csy*cos(rot); + znew = csz; + csx = xnew; csy = ynew; csz = znew; + + out = cell_new_from_cell(in); + cell_set_reciprocal(out, asx, asy, asz, bsx, bsy, bsz, csx, csy, csz); + + return out; +} @@ -80,6 +80,8 @@ extern double resolution(UnitCell *cell, signed int h, signed int k, signed int l); extern UnitCell *cell_rotate(UnitCell *in, struct quaternion quat); +extern UnitCell *rotate_cell(UnitCell *in, double omega, double phi, + double rot); extern void cell_print(UnitCell *cell); diff --git a/src/detector.c b/src/detector.c index af7b0c0d..154fe660 100644 --- a/src/detector.c +++ b/src/detector.c @@ -214,6 +214,7 @@ struct detector *get_detector_geometry(const char *filename) return NULL; } det->n_panels = -1; + det->panels = NULL; do { @@ -339,7 +340,7 @@ struct detector *get_detector_geometry(const char *filename) if ( det->n_panels == -1 ) { ERROR("No panel descriptions in geometry file.\n"); fclose(fh); - free(det->panels); + if ( det->panels != NULL ) free(det->panels); free(det); return NULL; } @@ -349,56 +350,46 @@ struct detector *get_detector_geometry(const char *filename) max_y = 0; for ( i=0; i<det->n_panels; i++ ) { - STATUS("Panel %i, min_x = %i\n", i, det->panels[i].min_x); if ( det->panels[i].min_x == -1 ) { ERROR("Please specify the minimum x coordinate for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, max_x = %i\n", i, det->panels[i].max_x); if ( det->panels[i].max_x == -1 ) { ERROR("Please specify the maximum x coordinate for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, min_y = %i\n", i, det->panels[i].min_y); if ( det->panels[i].min_y == -1 ) { ERROR("Please specify the minimum y coordinate for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, max_y = %i\n", i, det->panels[i].max_y); if ( det->panels[i].max_y == -1 ) { ERROR("Please specify the maximum y coordinate for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, cx = %f\n", i, det->panels[i].cx); if ( det->panels[i].cx == -1 ) { ERROR("Please specify the centre x coordinate for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, cy = %f\n", i, det->panels[i].cy); if ( det->panels[i].cy == -1 ) { ERROR("Please specify the centre y coordinate for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, clen = %f\n", i, det->panels[i].clen); if ( det->panels[i].clen == -1 ) { ERROR("Please specify the camera length for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, res = %f\n", i, det->panels[i].res); if ( det->panels[i].res == -1 ) { ERROR("Please specify the resolution for" " panel %i\n", i); reject = 1; } - STATUS("Panel %i, badrow direction = %c\n", i, - det->panels[i].badrow); /* It's OK if the badrow direction is '0' */ /* It's not a problem if "no_index" is still zero */ /* The default peak_sep is OK (maybe) */ @@ -431,3 +422,10 @@ out: return det; } + + +void free_detector_geometry(struct detector *det) +{ + free(det->panels); + free(det); +} diff --git a/src/detector.h b/src/detector.h index 63d4d268..8bd537d1 100644 --- a/src/detector.h +++ b/src/detector.h @@ -53,5 +53,6 @@ extern void record_image(struct image *image, int do_poisson); extern struct panel *find_panel(struct detector *det, int x, int y); extern struct detector *get_detector_geometry(const char *filename); +extern void free_detector_geometry(struct detector *det); #endif /* DETECTOR_H */ diff --git a/src/displaywindow.c b/src/displaywindow.c index fbf49f77..c2e94e71 100644 --- a/src/displaywindow.c +++ b/src/displaywindow.c @@ -857,7 +857,7 @@ static void displaywindow_addmenubar(DisplayWindow *dw, GtkWidget *vbox, g_signal_connect(dw->ui, "add_widget", G_CALLBACK(displaywindow_addui_callback), vbox); if ( gtk_ui_manager_add_ui_from_file(dw->ui, - DATADIR"/hdfsee/displaywindow.ui", &error) == 0 ) { + DATADIR"/crystfel/hdfsee.ui", &error) == 0 ) { fprintf(stderr, "Error loading message window menu bar: %s\n", error->message); return; diff --git a/src/dw-geomatic.c b/src/dw-geomatic.c new file mode 100644 index 00000000..c5137e43 --- /dev/null +++ b/src/dw-geomatic.c @@ -0,0 +1,801 @@ +/* + * dw-geomatic.c + * + * GUI geometry calibration + * + * (c) 2006-2011 Thomas White <taw@physics.org> + * + * Part of CrystFEL - crystallography with a FEL + * + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gtk/gtk.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <cairo.h> +#include <gdk-pixbuf/gdk-pixbuf.h> + +#include "dw-geomatic.h" +#include "render.h" +#include "hdf5-file.h" +#include "utils.h" +#include "cell.h" +#include "geometry.h" +#include "peaks.h" + + +static void displaywindow_error(DWGeomatic *dw, const char *message) +{ + GtkWidget *window; + + window = gtk_message_dialog_new(GTK_WINDOW(dw->window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_CLOSE, message); + gtk_window_set_title(GTK_WINDOW(window), "Error"); + + g_signal_connect_swapped(window, "response", + G_CALLBACK(gtk_widget_destroy), window); + gtk_widget_show(window); +} + + +static void displaywindow_update(DWGeomatic *dw) +{ + gint width; + + if ( dw->image != NULL ) { + dw->width = dw->image->width; + dw->height = dw->image->height; + } else { + dw->width = 320; + dw->height = 320; + } + + width = dw->width; + if ( dw->show_col_scale ) width += 20; + + if ( dw->pixbuf != NULL ) { + gdk_pixbuf_unref(dw->pixbuf); + } + if ( dw->image != NULL ) { + dw->pixbuf = render_get_image(dw->image, 1, dw->scale, + dw->boostint); + } else { + dw->pixbuf = NULL; + } + + if ( dw->col_scale != NULL ) { + gdk_pixbuf_unref(dw->col_scale); + } + dw->col_scale = render_get_colour_scale(20, dw->height, dw->scale); + + gdk_window_invalidate_rect(dw->drawingarea->window, NULL, FALSE); +} + + +/* Window closed - clean up */ +static gint displaywindow_closed(GtkWidget *window, DWGeomatic *dw) +{ + if ( dw->hdfile != NULL ) { + hdfile_close(dw->hdfile); + } + + exit(0); /* This program only handles one image at a time */ +} + + +static gboolean displaywindow_expose(GtkWidget *da, GdkEventExpose *event, + DWGeomatic *dw) +{ + cairo_t *cr; + Reflection *refl; + RefListIterator *iter; + + cr = gdk_cairo_create(da->window); + + /* Blank white background */ + cairo_rectangle(cr, 0.0, 0.0, da->allocation.width, + da->allocation.height); + cairo_set_source_rgb(cr, 0.0, 0.0, 1.0); + cairo_fill(cr); + + if ( dw->pixbuf != NULL ) { + gdk_draw_pixbuf(da->window, + da->style->bg_gc[GTK_WIDGET_STATE(da)], + dw->pixbuf, + 0, 0, 0, 0, dw->width, dw->height, + GDK_RGB_DITHER_NONE, 0, 0); + } + + if ( (dw->show_col_scale) && (dw->col_scale != NULL) ) { + gdk_draw_pixbuf(da->window, + da->style->bg_gc[GTK_WIDGET_STATE(da)], + dw->col_scale, + 0, 0, dw->width, 0, 20, dw->height, + GDK_RGB_DITHER_NONE, 0, 0); + } + + if ( dw->image->det != NULL ) { + + RefList *peaks; + UnitCell *rot; + + dw->image->bw = 0.01; + dw->image->div = 0.0; + dw->image->profile_radius = 0.0; + + rot = rotate_cell(dw->cell, dw->pos_x/100000.0, dw->pos_y/100000.0, 0.0); + peaks = find_intersections(dw->image, rot, 0); + cell_free(rot); + + for ( refl = first_refl(peaks, &iter); + refl != NULL; + refl = next_refl(refl, iter) ) { + + double x, y; + + get_detector_pos(refl, &x, &y); + cairo_new_path(cr); + cairo_arc(cr, x, y, 3.0, 0.0, 2.0*M_PI); + cairo_set_source_rgb(cr, 0.0, 0.0, 1.0); + cairo_stroke(cr); + + } + + reflist_free(peaks); + + } + + return FALSE; +} + + +static gint displaywindow_close(GtkWidget *widget, DWGeomatic *dw) +{ + gtk_widget_destroy(dw->window); + return 0; +} + + +static gint displaywindow_set_boostint_response(GtkWidget *widget, + gint response, + DWGeomatic *dw) +{ + int done = 1; + + if ( response == GTK_RESPONSE_OK ) { + + const char *sboostint; + float boostint; + int scanval; + + sboostint = gtk_entry_get_text( + GTK_ENTRY(dw->boostint_dialog->entry)); + scanval = sscanf(sboostint, "%f", &boostint); + if ( (scanval != 1) || (boostint <= 0) ) { + displaywindow_error(dw, "Please enter a positive " + "value for the intensity boost " + "factor."); + done = 0; + } else { + dw->boostint = boostint; + displaywindow_update(dw); + } + } + + if ( done ) { + gtk_widget_destroy(dw->boostint_dialog->window); + } + + return 0; +} + + +static gint displaywindow_set_boostint_destroy(GtkWidget *widget, + DWGeomatic *dw) +{ + free(dw->boostint_dialog); + dw->boostint_dialog = NULL; + return 0; +} + + +static gint displaywindow_set_boostint_response_ac(GtkWidget *widget, + DWGeomatic *dw) +{ + return displaywindow_set_boostint_response(widget, GTK_RESPONSE_OK, dw); +} + + +/* Create a window to ask the user for a new intensity boost factor */ +static gint displaywindow_set_boostint(GtkWidget *widget, DWGeomatic *dw) +{ + struct gmdialog *bd; + GtkWidget *vbox; + GtkWidget *hbox; + GtkWidget *table; + GtkWidget *label; + char tmp[64]; + + if ( dw->boostint_dialog != NULL ) { + return 0; + } + + if ( dw->hdfile == NULL ) { + return 0; + } + + bd = malloc(sizeof(struct gmdialog)); + if ( bd == NULL ) return 0; + dw->boostint_dialog = bd; + + bd->window = gtk_dialog_new_with_buttons("Intensity Boost", + GTK_WINDOW(dw->window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_CANCEL, GTK_RESPONSE_CLOSE, + GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + + vbox = gtk_vbox_new(FALSE, 0); + hbox = gtk_hbox_new(TRUE, 0); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(bd->window)->vbox), + GTK_WIDGET(hbox), FALSE, FALSE, 7); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(vbox), FALSE, FALSE, 5); + + table = gtk_table_new(3, 2, FALSE); + gtk_table_set_row_spacings(GTK_TABLE(table), 5); + gtk_table_set_col_spacings(GTK_TABLE(table), 5); + gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(table), FALSE, FALSE, 0); + + label = gtk_label_new("Boost Factor:"); + gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); + gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(label), + 1, 2, 3, 4); + + bd->entry = gtk_entry_new(); + snprintf(tmp, 63, "%.2f", dw->boostint); + gtk_entry_set_text(GTK_ENTRY(bd->entry), tmp); + gtk_table_attach_defaults(GTK_TABLE(table), GTK_WIDGET(bd->entry), + 2, 3, 3, 4); + + g_signal_connect(G_OBJECT(bd->entry), "activate", + G_CALLBACK(displaywindow_set_boostint_response_ac), + dw); + g_signal_connect(G_OBJECT(bd->window), "response", + G_CALLBACK(displaywindow_set_boostint_response), dw); + g_signal_connect(G_OBJECT(bd->window), "destroy", + G_CALLBACK(displaywindow_set_boostint_destroy), dw); + gtk_window_set_resizable(GTK_WINDOW(bd->window), FALSE); + gtk_widget_show_all(bd->window); + gtk_widget_grab_focus(GTK_WIDGET(bd->entry)); + + return 0; +} + + +static gint displaywindow_about(GtkWidget *widget, DWGeomatic *dw) +{ + GtkWidget *window; + + const gchar *authors[] = { + "Thomas White <taw@physics.org>", + NULL + }; + + window = gtk_about_dialog_new(); + gtk_window_set_transient_for(GTK_WINDOW(window), + GTK_WINDOW(dw->window)); + + gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(window), "geomatic"); + gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(window), PACKAGE_VERSION); + gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(window), + "(c) 2006-2011 Thomas White <taw@physics.org> and others"); + gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(window), + "Quick viewer for HDF files"); + gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(window), + "(c) 2006-2011 Thomas White <taw@physics.org>\n"); + gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(window), + "http://www.bitwiz.org.uk/"); + gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(window), authors); + + g_signal_connect(window, "response", G_CALLBACK(gtk_widget_destroy), + NULL); + + gtk_widget_show_all(window); + + return 0; +} + + +static gint displaywindow_set_colscale(GtkWidget *widget, DWGeomatic *dw) +{ + dw->show_col_scale = 1 - dw->show_col_scale; + displaywindow_update(dw); + return 0; +} + + +static void displaywindow_addui_callback(GtkUIManager *ui, GtkWidget *widget, + GtkContainer *container) +{ + gtk_box_pack_start(GTK_BOX(container), widget, FALSE, FALSE, 0); + + /* Enable overflow menu if this is a toolbar */ + if ( GTK_IS_TOOLBAR(widget) ) { + gtk_toolbar_set_show_arrow(GTK_TOOLBAR(widget), TRUE); + } +} + + +static gint displaywindow_setscale(GtkWidget *widget, GtkRadioAction *action, + DWGeomatic *dw) +{ + switch ( gtk_radio_action_get_current_value(action) ) + { + case 0 : dw->scale = SCALE_COLOUR; break; + case 1 : dw->scale = SCALE_MONO; break; + case 2 : dw->scale = SCALE_INVMONO; break; + } + displaywindow_update(dw); + + return 0; +} + + +static gint displaywindow_loadgeom_response(GtkWidget *d, gint response, + DWGeomatic *dw) +{ + if ( response == GTK_RESPONSE_ACCEPT ) { + + char *file; + struct detector *det; + + file = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(d)); + + det = get_detector_geometry(file); + g_free(file); + + if ( det == NULL ) { + displaywindow_error(dw, "Invalid geometry file"); + return 1; + } + + /* Validate geometry */ + if ( (1+det->max_x != dw->image->width) + || (1+det->max_y != dw->image->height) ) { + + displaywindow_error(dw, + "Geometry does not match image size"); + return 1; + + } else { + + if ( dw->image->det != NULL ) { + free_detector_geometry(dw->image->det); + } + dw->image->det = det; + + displaywindow_update(dw); + } + + } + + gtk_widget_destroy(d); + + return 0; +} + + + +static gint displaywindow_loadgeom(GtkWidget *widget, DWGeomatic *dw) +{ + GtkWidget *d; + + d = gtk_file_chooser_dialog_new("Load Geometry File", + GTK_WINDOW(dw->window), + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + + g_signal_connect(G_OBJECT(d), "response", + G_CALLBACK(displaywindow_loadgeom_response), dw); + + gtk_widget_show_all(d); + + return 0; +} + + +static void displaywindow_addmenubar(DWGeomatic *dw, GtkWidget *vbox, + int colscale) +{ + GError *error = NULL; + GtkActionEntry entries[] = { + + { "FileAction", NULL, "_File", NULL, NULL, NULL }, + { "LoadGeomAction", GTK_STOCK_OPEN, "_Load Geometry", NULL, + NULL, G_CALLBACK(displaywindow_loadgeom) }, + { "CloseAction", GTK_STOCK_CLOSE, "_Close", NULL, NULL, + G_CALLBACK(displaywindow_close) }, + + { "ViewAction", NULL, "_View", NULL, NULL, NULL }, + { "ImagesAction", NULL, "Images", NULL, NULL, NULL }, + { "BoostIntAction", NULL, "Boost Intensity...", "F5", NULL, + G_CALLBACK(displaywindow_set_boostint) }, + + { "HelpAction", NULL, "_Help", NULL, NULL, NULL }, + { "AboutAction", GTK_STOCK_ABOUT, "_About Geomatic...", + NULL, NULL, + G_CALLBACK(displaywindow_about) }, + + }; + guint n_entries = G_N_ELEMENTS(entries); + + GtkToggleActionEntry toggles[] = { + { "ColScaleAction", NULL, "Show Colour Scale", NULL, NULL, + G_CALLBACK(displaywindow_set_colscale), FALSE }, + }; + guint n_toggles = G_N_ELEMENTS(toggles); + GtkRadioActionEntry radios[] = { + { "ColAction", NULL, "Colour", NULL, NULL, + SCALE_COLOUR }, + { "MonoAction", NULL, "Monochrome", NULL, NULL, + SCALE_MONO }, + { "InvMonoAction", NULL, "Inverse Monochrome", NULL, NULL, + SCALE_INVMONO }, + }; + guint n_radios = G_N_ELEMENTS(radios); + + dw->action_group = gtk_action_group_new("geomatic"); + gtk_action_group_add_actions(dw->action_group, entries, n_entries, dw); + gtk_action_group_add_toggle_actions(dw->action_group, toggles, + n_toggles, dw); + gtk_action_group_add_radio_actions(dw->action_group, radios, n_radios, + colscale, + G_CALLBACK(displaywindow_setscale), + dw); + + dw->ui = gtk_ui_manager_new(); + gtk_ui_manager_insert_action_group(dw->ui, dw->action_group, 0); + g_signal_connect(dw->ui, "add_widget", + G_CALLBACK(displaywindow_addui_callback), vbox); + if ( gtk_ui_manager_add_ui_from_file(dw->ui, + DATADIR"/crystfel/geomatic.ui", &error) == 0 ) { + fprintf(stderr, "Error loading message window menu bar: %s\n", + error->message); + return; + } + + gtk_window_add_accel_group(GTK_WINDOW(dw->window), + gtk_ui_manager_get_accel_group(dw->ui)); + gtk_ui_manager_ensure_update(dw->ui); +} + + +struct newhdf { + DWGeomatic *dw; + char name[1024]; +}; + +static gint displaywindow_newhdf(GtkMenuItem *item, struct newhdf *nh) +{ + hdfile_set_image(nh->dw->hdfile, nh->name); + hdf5_read(nh->dw->hdfile, nh->dw->image, 0, 0.0); + gtk_widget_set_size_request(GTK_WIDGET(nh->dw->drawingarea), + nh->dw->image->width, + nh->dw->image->height); + displaywindow_update(nh->dw); + return 0; +} + + +static GtkWidget *displaywindow_addhdfgroup(struct hdfile *hdfile, + const char *group, + DWGeomatic *dw, GSList **rgp) +{ + char **names; + int *is_group; + int *is_image; + GtkWidget *ms; + int n, i; + + if ( hdfile == NULL ) return NULL; + + names = hdfile_read_group(hdfile, &n, group, &is_group, &is_image); + if ( n == 0 ) return NULL; + + ms = gtk_menu_new(); + + for ( i=0; i<n; i++ ) { + + GtkWidget *item; + GtkWidget *sub; + + if ( names[i] == NULL ) return NULL; + + if ( is_group[i] ) { + + item = gtk_menu_item_new_with_label(names[i]); + + sub = displaywindow_addhdfgroup(hdfile, names[i], + dw, rgp); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), sub); + + } else if ( is_image[i] ) { + + struct newhdf *nh; + + item = gtk_radio_menu_item_new_with_label(*rgp, + names[i]); + + if ( *rgp == NULL ) { + gtk_check_menu_item_set_active( + GTK_CHECK_MENU_ITEM(item), TRUE); + } else { + gtk_check_menu_item_set_active( + GTK_CHECK_MENU_ITEM(item), FALSE); + } + + *rgp = gtk_radio_menu_item_get_group( + GTK_RADIO_MENU_ITEM(item)); + + nh = malloc(sizeof(struct newhdf)); + if ( nh != NULL ) { + strncpy(nh->name, names[i], 1023); + nh->dw = dw; + g_signal_connect(G_OBJECT(item), "activate", + G_CALLBACK(displaywindow_newhdf), nh); + } + + } else { + + char *tmp; + + item = gtk_menu_item_new_with_label(names[i]); + + tmp = hdfile_get_string_value(hdfile, names[i]); + if ( tmp != NULL ) { + + GtkWidget *ss; + GtkWidget *mss; + + mss = gtk_menu_new(); + ss = gtk_menu_item_new_with_label(tmp); + gtk_widget_set_sensitive(ss, FALSE); + gtk_menu_shell_append(GTK_MENU_SHELL(mss), ss); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), + mss); + + } + + + } + + gtk_menu_shell_append(GTK_MENU_SHELL(ms), item); + + free(names[i]); + + + } + + free(is_group); + free(is_image); + + return ms; +} + + +static GtkWidget *displaywindow_createhdfmenus(struct hdfile *hdfile, + DWGeomatic *dw) +{ + GSList *rg = NULL; + + return displaywindow_addhdfgroup(hdfile, "/", dw, &rg); +} + + +static void displaywindow_update_menus(DWGeomatic *dw) +{ + GtkWidget *ms; + GtkWidget *w; + + ms = displaywindow_createhdfmenus(dw->hdfile, dw); + + if ( ms == NULL ) { + + /* Too bad. You'd better hope that /data/data exists... */ + ERROR("Couldn't get list of images in HDF file\n"); + w = gtk_ui_manager_get_widget(dw->ui, + "/ui/displaywindow/view/images"); + gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE); + + /* Add a dummy menu so that the user knows what's going on */ + ms = gtk_menu_new(); + w = gtk_ui_manager_get_widget(dw->ui, + "/ui/displaywindow/view/images"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(w), ms); + + return; + + } + + /* Make new menu be the submenu for File->Images */ + w = gtk_ui_manager_get_widget(dw->ui, "/ui/displaywindow/view/images"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(w), ms); + + gtk_widget_show_all(ms); +} + + +static gint displaywindow_release(GtkWidget *widget, GdkEventButton *event, + DWGeomatic *dw) +{ + if ( (event->type == GDK_BUTTON_RELEASE) && (event->button == 1) ) { + + g_signal_handler_disconnect(GTK_OBJECT(dw->drawingarea), + dw->motion_callback); + dw->motion_callback = 0; + + } + + return 0; +} + + +static gint displaywindow_motion(GtkWidget *widget, GdkEventMotion *event, + DWGeomatic *dw) +{ + double x, y; + + x = event->x - dw->motion_origx; + y = event->y - dw->motion_origy; + + dw->pos_x += x; + dw->pos_y += y; + + /* Schedule redraw */ + gtk_widget_queue_draw_area(dw->drawingarea, 0, 0, + dw->width, dw->height); + + return 0; +} + + +static gint displaywindow_press(GtkWidget *widget, GdkEventButton *event, + DWGeomatic *dw) +{ + if ( dw->motion_callback != 0 ) { + return 0; + } + + if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) ) { + + dw->motion_origx = event->x; + dw->motion_origy = event->y; + + /* Connect motion callback */ + dw->motion_callback = g_signal_connect( + GTK_OBJECT(dw->drawingarea), + "motion-notify-event", + G_CALLBACK(displaywindow_motion), + dw); + + } + + return 0; + +} + + +DWGeomatic *geomatic_open(const char *filename) +{ + DWGeomatic *dw; + char *title; + GtkWidget *vbox; + GtkWidget *sw; + int wr, hr; + + dw = calloc(1, sizeof(DWGeomatic)); + if ( dw == NULL ) return NULL; + dw->pixbuf = NULL; + dw->show_col_scale = 0; + dw->col_scale = NULL; + dw->boostint_dialog = NULL; + dw->boostint = 1; + dw->motion_callback = 0; + dw->image = NULL; + dw->scale = SCALE_COLOUR; + dw->pos_x = 0.0; + dw->pos_y = 0.0; + dw->pos_z = 0.0; + + dw->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + + if ( filename == NULL ) { + title = strdup("No file - geomatic"); + } else { + char *bn = safe_basename(filename); + title = malloc(strlen(bn)+14); + sprintf(title, "%s - geomatic", bn); + free(bn); + } + gtk_window_set_title(GTK_WINDOW(dw->window), title); + free(title); + + g_signal_connect(G_OBJECT(dw->window), "destroy", + G_CALLBACK(displaywindow_closed), dw); + + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(dw->window), vbox); + displaywindow_addmenubar(dw, vbox, dw->scale); + + /* Open the file, if any */ + if ( filename != NULL ) { + + dw->hdfile = hdfile_open(filename); + if ( dw->hdfile == NULL ) { + ERROR("Couldn't open file '%s'\n", filename); + return NULL; + } else if ( hdfile_set_first_image(dw->hdfile, "/") ) { + ERROR("Couldn't select path\n"); + return NULL; + } else { + dw->image = calloc(1, sizeof(struct image)); + hdf5_read(dw->hdfile, dw->image, 0, 0.0); + } + + } else { + return NULL; + } + + dw->drawingarea = gtk_drawing_area_new(); + gtk_widget_set_size_request(GTK_WIDGET(dw->drawingarea), + dw->image->width, + dw->image->height); + sw = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), + dw->drawingarea); + gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 0); + + wr = dw->image->width; + hr = dw->image->height; + if ( wr > 640 ) wr = 640; + if ( hr > 640 ) hr = 640; + gtk_widget_set_size_request(GTK_WIDGET(dw->window), wr, hr); + + g_signal_connect(GTK_OBJECT(dw->drawingarea), "expose-event", + G_CALLBACK(displaywindow_expose), dw); + + gtk_window_set_resizable(GTK_WINDOW(dw->window), TRUE); + gtk_widget_show_all(dw->window); + + dw->cell = load_cell_from_pdb("1JB0.pdb"); + + dw->boostint = 1.0; + displaywindow_update(dw); + + gtk_widget_add_events(GTK_WIDGET(dw->drawingarea), + GDK_BUTTON_PRESS_MASK + | GDK_BUTTON_RELEASE_MASK + | GDK_BUTTON1_MOTION_MASK); + g_object_set(G_OBJECT(dw->drawingarea), "can-focus", TRUE, NULL); + + g_signal_connect(GTK_OBJECT(dw->drawingarea), "button-press-event", + G_CALLBACK(displaywindow_press), dw); + g_signal_connect(GTK_OBJECT(dw->drawingarea), "button-release-event", + G_CALLBACK(displaywindow_release), dw); + + if ( dw->hdfile != NULL ) displaywindow_update_menus(dw); + + return dw; +} diff --git a/src/dw-geomatic.h b/src/dw-geomatic.h new file mode 100644 index 00000000..0482d26c --- /dev/null +++ b/src/dw-geomatic.h @@ -0,0 +1,68 @@ +/* + * dw-geomatic.h + * + * GUI geometry calibration + * + * (c) 2006-2011 Thomas White <taw@physics.org> + * + * Part of CrystFEL - crystallography with a FEL + * + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifndef DW_GEOMATIC_H +#define DW_GEOMATIC_H + +#include <gtk/gtk.h> + +#include "cell.h" +#include "reflist.h" + + +struct gmdialog { + GtkWidget *window; + GtkWidget *entry; +}; + + +typedef struct { + + GtkWidget *window; + GtkWidget *drawingarea; + GtkUIManager *ui; + GtkActionGroup *action_group; + GdkPixbuf *pixbuf; + gulong motion_callback; + + struct hdfile *hdfile; + struct image *image; + int width; + int height; + double boostint; + + /* Dialog boxes */ + struct gmdialog *boostint_dialog; + + int show_col_scale; + int scale; + GdkPixbuf *col_scale; + + double motion_origx; + double motion_origy; + + UnitCell *cell; + double pos_x; + double pos_y; + double pos_z; + +} DWGeomatic; + +/* Return an image display window showing the given filename, or NULL */ +extern DWGeomatic *geomatic_open(const char *filename); + + +#endif /* DW_GEOMATICs_H */ diff --git a/src/geomatic.c b/src/geomatic.c new file mode 100644 index 00000000..94975c25 --- /dev/null +++ b/src/geomatic.c @@ -0,0 +1,81 @@ +/* + * geomatic.c + * + * GUI geometry calibration + * + * (c) 2006-2011 Thomas White <taw@physics.org> + * + * Part of CrystFEL - crystallography with a FEL + * + */ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gtk/gtk.h> +#include <getopt.h> + +#include "dw-geomatic.h" +#include "utils.h" +#include "render.h" + + +static void show_help(const char *s) +{ + printf("Syntax: %s [options] image.h5\n\n", s); + printf( +"GUI geometry calibration.\n" +"\n" +" -h, --help Display this help message.\n" +"\n"); +} + + +int main(int argc, char *argv[]) +{ + int c; + int nfiles; + + /* Long options */ + const struct option longopts[] = { + {"help", 0, NULL, 'h'}, + {0, 0, NULL, 0} + }; + + gtk_init(&argc, &argv); + + /* Short options */ + while ((c = getopt_long(argc, argv, "hp:b:i:c:", + longopts, NULL)) != -1) { + + switch (c) { + case 'h' : + show_help(argv[0]); + return 0; + + case 0 : + break; + + default : + return 1; + } + + } + + nfiles = argc-optind; + + if ( nfiles < 1 ) { + ERROR("You need to give me a file to open!\n"); + return -1; + } + + if ( geomatic_open(argv[optind]) == NULL ) { + ERROR("Couldn't open display window\n"); + return 1; + } + gtk_main(); + + return 0; +} diff --git a/src/indexamajig.c b/src/indexamajig.c index f1684c8c..6112066c 100644 --- a/src/indexamajig.c +++ b/src/indexamajig.c @@ -400,12 +400,12 @@ static void process_image(void *pp, int cookie) image.div = beam->divergence; image.bw = beam->bandwidth; - image.profile_radius = 0.005e9; + image.profile_radius = 0.0001e9; - reflections = find_intersections(&image, image.indexed_cell, - 0); - //reflections = find_projected_peaks(&image, image.indexed_cell, - // 0, 0.1); + //reflections = find_intersections(&image, image.indexed_cell, + // 0); + reflections = find_projected_peaks(&image, image.indexed_cell, + 0, 0.1); output_intensities(&image, image.indexed_cell, reflections, pargs->static_args.output_mutex, diff --git a/src/templates.c b/src/templates.c index 79e60aec..37188145 100644 --- a/src/templates.c +++ b/src/templates.c @@ -47,66 +47,6 @@ struct template { }; -UnitCell *rotate_cell(UnitCell *in, double omega, double phi, double rot) -{ - UnitCell *out; - double asx, asy, asz; - double bsx, bsy, bsz; - double csx, csy, csz; - double xnew, ynew, znew; - - cell_get_reciprocal(in, &asx, &asy, &asz, &bsx, &bsy, - &bsz, &csx, &csy, &csz); - - /* Rotate by "omega" about +z (parallel to c* and c unless triclinic) */ - xnew = asx*cos(omega) + asy*sin(omega); - ynew = -asx*sin(omega) + asy*cos(omega); - znew = asz; - asx = xnew; asy = ynew; asz = znew; - xnew = bsx*cos(omega) + bsy*sin(omega); - ynew = -bsx*sin(omega) + bsy*cos(omega); - znew = bsz; - bsx = xnew; bsy = ynew; bsz = znew; - xnew = csx*cos(omega) + csy*sin(omega); - ynew = -csx*sin(omega) + csy*cos(omega); - znew = csz; - csx = xnew; csy = ynew; csz = znew; - - /* Rotate by "phi" about +x (not parallel to anything specific) */ - xnew = asx; - ynew = asy*cos(phi) + asz*sin(phi); - znew = -asy*sin(phi) + asz*cos(phi); - asx = xnew; asy = ynew; asz = znew; - xnew = bsx; - ynew = bsy*cos(phi) + bsz*sin(phi); - znew = -bsy*sin(phi) + bsz*cos(phi); - bsx = xnew; bsy = ynew; bsz = znew; - xnew = csx; - ynew = csy*cos(phi) + csz*sin(phi); - znew = -csy*sin(phi) + csz*cos(phi); - csx = xnew; csy = ynew; csz = znew; - - /* Rotate by "rot" about the new +z (in-plane rotation) */ - xnew = asx*cos(rot) + asy*sin(rot); - ynew = -asx*sin(rot) + asy*cos(rot); - znew = asz; - asx = xnew; asy = ynew; asz = znew; - xnew = bsx*cos(rot) + bsy*sin(rot); - ynew = -bsx*sin(rot) + bsy*cos(rot); - znew = bsz; - bsx = xnew; bsy = ynew; bsz = znew; - xnew = csx*cos(rot) + csy*sin(rot); - ynew = -csx*sin(rot) + csy*cos(rot); - znew = csz; - csx = xnew; csy = ynew; csz = znew; - - out = cell_new_from_cell(in); - cell_set_reciprocal(out, asx, asy, asz, bsx, bsy, bsz, csx, csy, csz); - - return out; -} - - /* Generate templates for the given cell using a representative image */ IndexingPrivate *generate_templates(UnitCell *cell, const char *filename, struct detector *det, |