viewmol-2.4.1/0040755000272700027270000000000010145666545011362 5ustar jrhjrhviewmol-2.4.1/source/0040755000272700027270000000000010145666463012661 5ustar jrhjrhviewmol-2.4.1/source/Makefile0100644000272700027270000003202310114362246014302 0ustar jrhjrh#******************************************************************************* # * # Viewmol * # * # M A K E F I L E * # * # Copyright (c) Joerg-R. Hill, October 2003 * # * #******************************************************************************* # # $Id: Makefile,v 1.6 2003/11/07 12:53:50 jrh Exp $ # $Log: Makefile,v $ # Revision 1.6 2003/11/07 12:53:50 jrh # Release 2.4 # # Revision 1.5 2000/12/10 15:36:51 jrh # Release 2.3 # # Revision 1.4 1999/05/24 01:24:15 jrh # Release 2.2.1 # # Revision 1.3 1999/02/07 21:42:47 jrh # Release 2.2 # # Revision 1.1 1996/12/10 18:39:05 jrh # Initial revision # # Do not edit this file - to set machine specific options edit getmachine! # BAGGER = CC = $(COMPILER) -c $(CFLAGS) -I$(INCLUDE) $(OPT) $(BAGGER) CCNOP = $(COMPILER) -c $(CFLAGS) -I$(INCLUDE) $(BAGGER) OBJ = annotate.o atommodule.o balanceform.o basisform.o bondform.o \ bondorder.o build.o calcmo.o cellform.o coledit.o confform.o \ cylinder.o device.o distort.o draw.o drawel.o drawform.o drawop.o \ drawsp.o elementmodule.o ellipse.o energylevelmodule.o feedback.o \ fileselect.o getmem.o getrc.o hardcopy.o historymodule.o hpgl.o \ inert.o infoform.o init.o input.o insint.o intern.o labelmodule.o \ lightmodule.o makemenu.o maketics.o manual.o marcub.o matrix.o \ messgb.o miller.o mkconn.o mkunitc.o mo.o modifygeo.o moform.o \ moleculemodule.o mouseaction.o mousecb.o normod.o optiform.o \ osname.o postscript.o printform.o pseform.o quaternion.o ray.o \ raytrace.o readgrid.o redraw.o resource.o runprog.o runscript.o \ save.o saveform.o shadow.o specform.o spectrummodule.o TabBook.o \ thermo.o thermoform.o viewmol.o viewmolmodule.o waveform.o \ window.o xfont.o zoom.o $(SCANDIR) ALLOBJ = $(OBJ) tm.o bio.o readgamess.o readgauss.o readmopac.o readpdb.o \ readframe.o eof.o scandir.o all : viewmol tm bio readgamess readgauss readmopac readpdb translations; annotate.o : ../annotate.c ../viewmol.h ; $(CC) ../annotate.c atommodule.o : ../atommodule.c ../viewmol.h ../modules.h ; $(CC) ../atommodule.c balanceform.o : ../balanceform.c ../viewmol.h ; $(CC) ../balanceform.c basisform.o : ../basisform.c ../viewmol.h ; $(CC) ../basisform.c bio.o : ../bio.c ; $(CCNOP) ../bio.c bondform.o : ../bondform.c ../viewmol.h ; $(CC) ../bondform.c bondorder.o : ../bondorder.c ../viewmol.h ; $(CC) ../bondorder.c build.o : ../build.c ../viewmol.h ../isotopes.h ; $(CC) ../build.c calcmo.o : ../calcmo.c ../viewmol.h ; $(CC) ../calcmo.c cellform.o : ../cellform.c ../viewmol.h ../dialog.h ; $(CC) ../cellform.c coledit.o : ../coledit.c ../viewmol.h ../dialog.h ; $(CC) ../coledit.c confform.o : ../confform.c ../viewmol.h ../dialog.h ; $(CC) ../confform.c cylinder.o : ../cylinder.c ; $(CC) ../cylinder.c device.o : ../device.c ; $(CC) ../device.c distort.o : ../distort.c ../viewmol.h ; $(CC) ../distort.c draw.o : ../draw.c ../viewmol.h ; $(CC) ../draw.c drawel.o : ../drawel.c ../viewmol.h ; $(CC) ../drawel.c drawform.o : ../drawform.c ../viewmol.h ; $(CC) ../drawform.c drawop.o : ../drawop.c ../viewmol.h ; $(CC) ../drawop.c drawsp.o : ../drawsp.c ../viewmol.h ; $(CC) ../drawsp.c elementmodule.o : ../elementmodule.c ../viewmol.h ../modules.h ; $(CC) ../elementmodule.c ellipse.o : ../ellipse.c ; $(CC) ../ellipse.c energylevelmodule.o : ../energylevelmodule.c ../viewmol.h ../modules.h ; $(CC) ../energylevelmodule.c eof.o : ../eof.c ; $(CC) ../eof.c feedback.o : ../feedback.c ../viewmol.h ; $(CC) ../feedback.c fileselect.o : ../fileselect.c ; $(CC) ../fileselect.c getmem.o : ../getmem.c ; $(CC) ../getmem.c getrc.o : ../getrc.c ../viewmol.h ../isotopes.h ; $(CC) ../getrc.c hardcopy.o : ../hardcopy.c ; $(CC) ../hardcopy.c historymodule.o : ../historymodule.c ../viewmol.h ../modules.h ; $(CC) ../historymodule.c hpgl.o : ../hpgl.c ; $(CC) ../hpgl.c inert.o : ../inert.c ../viewmol.h ; $(CC) ../inert.c infoform.o : ../infoform.c ../dialog.h ; $(CC) ../infoform.c init.o : ../init.c ../viewmol.h ../menudef.h ; $(CC) -DINIT ../init.c input.o : ../input.c ../viewmol.h ; $(CC) ../input.c insint.o : ../insint.c ../viewmol.h ; $(CC) ../insint.c intern.o : ../intern.c ../viewmol.h ; $(CC) ../intern.c labelmodule.o : ../labelmodule.c ../viewmol.h ../modules.h ; $(CC) ../labelmodule.c lightmodule.o : ../lightmodule.c ../viewmol.h ../modules.h ; $(CC) ../lightmodule.c makemenu.o : ../makemenu.c ; $(CC) ../makemenu.c maketics.o : ../maketics.c ; $(CC) ../maketics.c manual.o : ../manual.c ../viewmol.h ; $(CC) ../manual.c marcub.o : ../marcub.c ../marcub.h ; $(CC) ../marcub.c matrix.o : ../matrix.c ; $(CC) ../matrix.c messgb.o : ../messgb.c ../messgb.h ; $(CC) ../messgb.c miller.o : ../miller.c ../viewmol.h ; $(CC) ../miller.c mkconn.o : ../mkconn.c ../viewmol.h ; $(CC) ../mkconn.c mkunitc.o : ../mkunitc.c ../viewmol.h ; $(CC) ../mkunitc.c mo.o : ../mo.c ../viewmol.h ; $(CC) ../mo.c modifygeo.o : ../modifygeo.c ../viewmol.h ; $(CC) ../modifygeo.c moform.o : ../moform.c ../viewmol.h ; $(CC) ../moform.c moleculemodule.o : ../moleculemodule.c ../viewmol.h ../modules.h ; $(CC) ../moleculemodule.c mouseaction.o : ../mouseaction.c ../viewmol.h ; $(CC) ../mouseaction.c mousecb.o : ../mousecb.c ../viewmol.h ; $(CC) ../mousecb.c normod.o : ../normod.c ../viewmol.h ; $(CC) ../normod.c optiform.o : ../optiform.c ../viewmol.h ; $(CC) ../optiform.c osname.o : ../osname.c ; $(CC) ../osname.c postscript.o : ../postscript.c ../viewmol.h ; $(CC) ../postscript.c printform.o : ../printform.c ../viewmol.h ../menu.h ; $(CC) ../printform.c pseform.o : ../pseform.c ../viewmol.h ; $(CC) ../pseform.c quaternion.o : ../quaternion.c ; $(CC) ../quaternion.c ray.o : ../ray.c ../viewmol.h ; $(CC) ../ray.c raytrace.o : ../raytrace.c ../viewmol.h ; $(CC) ../raytrace.c readframe.o : ../readframe.c ; $(CC) ../readframe.c readgrid.o : ../readgrid.c ../viewmol.h ; $(CC) ../readgrid.c readgamess.o : ../readgamess.c ; $(CC) ../readgamess.c readgauss.o : ../readgauss.c ../isotopes.h ; $(CC) ../readgauss.c readmopac.o : ../readmopac.c ; $(CC) ../readmopac.c readpdb.o : ../readpdb.c ; $(CC) ../readpdb.c redraw.o : ../redraw.c ../viewmol.h ; $(CC) ../redraw.c resource.o : ../resource.c ; $(CC) ../resource.c runprog.o : ../runprog.c ; $(CC) ../runprog.c runscript.o : ../runscript.c ../viewmol.h ../dialog.h ; $(CC) ../runscript.c save.o : ../save.c ../viewmol.h ; $(CC) ../save.c saveform.o : ../saveform.c ../viewmol.h ; $(CC) ../saveform.c scandir.o : ../scandir.c ; $(CC) ../scandir.c shadow.o : ../shadow.c ../viewmol.h ; $(CC) ../shadow.c specform.o : ../specform.c ; $(CC) ../specform.c spectrummodule.o : ../spectrummodule.c ../viewmol.h ../modules.h ; $(CC) ../spectrummodule.c TabBook.o : ../TabBook.c ; $(CC) -DMOTIF ../TabBook.c thermo.o : ../thermo.c ../viewmol.h ; $(CC) ../thermo.c thermoform.o : ../thermoform.c ../viewmol.h ; $(CC) ../thermoform.c tm.o : ../tm.c ; $(CC) ../tm.c viewmol.o : ../viewmol.c ../viewmol.h ../fallbacks.h ; $(CC) ../viewmol.c viewmolmodule.o : ../viewmolmodule.c ; $(CC) ../viewmolmodule.c waveform.o : ../waveform.c ../viewmol.h ; $(CC) ../waveform.c window.o : ../window.c ../viewmol.h ; $(CC) ../window.c xdnd.o : ../xdnd.c ../xdnd.h ; $(CC) ../xdnd.c xfont.o : ../xfont.c ; $(CC) ../xfont.c zoom.o : ../zoom.c ../viewmol.h ; $(CC) ../zoom.c viewmol : ; /bin/sh getmachine viewmol viewmol_: $(OBJ) ; $(COMPILER) -o viewmol $(BAGGER) $(LDFLAGS) $(OBJ) $(LIBRARY) $(LIBS) tm : ; /bin/sh getmachine tm tm_ : tm.o readframe.o getmem.o ; $(COMPILER) -o tm $(LDFLAGS) tm.o readframe.o getmem.o -lm bio : ; /bin/sh getmachine bio bio_ : bio.o readframe.o getmem.o ; $(COMPILER) -o bio $(LDFLAGS) bio.o readframe.o getmem.o readgamess: ; /bin/sh getmachine readgamess readgamess_: readgamess.o eof.o getmem.o ; $(COMPILER) -o readgamess $(LDFLAGS) readgamess.o eof.o getmem.o -lm readgauss: ; /bin/sh getmachine readgauss readgauss_: readgauss.o eof.o getmem.o ; $(COMPILER) -o readgauss $(LDFLAGS) readgauss.o eof.o getmem.o readmopac: ; /bin/sh getmachine readmopac readmopac_: readmopac.o eof.o getmem.o ; $(COMPILER) -o readmopac $(LDFLAGS) readmopac.o eof.o getmem.o readpdb: ; /bin/sh getmachine readpdb readpdb_: readpdb.o eof.o ; $(COMPILER) -o readpdb $(LDFLAGS) readpdb.o eof.o translations: ; /bin/sh makeTranslations htmldoc: ; cd ../doc; latex2html -address "Jörg-Rüdiger Hill `date`" -white -no_navigation -html_version "4.0,unicode" -t Viewmol -noinfo viewmol.tex tar : ; tar -cvf viewmol.tar `echo $(ALLOBJ) | sed "s/\.o/\.c/g"` \ Makefile *.h readgulp readdmol* readmol readpqs writecar writemol \ writetm writegauss.py viewmolrc getmachine checkres README* \ bugs scripts locale makeTranslations `find doc -type f -print | grep -v RCS` ; \ gzip -9 viewmol.tar; mv viewmol.tar.gz viewmol.tgz distribution: ; tar -cvzf viewmol.tgz `echo $(ALLOBJ) | sed "s/\.o/\.c/g"` \ Makefile *.h readgulp readdmol* readmol readpqs writecar writemol \ writetm writegauss.py viewmolrc getmachine Xdefaults.* \ doc/html doc/viewmol.pdf doc/viewmol.html snapshot: ; tar -cvf viewmol-`date +'%Y%m%d'`.tar `echo $(ALLOBJ) | sed "s/\.o/\.c/g"` \ Makefile *.h readgulp readdmol readdmol.awk readmol readpqs writecar \ writemol writetm writegauss.py viewmolrc getmachine locale; \ gzip -9 viewmol-`date +'%Y%m%d'`.tar; \ mv viewmol-`date +'%Y%m%d'`.tar.gz viewmol-`date +'%Y%m%d'`.tgz; \ cd web; ./updateWeb clean : ; /bin/sh getmachine clean clean_ : ; rm -f $(ALLOBJ) *.il viewmol-2.4.1/source/TabBook.c0100644000272700027270000010400407752700021014327 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * T A B B O O K . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: TabBook.c,v 1.2 2003/11/07 11:20:49 jrh Exp $ * $Log: TabBook.c,v $ * Revision 1.2 2003/11/07 11:20:49 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:40:30 jrh * Initial revision * */ /* TabBook.h - TabBook widget (Like Motif Notebook) See TabBook documentation Copyright 1996 COMPUTER GENERATION, INC., The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall Computer Generation, inc. nor the author be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Author: Gary Aviv Computer Generation, Inc., gary@compgen.com */ /* ;+ TabBook.c - TabBook widget (Like Motif Notebook) MODULE NAME: $RCSfile: TabBook.c,v $ AUTHOR: $Author: jrh $ FUNCTIONS: Boolean XcgTabBookSetActivePage(Widget w, int page, int option ); int XcgTabBookGetActivePage(Widget w ); Widget XcgTabBookGetActivePageWidget(Widget w); USAGE: See Actual Functions For Description ;- */ /* Revision History: $Log: TabBook.c,v $ Revision 1.2 2003/11/07 11:20:49 jrh Release 2.4 Revision 1.1 2000/12/10 15:40:30 jrh Initial revision Revision 1.3 1997/05/30 12:28:24 gary Guard against realizing with no children Revision 1.2 1997/04/25 16:40:04 gary Chenged default of XcgNanchorChild from XcgANCHOR_NORTHWEST to XcgANCHOR_NORTH Revision 1.1 1997/04/10 18:16:25 jeff Initial revision $log Guard against realizing with no children $log */ #define VERSION "$Revision: 1.2 $" #include #include #include #include #include #ifdef MOTIF #include #include #include #include #else #include #include #endif /* #include #include #include */ #include "TabBookP.h" /* debugging */ #define TRACE_ON(a) fprintf a #define TRACE_OFF(a) #define CheckWidgetClass(routine) \ if (XtClass(w) != xcgTabBookWidgetClass) \ wrong_widget(routine) /* Private Definitions */ static void ResizeAllManagers( TabBookWidget cw ); static void FrameInsideArea(TabBookWidget cw, Boolean erase); static void draw_tab_bottom(TabBookWidget cw , Widget child, Boolean active); static void draw_tab_for_button(TabBookWidget cw , Widget child); static void create_GC(TabBookWidget cw ); static void InsertChild(Widget w); static void ExposeMeth(Widget w, XEvent *event, Region region ); static void ClassInitialize(), ClassPartInitialize(), Initialize(); static void Resize(Widget w); static Boolean ConstraintSetValues(Widget current, Widget request, Widget new, ArgList args,Cardinal *num_args); static Boolean SetValues(Widget current, Widget request, Widget new, ArgList args,Cardinal *num_args); static XtGeometryResult GeometryManager(Widget w,XtWidgetGeometry *request, XtWidgetGeometry *reply); XtGeometryResult TabBookPreferredGeometry(Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *reply); static void ChangeManaged(Widget w); /*static void Realize(Widget w, XtValueMask * valueMask, XSetWindowAttributes * attributes ); */ static void DoLayout(TabBookWidget cw); static void unmanage_all_Pages(TabBookWidget cw ); static void activate_cb(Widget w, XtPointer fieldp ,XtPointer cb_data); static Widget find_nth_button(TabBookWidget cw , int page); static void wrong_widget(char * routine); #define offset(field) XtOffsetOf(TabBookRec, field) static XtResource resources[] = { {XcgNautoManage, XcgCAutoManage, XtRBoolean , sizeof(Boolean), offset(tabBook.auto_manage), XtRImmediate, (XtPointer) True}, {XcgNactivePage, XcgCActivePage, XtRInt , sizeof(int), offset(tabBook.active_page), XtRImmediate, (XtPointer) 1}, { XcgNnewPageCallback, XcgCNewPageCallback, XmRCallback,sizeof(XtCallbackList), offset(tabBook.newPageCallback), XmRCallback, NULL }, }; #undef offset #define offset(field) XtOffsetOf(TabBookConstraintRec, field) static XtResource constraint_resources[] = { {XcgNresizeChild, XcgCResizeChild, XtRInt , sizeof(int), offset(tabBook.resize_child), XtRImmediate, (XtPointer) XcgRESIZE_NONE}, {XcgNanchorChild, XcgCAnchorChild, XtRInt , sizeof(int), offset(tabBook.anchor_child), XtRImmediate, (XtPointer) XcgANCHOR_NORTH}, }; #undef offset TabBookClassRec tabBookClassRec = { { /* core_class fields */ #ifdef MOTIF /* superclass */ (WidgetClass) &xmBulletinBoardClassRec, #else (WidgetClass) &constraintClassRec, #endif /* class_name */ "TabBook", /* widget_size */ sizeof(TabBookRec), /* class_initialize */ ClassInitialize, /* class_part_init */ ClassPartInitialize, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ XtInheritRealize, /* Realize, */ /* actions */ NULL, /* num_actions */ 0, /* resources */ (XtResourceList)resources, /* num_resources */ (Cardinal)XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, /* compress_enterleave*/ TRUE, /* visible_interest */ FALSE, /* destroy */ NULL, /* resize */ Resize, /* expose */ ExposeMeth, /* set_values */ SetValues, /* set_values_hook */ NULL, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* version */ XtVersion, /* callback_private */ NULL, /* tm_table */ NULL, /* query_geometry */ TabBookPreferredGeometry, /* display_accelerator*/ XtInheritDisplayAccelerator, /* extension */ NULL }, { /* composite_class fields */ /* geometry_manager */ GeometryManager, /* change_managed */ ChangeManaged, /* insert_child */ InsertChild, /* XtInheritInsertChild,*/ /* delete_child */ XtInheritDeleteChild, /* extension */ NULL }, { /* constraint_class fields */ /* subresourses */ (XtResourceList)constraint_resources, /* subresource_count */ (Cardinal)XtNumber(constraint_resources), /* constraint_size */ sizeof(TabBookConstraintRec), /* initialize */ NULL, /*ConstraintInitialize,*/ /* destroy */ NULL, /* set_values */ ConstraintSetValues, /* extension */ NULL }, #ifdef MOTIF { /*** xmManager-Class ***/ /* translations */ XtInheritTranslations, /* syn_resources */ NULL, /* num_syn_resources */ 0, /* syn_constraint_resources */ NULL, /* num_syn_constraint_resources */ 0, /* parent_process */ XmInheritParentProcess, /* extension */ NULL }, { /* Bulletin Board */ /* always_install_accelerators */ False, /* geo_matrix_create */ XmInheritGeoMatrixCreate, /*NULL,*/ /* focus_moved_proc */ XmInheritFocusMovedProc, /* extension */ NULL }, #endif { /* TabBook_class fields */ /* dummy */ 0 } }; WidgetClass xcgTabBookWidgetClass = (WidgetClass)&tabBookClassRec; /**************************************************************** * * Private Procedures * ****************************************************************/ static void ClassInitialize() { } static void ClassPartInitialize(class) WidgetClass class; { } /* ARGSUSED */ static void Initialize(Widget request, Widget new, ArgList args, Cardinal num_args) { TabBookWidget cw = (TabBookWidget)new; Pixel select_color ; cw->tabBook.managed_before = False; cw->tabBook.old_active_page = 0; cw->tabBook.total_managers = 0; cw->tabBook.total_buttons = 0; cw->tabBook.cur_height = 0; cw->tabBook.cur_width = 0; cw->tabBook.layout_completed = False; cw->tabBook.active_manager = NULL; cw->tabBook.active_tab = NULL; cw->tabBook. y_margin = 2; /* reserved margin around each pushbutton ... */ cw->tabBook. x_margin = 2; /* Used to draw Tab around it */ cw->tabBook. x_spacing = 2; /* x space between each button */ cw->tabBook. x_angle = 4; /* space on the right to draw andled line */ cw->tabBook.border = cw->tabBook.x_margin + 2 ; /* border around TabBook inside area */ cw->tabBook.clip = NULL; /* compute all the colors we will need */ cw->tabBook.drawBackground_color = cw->core.background_pixel; XmGetColors(XtScreen(cw), cw->core.colormap, cw->tabBook.drawBackground_color, &cw->tabBook.drawForeground_color, &cw->tabBook.top_shadow_color, &cw->tabBook.bot_shadow_color, &select_color ); create_GC(cw ); /* create the clip window in which all manager children will be re-parented */ cw->tabBook.clip = XtVaCreateManagedWidget("TabBookClip", xmBulletinBoardWidgetClass, new, XmNmarginHeight,0, XmNmarginWidth,0, NULL); } /* Creates the various graphic contexts we will need */ static void create_GC(TabBookWidget cw ) { XtGCMask valuemask; XGCValues myXGCV; valuemask = GCForeground | GCBackground | GCLineWidth | GCFillStyle ; myXGCV.foreground = cw->tabBook.drawForeground_color; myXGCV.background = cw->tabBook.drawBackground_color; myXGCV.fill_style = FillSolid; myXGCV.line_width = cw->tabBook.x_margin ; /* | GCJoinStyle ; myXGCV.join_style = JoinRound; */ if (cw->tabBook.drawForeground_GC ) XtReleaseGC((Widget) cw, cw->tabBook.drawForeground_GC ); cw->tabBook.drawForeground_GC = XtGetGC((Widget)cw, valuemask, &myXGCV); myXGCV.foreground = cw->tabBook.drawBackground_color; if (cw->tabBook.drawBackground_GC ) XtReleaseGC((Widget) cw, cw->tabBook.drawBackground_GC ); cw->tabBook.drawBackground_GC = XtGetGC((Widget)cw, valuemask, &myXGCV); myXGCV.foreground = cw->tabBook.bot_shadow_color; if (cw->tabBook.bot_shadow_GC ) XtReleaseGC((Widget) cw, cw->tabBook.bot_shadow_GC ); cw->tabBook.bot_shadow_GC = XtGetGC((Widget)cw, valuemask, &myXGCV); myXGCV.foreground = cw->tabBook.top_shadow_color; if (cw->tabBook.top_shadow_GC ) XtReleaseGC((Widget) cw, cw->tabBook.top_shadow_GC ); cw->tabBook.top_shadow_GC = XtGetGC((Widget)cw, valuemask, &myXGCV); } static void Resize(Widget w) { TabBookWidget cw = (TabBookWidget)w; /* Position x, y; Dimension width, height; */ Boolean bigger; TRACE_OFF((stderr,"Resize Old=%dx%d New=%dx%d \n",cw->tabBook.cur_width,cw->tabBook.cur_height,cw->core.width,cw->core.height )); if (cw->tabBook.cur_height ) FrameInsideArea(cw, True ); /* erase old frame */ if (cw->core.height <= cw->tabBook.cur_height && cw->core.width <= cw->tabBook.cur_width ) bigger = False; else bigger = True; cw->tabBook.cur_height = cw->core.height; cw->tabBook.cur_width = cw->core.width; /* new frame will be drawn when expose is next called unless it got smaller */ if (bigger == False) FrameInsideArea(cw, False); /* redraw new frame */ /* now resize all manager children */ ResizeAllManagers( cw ); } /* Resize all managers to fit (or to enlarge out) in the TabBook inside area */ static void ResizeAllManagers( TabBookWidget cw ) { XmBulletinBoardRec * clip = (XmBulletinBoardRec *) cw->tabBook.clip; WidgetList widget_list = clip->composite.children; Cardinal num_children = clip->composite.num_children; Cardinal n = 0; Dimension border = 2 * cw->tabBook.border; Dimension inside_width = cw->tabBook.cur_width - border; Dimension inside_height = cw->tabBook.cur_height - cw->tabBook.button_bot - border; XtResizeWidget(cw->tabBook.clip, inside_width, inside_height , clip->core.border_width) ; XtMoveWidget(cw->tabBook.clip, cw->tabBook.border , cw->tabBook.button_bot + cw->tabBook.border); #define _TOP 0 #define _BOTTOM (inside_height - child->core.height) #define _RIGHT (inside_width - child->core.width) #define _LEFT 0 #define _CENTER_VERT (inside_height - child->core.height)/2 #define _CENTER_HORIZ (inside_width - child->core.width)/2 for (n=0; n < num_children; n++) { Widget child = widget_list[n]; if ( XtIsSubclass(child, xmManagerWidgetClass ) ) { TabBookConstraints cw_c = (TabBookConstraints) child->core.constraints; switch (cw_c->tabBook.resize_child) { case XcgRESIZE_NONE: break; case XcgRESIZE_BOTH: XtResizeWidget(child, inside_width,inside_height, child->core.border_width) ; break; case XcgRESIZE_HORIZONTAL: XtResizeWidget(child, inside_width, child->core.height, child->core.border_width) ; break; case XcgRESIZE_VERTICAL: XtResizeWidget(child, child->core.width, inside_height, child->core.border_width) ; break; } switch (cw_c->tabBook.anchor_child) { case XcgANCHOR_CENTER: XtMoveWidget(child, _CENTER_HORIZ, _CENTER_VERT); break; case XcgANCHOR_NORTH: XtMoveWidget(child, _CENTER_HORIZ, _TOP); break; case XcgANCHOR_EAST: XtMoveWidget(child, _RIGHT, _CENTER_VERT); break; case XcgANCHOR_SOUTH: XtMoveWidget(child, _CENTER_HORIZ, _BOTTOM); break; case XcgANCHOR_WEST: XtMoveWidget(child, _LEFT, _CENTER_VERT); break; case XcgANCHOR_NORTHEAST: XtMoveWidget(child, _RIGHT, _TOP); break; case XcgANCHOR_NORTHWEST: XtMoveWidget(child, _LEFT, _TOP); break; case XcgANCHOR_SOUTHEAST: XtMoveWidget(child, _RIGHT,_BOTTOM); break; case XcgANCHOR_SOUTHWEST: XtMoveWidget(child, _LEFT,_BOTTOM); break; } } } } static XtGeometryResult GeometryManager(Widget w,XtWidgetGeometry *request, XtWidgetGeometry *reply) { TabBookWidget cw = (TabBookWidget) XtParent(w); TRACE_OFF((stderr,"GeometryManager request=%dx%d\n", request->width, request->height )); /* only honor changes in width or height */ if (request->request_mode & ~(CWWidth | CWHeight | XtCWQueryOnly)) return XtGeometryNo; if (request->request_mode & CWWidth ) reply->width = request->width; else reply->width = w->core.width; if (request->request_mode & CWHeight ) reply->height = request->height; else reply->height = w->core.height; if (reply->height == request->height && reply->width == request->width) return XtGeometryNo; if (request->request_mode & XtCWQueryOnly) return XtGeometryYes; if (XtClass(w) == xmPushButtonWidgetClass ) { reply->request_mode = CWWidth | CWHeight; XClearArea(XtDisplay(cw), XtWindow(cw), 0, 0, cw->tabBook.cur_width, cw->tabBook.button_bot , True); w->core.width = reply->width; w->core.height = reply->height; DoLayout(cw); } return(XtGeometryYes); } /* ARGSUSED */ static Boolean SetValues(Widget current, Widget request, Widget new, ArgList args,Cardinal *num_args) { TabBookWidget cw_new = (TabBookWidget) new; TabBookWidget cw_cur = (TabBookWidget) current; if (cw_new->tabBook.active_page != cw_cur->tabBook.active_page ) { if (cw_new->tabBook.layout_completed ) { Widget button = find_nth_button(cw_new, cw_new->tabBook.active_page ); /* emulate user pressing this button */ if (button && XtIsRealized(new)) activate_cb(button, NULL, NULL); } } return FALSE; } static Boolean ConstraintSetValues(Widget current, Widget request, Widget new, ArgList args,Cardinal *num_args) { /* TabBookWidget cw_new = (TabBookWidget) new->core.parent ; TabBookWidget cw_cur = (TabBookWidget) current->core.parent ; TabBookConstraints cw_c = (TabBookConstraints) new->core.constraints; */ return( FALSE ); } static void ChangeManaged(Widget w) { TabBookWidget cw = (TabBookWidget)w; TRACE_OFF((stderr,"Change Managed\n")); DoLayout(cw); /* first time, unmanage all but active manager */ if (!cw->tabBook.managed_before) { if (cw->tabBook.auto_manage ) unmanage_all_Pages(cw); /* Unmanage all pages except active one */ if (cw->tabBook.newPageCallback ) { XcgTabBookCallbackData rcb_data; memset(&rcb_data, 0, sizeof(rcb_data)); rcb_data.reason = XcgNewPage; /* reason for callback */ rcb_data.prev_active_page = 0; /* 0 when initially called */ rcb_data.active_page = cw->tabBook.active_page; /* new active page */ XtCallCallbackList((Widget)cw, cw->tabBook.newPageCallback, (XtPointer) &rcb_data); } } cw->tabBook.managed_before = True; } XtGeometryResult TabBookPreferredGeometry(Widget widget, XtWidgetGeometry *request, XtWidgetGeometry *reply) { TabBookWidget cw = (TabBookWidget)widget; /* Dimension width, height */; TRACE_OFF((stderr,"Query Geometry\n")); if (! cw->tabBook.layout_completed) DoLayout(cw); request->request_mode &= CWWidth | CWHeight; reply->request_mode = CWWidth | CWHeight; reply->width = cw->tabBook.cur_width ; reply->height = cw->tabBook.cur_height ; /* called with NULL request */ if (! request->request_mode ) { if (reply->width != cw->core.width || reply->height != cw->core.height) return XtGeometryNo; /* current and desired size the same */ else return XtGeometryAlmost; /* this is our desired size */ } /* called with non-NULL request */ if ( request->width == reply->width && request->height == reply->height) return XtGeometryYes; /* requested change is correct */ if (reply->width != cw->core.width || reply->height != cw->core.height) return XtGeometryNo; /* we want to stay the size we are now */ return XtGeometryAlmost; /* this is our desired size */ } /* Layout the children */ static void DoLayout(TabBookWidget cw) { XmBulletinBoardRec * clip = (XmBulletinBoardRec *) cw->tabBook.clip; WidgetList widget_list = cw->composite.children; Cardinal num_children = cw->composite.num_children; Cardinal n = 0; XtWidgetGeometry size; Dimension max_x, max_y, low_button_y ; XtGeometryResult GResult ; Dimension width_return, height_return; int max_button_height = 0; max_x = max_y = 0; /* place all the buttons side by side */ for (n=0; n < num_children; n++) { Widget child = widget_list[n]; if ( XtClass(child) == xmPushButtonWidgetClass) { XtQueryGeometry(child, NULL, &size); if (max_x) /* all but first button, space from its left neighbor */ max_x += cw->tabBook.x_spacing; max_x += cw->tabBook.x_margin ; XtMoveWidget(child, max_x, cw->tabBook.y_margin ); max_x += size.width + cw->tabBook.x_margin + cw->tabBook.x_angle ; if (max_button_height < size.height) max_button_height = size.height; if (max_y < size.height) max_y = size.height; /* max height */ continue; } } cw->tabBook.button_bot = low_button_y = max_y + cw->tabBook.y_margin ; low_button_y += cw->tabBook.border; /* allow space for inside border */ /* Set all buttons to the same height, the max height */ for (n=0; n < num_children; n++) { Widget child = widget_list[n]; if ( XtClass(child) == xmPushButtonWidgetClass) { XtResizeWidget(child, child->core.width, max_button_height, child->core.border_width) ; } } /* now position all manager ancestors below buttons, all at x=0, y=low_button_y (plus margin) and expand the TabBook width and height to accomodate all these managers */ widget_list = clip->composite.children; num_children = clip->composite.num_children; for (n=0; n < num_children; n++) { Widget child = widget_list[n]; if ( XtIsSubclass(child, xmManagerWidgetClass ) ) { XtQueryGeometry(child, NULL, &size); size.height += low_button_y ; if (max_y < size.height) max_y = size.height; /* max height */ size.width += cw->tabBook.border; if (max_x < size.width) max_x = size.width; /* max width */ } } cw->tabBook.cur_width = max_x + cw->tabBook.border ; cw->tabBook.cur_height = max_y + cw->tabBook.border ; /* space for right border */ cw->tabBook.layout_completed = True; if (cw->core.height != cw->tabBook.cur_height || cw->core.width != cw->tabBook.cur_width) { GResult = XtMakeResizeRequest((Widget)cw, cw->tabBook.cur_width, cw->tabBook.cur_height, &width_return, &height_return); cw->tabBook.cur_height = cw->core.height; cw->tabBook.cur_width = cw->core.width; } ResizeAllManagers( cw ); } /* Use standard method to chain Realize request. Use this opportunity to position child widgets. */ #if 0 static void Realize(Widget w, XtValueMask * valueMask, XSetWindowAttributes * attributes ) { /* TabBookWidget new = (TabBookWidget) w; */ TRACE_OFF((stderr,"Realize\n")); (*(&coreClassRec)->core_class.realize)(w, valueMask, attributes ); } #endif /* Draw (or erase) the shadow around the inside area of the TabBook */ static void FrameInsideArea(TabBookWidget cw, Boolean erase) { Dimension left_x, top_y, p_width, p_height, thickness; XPoint points[4]; GC gc1, gc2; if (!XtIsRealized((Widget)cw)) return; if (erase) gc1 = gc2 = cw->tabBook.drawBackground_GC ; else { gc1 = cw->tabBook.top_shadow_GC ; gc2 = cw->tabBook.bot_shadow_GC ; } /* draw shadow around inside area */ thickness = cw->tabBook.x_margin ; left_x = 0 + thickness/2 ; top_y = cw->tabBook.button_bot + thickness/2 ; p_width = cw->tabBook.cur_width ; p_height = cw->tabBook.cur_height - cw->tabBook.button_bot ; /* note that lines are drawn centered on their (x,y) pixel. we want to specify the outside pixel to contain the line so we have to add in the thickness/2 */ points[0].x = left_x ; points[0].y = top_y + p_height; /* lower left */ points[1].x = 0; points[1].y = - p_height; /* upper left */ points[2].x = p_width - thickness; points[2].y = 0; /* upper right */ /* draw left and top edges */ XDrawLines(XtDisplay(cw), XtWindow(cw), gc1 , points, 3, CoordModePrevious); points[0].x = left_x + p_width - thickness; points[0].y = top_y ; /* upper right */ points[1].x = 0; points[1].y = p_height - thickness; /* lower right*/ points[2].x = - p_width; points[2].y = 0; /* lower left */ /* draw right and bottom edge */ XDrawLines(XtDisplay(cw), XtWindow(cw), gc2 , points, 3, CoordModePrevious); } /* Draw shadows around tab buttons and the inside area */ static void draw_frames(TabBookWidget cw ) { WidgetList widget_list = cw->composite.children; Cardinal num_children = cw->composite.num_children; Cardinal n = 0; /* draw shadow around each button */ for (n=0; n < num_children; n++) { Widget child = widget_list[n]; if ( XtClass(child) == xmPushButtonWidgetClass) { draw_tab_for_button(cw, child); } } FrameInsideArea(cw, False); /* activate the current page's tab */ draw_tab_bottom(cw , cw->tabBook.active_tab, True); } static void ExposeMeth(Widget w, XEvent *xevent, Region region) { TabBookWidget cw = (TabBookWidget) w; XExposeEvent * event = (XExposeEvent *) xevent; /* WidgetList widget_list = cw->composite.children; Cardinal num_children = cw->composite.num_children; Cardinal n = 0; */ TRACE_OFF((stderr,"Expose %d \n", event->count)); if (!XtIsRealized(w)) return; if (event->count != 0) return; draw_frames(cw); } /* Draw the Tab looking border around the child widget which is a push button */ static void draw_tab_for_button(TabBookWidget cw , Widget child) { /* XtWidgetGeometry size;*/ Dimension left_x, top_y, p_width, p_height, thickness; XPoint points[4]; if (!child) return; if (!XtIsRealized((Widget)cw)) return; thickness = cw->tabBook.x_margin ; left_x = child->core.x - cw->tabBook.x_margin + thickness/2 ; top_y = child->core.y - cw->tabBook.y_margin + thickness/2 ; p_width = child->core.width + 2*(cw->tabBook.x_margin) ; p_height = cw->tabBook.button_bot - child->core.y +1; /* note that lines are drawn centered on their (x,y) pixel. we want to specify the outside pixel to contain the line so we have to add in the thickness/2 */ points[0].x = left_x ; points[0].y = top_y + p_height; /* lower left */ points[1].x = 0; points[1].y = - p_height; /* upper left */ points[2].x = p_width - thickness; points[2].y = 0; /* upper right */ /* draw left and top edges */ XDrawLines(XtDisplay(cw), XtWindow(cw), cw->tabBook.top_shadow_GC , points, 3, CoordModePrevious); points[0].x = left_x + p_width - thickness; points[0].y = top_y ; /* upper right */ points[1].x = cw->tabBook.x_angle ; points[1].y = cw->tabBook.x_angle ; /* angle out */ points[2].x = 0; points[2].y = p_height - cw->tabBook.x_angle ; /* lower right */ /* draw right edge */ XDrawLines(XtDisplay(cw), XtWindow(cw), cw->tabBook.bot_shadow_GC , points, 3, CoordModePrevious); } /* We draw the bottom line of the Tab to either activate or deactivate the page */ static void draw_tab_bottom(TabBookWidget cw , Widget child, Boolean active) { /* XtWidgetGeometry size; */ Dimension left_x, top_y, p_width, p_height, thickness; XPoint points[4]; if (!XtIsRealized((Widget)cw) || child == (Widget) 0) return; thickness = cw->tabBook.x_margin ; left_x = child->core.x - cw->tabBook.x_margin + 1 + thickness/2 ; top_y = child->core.y - cw->tabBook.y_margin + thickness/2 ; p_width = child->core.width + 2*(cw->tabBook.x_margin) ; p_height = cw->tabBook.button_bot - child->core.y + 1 + thickness/2 ; points[0].x = left_x ; points[0].y = top_y + p_height; /* lower left */ points[1].x = p_width ; points[1].y = 0; /* lower right */ XDrawLines(XtDisplay(cw), XtWindow(cw), active ? cw->tabBook.drawBackground_GC : cw->tabBook.top_shadow_GC , points, 2, CoordModePrevious); } /* Return page number (1,2,..) coressponding to this child's tab page */ static int find_page(TabBookWidget cw , Widget tab) { int page=1; WidgetList widget_list = cw->composite.children; Cardinal num_children = cw->composite.num_children; Cardinal n = 0; for (n=0; n < num_children; n++ ) { Widget child = widget_list[n]; if (tab == child) return page; if ( XtClass(child) == xmPushButtonWidgetClass) page++; } return 0; /* error */ } /* Return page Widget of n'th manager */ static Widget find_nth_manager(TabBookWidget cw , int page) { XmBulletinBoardRec * clip = (XmBulletinBoardRec *) cw->tabBook.clip; WidgetList widget_list = clip->composite.children; Cardinal num_children = clip->composite.num_children; Cardinal n = 0; int page_count ; for (page_count=0, n=0; n < num_children; n++ ) { Widget child = widget_list[n]; if ( XtIsSubclass(child, xmManagerWidgetClass ) ) { page_count++; if (page == page_count) return child; } } return NULL; /* error */ } /* Return page Widget of n'th button */ static Widget find_nth_button(TabBookWidget cw , int page) { WidgetList widget_list = cw->composite.children; Cardinal num_children = cw->composite.num_children; Cardinal n = 0; int page_count ; for (page_count=0, n=0; n < num_children; n++ ) { Widget child = widget_list[n]; if ( XtClass(child) == xmPushButtonWidgetClass) { page_count++; if (page == page_count) return child; } } return NULL; /* error */ } /* Unmanage all pages except active one */ static void unmanage_all_Pages(TabBookWidget cw ) { XmBulletinBoardRec * clip = (XmBulletinBoardRec *) cw->tabBook.clip; WidgetList widget_list = clip->composite.children; Cardinal num_children = clip->composite.num_children; Cardinal n = 0; for (n=0; n < num_children; n++ ) { Widget child = widget_list[n]; if ( XtIsSubclass(child, xmManagerWidgetClass ) ) { if (cw->tabBook.active_manager == child ) XtManageChild(child); else XtUnmanageChild(child); } } } /* Tab PushButton callback - activate this tab and deactivate the formerly activated tab */ static void activate_cb(Widget w, XtPointer ctx ,XtPointer cb_data) { TabBookWidget cw = (TabBookWidget) XtParent(w); XcgTabBookCallbackData rcb_data; XmPushButtonCallbackStruct * but_cb_data = (XmPushButtonCallbackStruct * ) cb_data; int option; if (cw->tabBook.active_tab == w) return; /* pressed the already active tab button */ if (ctx) /* callback called internally rather from button event */ option = *(int *) ctx; else option = 0; rcb_data.reason = XcgNewPage; /* reason for callback */ if (but_cb_data) rcb_data.event = but_cb_data->event; /* button event */ else rcb_data.event = NULL; /* not a real event, emulated */ rcb_data.prev_active_page = cw->tabBook.active_page ; /* 0 when initially called */ rcb_data.active_page = find_page(cw, w); /* new active page */ rcb_data.button = w; /* the button widget which was pressed (emulated or actual*/ rcb_data.ret_veto = False; rcb_data.future1 = 0; rcb_data.future2 = NULL; /* callback not called if we are here as a result of user calling XcgTabBookSetActivePage with option set to XcgTabBook_OPT_NO_CB */ if (cw->tabBook.newPageCallback && !(option & XcgTabBook_OPT_NO_CB) ) XtCallCallbackList((Widget)cw, cw->tabBook.newPageCallback, (XtPointer) &rcb_data); if (rcb_data.ret_veto ) return; draw_tab_bottom(cw , cw->tabBook.active_tab, False); draw_tab_bottom(cw , w, True); cw->tabBook.active_tab = w; cw->tabBook.old_active_page = cw->tabBook.active_page ; if (cw->tabBook.auto_manage && cw->tabBook.active_manager ) XtUnmanageChild(cw->tabBook.active_manager); cw->tabBook.active_page = rcb_data.active_page ; cw->tabBook.active_manager = find_nth_manager(cw, cw->tabBook.active_page ); if (cw->tabBook.auto_manage && cw->tabBook.active_manager ) XtManageChild(cw->tabBook.active_manager); } /* If child is push button, change its resources to meet our needs */ static void InsertChild(Widget w) { TabBookWidget cw = (TabBookWidget) XtParent(w); TRACE_OFF((stderr,"Insert Child\n")); if ( XtClass(w) == xmPushButtonWidgetClass) { cw->tabBook.total_buttons ++; XtVaSetValues(w, XmNfillOnArm, False, XmNshadowThickness, 0, NULL); XtAddCallback(w, XmNactivateCallback, (XtCallbackProc) activate_cb, NULL); if (cw->tabBook.active_page == cw->tabBook.total_buttons) cw->tabBook.active_tab = w; } else if ( XtIsSubclass(w, xmManagerWidgetClass ) ) { if (cw->tabBook.clip == NULL) /* first child inserted is our own clipping widget */ goto inherit_insert; cw->tabBook.total_managers ++; if (cw->tabBook.active_page == cw->tabBook.total_managers) cw->tabBook.active_manager = w; w->core.parent = cw->tabBook.clip ; /* reparent */ } else { XtAppError(XtWidgetToApplicationContext((Widget)cw), "TabBook: Only Buttons and manager widgets may be children of TabBook"); } inherit_insert: /* call insert child of superclass, which we know is at least a composite widget */ (*((CompositeWidgetClass)(tabBookClassRec.core_class.superclass))-> composite_class.insert_child) (w) ; } /* a routine to halt execution and force a core dump for debugging analysis when a public routine is called with the wrong class of widget */ static void wrong_widget(char * routine) { int mypid = getpid(); TRACE_OFF((stderr, "Wrong class of widget passed to %s\n", routine)); fflush(stderr); kill(mypid, SIGABRT); } /* ---------------- Widget API ---------------------------- */ /* ;+ XcgTabBookSetActivePage -- The active page is changed Func: The active page is changed to the passed page number. Page numbers begin with 1. If this results in a new active page, the result is as if the user pressed the corresponding tab button. It is also equivalent to setting the resource C-Call: Boolean XcgTabBookSetActivePage(Widget w, int page, int option ) Input: w - TabBook widget page - The new active page number (1,2,...) option - bitmapped XcgTabBook_OPT_NO_CB - don't call NewPage callback Return: True - page has been changed False - non-existent page number ;- */ Boolean XcgTabBookSetActivePage(Widget w, int page, int option ) { # define ROUTINE "XcgTabBookSetActivePage" TabBookWidget cw = (TabBookWidget) w; CheckWidgetClass(ROUTINE); /* make sure we are called with a TabBook widget */ if (cw->tabBook.layout_completed && cw->tabBook.active_page != page ) { Widget button = find_nth_button(cw, page ); /* emulate user pressing this button */ if (button) { activate_cb(button, &option, NULL); return True; } else return False; } cw->tabBook.active_page = page ; return True; # undef ROUTINE } /* ;+ XcgTabBookGetActivePage -- The active page is returned Func: The current active page is returned. C-Call: int XcgTabBookGetActivePage(Widget w) Input: w - TabBook widget Return: The current active page number (1,2,...) A zero means the widget has not been managed at least once ;- */ int XcgTabBookGetActivePage(Widget w) { # define ROUTINE "XcgTabBookGetActivePage" TabBookWidget cw = (TabBookWidget) w; CheckWidgetClass(ROUTINE); /* make sure we are called with a TabBook widget */ return cw->tabBook.active_page ; # undef ROUTINE } /* ;+ XcgTabBookGetActivePageWidget -- The manager widget child of the active page is returned Func: The manager widget child of the active page is returned. C-Call: Widget XcgTabBookGetActivePageWidget(Widget w) Input: w - TabBook widget Return: The manager Widget representing the active page. A NULL means the widget has not been managed at least once ;- */ Widget XcgTabBookGetActivePageWidget(Widget w) { # define ROUTINE "XcgTabBookGetActivePageWidget" TabBookWidget cw = (TabBookWidget) w; CheckWidgetClass(ROUTINE); /* make sure we are called with a TabBook widget */ return find_nth_manager(cw, cw->tabBook.active_page ); # undef ROUTINE } viewmol-2.4.1/source/TabBook.h0100644000272700027270000001050407752712707014353 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * T A B B O O K . H * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: TabBook.h,v 1.2 2003/11/07 12:53:27 jrh Exp $ * $Log: TabBook.h,v $ * Revision 1.2 2003/11/07 12:53:27 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:40:37 jrh * Initial revision * */ /* TabBook.h - Public definitions for TabBook widget See TabBook documentation Copyright 1996 COMPUTER GENERATION, INC., The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall Computer Generation, inc. nor the author be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. Author: Gary Aviv Computer Generation, Inc., gary@compgen.com */ /* Revision History: $Log: TabBook.h,v $ Revision 1.2 2003/11/07 12:53:27 jrh Release 2.4 Revision 1.1 2000/12/10 15:40:37 jrh Initial revision Revision 1.1 1997/05/01 22:20:51 eric Initial revision $log Initial $log */ #ifndef _XcgTabBook_h #define _XcgTabBook_h /*********************************************************************** * * TabBook Widget * ***********************************************************************/ /* New resource names/classes */ #define XcgNautoManage "autoManage" #define XcgCAutoManage "AutoManage" #define XcgNactivePage "activePage" #define XcgCActivePage "ActivePage" #define XcgNnewPageCallback "newPageCallback," #define XcgCNewPageCallback "NewPageCallback," /* Constraint resource names/classes */ #define XcgNresizeChild "resizeChild" #define XcgCResizeChild "ResizeChild" #define XcgRESIZE_NONE 0 #define XcgRESIZE_VERTICAL 1 #define XcgRESIZE_HORIZONTAL 2 #define XcgRESIZE_BOTH (XcgRESIZE_VERTICAL | XcgRESIZE_HORIZONTAL) #define XcgNanchorChild "anchorChild" #define XcgCAnchorChild "AnchorChild" #define XcgANCHOR_CENTER 0 #define XcgANCHOR_EAST 1 #define XcgANCHOR_NORTH 2 #define XcgANCHOR_NORTHEAST 3 #define XcgANCHOR_NORTHWEST 4 #define XcgANCHOR_SOUTH 5 #define XcgANCHOR_SOUTHEAST 6 #define XcgANCHOR_SOUTHWEST 7 #define XcgANCHOR_WEST 8 #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif typedef struct _TabBookClassRec *TabBookWidgetClass; typedef struct _TabBookRec *TabBookWidget; extern WidgetClass xcgTabBookWidgetClass; #define XcgTabBook_OPT_NO_CB 1 Boolean XcgTabBookSetActivePage(Widget w, int page, int option ); int XcgTabBookGetActivePage(Widget w ); Widget XcgTabBookGetActivePageWidget(Widget w); #if defined(__cplusplus) || defined(c_plusplus) } #endif /* * Callback reasons. Try to stay out of range of the Motif XmCR_* reasons. */ typedef enum _XcgTabBookgReasonType { XcgNewPage = 202 /* New page is active */ } XcgTabBookReasonType; /* ** Struct passed to application when called back */ typedef struct _XcgTabBookCallbackData { XcgTabBookReasonType reason; /* reason for callback */ XEvent *event; /* button event, NULL if emulated */ int prev_active_page; /* 0 when initially called */ int active_page; /* new active page */ Widget button; /* the button widget which was pressed (emulated or actual*/ Boolean ret_veto; /* caller may set to True to stop page change */ int future1; void * future2; } XcgTabBookCallbackData; #endif /* _XcgTabBook_h */ viewmol-2.4.1/source/TabBookP.h0100644000272700027270000000705607752712720014476 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * T A B B O O K P . H * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: TabBookP.h,v 1.2 2003/11/07 12:53:36 jrh Exp $ * $Log: TabBookP.h,v $ * Revision 1.2 2003/11/07 12:53:36 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:40:50 jrh * Initial revision * */ /* TabBook widget private definitions */ #ifndef _XcgTabBookP_h #define _XcgTabBookP_h #include "TabBook.h" #include #ifdef MOTIF #include # if XmVersion >= 1002 /* If motif version >= 1.2 */ # include # endif #include #include #endif #define XtInheritLayout ((Boolean (*)())_XtInherit) typedef struct { int dummy; } TabBookClassPart; typedef struct _TabBookClassRec { CoreClassPart core_class; CompositeClassPart composite_class; ConstraintClassPart constraint_class; #ifdef MOTIF XmManagerClassPart manager_class; XmBulletinBoardClassPart bulletin_class; #endif TabBookClassPart tabBook_class; } TabBookClassRec; extern TabBookClassRec tabBookClassRec; typedef struct _TabBookPart { int y_margin ; /* reserved margin around each pushbutton ... */ int x_margin ; /* Used to draw Tab around it */ int x_spacing; /* x space between each button */ int x_angle; /* space on the right to draw andled line */ int border; /* border around entire TabBook */ Dimension button_bot; /* largest button goes this far */ Dimension cur_width; Dimension cur_height; Boolean layout_completed; /* layout was done at least once */ Boolean managed_before; /* manged was done at least once */ Boolean auto_manage; /* manager children are automatically mapped when appropriate */ Widget active_tab; /* the current page's tab Button */ Widget active_manager; /* the current page's manager widget */ int active_page; /* 1,2,.. */ int total_buttons; int total_managers; int old_active_page; /* 1,2,.. 0 means none, i.e. init */ GC drawBackground_GC ; /* the drawing area background */ Pixel drawBackground_color; /* ... and its color */ GC drawForeground_GC ; /* the drawing area foreground */ Pixel drawForeground_color; /* ... and its color */ GC bot_shadow_GC; /* for drawing lines, bottom shadow */ Pixel bot_shadow_color; /* ... and its color */ GC top_shadow_GC; /* for drawing lines, top shadow */ Pixel top_shadow_color; /* ... and its color */ XtCallbackList newPageCallback; Widget clip; /* clip the manager children */ } TabBookPart; typedef struct _TabBookRec { CorePart core; CompositePart composite; ConstraintPart constraint; #ifdef MOTIF XmManagerPart manager; XmBulletinBoardPart bulletin_board; #endif TabBookPart tabBook; } TabBookRec; typedef struct _TabBookConstraintPart { int resize_child; /* constraint resources */ int anchor_child; } TabBookConstraintPart; typedef struct _TabBookConstraintRec { TabBookConstraintPart tabBook; } TabBookConstraintRec, *TabBookConstraints; #endif /* _XcgTabBookP_h */ viewmol-2.4.1/source/annotate.c0100644000272700027270000002547507752675131014652 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * A N N O T A T E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: annotate.c,v 1.5 2003/11/07 10:56:25 jrh Exp $ * $Log: annotate.c,v $ * Revision 1.5 2003/11/07 10:56:25 jrh * Release 2.4 * * Revision 1.4 2000/12/10 15:01:05 jrh * Release 2.3 * * Revision 1.3 1999/05/24 01:24:31 jrh * Release 2.2.1 * * Revision 1.2 1999/02/07 21:43:52 jrh * Release 2.2 * * Revision 1.1 1998/01/26 00:33:05 jrh * Initial revision * */ #include #include #include #include #include #include #include "viewmol.h" void modifyAnnotation(int, int, int); void getAnnotation(Widget, caddr_t, caddr_t); int makeAnnotation(int, int, float, float, float, int, const GLfloat *, int, int, char *); void deleteAnnotation(int *); void moveAnnotation(int, double, double); void setAnnotation(Widget, caddr_t, XmDrawingAreaCallbackStruct *); int TextGetBaseline(Widget); extern void redraw(int); extern void pixelToWorld(int, double *, double *); extern void setCursor(Widget, unsigned int); extern int StringWidth(XFontStruct *, char *); extern int StringHeight(XFontStruct *); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern char *getStringResource(Widget, char *); extern void getScreenCoordinates(double, double, double, double *, double *, double *); extern void modifyGeometry(int, char *); extern PyLabelSpecObject *label_new(void); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern struct ANNOTATION *annotation; extern int nAnnotations, annotate, imol; extern Pixel stdcol[9]; void modifyAnnotation(int which, int x, int y) { XmFontListEntry entry; XmFontList fontlist; XmFontType ret; XFontStruct *font; Widget text; Dimension width, height; Pixel bg; int l, xs; char str[MAXLENLINE], def[]="variable"; register char *p; if ((which != (-1)) || annotate) { if ((p=getStringResource(windows[VIEWER].widget, "font")) == NULL) p=def; entry=XmFontListEntryLoad(XtDisplay(windows[VIEWER].widget), p, XmFONT_IS_FONT, "TAG"); fontlist=XmFontListAppendEntry(NULL, entry); font=(XFontStruct *)XmFontListEntryGetFont(entry, &ret); XmFontListEntryFree(&entry); XtVaGetValues(windows[VIEWER].widget, XtNbackground, &bg, NULL); text=XtVaCreateWidget("annotation", xmTextWidgetClass, windows[VIEWER].widget, XmNfontList, fontlist, XmNshadowThickness, 0, XmNmarginWidth, 3, XmNmarginHeight, 0, XmNcolumns, 10, XmNresizeWidth, True, XtNbackground, bg, NULL); /* Lesstif does not yet have XmTextGetBaseline implemented */ /* height=XmTextGetBaseline(text); */ height=TextGetBaseline(text); if (which == (-1)) XtVaSetValues(text, XmNx, x-3, XmNy, y-height-1, NULL); if (which != (-1)) { annotation[which].widget=text; XtVaGetValues(windows[VIEWER].widget, XmNwidth, &width, XmNheight, &height, NULL); XtVaSetValues(annotation[which].widget, XmNx, (Position)(0.5*(annotation[which].x+1.0)*(double)width), XmNy, height-(Position)(0.5*(annotation[which].y+1.0)*(double)height+TextGetBaseline(annotation[which].widget)), NULL); /* moveAnnotation(which, 2.0*(double)x/(double)width, 2.0*(double)y/(double)height); */ xs=(int)(0.5*(annotation[which].x+1.0)*(double)width); l=xs; p=annotation[which].text; while (*p && (l < x)) { strncpy(str, annotation[which].text, p-annotation[which].text+1); str[p-annotation[which].text+1]='\0'; p++; l=xs+StringWidth(windows[VIEWER].font, str); } if (annotation[which].text[0]) { XtVaSetValues(annotation[which].widget, XmNvalue, annotation[which].text, XmNcursorPosition, (XmTextPosition)(p-annotation[which].text-1), XmNcolumns, (int)strlen(annotation[which].text), NULL); annotation[which].flags&=~DRAWANN; } } XtManageChild(text); XtAddCallback(text, XmNactivateCallback, (XtCallbackProc)getAnnotation, (XmAnyCallbackStruct *)which); XmProcessTraversal(text, XmTRAVERSE_CURRENT); } setCursor(windows[VIEWER].widget, XC_top_left_arrow); annotate=FALSE; } void getAnnotation(Widget w, caddr_t which, caddr_t call_data) { Dimension h; Position x, y; const GLfloat black[4] = {0.0, 0.0, 0.0, 0.0}; double xpix, ypix; int i, active; char *text; active=(int)which; text=XmTextGetString(w); if (*text != '\0') { XtVaGetValues(w, XmNx, &x, XmNy, &y, NULL); pixelToWorld(VIEWER, &xpix, &ypix); /* h=XmTextGetBaseline(w); */ h=TextGetBaseline(w); if (active == (-1)) { x+=3; y+=h; i=makeAnnotation((-1), COORDINATES, (float)(windows[VIEWER].left+x*xpix), (float)(windows[VIEWER].top-y*ypix), 0.0, stdcol[BLACK], black, EDITABLE | MOVEABLE, (-1), text); } else { if (annotation[active].flags & GEOMETRY) { molecules[imol].internals[annotation[active].userdata].type= (-molecules[imol].internals[annotation[active].userdata].type); if (strcmp(annotation[active].text, text)) modifyGeometry(annotation[active].userdata, text); deleteAnnotation(&active); } else { strcpy(annotation[active].text, text); annotation[active].flags|=DRAWANN; } active=(-1); } } else deleteAnnotation(&active); XtFree(text); XtDestroyWidget(w); } int makeAnnotation(int which, int type, float x, float y, float z, int color, const GLfloat color_rgb[4], int flags, int userdata, char *text) { PyLabelSpecObject *newLabel; Dimension width, height; double xpix, ypix; register int i; if (which == (-1)) { nAnnotations++; if (annotation == NULL) annotation=(struct ANNOTATION *)getmem(1, sizeof(struct ANNOTATION)); else annotation=(struct ANNOTATION *)expmem((void *)annotation, nAnnotations, sizeof(struct ANNOTATION)); which=nAnnotations-1; } if ((newLabel=label_new()) != NULL) { newLabel->labelID=which; annotation[which].pyObject=newLabel; } annotation[which].widget=NULL; if (text != NULL) strncpy(annotation[which].text, text, MAXLENLINE-1); XtVaGetValues(windows[VIEWER].widget, XtNwidth, &width, XtNheight, &height, NULL); pixelToWorld(VIEWER, &xpix, &ypix); if (type == CENTERED) { i=StringHeight(windows[VIEWER].font); annotation[which].x=((windows[VIEWER].left+windows[VIEWER].right -xpix*(double)StringWidth(windows[VIEWER].font, annotation[which].text)))/((double)width*xpix); annotation[which].y=2.0*(windows[VIEWER].top-2.*(double)y*ypix*(double)i)/((double)height*ypix); annotation[which].z=0.0; } else { /* x and y are in pixels */ annotation[which].x=2.0*x/((double)width*xpix); annotation[which].y=2.0*y/((double)height*ypix); annotation[which].z=z; } annotation[which].color=color; annotation[which].color_rgb[0]=color_rgb[0]; annotation[which].color_rgb[1]=color_rgb[1]; annotation[which].color_rgb[2]=color_rgb[2]; annotation[which].color_rgb[3]=color_rgb[3]; annotation[which].flags=flags | DRAWANN; annotation[which].userdata=userdata; return(which); } void deleteAnnotation(int *which) { register int i; if (*which != (-1)) { Py_DECREF(annotation[*which].pyObject); if (annotation[*which].widget) { XtDestroyWidget(annotation[*which].widget); annotation[*which].widget=NULL; } } if (*which > (-1) && *which != nAnnotations-1) { for (i=(*which)+1; ilabelID=i-1; annotation[i-1].widget=annotation[i].widget; annotation[i-1].x=annotation[i].x; annotation[i-1].y=annotation[i].y; annotation[i-1].z=annotation[i].z; annotation[i-1].color=annotation[i].color; annotation[i-1].color_rgb[0]=annotation[i].color_rgb[0]; annotation[i-1].color_rgb[1]=annotation[i].color_rgb[1]; annotation[i-1].color_rgb[2]=annotation[i].color_rgb[2]; annotation[i-1].color_rgb[3]=annotation[i].color_rgb[3]; annotation[i-1].flags=annotation[i].flags; annotation[i-1].userdata=annotation[i].userdata; strcpy(annotation[i-1].text, annotation[i].text); } } if (*which != (-1)) { nAnnotations--; if (nAnnotations) annotation=(struct ANNOTATION *)expmem((void *)annotation, nAnnotations, sizeof(struct ANNOTATION)); else fremem((void *)&annotation); *which=(-1); } } void scaleAnnotation(float scale) { register int i; for (i=0; iascent+margin+1); } viewmol-2.4.1/source/atommodule.c0100644000272700027270000002437407752675212015204 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * A T O M M O D U L E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: atommodule.c,v 1.2 2003/11/07 10:57:14 jrh Exp $ * $Log: atommodule.c,v $ * Revision 1.2 2003/11/07 10:57:14 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:01:16 jrh * Initial revision * */ #include #include #include #include #include "viewmol.h" #define PyAtom_API_pointers 1 #define PyAtomSpec_Type_NUM 0 PyAtomSpecObject *atom_new(void); static PyObject *atom_getElement(PyObject *, PyObject *); static PyObject *atom_coordinates(PyObject *, PyObject *); static PyObject *atom_radius(PyObject *, PyObject *); static PyObject *atom_radiusScaleFactor(PyObject *, PyObject *); static PyObject *atom_neutronScatteringFactor(PyObject *, PyObject *); static PyObject *atom_name(PyObject *, PyObject *); static PyObject *atom_replace(PyObject *, PyObject *); static PyObject *atom_delete(PyObject *, PyObject *); static PyObject *atom_getattr(PyAtomSpecObject *, char *); static void atom_dealloc(PyAtomSpecObject *); extern PyElementSpecObject *element_new(void); extern void buildMolecule(struct MOLECULE *, int, int, int); extern int checkInterrupt(void); extern void makeINSIntensity(void); extern struct MOLECULE *molecules; extern struct ELEMENT *elements; extern int nmolecule, ne, element; static char PyAtomSpec_Type__doc__[] = "Atom specification"; statichere PyTypeObject PyAtomSpec_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "AtomSpec", /*tp_name*/ sizeof(PyAtomSpecObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)atom_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)atom_getattr, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ /* Space for future expansion */ 0L,0L, /* Documentation string */ PyAtomSpec_Type__doc__ }; static PyMethodDef atom_methods[] = { {"getElement", atom_getElement, 1}, {"coordinates", atom_coordinates, 1}, {"radius", atom_radius, 1}, {"radiusScaleFactor", atom_radiusScaleFactor, 1}, {"neutronScatteringFactor", atom_neutronScatteringFactor, 1}, {"name", atom_name, 1}, {"replace", atom_replace, 1}, {"delete", atom_delete, 1}, {NULL, NULL} }; PyAtomSpecObject *atom_new(void) { PyAtomSpecObject *self; self=PyObject_NEW(PyAtomSpecObject, &PyAtomSpec_Type); if (self == NULL) { PyErr_NoMemory(); return(NULL); } self->moleculeID=0; self->atomID=0; return(self); } static PyObject *atom_getElement(PyObject *self, PyObject *args) { PyAtomSpecObject *s; PyElementSpecObject *element; int imol, iatom; register int i; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyAtomSpecObject *)self; imol=s->moleculeID; iatom=s->atomID; element=element_new(); if (element == NULL) return(NULL); for (i=0; ielementID=i; return((PyObject *)element); } } for (i=0; ielementID=i; return((PyObject *)element); } } return(NULL); } static PyObject *atom_coordinates(PyObject *self, PyObject *args) { PyAtomSpecObject *s; PyObject *tuple; int imol, iatom; double x=1.0e302, y=1.0e302, z=1.0e302; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyAtomSpecObject *)self; imol=s->moleculeID; iatom=s->atomID; if (!PyArg_ParseTuple(args, "|ddd", &x, &y, &z)) return(NULL); if (x < 1.0e300 && y < 1.0e300 && z < 1.0e300) /* set */ { molecules[imol].atoms[iatom].x=x; molecules[imol].atoms[iatom].y=y; molecules[imol].atoms[iatom].z=z; } else { if ((tuple=PyTuple_New(4))) /* get */ { PyTuple_SetItem(tuple, 0, PyFloat_FromDouble(molecules[imol].atoms[iatom].x)); PyTuple_SetItem(tuple, 1, PyFloat_FromDouble(molecules[imol].atoms[iatom].y)); PyTuple_SetItem(tuple, 2, PyFloat_FromDouble(molecules[imol].atoms[iatom].z)); PyTuple_SetItem(tuple, 3, PyString_FromString(molecules[imol].atoms[iatom].name)); return(tuple); } } Py_INCREF(Py_None); return(Py_None); } static PyObject *atom_radius(PyObject *self, PyObject *args) { PyAtomSpecObject *s; double radius=-1.0e0; int imol, iatom; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyAtomSpecObject *)self; imol=s->moleculeID; iatom=s->atomID; if (!PyArg_ParseTuple(args, "|d", &radius)) return(NULL); if (radius != -1.0e0) /* set */ { if (radius >= 0.0) molecules[imol].atoms[iatom].rad=radius; else { PyErr_SetString(PyExc_ValueError, "Value out of range"); return(NULL); } } else /* get */ return(PyFloat_FromDouble(molecules[imol].atoms[iatom].rad)); Py_INCREF(Py_None); return(Py_None); } static PyObject *atom_radiusScaleFactor(PyObject *self, PyObject *args) { PyAtomSpecObject *s; double radScale=-1.0e0; int imol, iatom; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyAtomSpecObject *)self; imol=s->moleculeID; iatom=s->atomID; if (!PyArg_ParseTuple(args, "|d", &radScale)) return(NULL); if (radScale != -1.0e0) /* set */ { if (radScale >= 0.0) molecules[imol].atoms[iatom].radScale=radScale; else { PyErr_SetString(PyExc_ValueError, "Value out of range"); return(NULL); } } else /* get */ return(PyFloat_FromDouble(molecules[imol].atoms[iatom].radScale)); Py_INCREF(Py_None); return(Py_None); } static PyObject *atom_neutronScatteringFactor(PyObject *self, PyObject *args) { PyAtomSpecObject *s; double factor=-1.0e0; int imol, iatom; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyAtomSpecObject *)self; imol=s->moleculeID; iatom=s->atomID; if (!PyArg_ParseTuple(args, "|d", &factor)) return(NULL); if (factor != -1.0e0) /* set */ { if (factor >= 0.0) { molecules[imol].atoms[iatom].neutronScatterfac=factor; makeINSIntensity(); } else { PyErr_SetString(PyExc_ValueError, "Value out of range"); return(NULL); } } else /* get */ return(PyFloat_FromDouble(molecules[imol].atoms[iatom].neutronScatterfac)); Py_INCREF(Py_None); return(Py_None); } static PyObject *atom_name(PyObject *self, PyObject *args) { PyAtomSpecObject *s; int imol, iatom; char *n=NULL, name[MAXLENLINE]; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyAtomSpecObject *)self; imol=s->moleculeID; iatom=s->atomID; if (!PyArg_ParseTuple(args, "|s", &n)) return(NULL); if (n != NULL) /* set */ { if (strlen(n) > 8) { PyErr_SetString(PyExc_ValueError, "Name is too long"); return(NULL); } else strncpy(molecules[imol].atoms[iatom].name, n, 8); } else /* get */ { sprintf(name, "%s%d", molecules[imol].atoms[iatom].name, iatom+1); return(PyString_FromString(name)); } Py_INCREF(Py_None); return(Py_None); } static PyObject *atom_replace(PyObject *self, PyObject *args) { PyAtomSpecObject *s; int imol, iatom, i, found; char *symbol; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyAtomSpecObject *)self; imol=s->moleculeID; iatom=s->atomID; if (!PyArg_ParseTuple(args, "s", &symbol)) return(NULL); symbol[0]=toupper(symbol[0]); symbol[1]=tolower(symbol[1]); found=FALSE; for (i=0; imoleculeID; iatom=s->atomID; buildMolecule(&molecules[imol], iatom, DELETE_ATOM, FALSE); } Py_INCREF(Py_None); return(Py_None); } static void atom_dealloc(PyAtomSpecObject *self) { if (!self) return; PyMem_DEL(self); } static PyObject *atom_getattr(PyAtomSpecObject *self, char *name) { return(Py_FindMethod(atom_methods, (PyObject *)self, name)); } void initAtomModule(void) { PyObject *module, *dict; static void *PyAtom_API[PyAtom_API_pointers]; PyAtomSpec_Type.ob_type=&PyType_Type; module=Py_InitModule("atom", atom_methods); dict=PyModule_GetDict(module); PyAtom_API[PyAtomSpec_Type_NUM]=(void *)&PyAtomSpec_Type; PyDict_SetItemString(dict, "_C_API", PyCObject_FromVoidPtr((void *)PyAtom_API, NULL)); } viewmol-2.4.1/source/balanceform.c0100644000272700027270000002070207752675227015304 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * B A L A N C E F O R M . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: balanceform.c,v 1.2 2003/11/07 10:57:27 jrh Exp $ * $Log: balanceform.c,v $ * Revision 1.2 2003/11/07 10:57:27 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:01:29 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" void balanceExit(Widget, caddr_t, XmPushButtonCallbackStruct *); void GetInt(Widget, caddr_t, XmPushButtonCallbackStruct *); int checkReaction(void); extern void MapBox(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern Widget CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern Widget initShell(Widget, char *, Widget *, Widget *); extern void getSumFormula(struct MOLECULE *, char *, int); extern XmString makeIndexedString(char *); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern void ringBell(void); extern XtAppContext app; extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern Widget topShell; extern int nmolecule, ne; static Widget dialog, *stoichioNumber; static int *balancedReactions=NULL, nmolecule_saved=0, cont; static char **balancedReactants=NULL, *reactants=NULL; void balanceDialog(Widget widget, caddr_t dummy, XmAnyCallbackStruct *data) { XEvent event; Widget form, board, form1, label=NULL, sep; static struct PushButtonRow buttons[] = { { "ok", balanceExit, (XtPointer)TRUE, NULL }, { "cancel", balanceExit, (XtPointer)FALSE, NULL }, }; XmString name; size_t mnc; int found; char formula[MAXLENLINE], last[MAXLENLINE], *p; register int i, j, k; /* This function creates the dialog for manually balancing reactions */ if (balancedReactions) { mnc=0; k=0; for (i=0; i 0) k++; } } if (nmolecule_saved == k) return; fremem((void **)&balancedReactions); fremem((void **)&balancedReactants); fremem((void **)&reactants); balancedReactions=(int *)getmem((size_t)nmolecule, sizeof(int)); balancedReactants=(char **)getmem((size_t)nmolecule, sizeof(char *)); reactants=(char *)getmem(mnc, sizeof(char)); } else { mnc=0; for (i=0; ina; j++) { found=FALSE; for (k=0; katoms[j].element->symbol)) { found=TRUE; count[k]+=mol->stoichioNumber; } } if (!found) { strcpy(&elements[4*nelem], mol->atoms[j].element->symbol); count[nelem]=mol->stoichioNumber; nelem++; } } } found=TRUE; for (i=0; i #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "tiffio.h" #include "viewmol.h" #include "dialog.h" void basisDialog(int); void basisDialogExit(Widget, caddr_t, XmPushButtonCallbackStruct *); void getBasisfunction(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void MapBox(Widget, caddr_t, XmAnyCallbackStruct *); extern Widget CreateToggleBox(Widget, struct PushButtonRow *, int, int, int, int, int); extern char *getStringResource(Widget, char *); /* extern char *bfname(int); extern void bfnamn(int, int *, int*);*/ extern void *getmem(size_t, size_t); extern void CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern void calcmo(void); extern void redraw(int); extern void deleteAnnotation(int *); extern void annotateWavefunction(void); extern Widget initShell(Widget, char *, Widget *, Widget *); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern Widget topShell; extern int iwavef, selectAtom, selectAtomAnnotation; static Widget dialog; void basisDialog(int bfAtom) { struct MOLECULE *mol; Widget board, form, form1, atomname, sep; Widget radiobox; XmString name; static struct PushButtonRow buttons[] = { { "ok", basisDialogExit, (XtPointer)TRUE, NULL }, { "cancel", basisDialogExit, (XtPointer)FALSE, NULL } }; struct PushButtonRow *radiobox_buttons; /*int start, end;*/ char *label, *word, aname[MAXLENLINE]; register int i, j; /* This function creates the dialog for selecting a basis function */ selectAtom=FALSE; deleteAnnotation(&selectAtomAnnotation); dialog=initShell(windows[VIEWER].widget, "basisForm", &board, &form); atomname=XtVaCreateManagedWidget("atomname", xmLabelWidgetClass, form, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, NULL); if (windows[VIEWER].set >= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; word=getStringResource(atomname, "labelString"); sprintf(aname, word, mol->atoms[bfAtom].name, bfAtom+1); name=XmStringCreateSimple(aname); XtVaSetValues(atomname, XmNlabelString, name, NULL); XmStringFree(name); form1=XtVaCreateWidget("controlarea", xmRowColumnWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); /*bfnamn(bfAtom, &start, &end); radiobox_buttons=(struct PushButtonRow *)getmem(end-start+2, sizeof(struct PushButtonRow)); */ radiobox_buttons=(struct PushButtonRow *)getmem(mol->atoms[bfAtom].nBasisFunctions+1, sizeof(struct PushButtonRow)); /*label=(char *)getmem(end-start+1, 19*sizeof(char));*/ label=(char *)getmem(mol->atoms[bfAtom].nBasisFunctions, 19*sizeof(char)); j=0; /*for (i=start; i<=end; i++)*/ for (i=0; iatoms[bfAtom].nBasisFunctions; i++) { if (iwavef == BASIS_IN_MO) { /* sprintf(&label[19*j], "%10.6f*%s", mol->orbitals[mol->imo].coeff[i], bfname(i));*/ sprintf(&label[19*j], "%10.6f*%s", mol->orbitals[mol->imo].coeff[i], mol->atoms[bfAtom].basisFunctionNames[i]); radiobox_buttons[j].label=&(label[19*j]); } else /* radiobox_buttons[j].label=bfname(i);*/ radiobox_buttons[j].label=mol->atoms[bfAtom].basisFunctionNames[i]; radiobox_buttons[j].callback=getBasisfunction; radiobox_buttons[j].client_data=(XtPointer)i; radiobox_buttons[j++].widget=(Widget)NULL; } radiobox=CreateToggleBox(form1, radiobox_buttons, j, (int)XmVERTICAL, j/10+1, True, 0); /*mol->ibasfu=start;*/ mol->ibasfu=0; sep=XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, form1, XmNorientation, XmHORIZONTAL, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, radiobox, NULL); XtManageChild(form1); CreatePushButtonRow(form, buttons, 2); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XmAnyCallbackStruct *)NULL); XtManageChild(form); XtManageChild(board); } void getBasisfunction(Widget widget, caddr_t which, XmToggleButtonCallbackStruct *data) { if (data->set) molecules[windows[VIEWER].set].ibasfu=(int)which; } void basisDialogExit(Widget widget, caddr_t what, XmPushButtonCallbackStruct *data) { XtDestroyWidget(dialog); if ((int)what) { calcmo(); annotateWavefunction(); redraw(VIEWER); } else { iwavef=ALL_OFF; molecules[windows[VIEWER].set].ibasfu=(-1); } } viewmol-2.4.1/source/bio.c0100644000272700027270000001305710114366251013565 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * B I O . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: bio.c,v 1.7 2004/08/29 14:48:09 jrh Exp $ * $Log: bio.c,v $ * Revision 1.7 2004/08/29 14:48:09 jrh * Release 2.4.1 * * Revision 1.6 2003/11/07 10:57:49 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:01:48 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:28:23 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:44:18 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:02 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:39:47 jrh * Initial revision * */ #include #include #include #include #include #define TRUE 1 #define FALSE 0 #define MAXLENLINE 82 int readFrame(FILE *, int, int, double, int, long *); void readNormalModes(FILE *); void readXtlFile(FILE *); extern void *getmem(size_t, size_t); extern void fremem(void **); int main(int argc, char **argv) { FILE *mainfile, *file; char line[MAXLENLINE], hessian[MAXLENLINE], *word; long offset; int version, pbc=FALSE, multiStruct=FALSE; if ((mainfile=fopen(argv[1], "r")) == NULL) { printf("$error noFile 1 %s\n", argv[1]); printf("$end\n"); exit(-1); } fgets(line, MAXLENLINE, mainfile); if (strstr(line, "!BIOSYM archive") == NULL && strstr(line, "TITLE") == NULL) { printf("$error wrongFiletype 1 %s\n", argv[1]); printf("$end\n"); exit(-1); } if (strstr(line, "TITLE") != NULL) { printf("$title\n%s", &line[6]); readXtlFile(mainfile); return(0); } sscanf(line+15, "%d", &version); /*if (version < 2) { printf("$error unsupportedVersion 1 %d\n", version); printf("$end\n"); exit(-1); } */ fgets(line, MAXLENLINE, mainfile); if (strstr(line, "PBC=ON") != NULL) pbc=TRUE; /* Find out whether there is more than one structure */ /* in the file */ offset=ftell(mainfile); while (fgets(line, MAXLENLINE, mainfile) != NULL) { if (strstr(line, "end") != NULL) { fgets(line, MAXLENLINE, mainfile); if (fgets(line, MAXLENLINE, mainfile) != NULL) multiStruct=TRUE; break; } } (void)fseek(mainfile, offset, SEEK_SET); if (multiStruct) { printf("$grad cartesian gradients\n"); while (readFrame(mainfile, pbc, FALSE, 1.0, version, &offset)); } (void)fseek(mainfile, offset, SEEK_SET); (void)readFrame(mainfile, pbc, TRUE, 1.0, version, &offset); fclose(mainfile); strcpy(hessian, argv[1]); if ((word=strrchr(hessian, '.'))) strcpy(word, ".hessian"); else strcat(hessian, ".hessian"); if ((file=fopen(hessian, "r")) != NULL) { readNormalModes(file); fclose(file); } printf("$end\n"); return(0); } void readNormalModes(FILE *file) { double *nm; int nfreq; char line[MAXLENLINE], *word; register int i, j; fgets(line, MAXLENLINE, file); if (strncmp(line, "!BIOSYM hessian", 15)) return; while (fgets(line, MAXLENLINE, file) != NULL) { if (strstr(line, "#frequencies and intensities")) { printf("$vibrational spectrum\n"); fscanf(file, "%d\n", &nfreq); for (i=0; i #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" void bondDialog(Widget, caddr_t, XmAnyCallbackStruct *); void bondDialogExit(Widget, caddr_t, XmPushButtonCallbackStruct *); void GetHBond(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetHBondThreshold(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); struct MenuItem *makeElementMenu(void); void GetRadiusScale(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetScaleFactor(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); static int compareElements(const void *s1, const void *s2); extern void MapBox(Widget, caddr_t, XmAnyCallbackStruct *); extern Widget CreateToggleBox(Widget, struct PushButtonRow *, int, int, int, int, int); extern void CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern char *getStringResource(Widget, char *); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern void setBondType(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void GetSlider(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); extern void redraw(int); extern int makeConnectivity(struct MOLECULE *, int, int); extern Widget initShell(Widget, char *, Widget *, Widget *); extern Widget makeMenu(Widget, int, char *, struct MenuItem *); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern Widget topShell; extern double hbondThreshold, scaleRadius; extern int nmolecule, bondType, showHBond; static Widget dialog, slider1, slider2; static double hbondThreshold_save, scaleFactor; static double scaleRadius_save, *radScale_save; static struct ELEMENT *scaleElement=NULL; static int bondType_save, showHBond_save, mol; static char *labels; void bondDialog(Widget widget, caddr_t which, XmAnyCallbackStruct *data) { Widget board, form, form1, sep, hb, element; Widget radiobox; int na; short decimals; struct MenuItem *menu; static struct SLIDER threshold; static struct SLIDER scaleRad; static struct PushButtonRow buttons[] = { { "ok", bondDialogExit, (XtPointer)TRUE, NULL }, { "cancel", bondDialogExit, (XtPointer)FALSE, NULL } }; static struct PushButtonRow radiobox_buttons[] = { { "single", setBondType, (XtPointer)SINGLE_BONDS, NULL }, { "multiple", setBondType, (XtPointer)MULTIPLE_BONDS, NULL }, { "conjugated", setBondType, (XtPointer)CONJUGATION, NULL }, }; register int i, j, k; /* This function creates the bond order dialog */ bondType_save=bondType; showHBond_save=showHBond; hbondThreshold_save=hbondThreshold; scaleRadius_save=scaleRadius; mol=windows[VIEWER].set; if (mol < 0) { na=0; for (i=0; isymbol)) { XtVaSetValues(element, XmNmenuHistory, menu[i].widget, NULL); break; } i++; } } (void)XtVaCreateManagedWidget("atoms", xmLabelWidgetClass, form1, NULL); slider2=XtVaCreateManagedWidget("scaleRadius", xmScaleWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNshowValue, True, XmNsensitive, True, NULL); XtVaGetValues(slider2, XmNdecimalPoints, &decimals, NULL); if (scaleElement != NULL) XtVaSetValues(slider2, XmNvalue, (int)(scaleElement->radScale*pow(10.0, (double)decimals)), NULL); else XtVaSetValues(slider2, XmNvalue, (int)(scaleRadius*pow(10.0, (double)decimals)), NULL); scaleRad.number=&scaleFactor; scaleRad.decimals=decimals; scaleRad.draw=NULL; XtAddCallback(slider2, XmNvalueChangedCallback, (XtCallbackProc)GetScaleFactor, &scaleRad); XtAddCallback(slider2, XmNdragCallback, (XtCallbackProc)GetScaleFactor, &scaleRad); XtManageChild(element); sep=XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNtraversalOn, False, NULL); CreatePushButtonRow(form, buttons, XtNumber(buttons)); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XmAnyCallbackStruct *)NULL); XtManageChild(form1); XtManageChild(form); XtManageChild(board); } void bondDialogExit(Widget button, caddr_t which, XmPushButtonCallbackStruct *data) { register int i, j, k; if (!(int)which) { bondType=bondType_save; showHBond=showHBond_save; hbondThreshold=hbondThreshold_save; scaleRadius=scaleRadius_save; k=0; if (mol < 0) { for (i=0; iset) { *(int *)which=TRUE; XtVaSetValues(slider1, XmNsensitive, True, NULL); } else { *(int *)which=FALSE; XtVaSetValues(slider1, XmNsensitive, False, NULL); } for (i=0; ina, sizeof(int)); menu=(struct MenuItem *)getmem((size_t)(mol->na+2), sizeof(struct MenuItem)); labels=(char *)getmem((size_t)mol->na+2, MAXLENLINE*sizeof(char)); menu[0].label=all; menu[0].class=&xmPushButtonGadgetClass; menu[0].callback=GetRadiusScale; menu[0].callback_data=0; menu[0].widget=NULL; menu[0].subitems=NULL; word=getStringResource(topShell, "elementMenuPrefix"); j=1; for (i=0; ina; i++) { if (!done[i]) { if (strcmp(mol->atoms[i].element->symbol, "Uc")) { strncpy(&labels[MAXLENLINE*j], word, MAXLENLINE-4); strcat(&labels[MAXLENLINE*j], " "); strcat(&labels[MAXLENLINE*j], mol->atoms[i].element->symbol); menu[j].label=&labels[MAXLENLINE*j]; menu[j].class=&xmPushButtonGadgetClass; menu[j].callback=GetRadiusScale; menu[j].callback_data=(XtPointer)mol->atoms[i].element; menu[j].widget=NULL; menu[j].subitems=NULL; j++; } for (k=i; kna; k++) { if (!strcmp(mol->atoms[i].element->symbol, mol->atoms[k].element->symbol)) done[k]=TRUE; } } } menu[j++].label=NULL; fremem((void **)&done); menu=(struct MenuItem *)expmem((void *)menu, (size_t)j, sizeof(struct MenuItem)); qsort((void *)(&menu[1]), (size_t)(j-2), sizeof(struct MenuItem), compareElements); return(menu); } void GetRadiusScale(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { short decimals; scaleElement=(struct ELEMENT *)which; XtVaGetValues(slider2, XmNdecimalPoints, &decimals, NULL); if (scaleElement == NULL) XtVaSetValues(slider2, XmNvalue, (int)(scaleRadius*pow((double)10.0, (double)decimals)), NULL); else XtVaSetValues(slider2, XmNvalue, (int)(scaleElement->radScale*pow((double)10.0, (double)decimals)), NULL); } void GetScaleFactor(Widget widget, struct SLIDER *slider, XmScrollBarCallbackStruct *data) { register int i, j; *(slider->number)=(double)(data->value)/pow((double)10.0, (double)slider->decimals); if (scaleElement != NULL) scaleElement->radScale=*(slider->number); else scaleRadius=*(slider->number); for (i=0; iradScale; makeConnectivity(&molecules[i], FALSE, TRUE); } redraw(VIEWER); } int compareElements(const void *s1, const void *s2) { struct MenuItem *p1, *p2; register int i; p1=(struct MenuItem *)s1; p2=(struct MenuItem *)s2; i=strcmp(p1->label, p2->label); return(i); } viewmol-2.4.1/source/bondorder.c0100644000272700027270000001574507752675313015020 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * B O N D O R D E R . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: bondorder.c,v 1.5 2003/11/07 10:58:19 jrh Exp $ * $Log: bondorder.c,v $ * Revision 1.5 2003/11/07 10:58:19 jrh * Release 2.4 * * Revision 1.4 2000/12/10 15:02:22 jrh * Release 2.3 * * Revision 1.3 1999/05/24 01:24:49 jrh * Release 2.2.1 * * Revision 1.2 1999/02/07 21:44:46 jrh * Release 2.2 * * Revision 1.1 1998/01/26 00:34:45 jrh * Initial revision * */ #include #include #include #include "viewmol.h" extern struct MOLECULE *molecules; extern void *getmem(size_t, size_t); void calculateShift(struct MOLECULE *, struct BOND *, int *, int, int, int); void findConjugation(struct MOLECULE *, struct BOND *, int *, int, int); void vectorProduct(double *, double *, double *); double scalarProduct(double *, double *); void bondOrder(struct MOLECULE *mol, struct BOND *bond, int *connectivity, int maxBondsPerAtom) { int i, j, ni, nj, bo=1; /* Assign bond orders by counting electrons. If the number of electrons for an atom is set to -1 assign only single bonds. */ i=bond->first; if (mol->atoms[i].nelectrons == (-1)) { bond->order=1; return; } j=bond->second; if (mol->atoms[j].nelectrons == (-1)) { bond->order=1; return; } /* Compare number of electrons with number of atoms atom is bound to and deduce bond order */ do { if (mol->atoms[i].nelectrons > 4) ni=8-mol->atoms[i].nelectrons; else ni=mol->atoms[i].nelectrons; if (mol->atoms[j].nelectrons > 4) nj=8-mol->atoms[j].nelectrons; else nj=mol->atoms[j].nelectrons; ni-=mol->atoms[i].nbonds-mol->atoms[i].hbonds; nj-=mol->atoms[j].nbonds-mol->atoms[j].hbonds; if (ni < 0) ni=mol->atoms[i].nelectrons-mol->atoms[i].nbonds+mol->atoms[i].hbonds; if (nj < 0) nj=mol->atoms[j].nelectrons-mol->atoms[j].nbonds+mol->atoms[j].hbonds; if (ni > 0 && nj > 0) { mol->atoms[i].nbonds++; mol->atoms[j].nbonds++; bo++; } else break; } while (bo <= 4); bond->order=bo; /* Bond order has been found, calculate shift vector to draw multiple bonds. */ if (bo > 1) calculateShift(mol, bond, connectivity, maxBondsPerAtom, i, j); } void calculateShift(struct MOLECULE *mol, struct BOND *bond, int *connectivity, int maxBondsPerAtom, int i, int j) { double v1[3], v2[3], v3[3]; int ni, nj, bo, kh=(-1); register double r1, r2; register int k, l; /* Rules for multiple bonds: Shall be in the same plane as other bond framework, but do not use hydrogens to determine this plane unless impossible otherwise. */ bo=abs(bond->order); ni=(mol->atoms[i].nbonds >= mol->atoms[j].nbonds ? i : j); nj=(ni == i ? j : i); l=0; do { k=abs(connectivity[maxBondsPerAtom*ni+l]); if (k != nj && strcmp(mol->atoms[k].element->symbol, "H")) break; if (k != nj && !strcmp(mol->atoms[k].element->symbol, "H")) kh=k; l++; } while (l < maxBondsPerAtom); /* No non-hydrogen atom found so we have to use a hydrogen atom */ if (l == maxBondsPerAtom && kh != (-1)) k=kh; v1[0]=mol->atoms[k].x-mol->atoms[ni].x; v1[1]=mol->atoms[k].y-mol->atoms[ni].y; v1[2]=mol->atoms[k].z-mol->atoms[ni].z; r1=scalarProduct(v1, v1); v2[0]=mol->atoms[nj].x-mol->atoms[ni].x; v2[1]=mol->atoms[nj].y-mol->atoms[ni].y; v2[2]=mol->atoms[nj].z-mol->atoms[ni].z; r2=scalarProduct(v2, v2); if (r1 != 0.0 && r2 != 0.0) r1=fabs(scalarProduct(v1, v2)/(sqrt(r1*r2))+1.0); else r1=0.0; if (r1 > 1.0e-6) { vectorProduct(v1, v2, v3); vectorProduct(v2, v3, v1); r1=mol->bondShift/sqrt(scalarProduct(v1, v1)); if (bo == 2) r1*=0.5; bond->x=v1[0]*r1; bond->y=v1[1]*r1; bond->z=v1[2]*r1; } else { v1[0]=1.0; v1[1]=0.0; v1[2]=0.0; r1=scalarProduct(v1, v2)/sqrt(r2); if (bo == 2) r2=0.5; else r2=1.0; bond->x=r2*mol->bondShift*sqrt(1.0-r1*r1); bond->y=r2*mol->bondShift*r1; bond->z=0.0; } /*v3[0]=0.5*(v1[0]-v2[0]); v3[1]=0.5*(v1[1]-v2[1]); v3[2]=0.5*(v1[2]-v2[2]); r1=mol->bondShift/sqrt(scalarProduct(v3, v3)); if (bo == 2) r1*=0.5; bond->x=v3[0]*r1; bond->y=v3[1]*r1; bond->z=v3[2]*r1; */ } void findConjugation(struct MOLECULE *mol, struct BOND *bonds, int *connectivity, int maxBondsPerAtom, int nb) { int atom1, atom2, conjugated; register int i, j, k, l; for (i=0; inb; i++) { if (abs(mol->bonds[i].order) == 2) { atom1=mol->bonds[i].first; while (TRUE) { for (j=0; jnb; j++) { if ((mol->bonds[j].first == atom1 || mol->bonds[j].second == atom1) && mol->bonds[j].order == 1) { atom2=mol->bonds[j].first == atom1 ? mol->bonds[j].second : mol->bonds[j].first; for (k=0; knb; k++) { if ((mol->bonds[k].first == atom2 || mol->bonds[k].second == atom2) && abs(mol->bonds[k].order) == 2) { conjugated=TRUE; for (l=0; lnb; l++) { if (l == i || l == j || l == k) continue; if (mol->bonds[l].first != atom1 && mol->bonds[l].second != atom1) continue; if (mol->bonds[l].order != 1 && mol->bonds[l].order != (-2)) { conjugated=FALSE; break; } } if (conjugated) { mol->bonds[i].order=(-2); mol->bonds[j].order=(-2); mol->bonds[k].order=(-2); /* calculate shift vector for bond j */ calculateShift(mol, &(mol->bonds[j]), connectivity, maxBondsPerAtom, atom1, atom2); break; } } } } } if (atom1 == mol->bonds[i].second) break; atom1=mol->bonds[i].second; } } } } void vectorProduct(double *v1, double *v2, double *v3) { v3[0]=v1[1]*v2[2]-v1[2]*v2[1]; v3[1]=v1[2]*v2[0]-v1[0]*v2[2]; v3[2]=v1[0]*v2[1]-v1[1]*v2[0]; } double scalarProduct(double *v1, double *v2) { return(v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]); } viewmol-2.4.1/source/build.c0100644000272700027270000003731010037763442014120 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * B U I L D . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: build.c,v 1.4 2003/11/07 10:58:28 jrh Exp $ * $Log: build.c,v $ * Revision 1.4 2003/11/07 10:58:28 jrh * Release 2.4 * * Revision 1.3 2000/12/10 15:02:33 jrh * Release 2.3 * * Revision 1.2 1999/05/24 01:24:52 jrh * Release 2.2.1 * * Revision 1.1 1999/02/07 21:45:03 jrh * Initial revision * * */ #include #include #include #include #include "viewmol.h" void buildMolecule(struct MOLECULE *, int, int, int); void replaceAtom(struct MOLECULE *, int); void addAtom(struct MOLECULE *, int, int); void changeCoordination(struct MOLECULE *); extern int makeConnectivity(struct MOLECULE *, int, int); extern double centerMolecule(struct MOLECULE *); extern void setWindowSize(double); extern int findBondPartners(int *, int, int); extern int findAttachedAtoms(int *, int, int); extern void changeBondLength(int, int, int *, double); extern int changeAngle(int, int, int *, double); extern void vectorProduct(double *, double *, double *); extern void *getmem(size_t, size_t); extern void fremem(void **); extern void *expmem(void *, size_t, size_t); extern double bondAngle(struct ATOM *, int, int, int); extern void clearGeometry(Widget, caddr_t, XmAnyCallbackStruct *); extern void addUndo(struct MOLECULE *); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern struct ELEMENT *elements; extern double torsionDefault; extern int element, bondType, localGeometry; void buildMolecule(struct MOLECULE *mol, int picked, int operation, int setWindow) { int which, *list; register int i, j, k; /* Save coordinates before any change */ if (mol->na > 0) addUndo(mol); if (mol->internals == NULL) mol->internals=(struct INTERNAL *)getmem((size_t)1, sizeof(struct INTERNAL)); else mol->internals=(struct INTERNAL *)expmem((void *)mol->internals, (size_t)mol->ninternal+1, sizeof(struct INTERNAL)); switch (operation) { case DELETE_ATOM: mol->na--; for (i=picked; ina; i++) { mol->atoms[i].x=mol->atoms[i+1].x; mol->atoms[i].y=mol->atoms[i+1].y; mol->atoms[i].z=mol->atoms[i+1].z; mol->atoms[i].rad=mol->atoms[i+1].rad; mol->atoms[i].radScale=mol->atoms[i+1].radScale; mol->atoms[i].mass=mol->atoms[i+1].mass; mol->atoms[i].neutronScatterfac=mol->atoms[i+1].neutronScatterfac; mol->atoms[i].nbonds=mol->atoms[i+1].nbonds; mol->atoms[i].nelectrons=mol->atoms[i+1].nelectrons; mol->atoms[i].ref=mol->atoms[i+1].ref; mol->atoms[i].flags=mol->atoms[i+1].flags; mol->atoms[i].element=mol->atoms[i+1].element; mol->atoms[i].basis=mol->atoms[i+1].basis; strcpy(mol->atoms[i].name, mol->atoms[i+1].name); strcpy(mol->atoms[i].basisname, mol->atoms[i+1].basisname); } mol->atoms=(struct ATOM *)expmem((void *)mol->atoms, (size_t)mol->na, sizeof(struct ATOM)); /* Scan through list of internal coordinates and delete all which contain deleted atom */ for (i=0; ininternal; i++) { if (mol->internals[i].atoms[0] == picked || mol->internals[i].atoms[1] == picked || mol->internals[i].atoms[2] == picked || mol->internals[i].atoms[3] == picked) clearGeometry((Widget)0, (caddr_t)i, (XmAnyCallbackStruct *)0); } /* Scan through lists of bonds added or deleted by user and change numbering of bonded atoms */ for (i=0; inbAdded; i++) { if (mol->addedBonds[3*i] > picked) mol->addedBonds[3*i]--; if (mol->addedBonds[3*i+1] > picked) mol->addedBonds[3*i+1]--; } for (i=0; inbDeleted; i++) { if (mol->deletedBonds[2*i] > picked) mol->deletedBonds[2*i]--; if (mol->deletedBonds[2*i+1] > picked) mol->deletedBonds[2*i+1]--; } /* Change coordination at atoms bond to deleted atom if user desires so */ if (localGeometry) { list=(int *)getmem((size_t)mol->nb, sizeof(int)); j=0; for (i=0; inb; i++) { if (mol->bonds[i].first == picked || mol->bonds[i].second == picked) { list[j++]=i; mol->bonds[i].order=(-1); /* mark bond as hydrogen bond to ex- */ } /* clude it from findBondPartners */ if (mol->bonds[i].first > picked) mol->bonds[i].first--; if (mol->bonds[i].second > picked) mol->bonds[i].second--; } for (i=0; ibonds[k].first == picked) mol->internals[mol->ninternal].atoms[1]=mol->bonds[k].second; else if (mol->bonds[k].second == picked) mol->internals[mol->ninternal].atoms[1]=mol->bonds[k].first; changeCoordination(mol); } fremem((void **)&list); } makeConnectivity(mol, FALSE, FALSE); break; case REPLACE_ATOM: replaceAtom(mol, picked); break; case ADD_ATOM: which=mol->na++; mol->atoms=(struct ATOM *)expmem((void *)mol->atoms, (size_t)mol->na, sizeof(struct ATOM)); replaceAtom(mol, which); if (mol->unitcell) makeConnectivity(mol, FALSE, TRUE); addAtom(mol, which, picked); break; } if (mol->ninternal == 0) fremem((void **)&(mol->internals)); else mol->internals=(struct INTERNAL *)expmem((void *)mol->internals, (size_t)mol->ninternal, sizeof(struct INTERNAL)); } void replaceAtom(struct MOLECULE *mol, int which) { #include "isotopes.h" int *move, nmove; register int i; mol->atoms[which].rad=elements[element].rad; mol->atoms[which].radScale=elements[element].radScale; mol->atoms[which].element=&elements[element]; mol->atoms[which].neutronScatterfac=0.0; mol->atoms[which].basis=(struct BASISSET *)NULL; strcpy(mol->atoms[which].name, elements[element].symbol); strcpy(mol->atoms[which].basisname, ""); for (i=0; iatoms[which].name, pse[i], 2)) { mol->atoms[which].mass=isotope[i][0]; mol->atoms[which].nelectrons=electrons[i]; } } /* Adjust bond lengths */ move=(int *)getmem((size_t)mol->na, sizeof(int)); for (i=0; inb; i++) { if (mol->bonds[i].first == which || mol->bonds[i].second == which) { mol->internals[mol->ninternal].atoms[0]=mol->bonds[i].first; mol->internals[mol->ninternal].atoms[1]=mol->bonds[i].second; mol->internals[mol->ninternal].type=BONDLENGTH; move[0]=mol->bonds[i].first == which ? mol->bonds[i].second : mol->bonds[i].first; if ((nmove=findAttachedAtoms(move, 1, which)) > 0) changeBondLength(mol->ninternal, nmove, move, 0.9*(mol->atoms[mol->bonds[i].first].rad +mol->atoms[mol->bonds[i].second].rad)); } } fremem((void *)&move); } void addAtom(struct MOLECULE *mol, int which, int picked) { mol->atoms[which].flags=ORIGINAL; mol->atoms[which].nbonds=0; if (picked == -1) /* if atom is not attached to another atom */ { mol->atoms[which].x=0.0; mol->atoms[which].y=0.0; mol->atoms[which].z=0.0; return; } else { mol->atoms[which].x=mol->atoms[picked].x+1.0; mol->atoms[which].y=mol->atoms[picked].y; mol->atoms[which].z=mol->atoms[picked].z; } mol->nb++; mol->bonds=(struct BOND *)expmem((void *)mol->bonds, (size_t)mol->nb, sizeof(struct BOND)); mol->bonds[mol->nb-1].first=picked; mol->bonds[mol->nb-1].second=which; mol->bonds[mol->nb-1].order=1; mol->bonds[mol->nb-1].frac=mol->atoms[picked].rad/(mol->atoms[picked].rad+mol->atoms[which].rad); mol->internals[mol->ninternal].atoms[0]=which; mol->internals[mol->ninternal].atoms[1]=picked; mol->internals[mol->ninternal].type=BONDLENGTH; changeBondLength(mol->ninternal, 1, &which, 0.9*(mol->atoms[which].rad+mol->atoms[picked].rad)); changeCoordination(mol); setWindowSize(centerMolecule(mol)); } void changeCoordination(struct MOLECULE *mol) { double v1[3], v2[3], v3[3], t=torsionDefault, angle, sign; int *bondPartners, *nbonds, max, imax, picked, added=FALSE; int linear=FALSE, useDummy=FALSE; register int i, j, n; bondPartners=(int *)getmem((size_t)mol->na, sizeof(int)); picked=mol->internals[mol->ninternal].atoms[1]; bondPartners[0]=picked; n=findBondPartners(bondPartners, 1, -1); if (n < 3) return; bondPartners=(int *)expmem((void *)bondPartners, (size_t)((n+2)*mol->na), sizeof(int)); nbonds=(int *)getmem((size_t)n, sizeof(int)); max=0; imax=0; for (i=1; ina]=bondPartners[i]; if (abs(nbonds[i]=findAttachedAtoms(&bondPartners[i*mol->na], 1, picked)) > max) { max=abs(nbonds[i]); imax=i; } } mol->internals[mol->ninternal].atoms[3]=bondPartners[imax*mol->na+1]; angle=180.; sign=1.0; for (i=1; ina-2 || mol->na < 4)) { mol->internals[mol->ninternal].atoms[0]=bondPartners[i]; mol->internals[mol->ninternal].atoms[2]=bondPartners[imax]; if (n > 4 && max <= 1) mol->internals[mol->ninternal].atoms[3]=(-1); else { if (bondAngle(mol->atoms, bondPartners[i], picked, bondPartners[imax]) < 179.9) linear=FALSE; else { if (nbonds[imax] > 1) { for (j=0; jatoms, bondPartners[i], picked, bondPartners[imax*mol->na+j]) < 179.9) { mol->internals[mol->ninternal].atoms[3]=bondPartners[imax*mol->na+j]; break; } } } else mol->internals[mol->ninternal].atoms[3]=(-1); linear=TRUE; } } mol->internals[mol->ninternal].type=ANGLE; if (n == 3 && mol->atoms[picked].nelectrons > 4) { n+=mol->atoms[picked].nelectrons-4; added=TRUE; } switch (n) { case 3: (void)changeAngle(mol->ninternal, nbonds[i], &bondPartners[i*mol->na], 180.); break; case 4: (void)changeAngle(mol->ninternal, nbonds[i], &bondPartners[i*mol->na], sign*120.0); if (linear) sign=(-1.0); break; case 5: (void)changeAngle(mol->ninternal, nbonds[i], &bondPartners[i*mol->na], 109.47122); break; default: (void)changeAngle(mol->ninternal, nbonds[i], &bondPartners[i*mol->na], angle); angle=90.; break; } if (added) { n-=mol->atoms[picked].nelectrons-4; added=FALSE; } if (n > 3) { mol->internals[mol->ninternal].type=TORSION; if (mol->internals[mol->ninternal].atoms[3] >= 0) { if (!changeAngle(mol->ninternal, nbonds[i], &bondPartners[i*mol->na], t)) { useDummy=TRUE; v1[0]=mol->atoms[bondPartners[i]].x-mol->atoms[picked].x; v1[1]=mol->atoms[bondPartners[i]].y-mol->atoms[picked].y; v1[2]=mol->atoms[bondPartners[i]].z-mol->atoms[picked].z; v2[0]=mol->atoms[bondPartners[imax]].x-mol->atoms[picked].x; v2[1]=mol->atoms[bondPartners[imax]].y-mol->atoms[picked].y; v2[2]=mol->atoms[bondPartners[imax]].z-mol->atoms[picked].z; vectorProduct(v1, v2, v3); mol->atoms=(struct ATOM *)expmem((void *)mol->atoms, (size_t)(mol->na+1), sizeof(struct ATOM)); mol->atoms[mol->na].x=mol->atoms[bondPartners[imax]].x+v3[0]; mol->atoms[mol->na].y=mol->atoms[bondPartners[imax]].y+v3[1]; mol->atoms[mol->na].z=mol->atoms[bondPartners[imax]].z+v3[2]; mol->internals[mol->ninternal].atoms[3]=mol->na; (void)changeAngle(mol->ninternal, nbonds[i], &bondPartners[i*mol->na], t); } if (n > 5) t+=360.0/(double)(n-3); else t+=360.0/(double)(n-2); } else { if (n > 4) { if (!useDummy) { useDummy=TRUE; v1[0]=mol->atoms[bondPartners[i]].x-mol->atoms[picked].x; v1[1]=mol->atoms[bondPartners[i]].y-mol->atoms[picked].y; v1[2]=mol->atoms[bondPartners[i]].z-mol->atoms[picked].z; v2[0]=mol->atoms[bondPartners[imax]].x-mol->atoms[picked].x; v2[1]=mol->atoms[bondPartners[imax]].y-mol->atoms[picked].y; v2[2]=mol->atoms[bondPartners[imax]].z-mol->atoms[picked].z; vectorProduct(v1, v2, v3); mol->atoms=(struct ATOM *)expmem((void *)mol->atoms, (size_t)(mol->na+1), sizeof(struct ATOM)); mol->atoms[mol->na].x=mol->atoms[bondPartners[imax]].x+v3[0]; mol->atoms[mol->na].y=mol->atoms[bondPartners[imax]].y+v3[1]; mol->atoms[mol->na].z=mol->atoms[bondPartners[imax]].z+v3[2]; } mol->internals[mol->ninternal].atoms[3]=mol->na; (void)changeAngle(mol->ninternal, nbonds[i], &bondPartners[i*mol->na], t); if (n > 5) t+=360.0/(double)(n-3); else t+=360.0/(double)(n-2); } } } } } /* end of for-loop */ fremem((void **)&bondPartners); fremem((void **)&nbonds); if (useDummy) mol->atoms=(struct ATOM *)expmem((void *)mol->atoms, (size_t)(mol->na), sizeof(struct ATOM)); } viewmol-2.4.1/source/calcmo.c0100644000272700027270000003574407752675333014303 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * C A L C M O . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: calcmo.c,v 1.6 2003/11/07 10:58:35 jrh Exp $ * $Log: calcmo.c,v $ * Revision 1.6 2003/11/07 10:58:35 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:02:43 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:24:54 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:45:16 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:08 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:39:57 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" void setGridObject(struct GRIDOBJECT *, double, double, int, int, int); extern double makemo(struct ATOM *, struct ORBITAL *, double, double, double, int, int, int, int); extern int runMoloch(double *, double, double, double, int, struct ORBITAL *, int); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern char *getStringResource(Widget, char *); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void setCursor(Widget, int); extern int norbs(struct MOLECULE *); /* extern char *bfname(int);*/ extern void fremem(void **); extern void restoreGeometry(struct SAVE *, int); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern int runProg(char *, int, char *, char *, char *, pid_t *); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern double gridres; extern int iwavef; extern int bfatom; extern Widget topShell; extern char moloch[]; static int imol; void calcmo(void) { struct ORBITAL *orb=NULL; double fac, boxf, step; #ifdef DEBUG double d, m, a; #endif int mo=0, morb; register double x, y, z; register int i, j, k, l; imol=windows[MO].set; if (molecules[imol].ngridobjects == 0) { molecules[imol].ngridobjects++; molecules[imol].gridObjects=(struct GRIDOBJECT *)getmem(molecules[imol].ngridobjects, sizeof(struct GRIDOBJECT)); setGridObject(&(molecules[imol].gridObjects[0]), windows[VIEWER].far, gridres, iwavef, molecules[imol].imo, molecules[imol].ibasfu); } else { j=FALSE; for (i=0; icoeff=(double *)getmem((size_t)morb, sizeof(double)); orb->coeff[molecules[imol].ibasfu]=1.0; mo=0; break; case BASIS_IN_MO: orb=(struct ORBITAL *)getmem((size_t)1, sizeof(struct ORBITAL)); orb->coeff=(double *)getmem((size_t)morb, sizeof(double)); orb->coeff[molecules[imol].ibasfu]=molecules[imol].orbitals[molecules[imol].imo].coeff[molecules[imol].ibasfu]; mo=0; break; case MOLECULAR_ORBITAL: mo=molecules[imol].imo; orb=molecules[imol].orbitals; break; case DENSITY: mo=-1; orb=molecules[imol].orbitals; break; } #ifndef DEBUG if ((iwavef == MOLECULAR_ORBITAL || iwavef == DENSITY) && molecules[imol].needMoloch) { #endif if (runMoloch(molecules[imol].gridObjects[molecules[imol].ngridobjects-1].grid, gridres, boxf, step, mo, molecules[imol].orbitals, molecules[imol].nbasfu)) iwavef=0; #ifndef DEBUG } else { #else d=0.0; m=0.0; #endif i=0; z=-boxf; for (j=0; j<=gridres; j++) { y=-boxf; for (k=0; k<=gridres; k++) { x=-boxf; for (l=0; l<=gridres; l++) { #ifdef DEBUG a=molecules[imol].gridObjects[molecules[imol].ngridobjects-1].grid[i]; #endif molecules[imol].gridObjects[molecules[imol].ngridobjects-1].grid[i++] =makemo(molecules[imol].atoms, orb, x, y, z, molecules[imol].na, morb, molecules[imol].nbasfu, mo); #ifdef DEBUG printf("%15.10f %15.10f %15.10f\n", a, molecules[imol].gridObjects[molecules[imol].ngridobjects-1].grid[i-1], a-molecules[imol].gridObjects[molecules[imol].ngridobjects-1].grid[i-1]); d=d+fabs(molecules[imol].gridObjects[molecules[imol].ngridobjects-1].grid[i-1]-a); m=m > fabs(molecules[imol].gridObjects[molecules[imol].ngridobjects-1].grid[i-1]-a) ? m : fabs(molecules[imol].gridObjects[molecules[imol].ngridobjects-1].grid[i-1]-a); #endif x+=step; } y+=step; } z+=step; } #ifndef DEBUG } #else printf("%d grid points, average deviation %15.10f, maximum %15.10f\n", i, d/((gridres+1.0)*(gridres+1.0)*(gridres+1.0)), m); #endif restoreGeometry(molecules[imol].coord, imol); if (iwavef == BASIS_FUNCTION || iwavef == BASIS_IN_MO) { fremem((void **)&orb->coeff); fremem((void **)&orb); } setCursor(windows[VIEWER].widget, XC_top_left_arrow); if (windows[MO].widget != NULL) setCursor(windows[MO].widget, XC_top_left_arrow); } int runMoloch(double *grid, double gridres, double box, double step, int imo, struct ORBITAL *orbitals, int nbasfu) { static struct PushButtonRow buttons[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; FILE *infile, *outfile; pid_t pid; char line[MAXLENLINE], mofile[MAXLENLINE], *word; register int i, j; if (access("control", F_OK)) { word=getStringResource(topShell, "noControlFile"); messgb(topShell, 1, word, buttons, 1); return(TRUE); } rename("control", "control.save"); if (!access("propinp", F_OK)) rename("propinp", "propinp.save"); if ((infile=fopen("control.save", "r")) == NULL) { word=getStringResource(topShell, "unableToOpen"); sprintf(line, word, "control.save"); messgb(topShell, 1, line, buttons, 1); return(TRUE); } if ((outfile=fopen("control", "w")) == NULL) { word=getStringResource(topShell, "unableToOpen"); sprintf(line, word, "control"); messgb(topShell, 1, line, buttons, 1); return(TRUE); } while (fgets(line, MAXLENLINE, infile) != NULL) { if (strstr(line, "$end")) break; if (strstr(line, "$scfmo")) { fprintf(outfile, "%s", line); if ((word=strtok(line, "=")) != NULL) strcpy(mofile, strtok(NULL, " \t\n")); else strcpy(mofile, "control"); continue; } if (!strstr(line, "$properties")) { fprintf(outfile, "%s", line); continue; } else { do { fgets(line, MAXLENLINE, infile); } while (!(word=strchr(line, '$'))); continue; } } fprintf(outfile, "$properties file=propinp\n"); fprintf(outfile, "$end\n"); fclose(infile); fclose(outfile); outfile=fopen("propinp", "w"); fprintf(outfile, "$properties\n"); fprintf(outfile, " trace off\n"); fprintf(outfile, " moments off\n"); fprintf(outfile, " potential off\n"); fprintf(outfile, " cowan-griffin off\n"); fprintf(outfile, " localization off\n"); fprintf(outfile, " population analyses off\n"); fprintf(outfile, " plot active\n"); fprintf(outfile, " firstorder off\n"); fprintf(outfile, " fit off\n"); j=0; for (i=0; i<=imo; i++) if (!strcmp(molecules[imol].orbitals[i].symmetry, molecules[imol].orbitals[imo].symmetry)) j++; fprintf(outfile, "$grid #1\n"); if (imo != -1) fprintf(outfile, " mo %d%s\n", j, molecules[imol].orbitals[imo].symmetry); else fprintf(outfile, " mo\n"); fprintf(outfile, " origin .000000 .000000 .000000\n"); fprintf(outfile, " vector1 1.000000 .000000 .000000\n"); fprintf(outfile, " vector2 .000000 1.000000 .000000\n"); fprintf(outfile, " vector3 .000000 .000000 1.000000\n"); fprintf(outfile, " grid1 range %13.6f%13.6f points %d\n", -box, -box+gridres*step, (int)(gridres)+1); fprintf(outfile, " grid2 range %13.6f%13.6f points %d\n", -box, -box+gridres*step, (int)(gridres)+1); fprintf(outfile, " grid3 range %13.6f%13.6f points %d\n", -box, -box+gridres*step, (int)(gridres)+1); fprintf(outfile, " infile = %s\n", mofile); fprintf(outfile, " outfile = grid.dat\n"); fprintf(outfile, "$end\n"); fclose(outfile); if (runProg(moloch, TRUE, "/dev/null", "/dev/null", "/dev/null", &pid)) { iwavef=ALL_OFF; word=getStringResource(topShell, "molochFailed"); messgb(topShell, 1, word, buttons, 1); return(TRUE); } rename("control.save", "control"); unlink("propinp"); if (!access("propinp.save", F_OK)) rename("propinp.save", "propinp"); if ((infile=fopen("grid.dat", "r")) == NULL) { word=getStringResource(topShell, "noMolochOutput"); messgb(topShell, 1, word, buttons, 1); return(TRUE); } while (fgets(line, MAXLENLINE, infile) != NULL) if (strstr(line, "$plotdata")) break; i=0; while (fgets(line, MAXLENLINE, infile) != NULL) { if (strchr(line, '$')) break; while ((word=strchr(line, 'D')) != NULL) *word='E'; word=line; if (strlen(line) > 76) { sscanf(word, "%16le", &grid[i++]); word+=16; while (sscanf(word, "%16le", &grid[i++]) != EOF) word+=16; } else { sscanf(word, "%15le", &grid[i++]); word+=15; while (sscanf(word, "%15le", &grid[i++]) != EOF) word+=15; } i--; } fclose(infile); unlink("grid.dat"); return(FALSE); } void setGridObject(struct GRIDOBJECT *gridObject, double start, double gridres, int iwavef, int imo, int ibasfu) { char *word; gridObject->origin[0]=0.0; gridObject->origin[1]=0.0; gridObject->origin[2]=0.0; gridObject->vector1[0]=1.0; gridObject->vector1[1]=0.0; gridObject->vector1[2]=0.0; gridObject->vector2[0]=0.0; gridObject->vector2[1]=1.0; gridObject->vector2[2]=0.0; gridObject->vector3[0]=0.0; gridObject->vector3[1]=0.0; gridObject->vector3[2]=1.0; gridObject->start[0]=gridObject->start[1]=gridObject->start[2]=(-start); gridObject->step[0]=gridObject->step[1]=gridObject->step[2]=2.0*start/gridres; gridObject->ngridpoints[0]=gridObject->ngridpoints[1]=gridObject->ngridpoints[2]=(int)gridres; gridObject->npoints[0]=gridObject->ngridpoints[0]; gridObject->npoints[1]=gridObject->ngridpoints[1]; gridObject->npoints[2]=gridObject->ngridpoints[2]; gridObject->resolution=gridres; gridObject->type=iwavef; gridObject->mo=imo; gridObject->basisfunction=ibasfu; switch (iwavef) { case BASIS_FUNCTION: word=getStringResource(topShell, "basisfunctionTitle"); sprintf(gridObject->text, word, ibasfu+1, molecules[imol].atoms[bfatom].name, /* bfatom+1, bfname(ibasfu));*/ bfatom+1, molecules[imol].atoms[bfatom].basisFunctionNames[ibasfu]); break; case BASIS_IN_MO: word=getStringResource(topShell, "basisfunctionInMOTitle"); sprintf(gridObject->text, word, ibasfu+1, imo+1, molecules[imol].atoms[bfatom].name, bfatom+1, molecules[imol].orbitals[imo].coeff[ibasfu], /* bfname(ibasfu));*/ molecules[imol].atoms[bfatom].basisFunctionNames[ibasfu]); break; case MOLECULAR_ORBITAL: word=getStringResource(topShell, "molecularOrbitalTitle"); sprintf(gridObject->text, word, imo+1, molecules[imol].orbitals[imo].symmetry, molecules[imol].orbitals[imo].energy); break; case DENSITY: word=getStringResource(topShell, "electronDensityTitle"); sprintf(gridObject->text, word); break; } } clock_t getCPUTime(void) { struct tms buffer; if (times(&buffer) != -1) return(buffer.tms_utime+buffer.tms_stime); else return((clock_t)0); } viewmol-2.4.1/source/cellform.c0100644000272700027270000002202110114366336014612 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * C E L L F O R M . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: cellform.c,v 1.5 2004/08/29 14:49:02 jrh Exp $ * $Log: cellform.c,v $ * Revision 1.5 2004/08/29 14:49:02 jrh * Release 2.4.1 * * Revision 1.4 2003/11/07 10:58:46 jrh * Release 2.4 * * Revision 1.3 2000/12/10 15:02:51 jrh * Release 2.3 * * Revision 1.2 1999/05/24 01:24:56 jrh * Release 2.2.1 * * Revision 1.1 1999/02/07 21:45:28 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" void unitcellExit(Widget, caddr_t, XmPushButtonCallbackStruct *); void setCellSliders(struct MOLECULE *); void makeNewCell(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); void makeMillerPlane(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); extern void GetSlider(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); extern void drawMolecule(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern int redraw(int); extern void expandCell(int, int); extern void millerPlane(void); extern void MapBox(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern Widget CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern Widget CreateToggleBox(Widget, struct PushButtonRow *, int, int, int, int, int); extern void changeBoolean(Widget, int *, XmDrawingAreaCallbackStruct *); extern Widget initShell(Widget, char *, Widget *, Widget *); extern void setMenuItem(int, int); extern void *getmem(size_t, size_t); extern void fremem(void **); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern Widget topShell; extern int showUnitCell, iwavef; static Widget dialog, millerButton, cellWidgets[3], millerWidgets[3]; static struct MOLECULE *mol; static int showUnitCell_save, showMiller_save; static int miller_save[3]; static double cellFactor_save[3], miller[3]; void unitcellDialog(Widget widget, caddr_t dummy, XmAnyCallbackStruct *data) { Widget form, form1, board, togglebox, sep; short decimals; static struct SLIDER cellSliders[3], millerSliders[3]; static struct PushButtonRow checkbox_button[] = {{"visible", changeBoolean, (XtPointer)&showUnitCell, NULL}, {"miller", changeBoolean, (XtPointer)NULL, NULL}}; static struct PushButtonRow buttons[] = { { "ok", unitcellExit, (XtPointer)TRUE, NULL }, { "cancel", unitcellExit, (XtPointer)FALSE, NULL }, }; char line[]=" value"; register int i; /* This function creates the dialog for the "Unit cell" option */ millerPlane(); if (windows[VIEWER].set < 0) mol=&molecules[0]; else mol=&molecules[windows[VIEWER].set]; setMenuItem(VIEWER_UNITCELL, False); showUnitCell_save=showUnitCell; showMiller_save=mol->unitcell->showMiller; cellFactor_save[0]=mol->unitcell->factor[0]; cellFactor_save[1]=mol->unitcell->factor[1]; cellFactor_save[2]=mol->unitcell->factor[2]; miller_save[0]=mol->unitcell->miller[0]; miller_save[1]=mol->unitcell->miller[1]; miller_save[2]=mol->unitcell->miller[2]; dialog=initShell(windows[VIEWER].widget, "unitcellForm", &board, &form); checkbox_button[1].client_data=(XtPointer)&(mol->unitcell->showMiller); togglebox=CreateToggleBox(form, checkbox_button, XtNumber(checkbox_button), XmHORIZONTAL, 1, False, ((mol->unitcell->showMiller << 1) | showUnitCell)); millerButton=checkbox_button[1].widget; sep=XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, form, NULL); form1=XtVaCreateWidget("rowcolumn", xmRowColumnWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNpacking, XmPACK_COLUMN, XmNnumColumns, (short)3, NULL); for (i=0; i<3; i++) { line[0]=(char)(97+i); cellWidgets[i]=XtVaCreateManagedWidget(line, xmScaleWidgetClass, form1, XmNorientation, XmHORIZONTAL, XmNshowValue, True, XmNsensitive, True, NULL); XtVaGetValues(cellWidgets[i], XmNdecimalPoints, &decimals, NULL); XtVaSetValues(cellWidgets[i], XmNvalue, (int)(mol->unitcell->factor[i]*pow(10.0, (double)decimals)), NULL); cellSliders[i].number=&(mol->unitcell->factor[i]); cellSliders[i].decimals=decimals; cellSliders[i].draw=(void (*)())drawMolecule; XtAddCallback(cellWidgets[i], XmNvalueChangedCallback, (XtCallbackProc)makeNewCell, &cellSliders[i]); line[0]=(char)(104+i); if (i > 0) line[0]+=2; millerWidgets[i]=XtVaCreateManagedWidget(line, xmScaleWidgetClass, form1, XmNorientation, XmHORIZONTAL, XmNshowValue, True, XmNsensitive, True, XmNdecimalPoints, 0, XmNvalue, mol->unitcell->miller[i], NULL); miller[i]=(double)(mol->unitcell->miller[i]); millerSliders[i].number=&miller[i]; millerSliders[i].decimals=0; millerSliders[i].draw=(void (*)())drawMolecule; XtAddCallback(millerWidgets[i], XmNvalueChangedCallback, (XtCallbackProc)makeMillerPlane, &millerSliders[i]); } XtManageChild(form1); sep=XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, form, NULL); CreatePushButtonRow(form, buttons, XtNumber(buttons)); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XmAnyCallbackStruct *)NULL); XtManageChild(form); XtManageChild(board); } void unitcellExit(Widget button, caddr_t which, XmPushButtonCallbackStruct *data) { XtDestroyWidget(dialog); dialog=NULL; if (!(int)which) { showUnitCell=showUnitCell_save; mol->unitcell->showMiller=showMiller_save; if (mol->unitcell->factor[0] != cellFactor_save[0] || mol->unitcell->factor[1] != cellFactor_save[1] || mol->unitcell->factor[2] != cellFactor_save[2]) { mol->unitcell->factor[0]=cellFactor_save[0]; mol->unitcell->factor[1]=cellFactor_save[1]; mol->unitcell->factor[2]=cellFactor_save[2]; expandCell(TRUE, TRUE); } mol->unitcell->miller[0]=miller_save[0]; mol->unitcell->miller[1]=miller_save[1]; mol->unitcell->miller[2]=miller_save[2]; redraw(VIEWER); } setMenuItem(VIEWER_UNITCELL, True); } void setCellSliders(struct MOLECULE *mol) { short decimals; register int i; if (dialog) { for (i=0; i<3; i++) { XtVaGetValues(cellWidgets[i], XmNdecimalPoints, &decimals, NULL); XtVaSetValues(cellWidgets[i], XmNvalue, (int)(mol->unitcell->factor[i]*pow(10.0, (double)decimals)), NULL); } } } void makeNewCell(Widget w, struct SLIDER *slider, XmScrollBarCallbackStruct *data) { GetSlider(w, slider, data); expandCell(TRUE, TRUE); redraw(VIEWER); } void makeMillerPlane(Widget w, struct SLIDER *slider, XmScrollBarCallbackStruct *data) { static int save=(-1); GetSlider(w, slider, data); mol->unitcell->miller[0]=(int)(miller[0]); mol->unitcell->miller[1]=(int)(miller[1]); mol->unitcell->miller[2]=(int)(miller[2]); if (mol->unitcell->miller[0] == 0 && mol->unitcell->miller[1] == 0 && mol->unitcell->miller[2] == 0) { save=mol->unitcell->showMiller; mol->unitcell->showMiller=FALSE; XtVaSetValues(millerButton, XmNsensitive, False, XmNset, False, NULL); } else { if (save != -1) mol->unitcell->showMiller=save; XtVaSetValues(millerButton, XmNsensitive, True, NULL); if (save == TRUE) XtVaSetValues(millerButton, XmNset, True, NULL); if (mol->unitcell->miller[0] != miller_save[0] || mol->unitcell->miller[1] != miller_save[1] || mol->unitcell->miller[2] != miller_save[2]) millerPlane(); } redraw(VIEWER); } viewmol-2.4.1/source/coledit.c0100644000272700027270000007530707752675356014474 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * C O L E D I T . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: coledit.c,v 1.6 2003/11/07 10:58:54 jrh Exp $ * $Log: coledit.c,v $ * Revision 1.6 2003/11/07 10:58:54 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:03:02 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:24:58 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:45:41 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:11 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:40:03 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" void colorEditor(Widget, caddr_t, XmAnyCallbackStruct *); void colorEditorExit(Widget, caddr_t, XmPushButtonCallbackStruct *); void GetColor(Widget, caddr_t, XmToggleButtonCallbackStruct *); void SetColor(Widget, float *, XmScrollBarCallbackStruct *); void getRGBColor(Widget, Pixel, float *, float *, float *); void storeColor(Pixel, struct WINDOW *, int); void SetSmooth(Widget, int *, XmToggleButtonCallbackStruct *); XVisualInfo *getVisualInfo(Display *, Visual *); Colormap getRGBcolormap(Display *, int, XVisualInfo *); extern Widget CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern void MapBox(Widget, caddr_t, XmAnyCallbackStruct *); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern Pixel getPixel(int); extern void redraw(int); extern char *getStringResource(Widget, char *); extern int getIntResource(Widget, char *); extern void setMenuItem(int, int); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern Widget initShell(Widget, char *, Widget *, Widget *); extern Widget topShell; extern struct MOLECULE *molecules; extern struct WINDOW windows[]; extern struct ELEMENT *elements; extern Pixel stdcol[9], historyColor; extern float historyColor_rgb[4]; extern int rgbMode, ne, debug, projectionMode; extern int nmolecule; static Widget dialog, red, green, blue, button[9]; static Pixel pixelSave; static float rSave, gSave, bSave; static int window, where, smoothSave; void colorEditor(Widget widget, caddr_t which, XmAnyCallbackStruct *data) { Widget board, form, form1, form2=(Widget)0, smoothRed, smoothGreen, smoothBlue; Pixmap selected, unselected; Pixel p; static struct PushButtonRow buttons[] = { { "ok", colorEditorExit, (XtPointer)TRUE, NULL }, { "cancel", colorEditorExit, (XtPointer)FALSE, NULL } }; static unsigned char selectedData[] = { 0xff, 0xff, 0xff, 0x01, 0x00, 0x80, 0x01, 0x00, 0xb8, 0x01, 0x00, 0xb8, 0x01, 0x00, 0x9c, 0x01, 0x00, 0x9c, 0x01, 0x00, 0x8e, 0x01, 0x00, 0x8e, 0x01, 0x00, 0x87, 0x01, 0x00, 0x87, 0x01, 0x80, 0x83, 0x01, 0x80, 0x83, 0x01, 0x80, 0x81, 0x19, 0xc0, 0x81, 0x39, 0xc0, 0x80, 0x71, 0xe0, 0x80, 0xe1, 0x60, 0x80, 0xc1, 0x71, 0x80, 0x81, 0x33, 0x80, 0x01, 0x3f, 0x80, 0x01, 0x1e, 0x80, 0x01, 0x1c, 0x80, 0x01, 0x00, 0x80, 0xff, 0xff, 0xff}; static unsigned char unselectedData[] = { 0xff, 0xff, 0xff, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0xff, 0xff, 0xff}; float *c=NULL, r, g, b, r1, g1, b1; int depth; char buttonName[8]; register int i, j; /* This function creates the dialog for the color editor */ setMenuItem(VIEWER_FOREGROUND, False); setMenuItem(VIEWER_BACKGROUND, False); if (windows[SPECTRUM].widget != 0) { setMenuItem(SPECTRUM_FOREGROUND, False); setMenuItem(SPECTRUM_BACKGROUND, False); } if (windows[MO].widget != 0) { setMenuItem(MO_FOREGROUND, False); setMenuItem(MO_BACKGROUND, False); } if (windows[HISTORY].widget != 0) { setMenuItem(HISTORY_ENERGY, False); setMenuItem(HISTORY_GRADIENT, False); setMenuItem(HISTORY_BACKGROUND, False); } window=(int)which & 0x7; where=((int)which & 0xFFFFFFF8) >> 3; dialog=initShell(topShell, "colorEditor", &board, &form); form1=XtVaCreateWidget("controlarea1", xmRowColumnWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNradioBehavior, True, NULL); switch (where) { case BACKGROUND: if (rgbMode) { r=windows[window].background_rgb[0]; g=windows[window].background_rgb[1]; b=windows[window].background_rgb[2]; pixelSave=-1; } else { getRGBColor(windows[window].widget, windows[window].background, &r, &g, &b); pixelSave=windows[window].background; } break; case FOREGROUND: if (rgbMode) { r=windows[window].foreground_rgb[0]; g=windows[window].foreground_rgb[1]; b=windows[window].foreground_rgb[2]; pixelSave=-1; } else { getRGBColor(windows[window].widget, windows[window].foreground, &r, &g, &b); pixelSave=windows[window].foreground; } break; case GNORM: if (rgbMode) { r=historyColor_rgb[0]; g=historyColor_rgb[1]; b=historyColor_rgb[2]; pixelSave=-1; } else { getRGBColor(windows[window].widget, historyColor, &r, &g, &b); pixelSave=historyColor; } break; } XtVaGetValues(topShell, XtNdepth, &depth, NULL); j=WHITE; for (i=0; i<=MAGENTA; i++) { sprintf(buttonName, "button%1d", i); p=getPixel(i); selected=XCreatePixmapFromBitmapData(XtDisplay(dialog), XtWindow(dialog), (char *)selectedData, 24, 24, stdcol[j], p, depth); unselected=XCreatePixmapFromBitmapData(XtDisplay(dialog), XtWindow(dialog), (char *)unselectedData, 24, 24, stdcol[BLACK], p, depth); button[i]=XtVaCreateManagedWidget(buttonName, xmToggleButtonWidgetClass, form1, XmNlabelType, XmPIXMAP, XmNlabelPixmap, unselected, XmNselectPixmap, selected, XmNindicatorOn, False, NULL); XtAddCallback(button[i], XmNvalueChangedCallback, (XtCallbackProc)GetColor, (caddr_t)i); getRGBColor(button[i], p, &r1, &g1, &b1); if (r1 == r && g1 == g && b1 == b) XtVaSetValues(button[i], XmNset, True, NULL); j=BLACK; } if (rgbMode && where == BACKGROUND && window == VIEWER) { form2=XtVaCreateWidget("controlarea2", xmRowColumnWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, form1, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); smoothRed=XtVaCreateManagedWidget("smoothRed", xmToggleButtonWidgetClass, form2, XtVaTypedArg, XmNforeground, XmRString, "Red", 4, NULL); XtAddCallback(smoothRed, XmNvalueChangedCallback, (XtCallbackProc)SetSmooth, (XtPointer)1); if (windows[window].smooth & 1) XtVaSetValues(smoothRed, XmNset, True, NULL); smoothGreen=XtVaCreateManagedWidget("smoothGreen", xmToggleButtonWidgetClass, form2, XtVaTypedArg, XmNforeground, XmRString, "Green", 6, NULL); XtAddCallback(smoothGreen, XmNvalueChangedCallback, (XtCallbackProc)SetSmooth, (XtPointer)2); if (windows[window].smooth & 2) XtVaSetValues(smoothGreen, XmNset, True, NULL); smoothBlue=XtVaCreateManagedWidget("smoothBlue", xmToggleButtonWidgetClass, form2, XtVaTypedArg, XmNforeground, XmRString, "Blue", 5, NULL); XtAddCallback(smoothBlue, XmNvalueChangedCallback, (XtCallbackProc)SetSmooth, (XtPointer)4); if (windows[window].smooth & 4) XtVaSetValues(smoothBlue, XmNset, True, NULL); } rSave=r; gSave=g; bSave=b; red=XtVaCreateManagedWidget("red", xmScaleWidgetClass, form, XmNorientation, XmHORIZONTAL, XtVaTypedArg, XmNtroughColor, XmRString, "Red", 4, XtVaTypedArg, XmNforeground, XmRString, "Red", 4, XmNvalue, (int)(1000.*r), XmNminimum, 0, XmNmaximum, 1000, XmNdecimalPoints, 3, XmNshowValue, True, XmNsensitive, True, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); switch (where) { case FOREGROUND: c=&windows[window].foreground_rgb[0]; break; case BACKGROUND: c=&windows[window].background_rgb[0]; break; case GNORM: c=&historyColor_rgb[0]; break; } XtAddCallback(red, XmNvalueChangedCallback, (XtCallbackProc)SetColor, c); XtAddCallback(red, XmNdragCallback, (XtCallbackProc)SetColor, c); green=XtVaCreateManagedWidget("green", xmScaleWidgetClass, form, XmNorientation, XmHORIZONTAL, XtVaTypedArg, XmNtroughColor, XmRString, "Green", 6, XtVaTypedArg, XmNforeground, XmRString, "Green", 6, XmNvalue, (int)(1000.*g), XmNminimum, 0, XmNmaximum, 1000, XmNdecimalPoints, 3, XmNshowValue, True, XmNsensitive, True, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); switch (where) { case FOREGROUND: c=&windows[window].foreground_rgb[1]; break; case BACKGROUND: c=&windows[window].background_rgb[1]; break; case GNORM: c=&historyColor_rgb[1]; break; } XtAddCallback(green, XmNvalueChangedCallback, (XtCallbackProc)SetColor, c); XtAddCallback(green, XmNdragCallback, (XtCallbackProc)SetColor, c); blue=XtVaCreateManagedWidget("blue", xmScaleWidgetClass, form, XmNorientation, XmHORIZONTAL, XtVaTypedArg, XmNtroughColor, XmRString, "Blue", 5, XtVaTypedArg, XmNforeground, XmRString, "Blue", 5, XmNvalue, (int)(1000.*b), XmNminimum, 0, XmNmaximum, 1000, XmNdecimalPoints, 3, XmNshowValue, True, XmNsensitive, True, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); switch (where) { case FOREGROUND: c=&windows[window].foreground_rgb[2]; break; case BACKGROUND: c=&windows[window].background_rgb[2]; break; case GNORM: c=&historyColor_rgb[2]; break; } XtAddCallback(blue, XmNvalueChangedCallback, (XtCallbackProc)SetColor, c); XtAddCallback(blue, XmNdragCallback, (XtCallbackProc)SetColor, c); XtManageChild(form1); if (rgbMode && where == BACKGROUND && window == VIEWER) XtManageChild(form2); CreatePushButtonRow(form, buttons, 2); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XmAnyCallbackStruct *)NULL); XtManageChild(form); XtManageChild(board); } void colorEditorExit(Widget widget, caddr_t which, XmPushButtonCallbackStruct *data) { XColor c; Colormap colormap; XtDestroyWidget(dialog); if (!(int)which) { switch (where) { case BACKGROUND: windows[window].background=pixelSave; windows[window].background_rgb[0]=rSave; windows[window].background_rgb[1]=gSave; windows[window].background_rgb[2]=bSave; windows[window].smooth=smoothSave; break; case FOREGROUND: windows[window].foreground=pixelSave; windows[window].foreground_rgb[0]=rSave; windows[window].foreground_rgb[1]=gSave; windows[window].foreground_rgb[2]=bSave; break; case GNORM: historyColor=pixelSave; historyColor_rgb[0]=rSave; historyColor_rgb[1]=gSave; historyColor_rgb[2]=bSave; break; } if (!rgbMode) { c.pixel=pixelSave; c.red=(unsigned short)(rSave*65535.+0.5); c.green=(unsigned short)(gSave*65535.+0.5); c.blue=(unsigned short)(bSave*65535.+0.5); c.flags=DoRed | DoGreen | DoBlue; XtVaGetValues(windows[window].widget, XmNcolormap, &colormap, NULL); XStoreColor(XtDisplay(windows[window].widget), colormap, &c); } redraw(window); } if (projectionMode != ORTHO) setMenuItem(VIEWER_FOREGROUND, True); setMenuItem(VIEWER_BACKGROUND, True); if (windows[SPECTRUM].widget != 0) { setMenuItem(SPECTRUM_FOREGROUND, True); setMenuItem(SPECTRUM_BACKGROUND, True); } if (windows[MO].widget != 0) { setMenuItem(MO_FOREGROUND, True); setMenuItem(MO_BACKGROUND, True); } if (windows[HISTORY].widget != 0) { setMenuItem(HISTORY_ENERGY, True); setMenuItem(HISTORY_GRADIENT, True); setMenuItem(HISTORY_BACKGROUND, True); } } void GetColor(Widget widget, caddr_t which, XmToggleButtonCallbackStruct *data) { XColor c; Colormap colormap; float r, g, b; if (data->set) { getRGBColor(widget, stdcol[(int)which], &r, &g, &b); switch (where) { case BACKGROUND: windows[window].background_rgb[0]=r; windows[window].background_rgb[1]=g; windows[window].background_rgb[2]=b; c.pixel=windows[window].background; break; case FOREGROUND: windows[window].foreground_rgb[0]=r; windows[window].foreground_rgb[1]=g; windows[window].foreground_rgb[2]=b; c.pixel=windows[window].foreground; break; case GNORM: historyColor_rgb[0]=r; historyColor_rgb[1]=g; historyColor_rgb[2]=b; c.pixel=historyColor; break; } XtVaSetValues(red, XmNvalue, (int)(1000.*r), NULL); XtVaSetValues(green, XmNvalue, (int)(1000.*g), NULL); XtVaSetValues(blue, XmNvalue, (int)(1000.*b), NULL); if (!rgbMode) { c.red=(unsigned short)(r*65535.+0.5); c.green=(unsigned short)(g*65535.+0.5); c.blue=(unsigned short)(b*65535.+0.5); c.flags=DoRed | DoGreen | DoBlue; XtVaGetValues(widget, XmNcolormap, &colormap, NULL); XStoreColor(XtDisplay(windows[window].widget), colormap, &c); } redraw(window); } } void SetColor(Widget widget, float *color, XmScrollBarCallbackStruct *data) { Colormap colormap; XColor c; float r, g, b; register int i; *color=0.001*(double)(data->value); switch (where) { case BACKGROUND: c.pixel=windows[window].background; c.red=(unsigned short)(windows[window].background_rgb[0]*65535.+0.5); c.green=(unsigned short)(windows[window].background_rgb[1]*65535.+0.5); c.blue=(unsigned short)(windows[window].background_rgb[2]*65535.+0.5); break; case FOREGROUND: c.pixel=windows[window].foreground; c.red=(unsigned short)(windows[window].foreground_rgb[0]*65535.+0.5); c.green=(unsigned short)(windows[window].foreground_rgb[1]*65535.+0.5); c.blue=(unsigned short)(windows[window].foreground_rgb[2]*65535.+0.5); break; case GNORM: c.pixel=historyColor; c.red=(unsigned short)(historyColor_rgb[0]*65535.+0.5); c.green=(unsigned short)(historyColor_rgb[1]*65535.+0.5); c.blue=(unsigned short)(historyColor_rgb[2]*65535.+0.5); break; } if (!rgbMode) { c.flags=DoRed | DoGreen | DoBlue; XtVaGetValues(windows[window].widget, XmNcolormap, &colormap, NULL); XStoreColor(XtDisplay(windows[window].widget), colormap, &c); } for (i=0; i<=MAGENTA; i++) { XtVaSetValues(button[i], XmNset, False, NULL); getRGBColor(button[i], stdcol[i], &r, &g, &b); if ((unsigned short)(65535.*r+0.5) == c.red && (unsigned short)(65535.*g+0.5) == c.green && (unsigned short)(65535.*b+0.5) == c.blue) { XtVaSetValues(button[i], XmNset, True, NULL); break; } } redraw(window); } void getRGBColor(Widget widget, Pixel pixel, float *r, float *g, float *b) { Display *display; Colormap colormap; XColor color; display=XtDisplay(widget); XtVaGetValues(widget, XmNcolormap, &colormap, NULL); color.pixel=pixel; XQueryColor(display, colormap, &color); *r=(float)(color.red)/65535.; *g=(float)(color.green)/65535.; *b=(float)(color.blue)/65535.; } void storeColor(Pixel pixel, struct WINDOW *window, int where) { Display *display; Colormap colormap; XColor c; switch (where) { case BACKGROUND: getRGBColor(window->widget, pixel, &(window->background_rgb[0]), &(window->background_rgb[1]), &(window->background_rgb[2])); break; case FOREGROUND: getRGBColor(window->widget, pixel, &(window->foreground_rgb[0]), &(window->foreground_rgb[1]), &(window->foreground_rgb[2])); break; case GNORM: display=XtDisplay(window->widget); XtVaGetValues(window->widget, XmNcolormap, &colormap, NULL); c.pixel=pixel; XQueryColor(display, colormap, &c); historyColor_rgb[0]=(float)(c.red)/65535.; historyColor_rgb[1]=(float)(c.green)/65535.; historyColor_rgb[2]=(float)(c.blue)/65535.; break; } if (rgbMode) return; /*if (rgbMode) colormap=DefaultColormapOfScreen(XtScreen(window->widget)); else*/ XtVaGetValues(window->widget, XmNcolormap, &colormap, NULL); c.flags=DoRed | DoGreen | DoBlue; switch (where) { case BACKGROUND: c.pixel=window->background; c.red=(unsigned short)(window->background_rgb[0]*65535.+0.5); c.green=(unsigned short)(window->background_rgb[1]*65535.+0.5); c.blue=(unsigned short)(window->background_rgb[2]*65535.+0.5); break; case FOREGROUND: c.pixel=window->foreground; c.red=(unsigned short)(window->foreground_rgb[0]*65535.+0.5); c.green=(unsigned short)(window->foreground_rgb[1]*65535.+0.5); c.blue=(unsigned short)(window->foreground_rgb[2]*65535.+0.5); break; case GNORM: c.pixel=historyColor; c.red=(unsigned short)(historyColor_rgb[0]*65535.+0.5); c.green=(unsigned short)(historyColor_rgb[1]*65535.+0.5); c.blue=(unsigned short)(historyColor_rgb[2]*65535.+0.5); break; } XStoreColor(XtDisplay(window->widget), colormap, &c); } void loadColorMap(void) { char *colorname[9] = { "black", "white", "red", "green", "blue", "yellow", "magenta", "cyan1", "SkyBlue"}; Display *display; Colormap colormap; XColor hardwarecolor, exactcolor; register int i; display=XtDisplay(windows[VIEWER].widget); XtVaGetValues(windows[VIEWER].widget, XmNcolormap, &colormap, NULL); for (i=0; i<9; i++) { if (XAllocNamedColor(display, colormap, colorname[i], &hardwarecolor, &exactcolor)) stdcol[i]=hardwarecolor.pixel; else stdcol[i]=0L; } } void loadAtomColors(XVisualInfo *visualInfo, Colormap colormap) { static struct PushButtonRow buttons[] = {{"exit", GetMessageBoxButton, (XtPointer)0, NULL}}; static unsigned long *pixels; static int allocated=0; Display *display; XColor c; float r, g, b; unsigned long nramp; struct ELEMENT **e; char *word; size_t total=0; int reserved=0, count=0, hasOrbitals=FALSE; register int i, j, k; for (i=0; icolormap_size-20-reserved)/count; pixels=(unsigned long *)getmem((size_t)(nramp*count), sizeof(unsigned long)); while (!XAllocColorCells(display, colormap, True, NULL, 0, pixels, (unsigned long)(nramp*count-reserved))) { nramp--; if (nramp < 3) { word=getStringResource(topShell, "noColors"); messgb(topShell, 3, word, buttons, 1); exit(-1); } } allocated=nramp*count-reserved; } else nramp=(allocated+reserved)/count; if (reserved) nramp-=reserved/count+1; if (debug) printf("%ld colors per atom available.\n", nramp); k=0; c.flags=DoRed | DoGreen | DoBlue; for (i=0; idark[0]; g=e[i]->dark[1]; b=e[i]->dark[2]; c.pixel=pixels[k]; c.red=(unsigned short)(r*65535.+0.5); c.green=(unsigned short)(g*65535.+0.5); c.blue=(unsigned short)(b*65535.+0.5); XStoreColor(display, colormap, &c); e[i]->colormap[0]=pixels[k++]; r=(e[i]->light[0]-e[i]->dark[0])/(nramp-1); g=(e[i]->light[1]-e[i]->dark[1])/(nramp-1); b=(e[i]->light[2]-e[i]->dark[2])/(nramp-1); for (j=1; jdark[0]+j*r)*65535.+0.5); c.green=(unsigned short)((e[i]->dark[1]+j*g)*65535.+0.5); c.blue=(unsigned short)((e[i]->dark[2]+j*b)*65535.+0.5); XStoreColor(display, colormap, &c); if (j == nramp/2) e[i]->colormap[1]=pixels[k]; k++; } r=e[i]->light[0]; g=e[i]->light[1]; b=e[i]->light[2]; c.pixel=pixels[k]; c.red=(unsigned short)(r*65535.+0.5); c.green=(unsigned short)(g*65535.+0.5); c.blue=(unsigned short)(b*65535.+0.5); XStoreColor(display, colormap, &c); e[i]->colormap[2]=pixels[k++]; } } fremem((void **)&e); } void allocWindowColors(void) { static struct PushButtonRow buttons[] = {{"exit", GetMessageBoxButton, (XtPointer)0, NULL}}; Display *display; Colormap colormap; Pixel pixel; unsigned long ncolors=9, *pixels; char *word; register int i; if (rgbMode) { XtVaGetValues(windows[VIEWER].widget, XmNbackground, &pixel, NULL); getRGBColor(windows[VIEWER].widget, pixel, &(windows[VIEWER].background_rgb[0]), &(windows[VIEWER].background_rgb[1]), &(windows[VIEWER].background_rgb[2])); XtVaGetValues(windows[VIEWER].widget, XmNforeground, &pixel, NULL); getRGBColor(windows[VIEWER].widget, pixel, &(windows[VIEWER].foreground_rgb[0]), &(windows[VIEWER].foreground_rgb[1]), &(windows[VIEWER].foreground_rgb[2])); windows[VIEWER].background_rgb[3]=1.0; windows[VIEWER].foreground_rgb[3]=1.0; } else { display=XtDisplay(windows[VIEWER].widget); XtVaGetValues(windows[VIEWER].widget, XmNcolormap, &colormap, NULL); pixels=(unsigned long *)getmem((size_t)ncolors, sizeof(unsigned long)); if (!XAllocColorCells(display, colormap, True, NULL, 0, pixels, ncolors)) { word=getStringResource(topShell, "noColors"); messgb(topShell, 3, word, buttons, 1); exit(-1); } i=0; windows[VIEWER].background=pixels[i++]; windows[VIEWER].foreground=pixels[i++]; windows[SPECTRUM].background=pixels[i++]; windows[SPECTRUM].foreground=pixels[i++]; windows[HISTORY].background=pixels[i++]; windows[HISTORY].foreground=pixels[i++]; historyColor=pixels[i++]; windows[MO].background=pixels[i++]; windows[MO].foreground=pixels[i++]; XtVaGetValues(windows[VIEWER].widget, XmNbackground, &pixel, NULL); storeColor(pixel, &windows[VIEWER], BACKGROUND); XtVaGetValues(windows[VIEWER].widget, XmNforeground, &pixel, NULL); storeColor(pixel, &windows[VIEWER], FOREGROUND); fremem((void **)&pixels); } } void SetSmooth(Widget widget, int *which, XmToggleButtonCallbackStruct *data) { if (data->set) windows[window].smooth |= (int)which; else windows[window].smooth &= ~(int)which; redraw(window); } XVisualInfo *getVisualInfo(Display *display, Visual *vi) { XVisualInfo template; int items; template.visual=vi; template.visualid=vi->visualid; /* leaks memory */ return(XGetVisualInfo(display, VisualIDMask, &template, &items)); } Colormap getRGBcolormap(Display *dpy, int scrnum, XVisualInfo *visinfo) { /* * Return an X colormap to use for OpenGL RGB-mode rendering. * Input: dpy - the X display * scrnum - the X screen number * visinfo - the XVisualInfo as returned by glXChooseVisual() * Return: an X Colormap or 0 if there's a _serious_ error. */ Atom hp_cr_maps; Status status; int numCmaps, i, using_mesa; XStandardColormap *standardCmaps; Window root = RootWindow(dpy,scrnum); /* * First check if visinfo's visual matches the default/root visual. */ if (visinfo->visual==DefaultVisual(dpy,scrnum)) { /* use the default/root colormap */ return DefaultColormap( dpy, scrnum ); } /* * Check if we're using Mesa. */ if (strstr(glXQueryServerString( dpy, scrnum, GLX_VERSION ), "Mesa")) { using_mesa = 1; } else { using_mesa = 0; } /* * Next, if we're using Mesa and displaying on an HP with the "Color * Recovery" feature and the visual is 8-bit TrueColor, search for a * special colormap initialized for dithering. Mesa will know how to * dither using this colormap. */ if (using_mesa) { hp_cr_maps = XInternAtom( dpy, "_HP_RGB_SMOOTH_MAP_LIST", True ); if (hp_cr_maps && visinfo->visual->class==TrueColor && visinfo->depth==8) { status = XGetRGBColormaps( dpy, root, &standardCmaps, &numCmaps, hp_cr_maps ); if (status) { for (i=0; i < numCmaps; i++) { if (standardCmaps[i].visualid==visinfo->visual->visualid) { Colormap cmap = standardCmaps[i].colormap; XFree(standardCmaps); return cmap; } } XFree(standardCmaps); } } } /* * Next, try to find a standard X colormap. */ #ifndef SOLARIS_BUG status = XmuLookupStandardColormap( dpy, visinfo->screen, visinfo->visualid, visinfo->depth, XA_RGB_DEFAULT_MAP, /* replace */ False, /* retain */ True); if (status == 1) { status = XGetRGBColormaps( dpy, root, &standardCmaps, &numCmaps, XA_RGB_DEFAULT_MAP); if (status == 1) { for (i = 0; i < numCmaps; i++) { if (standardCmaps[i].visualid == visinfo->visualid) { Colormap cmap = standardCmaps[i].colormap; XFree(standardCmaps); return cmap; } } XFree(standardCmaps); } } #endif /* * If we get here, give up and just allocate a new colormap. */ return XCreateColormap( dpy, root, visinfo->visual, AllocNone ); } viewmol-2.4.1/source/confform.c0100644000272700027270000002365307752675370014653 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * C O N F F O R M . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: confform.c,v 1.4 2003/11/07 10:59:04 jrh Exp $ * $Log: confform.c,v $ * Revision 1.4 2003/11/07 10:59:04 jrh * Release 2.4 * * Revision 1.3 2000/12/10 15:03:36 jrh * Release 2.3 * * Revision 1.2 1999/05/24 01:25:00 jrh * Release 2.2.1 * * Revision 1.1 1999/02/07 21:45:59 jrh * Initial revision * * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" void configurationDialog(Widget, caddr_t, XmAnyCallbackStruct *); void configurationDialogExit(Widget, caddr_t, XmPushButtonCallbackStruct *); void SetLanguage(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetString(Widget, caddr_t, XmAnyCallbackStruct *); #if defined LINUX || defined DARWIN int matchXdefaults(const struct dirent *); #else int matchXdefaults(struct dirent *); #endif extern Widget makeViewerMenu(Widget); extern void makeSpectrumMenu(void); extern void makeHistoryMenu(void); extern void makeMODiagramMenu(void); extern void MapBox(Widget, caddr_t, XmAnyCallbackStruct *); extern Widget CreateToggleBox(Widget, struct PushButtonRow *, int, int, int, int, int); extern void CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern char *getStringResource(Widget, char *); extern void checkProgram(char *, char *); extern void saveConfiguration(void); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern Widget initShell(Widget, char *, Widget *, Widget *); extern void getFormats(void); extern void *getmem(size_t, size_t); extern void fremem(void **); extern struct WINDOW windows[]; extern Widget topShell; extern int saveLanguage; extern char language[], webbrowser[], moloch[], raytracer[], displayImage[]; static Widget dialog; static XrmDatabase database; static struct PushButtonRow *radiobox_buttons=NULL; static char language_save[20]; void configurationDialog(Widget widget, caddr_t which, XmAnyCallbackStruct *data) { Widget board, form, sep, b, m, r, d; Widget radiobox=(Widget)NULL; struct dirent **namelist; static struct PushButtonRow buttons[] = { { "ok", configurationDialogExit, (XtPointer)1, NULL }, { "save", configurationDialogExit, (XtPointer)2, NULL }, { "cancel", configurationDialogExit, (XtPointer)3, NULL } }; int n, lang=0; char filename[FILENAME_MAX]; char *p; register int i; /* This function creates the configuration dialog */ strcpy(language_save, language); dialog=initShell(windows[VIEWER].widget, "configurationForm", &board, &form); database=XrmGetDatabase(XtDisplay(windows[VIEWER].widget)); strcpy(filename, getenv("VIEWMOLPATH")); strcat(filename, "/locale"); if ((n=scandir(filename, &namelist, matchXdefaults, alphasort)) > 0) { radiobox_buttons=(struct PushButtonRow *)getmem((size_t)n, sizeof(struct PushButtonRow)); for (i=0; id_name; radiobox_buttons[i].label=p; radiobox_buttons[i].callback=SetLanguage; radiobox_buttons[i].client_data=(XtPointer)p; radiobox_buttons[i].widget=NULL; if (!strcmp(language, p)) lang=i; } radiobox=CreateToggleBox(form, radiobox_buttons, n, XmVERTICAL, 4, True, lang); sep=XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNtraversalOn, False, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, radiobox, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); } (void)XtVaCreateManagedWidget("browserLabel", xmLabelWidgetClass, form, NULL); b=XtVaCreateManagedWidget("browser", xmTextWidgetClass, form, XmNvalue, webbrowser, NULL); XtAddCallback(b, XmNvalueChangedCallback, (XtCallbackProc)GetString, webbrowser); (void)XtVaCreateManagedWidget("molochLabel", xmLabelWidgetClass, form, NULL); m=XtVaCreateManagedWidget("moloch", xmTextWidgetClass, form, XmNvalue, moloch, NULL); XtAddCallback(m, XmNvalueChangedCallback, (XtCallbackProc)GetString, moloch); (void)XtVaCreateManagedWidget("raytracerLabel", xmLabelWidgetClass, form, NULL); r=XtVaCreateManagedWidget("raytracer", xmTextWidgetClass, form, XmNvalue, raytracer, NULL); XtAddCallback(r, XmNvalueChangedCallback, (XtCallbackProc)GetString, raytracer); (void)XtVaCreateManagedWidget("displayImageLabel", xmLabelWidgetClass, form, NULL); d=XtVaCreateManagedWidget("displayImage", xmTextWidgetClass, form, XmNvalue, displayImage, NULL); XtAddCallback(d, XmNvalueChangedCallback, (XtCallbackProc)GetString, displayImage); sep=XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNtraversalOn, False, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, radiobox, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); CreatePushButtonRow(form, buttons, XtNumber(buttons)); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XmAnyCallbackStruct *)NULL); XtManageChild(form); XtManageChild(board); } void SetLanguage(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { char filename[FILENAME_MAX]; if (data->set) { strcpy(filename, getenv("VIEWMOLPATH")); /* strcat(filename, "/Xdefaults.");*/ strcat(filename, "/locale/"); strcat(filename, (char *)which); strcat(filename, "/Viewmol"); XrmCombineFileDatabase(filename, &database, True); windows[VIEWER].menu=makeViewerMenu(windows[VIEWER].widget); if (windows[SPECTRUM].widget != NULL) makeSpectrumMenu(); if (windows[HISTORY].widget != NULL) makeHistoryMenu(); if (windows[MO].widget != NULL) makeMODiagramMenu(); if (strcmp(language, (char *)which)) saveLanguage=TRUE; strcpy(language, (char *)which); getFormats(); } } void configurationDialogExit(Widget button, caddr_t which, XmPushButtonCallbackStruct *dummy) { static struct PushButtonRow buttons[] = {{"ok", GetMessageBoxButton, (XtPointer)0, NULL}}; XmToggleButtonCallbackStruct data; char *word, line[MAXLENLINE]; switch ((int)which) { case 1: checkProgram(line, webbrowser); if (line[0] == '\0') { word=getStringResource(topShell, "wrongBrowser"); messgb(topShell, 0, word, buttons, 1); } else strcpy(webbrowser, line); checkProgram(line, moloch); if (line[0] == '\0') { word=getStringResource(topShell, "wrongMoloch"); messgb(topShell, 0, word, buttons, 1); } else strcpy(moloch, line); checkProgram(line, raytracer); if (line[0] == '\0') { if (raytracer[0] != '\0') { word=getStringResource(topShell, "noFile"); sprintf(line, word, raytracer); } else { word=getStringResource(topShell, "noRayshade"); strcpy(line, word); } messgb(topShell, 0, line, buttons, 1); } else strcpy(raytracer, line); checkProgram(line, displayImage); if (line[0] == '\0') { if (displayImage[0] == '\0') { word=getStringResource(topShell, "noFile"); sprintf(line, word, displayImage); } else { word=getStringResource(topShell, "noDisplay"); strcpy(line, word); } messgb(topShell, 0, line, buttons, 1); } else strcpy(displayImage, line); break; case 2: saveConfiguration(); break; case 3: data.set=TRUE; SetLanguage((Widget)0, (caddr_t)language_save, &data); strcpy(language, language_save); break; } XtDestroyWidget(dialog); if (radiobox_buttons != NULL) fremem((void **)&radiobox_buttons); } void GetString(Widget w, caddr_t text, XmAnyCallbackStruct *data) { char *str; str=XmTextGetString(w); strcpy((char *)text, str); } #if defined LINUX || defined DARWIN int matchXdefaults(const struct dirent *d) #else int matchXdefaults(struct dirent *d) #endif { /*return(!fnmatch("Xdefaults.*", d->d_name, 0));*/ return(fnmatch(".*", d->d_name, 0)); } viewmol-2.4.1/source/cylinder.c0100644000272700027270000000667607752675376014667 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * C Y L I N D E R . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: cylinder.c,v 1.6 2003/11/07 10:59:10 jrh Exp $ * $Log: cylinder.c,v $ * Revision 1.6 2003/11/07 10:59:10 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:03:46 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:02 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:46:18 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:17 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:40:09 jrh * Initial revision * */ #include #include #include extern void (*drawCylinder)(GLUquadricObj *, GLdouble, GLdouble, GLdouble, GLint, GLint); extern void (*drawCone)(GLUquadricObj *, GLdouble, GLdouble, GLdouble, GLint, GLint); GLdouble buildRotationMatrix(double x, double y, double z, GLdouble tmat[4][4]) { double height, d, ca, sa, cb, sb; height=sqrt((double)(x*x + y*y + z*z)); /* Builds the rotation matrix for rotating a vector defined by the points (0, 0, 0) and (0, 0, height) to the orientation (x, y, z) */ if ((d=sqrt((double)(x*x + y*y))) != 0.0) { ca=y/d; sa=x/d; y=x*sa+y*ca; } else { ca=1.0; sa=0.0; } if ((d=sqrt((double)(y*y + z*z))) != 0.0) { cb=z/d; sb=y/d; } else { cb=1.0; sb=0.0; } tmat[0][0]=ca; tmat[1][0]=sa*cb; tmat[2][0]=sa*sb; tmat[3][0]=0.0e0; tmat[0][1]=(-sa); tmat[1][1]=ca*cb; tmat[2][1]=ca*sb; tmat[3][1]=0.0e0; tmat[0][2]=0.; tmat[1][2]=(-sb); tmat[2][2]=cb; tmat[3][2]=0.0e0; tmat[0][3]=tmat[1][3]=tmat[2][3]=0.0e0; tmat[3][3]=1.0e0; return(height); } void cylinder(double x1, double y1, double z1, double x2, double y2, double z2, double r, int n, GLenum mode) { GLUquadricObj *obj; double vx=x2-x1, vy=y2-y1, vz=z2-z1; GLdouble tmat[4][4], height; height=buildRotationMatrix(vx, vy, vz, tmat); tmat[3][0]=x1; tmat[3][1]=y1; tmat[3][2]=z1; /* Select drawing function depending on mode */ obj=gluNewQuadric(); gluQuadricDrawStyle(obj, mode); gluQuadricTexture(obj, GL_TRUE); if (mode == GLU_FILL) gluQuadricNormals(obj, (GLenum)GLU_SMOOTH); else gluQuadricNormals(obj, (GLenum)GLU_NONE); glPushMatrix(); glMultMatrixd((GLdouble *)tmat); (*drawCylinder)(obj, r, r, height, n, 1); glPopMatrix(); } void cone(double x1, double y1, double z1, double x2, double y2, double z2, double rBase, int n) { GLUquadricObj *obj; double vx=x2-x1, vy=y2-y1, vz=z2-z1; GLdouble tmat[4][4], height; height=buildRotationMatrix(vx, vy, vz, tmat); tmat[3][0]=x1; tmat[3][1]=y1; tmat[3][2]=z1; obj=gluNewQuadric(); gluQuadricDrawStyle(obj, (GLenum)GLU_FILL); gluQuadricNormals(obj, (GLenum)GLU_SMOOTH); glPushMatrix(); glMultMatrixd((GLdouble *)tmat); (*drawCone)(obj, rBase, 0.0e0, height, n, 1); glPopMatrix(); } viewmol-2.4.1/source/device.c0100644000272700027270000000666307752675407014304 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * D E V I C E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: device.c,v 1.4 2003/11/07 10:59:19 jrh Exp $ * $Log: device.c,v $ * Revision 1.4 2003/11/07 10:59:19 jrh * Release 2.4 * * Revision 1.3 2000/12/10 15:04:26 jrh * Release 2.3 * * Revision 1.2 1999/05/24 01:25:04 jrh * Release 2.2.1 * * Revision 1.1 1999/02/07 21:46:29 jrh * Initial revision * * */ #include #include #include #include #include #define MAXLENLINE 80 void findInputDevices(Widget); extern Widget topShell; extern int debug; extern int spaceballButtonPress, spaceballMotionNotify; static XDevice *spaceball; static struct {int min; float range;} axis[6]; void findInputDevices(Widget w) { Display *display; XExtensionVersion *version; XDeviceInfo *list; XAnyClassPtr classinfo; XValuatorInfoPtr info; XAxisInfoPtr a; XEventClass eventList[2]; int ndev; register int i, j, k; display=XtDisplay(topShell); version=XGetExtensionVersion(display, "XInputExtension"); if (version == NULL || ((int)version) == NoSuchExtension) return; XFree(version); list=XListInputDevices(display, &ndev); for (i=0; iclass) { case ValuatorClass: info=(XValuatorInfoPtr)classinfo; if (info->num_axes < 6) goto nextDevice; a=(XAxisInfoPtr)((char *)info+sizeof(XValuatorInfo)); for (k=0; k<6; k++) { axis[k].min=a->min_value; axis[k].range=2.0/(float)(a->max_value-a->min_value); } break; } classinfo=(XAnyClassPtr)((char *)classinfo+classinfo->length); } spaceball=XOpenDevice(display, list[i].id); DeviceButtonPress(spaceball, spaceballButtonPress, eventList[0]); DeviceMotionNotify(spaceball, spaceballMotionNotify, eventList[1]); XSelectExtensionEvent(display, XtWindow(w), eventList, 2); break; } nextDevice:; } XFreeDeviceList(list); } void switchPointerDevice(void) { FILE *file; char line[MAXLENLINE], command[MAXLENLINE]; if ((file=popen("xsetpointer -l", "r")) != NULL) { while (fgets(line, MAXLENLINE, file) != NULL) { if (strstr(line, "XExtensionDevice")) { strcpy(command, "xsetpointer "); strcat(command, strtok(line, " \t")); system(command); } } fclose(file); } } viewmol-2.4.1/source/dialog.h0100644000272700027270000000237407752712246014275 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * D I A L O G . H * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: dialog.h,v 1.6 2003/11/07 12:48:38 jrh Exp $ * $Log: dialog.h,v $ * Revision 1.6 2003/11/07 12:48:38 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:04:36 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:06 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:46:41 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:20 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:45:27 jrh * Initial revision * */ struct PushButtonRow { char *label; void (*callback)(); XtPointer client_data; Widget widget; }; viewmol-2.4.1/source/distort.c0100644000272700027270000000364107752675415014525 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * D I S T O R T . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: distort.c,v 1.6 2003/11/07 10:59:25 jrh Exp $ * $Log: distort.c,v $ * Revision 1.6 2003/11/07 10:59:25 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:04:51 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:08 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:46:57 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:24 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:40:16 jrh * Initial revision * */ #include #include "viewmol.h" #include "dialog.h" extern struct MOLECULE *molecules; extern struct WINDOW windows[]; void distortGeometry(double); extern int calcInternal(struct MOLECULE *, int); extern int ninternal; void distortGeometry(double factor) { struct MOLECULE *mol; int mode; register int i, l, n; mol=&molecules[windows[SPECTRUM].set]; mode=mol->mode; if (mode != -1) { n=mol->na; if (mol->unitcell) n-=8; for (i=0; iatoms[i].ref; mol->atoms[i].x+=factor*mol->cnm[mode+mol->nmodes*l]; mol->atoms[i].y+=factor*mol->cnm[mode+mol->nmodes*(l+1)]; mol->atoms[i].z+=factor*mol->cnm[mode+mol->nmodes*(l+2)]; l+=3; } for (i=0; ininternal; i++) (void)calcInternal(mol, i); } } viewmol-2.4.1/source/draw.c0100644000272700027270000015004310114366425013751 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * D R A W . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: draw.c,v 1.7 2004/08/29 14:49:57 jrh Exp $ * $Log: draw.c,v $ * Revision 1.7 2004/08/29 14:49:57 jrh * Release 2.4.1 * * Revision 1.6 2003/11/07 10:59:34 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:04:57 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:10 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:36:48 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:27 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:40:22 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" int renderMolecule(struct MOLECULE *, int, int); void wireModel(struct MOLECULE *, Dimension, int); void stickModel(struct MOLECULE *, int); void balls(struct MOLECULE *, double, int); void setAtomProperties(struct ELEMENT *, int); void drawIntern(struct MOLECULE *); void drawUnitCell(struct MOLECULE *, Dimension, int); void drawMillerPlane(struct MOLECULE *, int); void labelAtoms(struct MOLECULE *, int); void drawAnnotation(void); void drawForces(struct MOLECULE *, int); void drawNormalMode(struct MOLECULE *, int); void drawArrow(double, double, double, double, double, double); void drawGround(void); void setupProjection(int); void setupModelview(int); void shadow(GLfloat v0[3], GLfloat v1[3], GLfloat v2[3], GLfloat vector[4]); void shadowColor(void); extern void setWindowColor(int, Pixel, const float *); extern int StringWidth(XFontStruct *, char *); extern int StringHeight(XFontStruct *); extern void cone(double, double, double, double, double, double, double, int); extern double dist(double, double, double, double, double, double); extern void pixelToWorld(int, double *, double *); extern void (*drawBegin)(GLenum), (*drawEnd)(void); extern void (*drawVertex3d)(double, double, double); extern void (*drawNormal3d)(double, double, double); extern void (*drawColor4fv)(const GLfloat *); extern void (*drawSphere)(GLUquadricObj *, GLdouble, GLint, GLint); extern void (*drawString)(char *, double, double, double, double, GLuint, char); extern void (*drawLineStipple)(GLint, GLushort); extern void (*drawLineWidth)(GLfloat); extern void (*drawDisable)(GLenum); extern void raytracerBegin(GLenum); extern void manual(Widget, caddr_t, caddr_t); extern char *getStringResource(Widget, char *); extern void printDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void marchingCube(struct GRIDOBJECT *, double, int, void (*)(GLenum), void (*)(void), void (*)(double, double, double), void (*)(double, double, double), int, int); extern void ellipse(double, double, double, double, double, double, double, double, double, int); extern void cylinder(double, double, double, double, double, double, double, int, GLenum); extern void raytracerMaterial(struct ELEMENT *); extern void transformCoordinates(int, float input[4], float output[4]); extern void redraw(int); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern clock_t getCPUTime(void); extern void scaleAnnotation(float); extern void moveAnnotation(int, double, double); extern void selectMolecule(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void quaternionToMatrix(int, float *); extern void incrementQuaternion(double, double, double, float *); extern void deleteSelection(void); extern void getScreenCoordinates(double, double, double, double *, double *, double *); extern struct MOLECULE *molecules; extern struct ELEMENT *elements; extern struct WINDOW windows[]; extern struct ANNOTATION *annotation; extern Pixel stdcol[9]; extern Widget topShell; extern GLfloat light0p[], light1p[]; extern int ne, nmolecule; extern int label, showForces, animate, showUnitCell, showInertia; extern int primitive, bfatom, lights, moveItem, projectionMode, showHBond; extern int shadows, ground, drawIcon; extern double amplitude, forceScale, wnScale; extern double gridres, sphereres, lineWidth, drawingSpeed; extern float *transObject, *rotObject; extern int rgbMode, picking, swapBuffers, selectAtom; extern int iwavef, interp, debug, setins, nAnnotations; extern double *grid, level, weight; extern char *formBondLength, *formBondAngle, *formTorsionAngle; void drawBackground(int window, Pixel color, double depthBufferClear) { float background_rgb[4] = {0.0, 0.0, 1.0, 0.0}; int clear=GL_COLOR_BUFFER_BIT; if (windows[window].smooth) { background_rgb[0]=windows[window].background_rgb[0]; background_rgb[1]=windows[window].background_rgb[1]; background_rgb[2]=windows[window].background_rgb[2]; glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0); glShadeModel(GL_SMOOTH); glBegin(GL_POLYGON); if (windows[window].smooth & 1) background_rgb[0]=0.7; if (windows[window].smooth & 2) background_rgb[1]=0.7; if (windows[window].smooth & 4) background_rgb[2]=0.7; setWindowColor(FOREGROUND, color, background_rgb); glVertex3f(0.0, 0.0, 0.0); glVertex3f(1.0, 0.0, 0.0); if (windows[window].smooth & 1) background_rgb[0]=0.3; if (windows[window].smooth & 2) background_rgb[1]=0.3; if (windows[window].smooth & 4) background_rgb[2]=0.3; setWindowColor(FOREGROUND, color, background_rgb); glVertex3f(1.0, 1.0, 0.0); glVertex3f(0.0, 1.0, 0.0); glEnd(); glShadeModel(GL_FLAT); glPopMatrix(); glMatrixMode(GL_MODELVIEW); clear=GL_DEPTH_BUFFER_BIT; } else { setWindowColor(BACKGROUND, color, windows[window].background_rgb); if (depthBufferClear != 0.0) clear|=GL_DEPTH_BUFFER_BIT; } if (depthBufferClear != 0.0) glClearDepth(depthBufferClear); if (shadows) clear|=GL_STENCIL_BUFFER_BIT; glClear(clear); } void drawMolecule(Widget w, caddr_t client_data, XmDrawingAreaCallbackStruct *data) { struct MOLECULE *mol; double clockTick; GLfloat light1t[4]; GLfloat light0c[4] = {1.0, 1.0, 1.0, 1.0}; GLfloat light1c[4] = {1.0, 1.0, 1.0, 1.0}; GLfloat ground0[3] = {0.0, 0.0, 0.0}; GLfloat ground1[3] = {1.0, 0.0, 0.0}; GLfloat ground2[3] = {0.0, 0.0, 1.0}; clock_t startTime=0; Dimension width, height; int renderMode; register int found, i; XtRemoveAllCallbacks(windows[VIEWER].widget, XmNexposeCallback); XtVaGetValues(windows[VIEWER].widget, XtNwidth, &width, XtNheight, &height, NULL); startTime=getCPUTime(); glGetIntegerv(GL_RENDER_MODE, &renderMode); if (renderMode == GL_RENDER && !drawIcon) glXMakeCurrent(XtDisplay(windows[VIEWER].widget), XtWindow(windows[VIEWER].widget), windows[VIEWER].context); if (!picking) { drawBackground(VIEWER, windows[VIEWER].background, windows[VIEWER].far); } if (nAnnotations > 0) drawAnnotation(); setupProjection(picking); if (shadows) glPushMatrix(); if (primitive == GLU_FILL && (windows[VIEWER].mode != WIREMODEL || iwavef != ALL_OFF)) { if (lights & 0x1) { glPushMatrix(); quaternionToMatrix(GL_MODELVIEW, &rotObject[4*LIGHTNO0]); glLightfv(GL_LIGHT0, GL_POSITION, light0p); glLightfv(GL_LIGHT0, GL_DIFFUSE, light0c); glPopMatrix(); } if (lights & 0x2) { glPushMatrix(); quaternionToMatrix(GL_MODELVIEW, &rotObject[4*LIGHTNO1]); glLightfv(GL_LIGHT1, GL_POSITION, light1p); glLightfv(GL_LIGHT1, GL_DIFFUSE, light1c); glPopMatrix(); } } if (projectionMode == PERSPECTIVE && ground) { drawGround(); } glTranslatef(transObject[3*WORLD], transObject[3*WORLD+1], transObject[3*WORLD+2]); quaternionToMatrix(GL_MODELVIEW, &rotObject[4*WORLD]); for (i=0; i %.1f fps (< %.2f ms per frame)\n", drawingSpeed, 1000./clockTick); } XtAddCallback(windows[VIEWER].widget, XmNexposeCallback, (XtCallbackProc)drawMolecule, NULL); } int renderMolecule(struct MOLECULE *mol, int width, int lighting) { double boxf; const float black[4] = {0.0, 0.0, 0.0, 1.0}; int prim=GL_LINE_LOOP; register int i, found=0; glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); if (windows[VIEWER].mode == WIREMODEL || primitive == GLU_POINT) { glShadeModel(GL_FLAT); wireModel(mol, width, lighting); } if (primitive != GLU_FILL || windows[VIEWER].mode == WIREMODEL) glShadeModel(GL_FLAT); else { glShadeModel(GL_SMOOTH); glCullFace(GL_BACK); glEnable(GL_CULL_FACE); if (lighting) { glEnable(GL_LIGHTING); if (lights & 0x1) glEnable(GL_LIGHT0); if (lights & 0x2) glEnable(GL_LIGHT1); } } if (windows[VIEWER].mode == STICKMODEL || windows[VIEWER].mode == BALLMODEL) stickModel(mol, lighting); if (windows[VIEWER].mode == STICKMODEL) { if (lighting) glPassThrough((GLfloat)(ADD_DEPTH+(int)(windows[VIEWER].far))); balls(mol, -(mol->bondRadius), lighting); if (lighting) glPassThrough((GLfloat)(ADD_DEPTH)); } if (windows[VIEWER].mode == BALLMODEL) balls(mol, 0.5, lighting); if (windows[VIEWER].mode == CUPMODEL) { balls(mol, 1.3, lighting); stickModel(mol, lighting); } if (mol->unitcell && showUnitCell) drawUnitCell(mol, width, lighting); if (primitive == GLU_FILL) glDisable(GL_CULL_FACE); if ((mol->imo != -1 || mol->ibasfu != -1 || iwavef != ALL_OFF) && !selectAtom) { if (iwavef > DENSITY && iwavef-DENSITY <= mol->ngridobjects) found=iwavef-DENSITY; else { for (i=0; ingridobjects; i++) { if ((mol->gridObjects[i].type & ~GRIDREAD) == iwavef) { if ((iwavef == MOLECULAR_ORBITAL && mol->gridObjects[i].mo == mol->imo) || (iwavef == BASIS_IN_MO && mol->gridObjects[i].mo == mol->imo && mol->gridObjects[i].basisfunction == mol->ibasfu) || (iwavef == BASIS_FUNCTION && mol->gridObjects[i].basisfunction == mol->ibasfu) || iwavef >= DENSITY) { found=i+1; if (debug) printf("Found MO/basis function: %d\n", found); break; } } } } if (found) { boxf=windows[VIEWER].far; gridres=mol->gridObjects[found-1].resolution; (*drawLineWidth)((GLfloat)1.); switch (primitive) { case GLU_POINT: prim=GL_POINTS; break; case GLU_LINE: prim=GL_LINE_LOOP; break; case GLU_FILL: prim=GL_TRIANGLE_STRIP; break; } if (primitive == GLU_FILL) { glShadeModel(GL_SMOOTH); if (lighting) { glEnable(GL_LIGHTING); if (lights & 0x1) glEnable(GL_LIGHT0); if (lights & 0x2) glEnable(GL_LIGHT1); } glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); } for (i=0; iunitcell != NULL) glTranslatef(mol->unitcell->corners[0].x, mol->unitcell->corners[0].y, mol->unitcell->corners[0].z); else glTranslatef(mol->transx, mol->transy, mol->transz); marchingCube(&(mol->gridObjects[found-1]), level, prim, drawBegin, drawEnd, drawVertex3d, drawNormal3d, interp, debug); if (iwavef != DENSITY) { for (i=0; igridObjects[found-1]), level, prim, drawBegin, drawEnd, drawVertex3d, drawNormal3d, interp, debug); level=(-level); } glPopMatrix(); glPassThrough((GLfloat)VISIBILITY); } } if (mol->unitcell && mol->unitcell->showMiller) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); drawMillerPlane(mol, lighting); glDisable(GL_BLEND); } if (showForces && !picking) drawForces(mol, lighting); if (mol->mode != -1 && animate == ARROWS && mol->cnm != NULL) drawNormalMode(mol, lighting); glDisable(GL_DEPTH_TEST); if (primitive == GLU_FILL) { glShadeModel(GL_FLAT); if (lighting) { glDisable(GL_LIGHTING); if (lights & 0x1) glDisable(GL_LIGHT0); if (lights & 0x2) glDisable(GL_LIGHT1); } glDisable(GL_BLEND); } if (showInertia) { (*drawLineWidth)((GLfloat)1.); if (lighting) setWindowColor(FOREGROUND, stdcol[BLACK], black); else shadowColor(); ellipse(0.0, 0.0, 0.0, mol->tinert[0][0], mol->tinert[0][1], mol->tinert[0][2], mol->tinert[1][0], mol->tinert[1][1], mol->tinert[1][2], 40); ellipse(0.0, 0.0, 0.0, mol->tinert[1][0], mol->tinert[1][1], mol->tinert[1][2], mol->tinert[2][0], mol->tinert[2][1], mol->tinert[2][2], 40); ellipse(0.0, 0.0, 0.0, mol->tinert[2][0], mol->tinert[2][1], mol->tinert[2][2], mol->tinert[0][0], mol->tinert[0][1], mol->tinert[0][2], 40); } if (mol->ninternal && lighting) drawIntern(mol); return(found); } void wireModel(struct MOLECULE *mol, Dimension width, int lighting) { double x, y, z, nline, sline; int first, second; register int i; if (lineWidth == 0.0) nline=width*0.005; else nline=lineWidth; sline=2.0*nline; (*drawLineWidth)((GLfloat)nline); for (i=0; inb; i++) { first=mol->bonds[i].first; second=mol->bonds[i].second; x=mol->atoms[first].x+mol->bonds[i].frac *(mol->atoms[second].x-mol->atoms[first].x); y=mol->atoms[first].y+mol->bonds[i].frac *(mol->atoms[second].y-mol->atoms[first].y); z=mol->atoms[first].z+mol->bonds[i].frac *(mol->atoms[second].z-mol->atoms[first].z); if (abs(mol->bonds[i].order) != 2) { if (mol->bonds[i].order == (-1)) /* Hydrogen bond */ { if (!showHBond) continue; glEnable(GL_LINE_STIPPLE); /* Dashed lines */ (*drawLineStipple)(1, 0xf0f0); } if (picking || mol->atoms[first].flags & SELECTED) { glPushName(first+1); (*drawLineWidth)((GLfloat)sline); (*drawBegin)(GL_LINES); } else (*drawBegin)(GL_LINE_STRIP); if (mol->bonds[i].order == (-1)) setAtomProperties(mol->bondStyle, lighting); else setAtomProperties(mol->atoms[first].element, lighting); (*drawVertex3d)(mol->atoms[first].x, mol->atoms[first].y, mol->atoms[first].z); (*drawVertex3d)(x, y, z); if (picking || mol->atoms[first].flags & SELECTED || mol->atoms[second].flags & SELECTED) { (*drawEnd)(); glPopName(); if (mol->atoms[first].flags & SELECTED) (*drawLineWidth)((GLfloat)nline); glPushName(second+1); if (mol->atoms[second].flags & SELECTED) (*drawLineWidth)((GLfloat)sline); (*drawBegin)(GL_LINES); (*drawVertex3d)(x, y, z); } if (mol->bonds[i].order != (-1)) setAtomProperties(mol->atoms[second].element, lighting); (*drawVertex3d)(mol->atoms[second].x, mol->atoms[second].y, mol->atoms[second].z); (*drawEnd)(); if (mol->atoms[second].flags & SELECTED) (*drawLineWidth)((GLfloat)nline); if (picking) glPopName(); if (mol->bonds[i].order == (-1)) (*drawDisable)(GL_LINE_STIPPLE); } if (abs(mol->bonds[i].order) > 1) { if (picking || mol->atoms[first].flags & SELECTED) { glPushName(first+1); (*drawLineWidth)((GLfloat)sline); (*drawBegin)(GL_LINES); } else (*drawBegin)(GL_LINE_STRIP); setAtomProperties(mol->atoms[first].element, lighting); (*drawVertex3d)(mol->atoms[first].x-mol->bonds[i].x, mol->atoms[first].y-mol->bonds[i].y, mol->atoms[first].z-mol->bonds[i].z); (*drawVertex3d)(x-mol->bonds[i].x, y-mol->bonds[i].y, z-mol->bonds[i].z); if (picking || mol->atoms[first].flags & SELECTED || mol->atoms[second].flags & SELECTED) { (*drawEnd)(); glPopName(); if (mol->atoms[first].flags & SELECTED) (*drawLineWidth)((GLfloat)nline); glPushName(second+1); if (mol->atoms[second].flags & SELECTED) (*drawLineWidth)((GLfloat)sline); (*drawBegin)(GL_LINES); (*drawVertex3d)(x-mol->bonds[i].x, y-mol->bonds[i].y, z-mol->bonds[i].z); } setAtomProperties(mol->atoms[second].element, lighting); (*drawVertex3d)(mol->atoms[second].x-mol->bonds[i].x, mol->atoms[second].y-mol->bonds[i].y, mol->atoms[second].z-mol->bonds[i].z); (*drawEnd)(); if (mol->atoms[second].flags & SELECTED) (*drawLineWidth)((GLfloat)nline); if (picking) glPopName(); if (mol->bonds[i].order == (-2)) { glEnable(GL_LINE_STIPPLE); /* Dashed lines */ (*drawLineStipple)(1, 0xf0f0); } if (picking || mol->atoms[first].flags & SELECTED) { glPushName(first+1); (*drawLineWidth)((GLfloat)sline); (*drawBegin)(GL_LINES); } else (*drawBegin)(GL_LINE_STRIP); setAtomProperties(mol->atoms[first].element, lighting); (*drawVertex3d)(mol->atoms[first].x+mol->bonds[i].x, mol->atoms[first].y+mol->bonds[i].y, mol->atoms[first].z+mol->bonds[i].z); (*drawVertex3d)(x+mol->bonds[i].x, y+mol->bonds[i].y, z+mol->bonds[i].z); if (picking || mol->atoms[first].flags & SELECTED || mol->atoms[second].flags & SELECTED) { (*drawEnd)(); glPopName(); if (mol->atoms[first].flags & SELECTED) (*drawLineWidth)((GLfloat)nline); glPushName(second+1); if (mol->atoms[second].flags & SELECTED) (*drawLineWidth)((GLfloat)sline); (*drawBegin)(GL_LINES); (*drawVertex3d)(x+mol->bonds[i].x, y+mol->bonds[i].y, z+mol->bonds[i].z); } setAtomProperties(mol->atoms[second].element, lighting); (*drawVertex3d)(mol->atoms[second].x+mol->bonds[i].x, mol->atoms[second].y+mol->bonds[i].y, mol->atoms[second].z+mol->bonds[i].z); (*drawEnd)(); if (mol->atoms[second].flags & SELECTED) (*drawLineWidth)((GLfloat)nline); if (picking) glPopName(); if (mol->bonds[i].order == (-2)) (*drawDisable)(GL_LINE_STIPPLE); } } x=0.01*windows[VIEWER].far; for (i=0; ina; i++) { if (mol->atoms[i].nbonds == 0) { if (picking) glPushName(i+1); setAtomProperties(mol->atoms[i].element, lighting); if (mol->atoms[i].flags & SELECTED) (*drawLineWidth)((GLfloat)sline); (*drawBegin)(GL_LINES); (*drawVertex3d)(mol->atoms[i].x-x, mol->atoms[i].y, mol->atoms[i].z); (*drawVertex3d)(mol->atoms[i].x+x, mol->atoms[i].y, mol->atoms[i].z); (*drawVertex3d)(mol->atoms[i].x, mol->atoms[i].y-x, mol->atoms[i].z); (*drawVertex3d)(mol->atoms[i].x, mol->atoms[i].y+x, mol->atoms[i].z); (*drawVertex3d)(mol->atoms[i].x, mol->atoms[i].y, mol->atoms[i].z-x); (*drawVertex3d)(mol->atoms[i].x, mol->atoms[i].y, mol->atoms[i].z+x); (*drawEnd)(); if (mol->atoms[i].flags & SELECTED) (*drawLineWidth)((GLfloat)nline); if (picking) glPopName(); } } } void stickModel(struct MOLECULE *mol, int lighting) { double x, y, z, f=0.1; double xold, yold, zold; int first, second; register int i, j; (*drawLineWidth)(1.); glTexEnvf(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE); for (i=0; inb; i++) { first=mol->bonds[i].first; second=mol->bonds[i].second; if (mol->bonds[i].order == (-1)) { if (!showHBond) continue; glDisable(GL_CULL_FACE); setAtomProperties(mol->bondStyle, lighting); xold=mol->atoms[first].x; yold=mol->atoms[first].y; zold=mol->atoms[first].z; for (j=1; j<10; j+=2) { x=xold+f*(mol->atoms[second].x-mol->atoms[first].x); y=yold+f*(mol->atoms[second].y-mol->atoms[first].y); z=zold+f*(mol->atoms[second].z-mol->atoms[first].z); cylinder(xold, yold, zold, x, y, z, mol->bondRadius, (int)sphereres, (GLenum)primitive); xold=x+f*(mol->atoms[second].x-mol->atoms[first].x); yold=y+f*(mol->atoms[second].y-mol->atoms[first].y); zold=z+f*(mol->atoms[second].z-mol->atoms[first].z); } glEnable(GL_CULL_FACE); } else { x=mol->atoms[first].x+mol->bonds[i].frac *(mol->atoms[second].x-mol->atoms[first].x); y=mol->atoms[first].y+mol->bonds[i].frac *(mol->atoms[second].y-mol->atoms[first].y); z=mol->atoms[first].z+mol->bonds[i].frac *(mol->atoms[second].z-mol->atoms[first].z); setAtomProperties(mol->atoms[first].element, lighting); glPushName(first+1); if (mol->atoms[first].flags & SELECTED) glEnable(GL_TEXTURE_2D); cylinder(mol->atoms[first].x, mol->atoms[first].y, mol->atoms[first].z, x, y, z, mol->bondRadius, (int)sphereres, (GLenum)primitive); if (mol->atoms[first].flags & SELECTED) glDisable(GL_TEXTURE_2D); glPopName(); setAtomProperties(mol->atoms[second].element, lighting); glPushName(second+1); if (mol->atoms[second].flags & SELECTED) glEnable(GL_TEXTURE_2D); cylinder(mol->atoms[second].x, mol->atoms[second].y, mol->atoms[second].z, x, y, z, mol->bondRadius, (int)sphereres, (GLenum)primitive); if (mol->atoms[second].flags & SELECTED) glDisable(GL_TEXTURE_2D); glPopName(); } } } void balls(struct MOLECULE *mol, double fac, int lighting) { GLUquadricObj *obj; register double rad; register int i; (*drawLineWidth)(1.); obj=gluNewQuadric(); gluQuadricDrawStyle(obj, (GLenum)primitive); gluQuadricTexture(obj, GL_TRUE); if (primitive == GLU_FILL) gluQuadricNormals(obj, (GLenum)GLU_SMOOTH); else gluQuadricNormals(obj, (GLenum)GLU_NONE); glTexEnvf(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE); for (i=0; ina; i++) { if (fac < 0.0) rad=-fac; else rad=fac*mol->atoms[i].rad*mol->atoms[i].radScale; glPushMatrix(); glTranslated(mol->atoms[i].x, mol->atoms[i].y, mol->atoms[i].z); setAtomProperties(mol->atoms[i].element, lighting); glPushName(i+1); if (mol->atoms[i].flags & SELECTED) glEnable(GL_TEXTURE_2D); (*drawSphere)(obj, rad, (int)sphereres, (int)sphereres); if (mol->atoms[i].flags & SELECTED) glDisable(GL_TEXTURE_2D); glPopName(); glPopMatrix(); } } void drawIntern(struct MOLECULE *mol) { const float black[4] = {0.0, 0.0, 0.0, 0.0}; const float white[4] = {1.0, 1.0, 1.0, 0.0}; Dimension width, height; char line[24], *form; double xpix, ypix; double wx1, wy1, wz, wx2, wy2, matrix[16]; double h; register int i, j, k; if ((rgbMode && windows[VIEWER].background_rgb[0] == 0.0 && windows[VIEWER].background_rgb[1] == 0.0 && windows[VIEWER].background_rgb[2] == 0.0) || (!rgbMode && windows[VIEWER].background == stdcol[BLACK])) setWindowColor(FOREGROUND, stdcol[WHITE], white); else setWindowColor(FOREGROUND, stdcol[BLACK], black); pixelToWorld(VIEWER, &xpix, &ypix); h=(double)StringHeight(windows[VIEWER].font)*ypix; if (!picking) { glEnable(GL_LINE_STIPPLE); (*drawLineStipple)(1, 0xf0f0); (*drawLineWidth)((GLfloat)1.); } for (i=0; ininternal; i++) { switch (abs(mol->internals[i].type)) { case BONDAVERAGE: form=formBondLength; break; case BONDLENGTH: j=mol->internals[i].atoms[0]; k=mol->internals[i].atoms[1]; form=formBondLength; (*drawBegin)(GL_LINES); if (j & 0x20000000 && k & 0x20000000) { j&=0x1fffffff; k&=0x1fffffff; (*drawVertex3d)(mol->unitcell->corners[j].x, mol->unitcell->corners[j].y, mol->unitcell->corners[j].z); (*drawVertex3d)(mol->unitcell->corners[k].x, mol->unitcell->corners[k].y, mol->unitcell->corners[k].z); } else { (*drawVertex3d)(mol->atoms[j].x, mol->atoms[j].y, mol->atoms[j].z); (*drawVertex3d)(mol->atoms[k].x, mol->atoms[k].y, mol->atoms[k].z); } (*drawEnd)(); break; case ANGLE: /* j=mol->internals[i].atoms[1]; */ form=formBondAngle; (*drawBegin)(GL_LINE_STRIP); j=mol->internals[i].atoms[0]; if (j & 0x20000000) { j&=0x1fffffff; (*drawVertex3d)(mol->unitcell->corners[j].x, mol->unitcell->corners[j].y, mol->unitcell->corners[j].z); } else (*drawVertex3d)(mol->atoms[j].x, mol->atoms[j].y, mol->atoms[j].z); j=mol->internals[i].atoms[1]; if (j & 0x20000000) { j&=0x1fffffff; (*drawVertex3d)(mol->unitcell->corners[j].x, mol->unitcell->corners[j].y, mol->unitcell->corners[j].z); } else (*drawVertex3d)(mol->atoms[j].x, mol->atoms[j].y, mol->atoms[j].z); j=mol->internals[i].atoms[2]; if (j & 0x20000000) { j&=0x1fffffff; (*drawVertex3d)(mol->unitcell->corners[j].x, mol->unitcell->corners[j].y, mol->unitcell->corners[j].z); } else (*drawVertex3d)(mol->atoms[j].x, mol->atoms[j].y, mol->atoms[j].z); (*drawEnd)(); break; case TORSION: /* j=mol->internals[i].atoms[1]; k=mol->internals[i].atoms[2]; */ form=formTorsionAngle; (*drawBegin)(GL_LINE_STRIP); j=mol->internals[i].atoms[0]; if (j & 0x20000000) { j&=0x1fffffff; (*drawVertex3d)(mol->unitcell->corners[j].x, mol->unitcell->corners[j].y, mol->unitcell->corners[j].z); } else (*drawVertex3d)(mol->atoms[j].x, mol->atoms[j].y, mol->atoms[j].z); j=mol->internals[i].atoms[1]; if (j & 0x20000000) { j&=0x1fffffff; (*drawVertex3d)(mol->unitcell->corners[j].x, mol->unitcell->corners[j].y, mol->unitcell->corners[j].z); } else (*drawVertex3d)(mol->atoms[j].x, mol->atoms[j].y, mol->atoms[j].z); j=mol->internals[i].atoms[2]; if (j & 0x20000000) { j&=0x1fffffff; (*drawVertex3d)(mol->unitcell->corners[j].x, mol->unitcell->corners[j].y, mol->unitcell->corners[j].z); } else (*drawVertex3d)(mol->atoms[j].x, mol->atoms[j].y, mol->atoms[j].z); j=mol->internals[i].atoms[3]; if (j & 0x20000000) { j&=0x1fffffff; (*drawVertex3d)(mol->unitcell->corners[j].x, mol->unitcell->corners[j].y, mol->unitcell->corners[j].z); } else (*drawVertex3d)(mol->atoms[j].x, mol->atoms[j].y, mol->atoms[j].z); (*drawEnd)(); break; default: (*drawDisable)(GL_LINE_STIPPLE); return; } if (mol->internals[i].type > 0) { sprintf(line, form, mol->internals[i].value); if (picking) { glGetDoublev(GL_MODELVIEW_MATRIX, matrix); wx1=matrix[0]*mol->internals[i].x +matrix[4]*mol->internals[i].y +matrix[8]*mol->internals[i].z+matrix[12]; wy1=matrix[1]*mol->internals[i].x +matrix[5]*mol->internals[i].y +matrix[9]*mol->internals[i].z+matrix[13] -ypix*windows[VIEWER].font->descent; wz=matrix[2]*mol->internals[i].x +matrix[6]*mol->internals[i].y +matrix[10]*mol->internals[i].z+matrix[14]; wx2=wx1+(double)StringWidth(windows[VIEWER].font, line)*xpix; wy2=wy1+h; glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glPushName((GLuint)((i+1) | 0x40000000)); glBegin(GL_POLYGON); glVertex3d(wx1, wy1, wz); glVertex3d(wx2, wy1, wz); glVertex3d(wx2, wy2, wz); glVertex3d(wx1, wy2, wz); glEnd(); glPopMatrix(); glPopName(); } else { (*drawString)(line, mol->internals[i].x, mol->internals[i].y, mol->internals[i].z, 0.0, windows[VIEWER].GLfontId, 'l'); } } else { XtVaGetValues(windows[VIEWER].widget, XtNwidth, &width, XtNheight, &height, NULL); for (j=0; jinternals[i].x, mol->internals[i].y, mol->internals[i].z, &wx1, &wy1, &wz); moveAnnotation(j, 2.0*wx1/(double)width-1.0, 2.0*wy1/(double)height-1.0); /* printf("%f %f\n", 2.0*wx1/(double)width-1.0, 2.0*wy1/(double)height-1.0);*/ } } } } (*drawDisable)(GL_LINE_STIPPLE); } void drawUnitCell(struct MOLECULE *mol, Dimension width, int lighting) { GLUquadricObj *obj; double nline, sline; double x, y, z; int first, second; register int i; /*char name[4];*/ nline=1.0; sline=2.0; if (windows[VIEWER].mode == WIREMODEL) { if (lineWidth == 0.0) nline=width*0.01; else nline=lineWidth; sline=2.0*nline; (*drawLineWidth)((GLfloat)nline); } else { (*drawLineWidth)(1.); glTexEnvf(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE); obj=gluNewQuadric(); gluQuadricDrawStyle(obj, (GLenum)primitive); gluQuadricTexture(obj, GL_TRUE); if (primitive == GLU_FILL) gluQuadricNormals(obj, (GLenum)GLU_SMOOTH); else gluQuadricNormals(obj, (GLenum)GLU_NONE); glTexEnvf(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE); for (i=0; iunitcell->nc; i++) { glPushMatrix(); glTranslated(mol->unitcell->corners[i].x, mol->unitcell->corners[i].y, mol->unitcell->corners[i].z); setAtomProperties(mol->unitcell->corners[i].element, lighting); (*drawSphere)(obj, mol->bondRadius, (int)sphereres, (int)sphereres); glPopMatrix(); /* sprintf(name, "%d", i); (*drawString)(name, mol->unitcell->corners[i].x+0.05, mol->unitcell->corners[i].y+0.05, mol->unitcell->corners[i].z+0.05, 0.0, windows[VIEWER].GLfontId, 'l'); */ } } for (i=0; iunitcell->ne; i++) { first=mol->unitcell->edges[i].first; second=mol->unitcell->edges[i].second; x=mol->unitcell->corners[first].x+0.5*(mol->unitcell->corners[second].x -mol->unitcell->corners[first].x); y=mol->unitcell->corners[first].y+0.5*(mol->unitcell->corners[second].y -mol->unitcell->corners[first].y); z=mol->unitcell->corners[first].z+0.5*(mol->unitcell->corners[second].z -mol->unitcell->corners[first].z); setAtomProperties(mol->unitcell->corners[first].element, lighting); if (picking) glPushName((GLuint)((first+1) | 0x20000000)); if (windows[VIEWER].mode == WIREMODEL) { if (mol->unitcell->corners[first].flags & SELECTED) { (*drawLineWidth)((GLfloat)sline); (*drawBegin)(GL_LINES); } else (*drawBegin)(GL_LINE_STRIP); (*drawVertex3d)(mol->unitcell->corners[first].x, mol->unitcell->corners[first].y, mol->unitcell->corners[first].z); (*drawVertex3d)(x, y, z); if (picking || mol->unitcell->corners[first].flags & SELECTED || mol->unitcell->corners[second].flags & SELECTED) { (*drawEnd)(); glPopName(); if (mol->unitcell->corners[first].flags & SELECTED) (*drawLineWidth)((GLfloat)nline); glPushName((GLuint)((second+1) | 0x20000000)); if (mol->unitcell->corners[second].flags & SELECTED) (*drawLineWidth)((GLfloat)sline); (*drawBegin)(GL_LINES); (*drawVertex3d)(x, y, z); } } else { if (mol->unitcell->corners[first].flags & SELECTED) glEnable(GL_TEXTURE_2D); cylinder(mol->unitcell->corners[first].x, mol->unitcell->corners[first].y, mol->unitcell->corners[first].z, x, y, z, mol->bondRadius, (int)sphereres, (GLenum)primitive); if (mol->unitcell->corners[first].flags & SELECTED) glDisable(GL_TEXTURE_2D); } setAtomProperties(mol->unitcell->corners[second].element, lighting); if (windows[VIEWER].mode == WIREMODEL) { (*drawVertex3d)(mol->unitcell->corners[second].x, mol->unitcell->corners[second].y, mol->unitcell->corners[second].z); (*drawEnd)(); if (mol->unitcell->corners[second].flags & SELECTED) (*drawLineWidth)((GLfloat)nline); } else { if (picking) { glPopName(); glPushName((GLuint)((second+1) | 0x20000000)); } if (mol->unitcell->corners[second].flags & SELECTED) glEnable(GL_TEXTURE_2D); cylinder(mol->unitcell->corners[second].x, mol->unitcell->corners[second].y, mol->unitcell->corners[second].z, x, y, z, mol->bondRadius, (int)sphereres, (GLenum)primitive); if (mol->unitcell->corners[second].flags & SELECTED) glDisable(GL_TEXTURE_2D); } if (picking) glPopName(); } } void drawMillerPlane(struct MOLECULE *mol, int lighting) { int step; register int i, j; setAtomProperties(mol->unitcell->millerPlanes[0].element, lighting); step=mol->unitcell->nmiller % 3 ? 4 : 3; (*drawBegin)(GL_POLYGON); for (i=0; iunitcell->nmiller; i+=step) { for (j=0; junitcell->millerPlanes[i+j].x, mol->unitcell->millerPlanes[i+j].y, mol->unitcell->millerPlanes[i+j].z); } (*drawEnd)(); } void labelAtoms(struct MOLECULE *mol, int what) { const float black[4] = {0.0, 0.0, 0.0, 0.0}; const float white[4] = {1.0, 1.0, 1.0, 0.0}; char name[MAXLENLINE]; register int i; if ((rgbMode && windows[VIEWER].background_rgb[0] == 0.0 && windows[VIEWER].background_rgb[1] == 0.0 && windows[VIEWER].background_rgb[2] == 0.0) || (!rgbMode && windows[VIEWER].background == stdcol[BLACK])) setWindowColor(FOREGROUND, stdcol[WHITE], white); else setWindowColor(FOREGROUND, stdcol[BLACK], black); for (i=0; ina; i++) { if (strncmp(mol->atoms[i].name, "Uc", 2) && strncmp(mol->atoms[i].name, "Mp", 2)) { switch(what) { case LABEL: sprintf(name, "%s%d", mol->atoms[i].name, i+1); break; case INS: sprintf(name, "%f", mol->atoms[i].neutronScatterfac); break; } glPushName(i+1); (*drawString)(name, mol->atoms[i].x+0.05, mol->atoms[i].y+0.05, mol->atoms[i].z+0.05, 0.0, windows[VIEWER].GLfontId, 'l'); glPopName(); } } } void drawAnnotation() { Dimension width, height; register double h, l; float savedRGBColor[3]; int savedColor; register int i; glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glPushMatrix(); if (!picking) glLoadIdentity(); else glPushName((GLuint)0x80000000); /* The name of the "molecule" */ glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); XtVaGetValues(windows[VIEWER].widget, XtNwidth, &width, XtNheight, &height, NULL); h=2.0*(double)StringHeight(windows[VIEWER].font)/height; for (i=0; ihistory == NULL) return; i=0; while ((i < mol->na) && (mol->atoms[i].flags & ORIGINAL)) i++; /*if (mol->unitcell && i != mol->na) i+=8;*/ j=i*(mol->cycle-1); if (lighting) setWindowColor(FOREGROUND, stdcol[BLACK], black); else shadowColor(); (*drawLineWidth)((GLfloat)1.); if (drawBegin != glBegin) primitive=GLU_LINE; for (i=0; ina; i++) { k=mol->atoms[i].ref; if (mol->atoms[i].flags & X_FIXED) gx=0.0; else gx=-100.0*forceScale*mol->history[j+k].gx; if (mol->atoms[i].flags & Y_FIXED) gy=0.0; else gy=-100.0*forceScale*mol->history[j+k].gy; if (mol->atoms[i].flags & Z_FIXED) gz=0.0; else gz=-100.0*forceScale*mol->history[j+k].gz; drawArrow(mol->atoms[i].x, mol->atoms[i].y, mol->atoms[i].z, gx, gy, gz); } if (drawBegin != glBegin) primitive=primitiveSave; } void drawNormalMode(struct MOLECULE *mol, int lighting) { const float black[4] = {0.0, 0.0, 0.0, 0.0}; int primitiveSave=primitive, mode; register int i, j; if (mol->normal_modes == NULL) return; mode=mol->mode; if (mode == (-1)) return; if (lighting) setWindowColor(FOREGROUND, stdcol[BLACK], black); else shadowColor(); if (drawBegin != glBegin) primitive=GLU_LINE; for (i=0; ina; i++) { j=3*mol->atoms[i].ref; drawArrow(mol->atoms[i].x, mol->atoms[i].y, mol->atoms[i].z, amplitude*mol->cnm[mode+mol->nmodes*j], amplitude*mol->cnm[mode+mol->nmodes*(j+1)], amplitude*mol->cnm[mode+mol->nmodes*(j+2)]); } if (drawBegin != glBegin) primitive=primitiveSave; } void drawArrow(double x1, double y1, double z1, double x2, double y2, double z2) { double length; if ((length=dist(x1, y1, z1, x1+x2, y1+y2, z1+z2)) > 1.0e-04) { if (length > 0.2*windows[VIEWER].top || drawBegin != glBegin) cylinder(x1, y1, z1, x1+0.8*x2, y1+0.8*y2, z1+0.8*z2, 0.01*length, (int)sphereres, (GLenum)primitive); else { (*drawLineWidth)((GLfloat)1.); (*drawBegin)(GL_LINES); (*drawVertex3d)(x1, y1, z1); (*drawVertex3d)(x1+0.8*x2, y1+0.8*y2, z1+0.8*z2); (*drawEnd)(); } cone(x1+0.8*x2, y1+0.8*y2, z1+0.8*z2, x1+x2, y1+y2, z1+z2, 0.03*length, (int)sphereres); } } void setupProjection(int picking) { GLfloat xview, yview, zview; Dimension width, height; if (!picking) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); } if (projectionMode == ORTHO) glOrtho(windows[VIEWER].left, windows[VIEWER].right, windows[VIEWER].bottom, windows[VIEWER].top, windows[VIEWER].near, windows[VIEWER].far); else { XtVaGetValues(windows[VIEWER].widget, XtNwidth, &width, XtNheight, &height, NULL); if (2.0*windows[VIEWER].far > transObject[3*VIEWPOINT+2]) zview=2.0*windows[VIEWER].far-transObject[3*VIEWPOINT+2]; else zview=0.1; yview=0.75*windows[VIEWER].near*windows[VIEWER].top/windows[VIEWER].far; xview=yview*(double)(width)/(double)(height); glFrustum(xview, (-xview), yview, (-yview), zview, 10.0*windows[VIEWER].far-transObject[3*VIEWPOINT+2]); glTranslatef(transObject[3*VIEWPOINT], transObject[3*VIEWPOINT+1], transObject[3*VIEWPOINT+2]); quaternionToMatrix(GL_PROJECTION, &rotObject[4*VIEWPOINT]); gluLookAt(0.0, 0.0, 3.0*windows[VIEWER].far, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); } glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void setupModelview(int i) { glTranslatef(transObject[3*(i+MOLECULES)], transObject[3*(i+MOLECULES)+1], transObject[3*(i+MOLECULES)+2]); quaternionToMatrix(GL_MODELVIEW, &rotObject[4*(i+MOLECULES)]); } void drawGround(void) { GLdouble plane[4]={0.0, 1.0, 0.0, 0.0}; setWindowColor(FOREGROUND, windows[VIEWER].foreground, windows[VIEWER].foreground_rgb); if (shadows) { glEnable(GL_STENCIL_TEST); glStencilFunc(GL_ALWAYS, 3, 0xffffffff); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); } glPassThrough((GLfloat)(ADD_DEPTH+(int)(3.0*windows[VIEWER].far))); glBegin(GL_POLYGON); glVertex3d(10.0*windows[VIEWER].left, windows[VIEWER].bottom, 10.0*windows[VIEWER].near); glVertex3d(10.0*windows[VIEWER].left, windows[VIEWER].bottom, 10.0*windows[VIEWER].far); glVertex3d(10.0*windows[VIEWER].right, windows[VIEWER].bottom, 10.0*windows[VIEWER].far); glVertex3d(10.0*windows[VIEWER].right, windows[VIEWER].bottom, 10.0*windows[VIEWER].near); glEnd(); plane[3]=(-windows[VIEWER].bottom); glClipPlane(GL_CLIP_PLANE0, plane); glPassThrough((GLfloat)(ADD_DEPTH)); } void shadow(GLfloat ground0[3], GLfloat ground1[3], GLfloat ground2[3], GLfloat lightpos[4]) { GLfloat vec0[3], vec1[3], plane[4]; GLfloat shadowMat[4][4]; register GLfloat dot; /* Need 2 vectors to find cross product. */ vec0[0]=ground1[0]-ground0[0]; vec0[1]=ground1[1]-ground0[1]; vec0[2]=ground1[2]-ground0[2]; vec1[0]=ground2[0]-ground0[0]; vec1[1]=ground2[1]-ground0[1]; vec1[2]=ground2[2]-ground0[2]; /* find cross product to get A, B, and C of plane equation */ plane[0]=vec0[1]*vec1[2]-vec0[2]*vec1[1]; plane[1]=vec0[0]*vec1[2]-vec0[2]*vec1[0]; plane[2]=vec0[0]*vec1[1]-vec0[1]*vec1[0]; plane[3]=-(plane[0]*ground0[0]+plane[1]*ground0[1]+plane[2]*ground0[2]); /* Find dot product between light position vector and ground plane normal. */ dot=plane[0]*lightpos[0]+plane[1]*lightpos[1]+plane[2]*lightpos[2] +plane[3]*lightpos[3]; shadowMat[0][0]=dot-lightpos[0]*plane[0]; shadowMat[1][0]=(-lightpos[0]*plane[1]); shadowMat[2][0]=(-lightpos[0]*plane[2]); shadowMat[3][0]=(-lightpos[0]*plane[3]); shadowMat[0][1]=(-lightpos[1]*plane[0]); shadowMat[1][1]=dot-lightpos[1]*plane[1]; shadowMat[2][1]=(-lightpos[1]*plane[2]); shadowMat[3][1]=(-lightpos[1]*plane[3]); shadowMat[0][2]=(-lightpos[2]*plane[0]); shadowMat[1][2]=(-lightpos[2]*plane[1]); shadowMat[2][2]=dot-lightpos[2]*plane[2]; shadowMat[3][2]=(-lightpos[2]*plane[3]); shadowMat[0][3]=(-lightpos[3]*plane[0]); shadowMat[1][3]=(-lightpos[3]*plane[1]); shadowMat[2][3]=(-lightpos[3]*plane[2]); shadowMat[3][3]=dot-lightpos[3]*plane[3]; glMultMatrixf((const GLfloat *)shadowMat); } void setAtomProperties(struct ELEMENT *element, int lighting) { GLfloat v[4]; if (drawBegin == raytracerBegin) raytracerMaterial(element); if (!lighting) { shadowColor(); return; } if (rgbMode) { v[0]=0.5*(element->dark[0]+element->light[0]); v[1]=0.5*(element->dark[1]+element->light[1]); v[2]=0.5*(element->dark[2]+element->light[2]); v[3]=element->alpha; } if (primitive == GLU_FILL && (windows[VIEWER].mode != WIREMODEL || !strcmp(element->symbol, "Ps") || !strcmp(element->symbol, "Ms"))) { if (rgbMode) { glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, element->ambient); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, v); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, element->specular); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, element->emission); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, element->shininess); } else { glMaterialiv(GL_FRONT_AND_BACK, GL_COLOR_INDEXES, element->colormap); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, element->shininess); } } else { if (rgbMode) (*drawColor4fv)(v); else glIndexi(element->colormap[1]); } } void shadowColor(void) { GLfloat v[4]={0.0, 0.0, 0.0, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, v); glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, v); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, v); glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, v); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 0.0); } void viewerKeyAction(KeySym keysym) { XmToggleButtonCallbackStruct data; switch (keysym) { case XK_F1: manual((Widget)0, (caddr_t)0, (caddr_t)0); break; case XK_Print: printDialog((Widget)0, (caddr_t)VIEWER, (XmAnyCallbackStruct *)0); break; case XK_KP_Add: case XK_plus: forceScale*=1.4; break; case XK_KP_Subtract: case XK_minus: forceScale/=1.4; break; case XK_Up: windows[VIEWER].top/=1.5; windows[VIEWER].bottom/=1.5; windows[VIEWER].right/=1.5; windows[VIEWER].left/=1.5; if (nAnnotations) scaleAnnotation(1.0/1.5); break; case XK_Down: windows[VIEWER].top*=1.5; windows[VIEWER].bottom*=1.5; windows[VIEWER].right*=1.5; windows[VIEWER].left*=1.5; if (nAnnotations) scaleAnnotation(1.5); break; case XK_Tab: if (nmolecule > 1) { data.set=TRUE; windows[VIEWER].set++; if (windows[VIEWER].set >= nmolecule) { windows[VIEWER].set=(-1); (void)selectMolecule((Widget)0, (XtPointer)&windows[VIEWER].selectMenu[0], &data); } else (void)selectMolecule((Widget)0, (XtPointer)&windows[VIEWER].selectMenu[windows[VIEWER].set+2], &data); } break; case XK_x: incrementQuaternion(5.0, 0.0, 0.0, &rotObject[4*moveItem]); break; case XK_X: incrementQuaternion(-5.0, 0.0, 0.0, &rotObject[4*moveItem]); break; case XK_y: incrementQuaternion(0.0, 5.0, 0.0, &rotObject[4*moveItem]); break; case XK_Y: incrementQuaternion(0.0, -5.0, 0.0, &rotObject[4*moveItem]); break; case XK_z: incrementQuaternion(0.0, 0.0, 5.0, &rotObject[4*moveItem]); break; case XK_Z: incrementQuaternion(0.0, 0.0, -5.0, &rotObject[4*moveItem]); break; case XK_0: rotObject[4*moveItem]=rotObject[4*moveItem+1]=rotObject[4*moveItem+2]=0.0; rotObject[4*moveItem+3]=1.0; break; case XK_Escape: deleteSelection(); break; } redraw(VIEWER); } viewmol-2.4.1/source/drawel.c0100644000272700027270000004454607752675434014325 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * D R A W E L . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: drawel.c,v 1.6 2003/11/07 10:59:40 jrh Exp $ * $Log: drawel.c,v $ * Revision 1.6 2003/11/07 10:59:40 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:05:02 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:12 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:47:09 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:29 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:40:27 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include "viewmol.h" void updateMOs(int); extern double makeTics(double, double, double *, char *); extern void setWindowColor(int, Pixel, const float*); extern void (*drawBegin)(GLenum), (*drawEnd)(void), (*drawVertex2d)(double, double); extern void (*drawString)(char *, double, double, double, double, GLuint, char); extern void (*drawLineStipple)(GLint, GLushort); extern void (*drawLineWidth)(GLfloat); extern void (*drawDisable)(GLenum); extern void printDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void pixelToWorld(int, double *, double *); extern void drawBackground(int, Pixel, double); extern int StringWidth(XFontStruct *, char *); extern int StringHeight(XFontStruct *); extern void setMenuItem(int, int); extern void fremem(void **); extern void deleteGridObjects(void); extern void redraw(int); extern void annotateWavefunction(void); extern char *getStringResource(Widget, char *); extern void selectMolecule(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern int makeAnnotation(int, int, float, float, float, int, const GLfloat *, int, int, char *); extern int existsGridObject(void); extern void calcmo(void); extern struct MOLECULE *molecules; extern struct WINDOW windows[]; extern Widget topShell; extern Pixel stdcol[9]; extern double denres, *grid; extern int nmolecule, iwavef; extern int unit, selectAtom, selectAtomAnnotation, automaticRecalculate; extern int picking, swapBuffers; void drawMODiagram(Widget w, caddr_t client_data, XmDrawingAreaCallbackStruct *data) { char line[15], trans[15]; char form[8], units[7]; double scan[500]; double eunit=1.0, e1h, e2h, e; double xpix, ypix, strl=0.0e0; double ticMark, ticSave, ticInc; double smax, shape, center, ehelp, fac; double off1, off2, off; const float red[4] = {1.0, 0.0, 0.0, 0.0}; const float green[4] = {0.0, 1.0, 0.0, 0.0}; const float blue[4] = {0.0, 0.0, 1.0, 0.0}; const float white[4] = {1.0, 1.0, 1.0, 0.0}; int renderMode, imol, draw, spin; register double l; register int i, j; /* This subroutine draws a MO energy diagram */ /* Convert units from Hartree/particle */ switch (unit) { case HARTREE: eunit=1.0; /* to Hartree/particle */ strcpy(units, "Eh"); break; case KJ_MOL: eunit=2625.5001; /* to kJ/mol */ strcpy(units, "kJ/mol"); break; case EV: eunit=27.211611; /* to eV */ strcpy(units, "eV"); break; case CM: eunit=4.3598149e6/(6.626176*2.99792458); /* to 1/cm (E/hc) */ strcpy(units, "1/cm"); break; } imol=windows[MO].set; glGetIntegerv(GL_RENDER_MODE, &renderMode); if (renderMode == GL_RENDER) glXMakeCurrent(XtDisplay(windows[MO].widget), XtWindow(windows[MO].widget), windows[MO].context); if (!picking) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); } pixelToWorld(MO, &xpix, &ypix); drawBackground(MO, windows[MO].background, (double)0.0); setWindowColor(FOREGROUND, windows[MO].foreground, windows[MO].foreground_rgb); if (molecules[imol].orbitals[0].spin != ALPHAANDBETA) off=ypix*(double)StringHeight(windows[MO].greekFont); else off=0.0; glOrtho(windows[MO].left, windows[MO].right, windows[MO].bottom-off, windows[MO].top, windows[MO].near, windows[MO].far); e1h=(windows[MO].bottom-off)*eunit; e2h=windows[MO].top*eunit; glShadeModel(GL_FLAT); /* Calculate and draw tic marks */ glPushName(imol); ticInc=makeTics(e1h, e2h, &ticMark, form); ticSave=ticMark; do { if (fabs(ticMark) < 1.0e-5) ticMark=0.0; sprintf(line, form, ticMark); l=(double)(StringWidth(windows[MO].font, line)+9.0); strl= strl > l ? strl : l; (*drawString)(line, 2.0*xpix, ticMark/eunit-5.0*ypix, 0.0, 0.0, windows[MO].GLfontId, 'l'); ticMark+=ticInc; } while (ticMark < e2h); strl*=xpix; ticMark=ticSave; (*drawLineWidth)((GLfloat)1.); glEnable(GL_LINE_STIPPLE); /* Dotted lines */ (*drawLineStipple)(1, 0x3333); (*drawBegin)(GL_LINES); (*drawVertex2d)(strl, 0.0); (*drawVertex2d)(1.0e0, 0.0); (*drawEnd)(); (*drawDisable)(GL_LINE_STIPPLE); (*drawBegin)(GL_LINES); (*drawVertex2d)(strl, windows[MO].bottom-off); (*drawVertex2d)(strl, windows[MO].top); (*drawEnd)(); do { (*drawBegin)(GL_LINES); (*drawVertex2d)(strl-5.0*xpix, ticMark/eunit); (*drawVertex2d)(strl+5.0*xpix, ticMark/eunit); (*drawEnd)(); ticMark+=ticInc; } while (ticMark < e2h); (*drawString)(units, 2.0*xpix, (ticMark-5.0*ticInc/2.0)/eunit, 0.0, 0.0, windows[MO].GLfontId, 'l'); /* Check for UHF calculation and label alpha and beta eigenvalues */ if (molecules[imol].orbitals[0].spin != ALPHAANDBETA) { (*drawString)("a", 0.25+0.75*strl+5.0*xpix, windows[MO].bottom+5.0*ypix, 0.0, 0.0, windows[MO].GLgreekFontId, 'c'); (*drawString)("b", 0.75+0.25*strl-5.0*xpix, windows[MO].bottom+5.0*ypix, 0.0, 0.0, windows[MO].GLgreekFontId, 'c'); } /* Draw energy levels */ if (windows[MO].mode == DENSITY_OF_STATES) { if (molecules[imol].orbitals[0].spin == ALPHAANDBETA) { e=windows[MO].bottom; smax=0.0; for (i=0; i<500; i++) { scan[i]=0.0; for (j=0; j scan[i] ? smax : scan[i]; e+=(windows[MO].top-windows[MO].bottom)/500.0; } (*drawBegin)(GL_LINE_STRIP); (*drawVertex2d)(scan[0]*(1.0-strl)/smax+strl, windows[MO].bottom); for (i=1; i<500; i++) (*drawVertex2d)(scan[i]*(1.0-strl)/smax+strl, windows[MO].bottom+ (double)i*(windows[MO].top-windows[MO].bottom)/500.0); (*drawEnd)(); } else { draw=TRUE; spin=ALPHA; setWindowColor(FOREGROUND, stdcol[BLUE], blue); while (draw) { e=windows[MO].bottom; smax=0.0; for (i=0; i<500; i++) { scan[i]=0.0; for (j=0; j scan[i] ? smax : scan[i]; e+=(windows[MO].top-windows[MO].bottom)/500.0; } (*drawBegin)(GL_LINE_STRIP); (*drawVertex2d)(scan[0]*(1.0-strl)/smax+strl, windows[MO].bottom); for (i=1; i<500; i++) (*drawVertex2d)(scan[i]*(1.0-strl)/smax+strl, windows[MO].bottom+ (double)i*(windows[MO].top-windows[MO].bottom)/500.0); (*drawEnd)(); switch (spin) { case ALPHA: spin=BETA; (*drawBegin)(GL_LINE_STRIP); (*drawVertex2d)(0.25+0.75*strl, windows[MO].bottom+0.5*StringHeight(windows[MO].greekFont)*ypix); (*drawVertex2d)(0.25, windows[MO].bottom+0.5*StringHeight(windows[MO].greekFont)*ypix); (*drawEnd)(); setWindowColor(FOREGROUND, stdcol[GREEN], green); break; case BETA: draw=FALSE; (*drawBegin)(GL_LINE_STRIP); (*drawVertex2d)(0.75+0.25*strl-10.0*xpix, windows[MO].bottom+0.5*StringHeight(windows[MO].greekFont)*ypix); (*drawVertex2d)(0.75-0.5*strl-10.0*xpix, windows[MO].bottom+0.5*StringHeight(windows[MO].greekFont)*ypix); (*drawEnd)(); break; } } } } else { for (i=0; i %s", molecules[imol].orbitals[molecules[imol].imosave].symmetry, molecules[imol].orbitals[molecules[imol].imo].symmetry); ehelp=fabs(ehelp)/2.0+molecules[imol].orbitals[molecules[imol].imo < molecules[imol].imosave ? molecules[imol].imo : molecules[imol].imosave].energy+13.*ypix; } else { ehelp=molecules[imol].orbitals[molecules[imol].imo].energy; sprintf(line, "%.6f", eunit*molecules[imol].orbitals[molecules[imol].imo].energy); sprintf(trans, "%s", molecules[imol].orbitals[molecules[imol].imo].symmetry); } off1=(double)(StringWidth(windows[MO].font, trans)+4)/2.0; off2=(double)(StringWidth(windows[MO].font, line)+4)/2.0; off=xpix*(off1 > off2 ? off1 : off2); setWindowColor(FOREGROUND, stdcol[WHITE], white); if (ehelp-windows[MO].bottom < 27.0*ypix) { glRectd(center-off, ehelp+27.0*ypix, center+off, ehelp); setWindowColor(FOREGROUND, windows[MO].foreground, windows[MO].foreground_rgb); (*drawBegin)(GL_LINE_LOOP); (*drawVertex2d)(center-off, ehelp+27.0*ypix); (*drawVertex2d)(center-off, ehelp); (*drawVertex2d)(center+off, ehelp); (*drawVertex2d)(center+off, ehelp+27.0*ypix); (*drawEnd)(); (*drawString)(trans, center-(off1-2.0)*xpix, ehelp+16.0*ypix, 0.0, 0.0, windows[MO].GLfontId, 'l'); (*drawString)(line, center-(off2-2.0)*xpix, ehelp+3.0*ypix, 0.0, 0.0, windows[MO].GLfontId, 'l'); } else { glRectd(center-off, ehelp-27.0*ypix, center+off, ehelp); setWindowColor(FOREGROUND, windows[MO].foreground, windows[MO].foreground_rgb); (*drawBegin)(GL_LINE_LOOP); (*drawVertex2d)(center-off, ehelp-27.0*ypix); (*drawVertex2d)(center-off, ehelp); (*drawVertex2d)(center+off, ehelp); (*drawVertex2d)(center+off, ehelp-27.0*ypix); (*drawEnd)(); (*drawString)(trans, center-(off1-2.0)*xpix, ehelp-11.0*ypix, 0.0, 0.0, windows[MO].GLfontId, 'l'); (*drawString)(line, center-(off2-2.0)*xpix, ehelp-24.0*ypix, 0.0, 0.0, windows[MO].GLfontId, 'l'); } } } glPopName(); if (swapBuffers) glXSwapBuffers(XtDisplay(windows[MO].widget), XtWindow(windows[MO].widget)); } void quitMODiagram(Widget w, caddr_t client_data, XmAnyCallbackStruct *data) { register int imol; if (windows[MO].widget == NULL) return; imol=windows[MO].set; deleteGridObjects(); glXMakeCurrent(XtDisplay(windows[VIEWER].widget), XtWindow(windows[VIEWER].widget), windows[VIEWER].context); fremem((void **)&windows[MO].font); XtUnmanageChild(XtParent(windows[MO].widget)); XtDestroyWidget(XtParent(windows[MO].widget)); windows[MO].widget=0; setMenuItem(VIEWER_ENERGYLEVEL, True); if (nmolecule > 0) { molecules[imol].imo=(-1); molecules[imol].imosave=(-1); redraw(VIEWER); } } void setTransition(Widget w, caddr_t dummy, XmToggleButtonCallbackStruct *data) { register int imol; imol=windows[MO].set; if (data->set) molecules[imol].imosave=molecules[imol].imo; else molecules[imol].imosave=(-1); } void MODiagramKeyAction(KeySym keysym) { XmToggleButtonCallbackStruct data; struct MOLECULE *mol; int imoSave, spin; mol=&molecules[windows[MO].set]; imoSave=mol->imo; switch (keysym) { case XK_Print: printDialog((Widget)0, (caddr_t)MO, (XmAnyCallbackStruct *)0); break; case XK_Down: if (mol->imo != -1) { spin=mol->orbitals[mol->imo].spin; while (mol->orbitals[--mol->imo].spin != spin && mol->imo >= 0); if (mol->imo < 0) { mol->imo=mol->nbasfu; while (mol->orbitals[--mol->imo].spin != spin && mol->imo >= 0); } } break; case XK_Up: if (mol->imo != -1) { spin=mol->orbitals[mol->imo].spin; while (mol->orbitals[++mol->imo].spin != spin && mol->imo < mol->nbasfu); if (mol->imo >= mol->nbasfu) { mol->imo=-1; while (mol->orbitals[++mol->imo].spin != spin && mol->imo < mol->nbasfu); } } break; case XK_Left: if (mol->imo != -1) { if (mol->orbitals[mol->imo].spin == BETA) while (mol->orbitals[--mol->imo].spin == BETA && mol->imo >= 0); } break; case XK_Right: if (mol->imo != -1) { if (mol->orbitals[mol->imo].spin == ALPHA) while (mol->orbitals[++mol->imo].spin == ALPHA && mol->imo < mol->nbasfu); } break; case XK_Tab: if (nmolecule > 1) { data.set=TRUE; do { windows[MO].set++; if (windows[MO].set >= nmolecule) windows[MO].set=0; } while (molecules[windows[MO].set].orbitals == NULL); (void)selectMolecule((Widget)0, (XtPointer)&windows[MO].selectMenu[windows[MO].set], &data); } break; } updateMOs(imoSave); annotateWavefunction(); } void updateMOs(int imoSave) { struct MOLECULE *mol; const GLfloat black[4] = {0.0, 0.0, 0.0, 0.0}; char *word; mol=&molecules[windows[MO].set]; if (automaticRecalculate) { switch (iwavef) { case BASIS_IN_MO: word=getStringResource(topShell, "selectAtomTitle"); selectAtomAnnotation=makeAnnotation(selectAtomAnnotation, CENTERED, 0.0, 1.0, 0.0, stdcol[BLACK], black, 0, 0, word); selectAtom=TRUE; break; case MOLECULAR_ORBITAL: selectAtom=FALSE; if (!existsGridObject()) calcmo(); break; } } if (mol->imo != imoSave && grid != NULL) fremem((void **)&grid); if (mol->orbitals[mol->imo].occupation == 0.0 && mol->needMoloch) setMenuItem(VIEWER_WAVEFUNCTION, False); else if (mol->basisset != NULL) setMenuItem(VIEWER_WAVEFUNCTION, True); } viewmol-2.4.1/source/drawform.c0100644000272700027270000003355407752675446014670 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * D R A W F O R M . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: drawform.c,v 1.6 2003/11/07 10:59:50 jrh Exp $ * $Log: drawform.c,v $ * Revision 1.6 2003/11/07 10:59:50 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:05:13 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:14 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:47:29 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:31 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:40:31 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" extern void GetSlider(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); extern void MapBox(Widget, caddr_t, caddr_t); extern Widget CreateToggleBox(Widget, struct PushButtonRow *, int, int, int, int, int); extern Widget CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern void redraw(int); extern void changeBoolean(Widget, int *, XmDrawingAreaCallbackStruct *); extern void drawMolecule(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void setMenuItem(int, int); extern Widget initShell(Widget, char *, Widget *, Widget *); void drawingModeDialogExit(Widget, caddr_t, XmPushButtonCallbackStruct *); void switchLight(Widget, caddr_t, XmToggleButtonCallbackStruct *); void switchMove(Widget, caddr_t, XmToggleButtonCallbackStruct *); void setDrawingMode(Widget, caddr_t, XmToggleButtonCallbackStruct *); void setProjection(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern struct WINDOW windows[]; extern Widget topShell; extern int primitive, lights, moveItem, simplify, projectionMode, shadows; extern double sphereres, lineWidth; static Widget dialog, simpleRot=NULL, viewPoint; static int primitive_save, lights_save, moveItem_save, projectionMode_save; static double sphereres_save, lineWidth_save; void drawingModeDialog(Widget widget, caddr_t dummy, XmAnyCallbackStruct *data) { Widget board, form, form1, form2, form3, label, slider1, slider2; Widget radiobox, checkbox, sep1, sep2, sep3, sep4, sep5; static struct PushButtonRow buttons[] = { { "ok", drawingModeDialogExit, (XtPointer)TRUE, NULL }, { "cancel", drawingModeDialogExit, (XtPointer)FALSE, NULL }, }; static struct PushButtonRow radiobox_buttons1[] = { { "dots", setDrawingMode, (XtPointer)GLU_POINT, NULL }, { "lines", setDrawingMode, (XtPointer)GLU_LINE, NULL }, { "surfaces", setDrawingMode, (XtPointer)GLU_FILL, NULL }, }; static struct PushButtonRow radiobox_buttons3[] = { { "orthographic", setProjection, (XtPointer)ORTHO, NULL }, { "perspective", setProjection, (XtPointer)PERSPECTIVE, NULL }, }; static struct PushButtonRow checkbox_buttons[] = { { "light0OnOff", switchLight, (XtPointer)0, NULL }, { "light1OnOff", switchLight, (XtPointer)1, NULL }, }; static struct PushButtonRow radiobox_buttons2[] = { { "viewpoint", switchMove, (XtPointer)VIEWPOINT, NULL}, { "light0", switchMove, (XtPointer)LIGHTNO0, NULL }, { "light1", switchMove, (XtPointer)LIGHTNO1, NULL }, { "molecule", switchMove, (XtPointer)MOLECULES, NULL }, }; static struct SLIDER spheregrid, lineWidthSlider; setMenuItem(VIEWER_DRAWING, False); primitive_save=primitive; lights_save=lights; moveItem_save=moveItem; projectionMode_save=projectionMode; sphereres_save=sphereres; spheregrid.number=&sphereres; spheregrid.decimals=0; spheregrid.draw=(void (*)())drawMolecule; lineWidth_save=lineWidth; lineWidthSlider.number=&lineWidth; lineWidthSlider.decimals=0; lineWidthSlider.draw=(void (*)())drawMolecule; dialog=initShell(windows[VIEWER].widget, "drawingModeForm", &board, &form); form1=XtVaCreateWidget("rowcolumn", xmRowColumnWidgetClass, form, XmNorientation, XmHORIZONTAL, NULL); form2=XtVaCreateWidget("rowcolumn", xmRowColumnWidgetClass, form1, XmNorientation, XmVERTICAL, NULL); sep5=XtVaCreateManagedWidget("sep5", xmSeparatorWidgetClass, form1, XmNtraversalOn, False, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNorientation, XmVERTICAL, NULL); form3=XtVaCreateWidget("rowcolumn", xmRowColumnWidgetClass, form1, XmNorientation, XmVERTICAL, NULL); radiobox=CreateToggleBox(form2, radiobox_buttons1, XtNumber(radiobox_buttons1), XmVERTICAL, 1, True, primitive-GLU_POINT); XtVaSetValues(radiobox, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, NULL); simpleRot=XtVaCreateManagedWidget("simplify", xmToggleButtonWidgetClass, form2, NULL); if (simplify) XtVaSetValues(simpleRot, XmNset, True, NULL); if (primitive != GLU_FILL) XtVaSetValues(simpleRot, XmNsensitive, False, NULL); XtAddCallback(simpleRot, XmNvalueChangedCallback, (XtCallbackProc)changeBoolean, &simplify); sep1=XtVaCreateManagedWidget("sep1", xmSeparatorWidgetClass, form2, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, radiobox, NULL); label=XtVaCreateManagedWidget("projectionLabel", xmLabelWidgetClass, form2, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, sep1, NULL); radiobox=CreateToggleBox(form2, radiobox_buttons3, XtNumber(radiobox_buttons3), XmVERTICAL, 1, True, projectionMode); XtVaSetValues(radiobox, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); radiobox=CreateToggleBox(form3, radiobox_buttons2, XtNumber(radiobox_buttons2), XmVERTICAL, 1, True, moveItem < WORLD ? moveItem : WORLD); viewPoint=radiobox_buttons2[VIEWPOINT].widget; if (projectionMode == ORTHO) XtVaSetValues(viewPoint, XmNsensitive, False, NULL); sep2=XtVaCreateManagedWidget("sep2", xmSeparatorWidgetClass, form3, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, radiobox, NULL); label=XtVaCreateManagedWidget("onOffLabel", xmLabelWidgetClass, form3, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, sep2, NULL); checkbox=CreateToggleBox(form3, checkbox_buttons, XtNumber(checkbox_buttons), XmVERTICAL, 1, False, 0); if (lights & 0x1) XtVaSetValues(checkbox_buttons[0].widget, XmNset, True, NULL); if (lights & 0x2) XtVaSetValues(checkbox_buttons[1].widget, XmNset, True, NULL); sep3=XtVaCreateManagedWidget("sep3", xmSeparatorWidgetClass, form, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, checkbox, NULL); label=XtVaCreateManagedWidget("sphereResolutionLabel", xmLabelWidgetClass, form, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, sep3, NULL); slider1=XtVaCreateManagedWidget("sphereResolution", xmScaleWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNvalue, (int)sphereres, XmNminimum, 4, XmNmaximum, sphereres > 30. ? (int)sphereres : 30, XmNdecimalPoints, 0, XmNshowValue, True, XmNsensitive, True, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, label, NULL); XtAddCallback(slider1, XmNvalueChangedCallback, (XtCallbackProc)GetSlider, &spheregrid); label=XtVaCreateManagedWidget("lineWidthLabel", xmLabelWidgetClass, form, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, slider1, NULL); slider2=XtVaCreateManagedWidget("lineWidth", xmScaleWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNvalue, (int)lineWidth, XmNminimum, 0, XmNmaximum, lineWidth > 10. ? (int)lineWidth : 10, XmNdecimalPoints, 0, XmNshowValue, True, XmNsensitive, True, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, label, NULL); XtAddCallback(slider2, XmNvalueChangedCallback, (XtCallbackProc)GetSlider, &lineWidthSlider); sep4=XtVaCreateManagedWidget("sep4", xmSeparatorWidgetClass, form, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, slider1, NULL); CreatePushButtonRow(form, buttons, XtNumber(buttons)); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XtPointer)NULL); XtManageChild(form3); XtManageChild(form2); XtManageChild(form1); XtManageChild(form); XtManageChild(board); } void drawingModeDialogExit(Widget widget, caddr_t which, XmPushButtonCallbackStruct *data) { XtDestroyWidget(dialog); simpleRot=NULL; if (!(int)which) { primitive=primitive_save; lights=lights_save; moveItem=moveItem_save; projectionMode=projectionMode_save; sphereres=sphereres_save; lineWidth=lineWidth_save; if (projectionMode == PERSPECTIVE) shadows=TRUE; else shadows=FALSE; } setMenuItem(VIEWER_DRAWING, True); redraw(VIEWER); } void setDrawingMode(Widget w, caddr_t mode, XmToggleButtonCallbackStruct *data) { if (data->set) { primitive=(int)mode; if (simpleRot != NULL) { if (primitive == GLU_FILL) XtVaSetValues(simpleRot, XmNsensitive, True, NULL); else XtVaSetValues(simpleRot, XmNsensitive, False, NULL); } redraw(VIEWER); } } void setProjection(Widget w, caddr_t mode, XmToggleButtonCallbackStruct *data) { if (data->set) { projectionMode=(int)mode; if (projectionMode == PERSPECTIVE) { shadows=TRUE; setMenuItem(VIEWER_FOREGROUND, True); } else { shadows=FALSE; setMenuItem(VIEWER_FOREGROUND, False); } if (viewPoint) XtVaSetValues(viewPoint, XmNsensitive, shadows, NULL); redraw(VIEWER); } } void switchLight(Widget widget, caddr_t which, XmToggleButtonCallbackStruct *data) { register int i; i=1 << (int)which; if (data->set) lights|=i; else lights&=~i; redraw(VIEWER); } void switchMove(Widget widget, caddr_t which, XmToggleButtonCallbackStruct *data) { if (data->set) moveItem=(int)which; redraw(VIEWER); } viewmol-2.4.1/source/drawop.c0100644000272700027270000003214507752675455014336 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * D R A W O P . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: drawop.c,v 1.6 2003/11/07 10:59:57 jrh Exp $ * $Log: drawop.c,v $ * Revision 1.6 2003/11/07 10:59:57 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:05:20 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:16 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:47:38 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:34 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:40:36 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include "viewmol.h" void cross(double, double, double, double); Boolean animateHistory(XtPointer); extern double makeTics(double, double, double *, char *); extern void pixelToWorld(int, double *, double *); extern void drawBackground(int, Pixel, double); extern void setWindowColor(int, Pixel, const float *); extern int StringWidth(XFontStruct *, char *); extern void (*drawBegin)(GLenum), (*drawEnd)(void), (*drawVertex2d)(double, double); extern void (*drawString)(char *, double, double, double, double, GLuint, char); extern void (*drawLineWidth)(GLfloat); extern void printDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern char *getStringResource(Widget, char*); extern void restoreGeometry(struct SAVE *, int); extern void redraw(int); extern void setMenuItem(int, int); extern void setGeometry(int); extern void deleteAnnotation(int *); extern void fremem(void **); extern void selectMolecule(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void setHistoryAnimation(Widget, caddr_t, XmAnyCallbackStruct *); extern void getWorldCoordinates(double, double, double, double *, double *, double *); extern void getScreenCoordinates(double, double, double, double *, double *, double *); extern struct MOLECULE *molecules; extern struct WINDOW windows[]; extern Widget topShell; extern Pixel stdcol[9], historyColor; extern float historyColor_rgb[4]; extern int historyAnnotation, nmolecule; extern int animate, swapBuffers; void drawHistory(Widget w, caddr_t x, XmDrawingAreaCallbackStruct *data) { Dimension width, height; char line[18], form[8], *word; double left, right, bottom, top; double g, e, xpix, ypix=0.0, xpixold, ticMark, ticInc, strl; const float black[4] = {0.0, 0.0, 0.0, 0.0}; int imol, renderMode; register int i; /* This subroutine draws the diagram for optimization history */ imol=windows[HISTORY].set; glGetIntegerv(GL_RENDER_MODE, &renderMode); if (renderMode == GL_RENDER) glXMakeCurrent(XtDisplay(windows[HISTORY].widget), XtWindow(windows[HISTORY].widget), windows[HISTORY].context); XtVaGetValues(windows[HISTORY].widget, XtNwidth, &width, XtNheight, &height, NULL); e=molecules[imol].emax-molecules[imol].emin > 0.00001 ? molecules[imol].emax-molecules[imol].emin : 0.00001; g=molecules[imol].gmax == 0.0 ? 0.01 : molecules[imol].gmax; left=windows[HISTORY].left; right=windows[HISTORY].right=(double)(molecules[imol].nhist); bottom=windows[HISTORY].bottom; top=windows[HISTORY].top=g; xpixold=0.0; xpix=1.0; while (fabs(xpixold-xpix) > 1.0e-4) { xpixold=xpix; xpix=(right-left)/(double)width; ypix=(top-bottom)/(double)height; left=windows[HISTORY].left-10.0*xpix; right=windows[HISTORY].right+10.0*xpix; bottom=windows[HISTORY].bottom-10.0*ypix; top=windows[HISTORY].top+10.0*ypix; } drawBackground(HISTORY, windows[HISTORY].background, (double)0.0); setWindowColor(FOREGROUND, stdcol[BLACK], black); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(left, right, bottom, top, windows[HISTORY].near, windows[HISTORY].far); glShadeModel(GL_FLAT); /* Draw tic marks */ if (windows[HISTORY].mode & SCALES) { (*drawLineWidth)((GLfloat)1.); ticInc=makeTics(1.0, (double)molecules[imol].nhist, &ticMark, form); if (ticInc < 1.0) ticInc=1.0; if (ticMark == 1.0) ticMark+=ticInc; do { (*drawBegin)(GL_LINES); (*drawVertex2d)(ticMark, g); (*drawVertex2d)(ticMark, g+5.0*ypix); (*drawEnd)(); (*drawBegin)(GL_LINES); (*drawVertex2d)(ticMark, 0.0); (*drawVertex2d)(ticMark, -5.0*ypix); (*drawEnd)(); sprintf(line, "%d", (int)ticMark); strl=(double)StringWidth(windows[HISTORY].font, line)/2.0*xpix; (*drawString)(line, ticMark-strl, g-15.0*ypix, 0.0, 0.0, windows[HISTORY].GLfontId, 'l'); ticMark+=ticInc; } while (ticMark < (double)molecules[imol].nhist); if (windows[HISTORY].mode & GNORM) { ticInc=makeTics(0.0, g, &ticMark, form); ticMark+=ticInc; do { (*drawBegin)(GL_LINES); (*drawVertex2d)((double)molecules[imol].nhist, ticMark); (*drawVertex2d)((double)molecules[imol].nhist+5.0*xpix, ticMark); (*drawEnd)(); sprintf(line, form, ticMark); strl=(double)(StringWidth(windows[HISTORY].font, line)+4)*xpix; setWindowColor(FOREGROUND, historyColor, historyColor_rgb); (*drawString)(line, (double)molecules[imol].nhist, ticMark-5.0*ypix, 0.0, strl, windows[HISTORY].GLfontId, 'r'); setWindowColor(FOREGROUND, stdcol[BLACK], black); ticMark+=ticInc; } while (ticMark < g); } if (windows[HISTORY].mode & ENERGY) { ticInc=makeTics(molecules[imol].emin, e+molecules[imol].emin, &ticMark, form); do { (*drawBegin)(GL_LINES); (*drawVertex2d)(1.0-5.0*xpix, (ticMark-molecules[imol].emin)*g/e); (*drawVertex2d)(1.0, (ticMark-molecules[imol].emin)*g/e); (*drawEnd)(); sprintf(line, form, ticMark); setWindowColor(FOREGROUND, windows[HISTORY].foreground, windows[HISTORY].foreground_rgb); (*drawString)(line, 1.0+3.0*xpix, (ticMark-molecules[imol].emin)*g/e-5.0*ypix, 0.0, 0.0, windows[HISTORY].GLfontId, 'l'); setWindowColor(FOREGROUND, stdcol[BLACK], black); ticMark+=ticInc; } while (ticMark < e+molecules[imol].emin); } } /* Draw diagram frame and labels */ (*drawLineWidth)((GLfloat)3.); (*drawBegin)(GL_LINE_LOOP); (*drawVertex2d)(1.0, 0.0); (*drawVertex2d)(1.0, g); (*drawVertex2d)((double)molecules[imol].nhist, g); (*drawVertex2d)((double)molecules[imol].nhist, 0.0); (*drawEnd)(); if (windows[HISTORY].mode & GNORM) { setWindowColor(FOREGROUND, historyColor, historyColor_rgb); (*drawBegin)(GL_LINES); (*drawVertex2d)((double)molecules[imol].nhist-150.0*xpix, g-40.0*ypix); (*drawVertex2d)((double)molecules[imol].nhist-130.0*xpix, g-40.0*ypix); (*drawEnd)(); setWindowColor(FOREGROUND, stdcol[BLACK], black); word=getStringResource(topShell, "gradientNorm"); (*drawString)(word, (double)molecules[imol].nhist-120.0*xpix, g-40.0*ypix, 0.0, 0.0, windows[HISTORY].GLfontId, 'l'); } if (windows[HISTORY].mode & ENERGY) { setWindowColor(FOREGROUND, windows[HISTORY].foreground, windows[HISTORY].foreground_rgb); (*drawBegin)(GL_LINES); (*drawVertex2d)((double)molecules[imol].nhist-150.0*xpix, g-60.0*ypix); (*drawVertex2d)((double)molecules[imol].nhist-130.0*xpix, g-60.0*ypix); (*drawEnd)(); setWindowColor(FOREGROUND, stdcol[BLACK], black); word=getStringResource(topShell, "energy"); (*drawString)(word, (double)molecules[imol].nhist-120.0*xpix, g-60.0*ypix, 0.0, 0.0, windows[HISTORY].GLfontId, 'l'); } /* Draw gradient norm curve */ if (windows[HISTORY].mode & GNORM) { setWindowColor(FOREGROUND, historyColor, historyColor_rgb); (*drawBegin)(GL_LINE_STRIP); for (i=0; i molecules[imol].nhist ? molecules[imol].nhist : c1; c2=(int)ceil(xw); c2=c2 < 1 ? 1 : c2; c2=c2 > molecules[imol].nhist ? molecules[imol].nhist : c2; setWindowColor(FOREGROUND, stdcol[RED], red); if (windows[HISTORY].mode & ENERGY) { a=molecules[imol].optimization[c1-1].energy-molecules[imol].optimization[c2-1].energy; b=molecules[imol].optimization[c1-1].energy-molecules[imol].emin+a*((double)c1-xw); } else if (windows[HISTORY].mode & GNORM) { a=molecules[imol].optimization[c1-1].gnorm-molecules[imol].optimization[c2-1].gnorm; b=molecules[imol].optimization[c1-1].gnorm+a*((double)c1-xw); y=windows[HISTORY].top; } xpix*=10.0; ypix*=10.0; (*drawBegin)(GL_LINES); (*drawVertex2d)(xw, b*windows[HISTORY].top/y-ypix); (*drawVertex2d)(xw, b*windows[HISTORY].top/y+ypix); (*drawEnd)(); (*drawBegin)(GL_LINES); (*drawVertex2d)(xw-xpix, b*windows[HISTORY].top/y); (*drawVertex2d)(xw+xpix, b*windows[HISTORY].top/y); (*drawEnd)(); } void quitHistory(Widget w, caddr_t client_data, XmAnyCallbackStruct *data) { int imol; if (windows[HISTORY].widget == NULL) return; imol=windows[HISTORY].set; glXMakeCurrent(XtDisplay(windows[VIEWER].widget), XtWindow(windows[VIEWER].widget), windows[VIEWER].context); if (animate == TRAJECTORY) setHistoryAnimation((Widget)0, (caddr_t)0, (XmAnyCallbackStruct *)0) ; fremem((void **)&windows[HISTORY].font); XtUnmanageChild(XtParent(windows[HISTORY].widget)); XtDestroyWidget(XtParent(windows[HISTORY].widget)); windows[HISTORY].widget=0; deleteAnnotation(&historyAnnotation); if (molecules) restoreGeometry(molecules[imol].coord, imol); redraw(VIEWER); setMenuItem(VIEWER_OPTIMIZATION, True); } Boolean animateHistory(XtPointer data) { static int direction=1; struct MOLECULE *mol; double xs, ys, zs; mol=&molecules[windows[HISTORY].set]; if ((int)data > 0) mol->cycle=(int)data; else { mol->cycle+=direction; if (mol->cycle >= mol->nhist) { direction=(-1); mol->cycle=mol->nhist; } if (mol->cycle <= 1) { direction=1; mol->cycle=1; } } setGeometry(TRUE); getScreenCoordinates((double)(mol->cycle), 0.0, 0.0, &xs, &ys, &zs); windows[HISTORY].mouseX=(int)xs; redraw(VIEWER); redraw(HISTORY); return(False); } void historyKeyAction(KeySym keysym) { XmToggleButtonCallbackStruct data; struct MOLECULE *mol; double xs, ys, zs; mol=&molecules[windows[HISTORY].set]; switch (keysym) { case XK_Print: printDialog((Widget)0, (caddr_t)HISTORY, (XmAnyCallbackStruct *)0); break; case XK_Left: if (--mol->cycle < 1) mol->cycle=mol->nhist; getScreenCoordinates((double)mol->cycle, 0.0, 0.0, &xs, &ys, &zs); windows[HISTORY].mouseX=(int)xs; break; case XK_Right: if (++mol->cycle > mol->nhist) mol->cycle=1; getScreenCoordinates((double)mol->cycle, 0.0, 0.0, &xs, &ys, &zs); windows[HISTORY].mouseX=(int)xs; break; case XK_Tab: if (nmolecule > 1) { data.set=TRUE; do { windows[HISTORY].set++; if (windows[HISTORY].set >= nmolecule) windows[HISTORY].set=0; } while (molecules[windows[HISTORY].set].optimization == NULL); (void)selectMolecule((Widget)0, (XtPointer)&windows[HISTORY].selectMenu[windows[HISTORY].set], &data); } break; } setGeometry(TRUE); } viewmol-2.4.1/source/drawsp.c0100644000272700027270000005544107752675463014345 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * D R A W S P . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: drawsp.c,v 1.6 2003/11/07 11:00:03 jrh Exp $ * $Log: drawsp.c,v $ * Revision 1.6 2003/11/07 11:00:03 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:05:27 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:18 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:47:45 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:36 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:40:41 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include "viewmol.h" #define max(a, b) (a) > (b) ? (a) : (b) #define min(a, b) (a) < (b) ? (a) : (b) void setWindowColor(int, Pixel, const float *); void paper(Dimension, Dimension); void pixelToWorld(int, double *, double *); void annotateNormalMode(struct MOLECULE *); extern int StringWidth(XFontStruct *, char *); extern int StringHeight(XFontStruct *); extern int StringAscent(XFontStruct *); extern void (*drawColor4fv)(const GLfloat *); extern void (*drawBegin)(GLenum), (*drawEnd)(void), (*drawVertex2d)(double, double); extern void (*drawString)(char *, double, double, double, double, GLuint, char); extern void (*drawLineStipple)(GLint, GLushort), (*drawDisable)(GLenum); extern void (*drawLineWidth)(GLfloat); extern void (*drawClearColor)(GLclampf, GLclampf, GLclampf, GLclampf); extern void printDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern char *getStringResource(Widget, char *); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern void drawBackground(int, Pixel, double); extern void setAnimation(int); extern void restoreGeometry(struct SAVE *, int); extern void redraw(int); extern void setMenuItem(int, int); extern void distortGeometry(double); extern int makeAnnotation(int, int, float, float, float, int, const GLfloat *, int, int, char *); extern void deleteAnnotation(int *); extern char *selectFile(char *, char *, int); extern void redraw(int); extern void selectMolecule(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern double makeTics(double, double, double *, char *); extern struct MOLECULE *molecules; extern struct WINDOW windows[]; extern Widget topShell; extern int nmolecule; extern int lines, animate, normalModeAnnotation, xIsTop, showGrid; extern double temp, wnScale, amplitude, spectrumLineWidth; extern int rgbMode, picking, swapBuffers; extern Pixel stdcol[9]; static double *expwn, *expint; static int expwnc; void drawSpectrum(Widget w, caddr_t client_data, XmDrawingAreaCallbackStruct *data) { const double h=6.626176e-34, c=2.99792458e10, kb=1.380662e-23; const float red[4] = {1.0, 0.0, 0.0, 0.0}; const float blue[4] = {0.0, 0.0, 1.0, 0.0}; /*FILE *file;*/ Dimension width, height; double *scan, *s; double f, zz, wmax, frq, frqinc, shape, a, b; int renderMode, imol; register int i, j; if (temp > 0.0) f=-h*c/(kb*temp); else f=-h*c/(kb*0.001); /*a=512.0*(atan(1.0))**3*6.022045e23/(h*c*3000.0*log(10.0)); */ imol=windows[SPECTRUM].set; glGetIntegerv(GL_RENDER_MODE, &renderMode); if (renderMode == GL_RENDER) glXMakeCurrent(XtDisplay(windows[SPECTRUM].widget), XtWindow(windows[SPECTRUM].widget), windows[SPECTRUM].context); if (!picking) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); } glShadeModel(GL_FLAT); XtVaGetValues(windows[SPECTRUM].widget, XtNwidth, &width, XtNheight, &height, NULL); paper(width, height); /* Draw line spectrum */ (*drawLineWidth)((GLfloat)spectrumLineWidth); glPushName(imol); if (lines) { /* Loop over wave numbers */ for (i=0; i= windows[SPECTRUM].left && frq <= windows[SPECTRUM].right) { glPushName(i+1); (*drawBegin)(GL_LINES); (*drawVertex2d)(frq, max(0.0, windows[SPECTRUM].top)); if (windows[SPECTRUM].mode == SPECTRUM_ALL) (*drawVertex2d)(frq, windows[SPECTRUM].bottom); if (windows[SPECTRUM].mode == SPECTRUM_IR && molecules[imol].normal_modes[i].rel_ir_intensity != 0.0) (*drawVertex2d)(frq, min(windows[SPECTRUM].bottom, molecules[imol].normal_modes[i].rel_ir_intensity)); if (windows[SPECTRUM].mode == SPECTRUM_RAMAN && molecules[imol].normal_modes[i].rel_raman_intensity != 0.0) (*drawVertex2d)(frq, min(windows[SPECTRUM].bottom, molecules[imol].normal_modes[i].rel_raman_intensity)); if (windows[SPECTRUM].mode == SPECTRUM_INS && molecules[imol].normal_modes[i].rel_ins_intensity != 0.0) (*drawVertex2d)(frq, min(windows[SPECTRUM].bottom, molecules[imol].normal_modes[i].rel_ins_intensity)); (*drawEnd)(); glPopName(); } } /* Plot the selected wave number in red */ if (molecules[imol].mode > (-1) && molecules[imol].mode <= molecules[imol].nmodes) { setWindowColor(FOREGROUND, stdcol[RED], red); frq=wnScale*molecules[imol].normal_modes[molecules[imol].mode].wavenumber; if (frq >= windows[SPECTRUM].left && frq <= windows[SPECTRUM].right) { glPushName(molecules[imol].mode+1); (*drawBegin)(GL_LINES); (*drawVertex2d)(frq, max(0.0, windows[SPECTRUM].top)); if (windows[SPECTRUM].mode == SPECTRUM_ALL) (*drawVertex2d)(frq, windows[SPECTRUM].bottom); if (windows[SPECTRUM].mode == SPECTRUM_IR && molecules[imol].normal_modes[molecules[imol].mode].rel_ir_intensity != 0.0) (*drawVertex2d)(frq, min(windows[SPECTRUM].bottom, molecules[imol].normal_modes[molecules[imol].mode].rel_ir_intensity)); if (windows[SPECTRUM].mode == SPECTRUM_RAMAN && molecules[imol].normal_modes[molecules[imol].mode].rel_raman_intensity != 0.0) (*drawVertex2d)(frq, min(windows[SPECTRUM].bottom, molecules[imol].normal_modes[molecules[imol].mode].rel_raman_intensity)); if (windows[SPECTRUM].mode == SPECTRUM_INS && molecules[imol].normal_modes[imol].rel_ins_intensity != 0.0) (*drawVertex2d)(frq, min(windows[SPECTRUM].bottom, molecules[imol].normal_modes[molecules[imol].mode].rel_ins_intensity)); (*drawEnd)(); glPopName(); } } } else { /* Draw spectrum with gaussian functions */ s=(double *)getmem(molecules[imol].nmodes, sizeof(double)); scan=(double *)getmem((size_t)(width+1), sizeof(double)); for (i=0; i 0.0 && molecules[imol].normal_modes[i].wavenumber > 0.0) { zz=1.0-exp(f*wnScale*molecules[imol].normal_modes[i].wavenumber); s[i]=0.5*molecules[imol].normal_modes[i].rel_ir_intensity*wnScale *molecules[imol].normal_modes[i].wavenumber/zz; } } /* Scan spectrum */ frq=windows[SPECTRUM].left; frqinc=(windows[SPECTRUM].right-windows[SPECTRUM].left)/(double)width; for (i=0; i 0.0 && molecules[imol].normal_modes[j].wavenumber > 0.0) { shape=frq-wnScale*molecules[imol].normal_modes[j].wavenumber; shape=exp(-32.0*shape*shape/(wnScale*molecules[imol].normal_modes[j].wavenumber)); scan[i]+=s[j]*shape; } } /* scan[i]*=a; */ frq+=frqinc; } /* Scale intensities */ wmax=scan[0]; for (i=1; i= windows[SPECTRUM].top && scan[i] <= windows[SPECTRUM].bottom && scan[i+1] >= windows[SPECTRUM].top && scan[i+1] <= windows[SPECTRUM].bottom) { (*drawVertex2d)(frq, scan[i]); } else if (scan[i] > windows[SPECTRUM].bottom && scan[i+1] < windows[SPECTRUM].bottom) { a=(scan[i]-scan[i+1])/frqinc; b=scan[i]-a*frq; (*drawBegin)(GL_LINE_STRIP); (*drawVertex2d)((windows[SPECTRUM].bottom-b)/a, windows[SPECTRUM].bottom); } else if (scan[i] < windows[SPECTRUM].bottom && scan[i+1] > windows[SPECTRUM].bottom) { a=(scan[i]-scan[i+1])/frqinc; b=scan[i]-a*frq; (*drawVertex2d)((windows[SPECTRUM].bottom-b)/a, windows[SPECTRUM].bottom); (*drawEnd)(); } else if (scan[i] < windows[SPECTRUM].top && scan[i+1] > windows[SPECTRUM].top) { a=(scan[i]-scan[i+1])/frqinc; b=scan[i]-a*frq; (*drawBegin)(GL_LINE_STRIP); (*drawVertex2d)((windows[SPECTRUM].top-b)/a, windows[SPECTRUM].top); } else if (scan[i] > windows[SPECTRUM].top && scan[i+1] < windows[SPECTRUM].top) { a=(scan[i]-scan[i+1])/frqinc; b=scan[i]-a*frq; (*drawBegin)(GL_LINE_STRIP); (*drawVertex2d)((windows[SPECTRUM].top-b)/a, windows[SPECTRUM].top); } /* fprintf(file, "%10.3f %10.6f\n", frq, scan[i]); */ frq+=frqinc; } (*drawEnd)(); /* fclose(file); */ fremem((void **)&scan); } glPopName(); /* If we have an observed spectrum draw it */ if (expwn != NULL) { setWindowColor(FOREGROUND, stdcol[BLUE], blue); (*drawBegin)(GL_LINE_STRIP); for (j=0; j 0.0 && molecules[imol].normal_modes[j].wavenumber > 0.0) { shape=expwn[i]-wnScale*molecules[imol].normal_modes[j].wavenumber; shape=exp(-32.0*shape*shape/(wnScale*molecules[imol].normal_modes[j].wavenumber)); frq+=s[j]*shape; } } zz+=fabs(fabs(expint[i])-fabs(frq)); wmax+=fabs(expint[i]); } printf("R = %10.4f\n", zz/wmax); */ fremem((void **)&s); } } if (swapBuffers) glXSwapBuffers(XtDisplay(windows[SPECTRUM].widget), XtWindow(windows[SPECTRUM].widget)); } void paper(Dimension width, Dimension height) { double grid, gridStep, xpix, ypix, top, bottom, left, right, texty; int swidth1, swidth2, sfullheight, sheight; char line[6], *word, dummy[8]; register int i; word=getStringResource(topShell, "wavenumber"); swidth1=StringWidth(windows[SPECTRUM].font, word)+2; /* Write labels */ swidth2=StringWidth(windows[SPECTRUM].font, "100")+2; sfullheight=StringHeight(windows[SPECTRUM].font)+4; sheight=StringAscent(windows[SPECTRUM].font)+2; xpix=(windows[SPECTRUM].right-windows[SPECTRUM].left)/(double)(width-2*(swidth2+5)); ypix=fabs(windows[SPECTRUM].top-windows[SPECTRUM].bottom)/(double)(height-2*(sfullheight+5)); windows[SPECTRUM].horizontalMargin=swidth2+5; windows[SPECTRUM].verticalMargin=sfullheight+5; left=windows[SPECTRUM].left-xpix*windows[SPECTRUM].horizontalMargin; right=windows[SPECTRUM].right+xpix*windows[SPECTRUM].horizontalMargin; if (xIsTop) { bottom=windows[SPECTRUM].bottom+ypix*windows[SPECTRUM].verticalMargin; top=windows[SPECTRUM].top-ypix*windows[SPECTRUM].verticalMargin; texty=top+sheight*ypix; } else { bottom=windows[SPECTRUM].top-ypix*windows[SPECTRUM].verticalMargin; top=windows[SPECTRUM].bottom+ypix*windows[SPECTRUM].verticalMargin; texty=bottom+(sfullheight-sheight)*ypix; } glOrtho(left, right, bottom, top, windows[SPECTRUM].near, windows[SPECTRUM].far); drawBackground(SPECTRUM, windows[SPECTRUM].background, (double)0.0); setWindowColor(FOREGROUND, windows[SPECTRUM].foreground, windows[SPECTRUM].foreground_rgb); (*drawLineWidth)((GLfloat)spectrumLineWidth); (*drawString)(word, right, texty, 0.0, (double)swidth1*xpix, windows[SPECTRUM].GLfontId, 'r'); word=getStringResource(topShell, "intensity"); if (xIsTop) { (*drawString)(word, left+xpix, bottom-(double)(sfullheight-sheight)*ypix, 0.0, 0.0, windows[SPECTRUM].GLfontId, 'l'); } else { (*drawString)(word, left+xpix, top-(double)sheight*ypix, 0.0, 0.0, windows[SPECTRUM].GLfontId, 'l'); } (*drawBegin)(GL_LINE_LOOP); /* Draw frame */ (*drawVertex2d)(windows[SPECTRUM].left, windows[SPECTRUM].top); (*drawVertex2d)(windows[SPECTRUM].left, windows[SPECTRUM].bottom); (*drawVertex2d)(windows[SPECTRUM].right, windows[SPECTRUM].bottom); (*drawVertex2d)(windows[SPECTRUM].right, windows[SPECTRUM].top); (*drawEnd)(); gridStep=makeTics(windows[SPECTRUM].left, windows[SPECTRUM].right, &grid, dummy); while (grid < windows[SPECTRUM].right) { if (grid >= windows[SPECTRUM].left && grid <= windows[SPECTRUM].right) { (*drawBegin)(GL_LINES); /* Tick marks */ (*drawVertex2d)(grid, windows[SPECTRUM].top); (*drawVertex2d)(grid, windows[SPECTRUM].top-5.0*ypix); (*drawEnd)(); (*drawBegin)(GL_LINES); (*drawVertex2d)(grid, windows[SPECTRUM].bottom); (*drawVertex2d)(grid, windows[SPECTRUM].bottom+5.0*ypix); (*drawEnd)(); if (showGrid) { glEnable(GL_LINE_STIPPLE); /* Dashed lines */ (*drawLineStipple)(1, 0xf0f0); (*drawBegin)(GL_LINES); (*drawVertex2d)(grid, windows[SPECTRUM].top); (*drawVertex2d)(grid, windows[SPECTRUM].bottom); (*drawEnd)(); (*drawDisable)(GL_LINE_STIPPLE); } sprintf(line, "%d", (int)grid); swidth2=StringWidth(windows[SPECTRUM].font, line); if (((windows[SPECTRUM].left < windows[SPECTRUM].right && grid+0.5*(double)swidth2*xpix < windows[SPECTRUM].right-(double)swidth1*xpix) || (windows[SPECTRUM].left > windows[SPECTRUM].right && grid+0.5*(double)swidth2*xpix > windows[SPECTRUM].right-(double)swidth1*xpix))) { (*drawString)(line, grid, texty, 0.0, (double)swidth2*xpix, windows[SPECTRUM].GLfontId, 'c'); } } grid+=gridStep; } grid=0.0; for (i=0; i<5; i++) { if (grid >= windows[SPECTRUM].top && grid <= windows[SPECTRUM].bottom) { (*drawBegin)(GL_LINES); /* Tick marks */ (*drawVertex2d)(windows[SPECTRUM].left, grid); (*drawVertex2d)(windows[SPECTRUM].left-5.0*xpix, grid); (*drawEnd)(); (*drawBegin)(GL_LINES); (*drawVertex2d)(windows[SPECTRUM].right, grid); (*drawVertex2d)(windows[SPECTRUM].right+5.0*xpix, grid); (*drawEnd)(); if (showGrid) { glEnable(GL_LINE_STIPPLE); /* Dashed lines */ (*drawLineStipple)(1, 0xf0f0); (*drawBegin)(GL_LINES); (*drawVertex2d)(windows[SPECTRUM].left, grid); (*drawVertex2d)(windows[SPECTRUM].right, grid); (*drawEnd)(); (*drawDisable)(GL_LINE_STIPPLE); } sprintf(line, "%d", (int)grid); if (xIsTop) { (*drawString)(line, left+xpix, grid+0.5*(double)(sheight-2)*ypix, 0.0, 0.0, windows[SPECTRUM].GLfontId, 'l'); } else { (*drawString)(line, left+xpix, grid-0.5*(double)(sheight-2)*ypix, 0.0, 0.0, windows[SPECTRUM].GLfontId, 'l'); } } grid+=25.0; } } void readSpectrum(Widget w, caddr_t client_data, XmAnyCallbackStruct *data) { FILE *file; size_t maxwnc=100; double maxint=0.0; char *filename, line[MAXLENLINE], *word; register int i; if ((filename=selectFile("*", "", TRUE)) != NULL) { if ((file=fopen(filename, "r")) != NULL) { if (expwn != NULL) { fremem((void **)&expwn); fremem((void **)&expint); } expwn=(double *)getmem(maxwnc, sizeof(double)); expint=(double *)getmem(maxwnc, sizeof(double)); expwnc=0; while (fgets(line, MAXLENLINE, file) != NULL) { if (line[0] == '#' || isalpha(line[0])) continue; if ((word=strtok(line, " \t")) != NULL) expwn[expwnc]=atof(word); if ((word=strtok(NULL, " \t")) != NULL) expint[expwnc]=atof(word); maxint=expint[expwnc] > maxint ? expint[expwnc] : maxint; if (++expwnc >= maxwnc) { maxwnc+=100; expwn=(double *)expmem((void *)expwn, maxwnc, sizeof(double)); expint=(double *)expmem((void *)expint, maxwnc, sizeof(double)); } } expwn=(double *)expmem((void *)expwn, expwnc, sizeof(double)); expint=(double *)expmem((void *)expint, expwnc, sizeof(double)); fclose(file); for (i=0; i 0) { if (animate) setAnimation(animate); deleteAnnotation(&normalModeAnnotation); for (i=0; i= molecules[imol].nmodes) molecules[imol].mode=0; if (windows[SPECTRUM].mode == SPECTRUM_IR && molecules[imol].normal_modes[molecules[imol].mode].ir_intensity != 0.0) break; if (windows[SPECTRUM].mode == SPECTRUM_RAMAN && molecules[imol].normal_modes[molecules[imol].mode].raman_intensity != 0.0) break; if (windows[SPECTRUM].mode == SPECTRUM_INS && molecules[imol].normal_modes[molecules[imol].mode].ins_intensity != 0.0) break; if (windows[SPECTRUM].mode == SPECTRUM_ALL && molecules[imol].normal_modes[molecules[imol].mode].wavenumber != 0.0) break; } break; case XK_Tab: if (nmolecule > 1) { data.set=TRUE; do { imol++; if (imol >= nmolecule) imol=0; } while (molecules[imol].normal_modes == NULL); windows[SPECTRUM].set=imol; (void)selectMolecule((Widget)0, (XtPointer)&windows[SPECTRUM].selectMenu[windows[SPECTRUM].set], &data); } break; } restoreGeometry(molecules[imol].coord, imol); if (animate == DISTORT) distortGeometry(amplitude); annotateNormalMode(&molecules[imol]); } void annotateNormalMode(struct MOLECULE *mol) { const GLfloat black[4] = {0.0, 0.0, 0.0, 1.0}; char line[MAXLENLINE], *word; if (mol->mode != (-1)) { word=getStringResource(topShell, "wavenumberTitle"); sprintf(line, word, mol->normal_modes[mol->mode].sym, wnScale*mol->normal_modes[mol->mode].wavenumber); normalModeAnnotation=makeAnnotation(normalModeAnnotation, CENTERED, 0.0, 1.0, 0.0, stdcol[BLACK], black, 0, 0, line); } else { if (normalModeAnnotation) deleteAnnotation(&normalModeAnnotation); } } viewmol-2.4.1/source/elementmodule.c0100644000272700027270000002734407752675475015710 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * E L E M E N T M O D U L E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: elementmodule.c,v 1.2 2003/11/07 11:00:13 jrh Exp $ * $Log: elementmodule.c,v $ * Revision 1.2 2003/11/07 11:00:13 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:05:35 jrh * Initial revision * */ #include #include #include #include #include "viewmol.h" #define PyElement_API_pointers 1 #define PyElementSpec_Type_NUM 0 extern int checkInterrupt(void); PyElementSpecObject *element_new(void); static PyObject *element_getSymbol(PyObject *, PyObject *); static PyObject *element_darkColor(PyObject *, PyObject *); static PyObject *element_lightColor(PyObject *, PyObject *); static PyObject *element_emissionColor(PyObject *, PyObject *); static PyObject *element_ambientColor(PyObject *, PyObject *); static PyObject *element_specularColor(PyObject *, PyObject *); static PyObject *element_shininess(PyObject *, PyObject *); static PyObject *element_transperancy(PyObject *, PyObject *); static PyObject *element_getattr(PyElementSpecObject *, char *); static void element_dealloc(PyElementSpecObject *); extern struct ELEMENT *elements; extern int nmolecule; static char PyElementSpec_Type__doc__[] = "Element specification"; statichere PyTypeObject PyElementSpec_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "ElementSpec", /*tp_name*/ sizeof(PyElementSpecObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)element_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)element_getattr, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ /* Space for future expansion */ 0L,0L, /* Documentation string */ PyElementSpec_Type__doc__ }; static PyMethodDef element_methods[] = { {"getSymbol", element_getSymbol, 1}, {"darkColor", element_darkColor, 1}, {"lightColor", element_lightColor, 1}, {"emissionColor", element_emissionColor, 1}, {"ambientColor", element_ambientColor, 1}, {"specularColor", element_specularColor, 1}, {"shininess", element_shininess, 1}, {"transperancy", element_transperancy, 1}, {NULL, NULL} }; PyElementSpecObject *element_new(void) { PyElementSpecObject *self; self=PyObject_NEW(PyElementSpecObject, &PyElementSpec_Type); if (self == NULL) { PyErr_NoMemory(); return(NULL); } self->elementID=0; return(self); } static PyObject *element_getSymbol(PyObject *self, PyObject *args) { PyElementSpecObject *s; int ielement; if (checkInterrupt()) return(NULL); if (self) { s=(PyElementSpecObject *)self; ielement=s->elementID; return(PyString_FromString(elements[ielement].symbol)); } Py_INCREF(Py_None); return(Py_None); } static PyObject *element_darkColor(PyObject *self, PyObject *args) { PyElementSpecObject *s; PyObject *tuple; float r=-1.0, g=-1.0, b=-1.0; int ielement; if (checkInterrupt()) return(NULL); if (self) { s=(PyElementSpecObject *)self; ielement=s->elementID; if (!PyArg_ParseTuple(args, "|fff", &r, &g, &b)) return(NULL); if (r == -1.0 && g == -1.0 && b == -1.0) /* get */ { if ((tuple=PyTuple_New(3))) { PyTuple_SetItem(tuple, 0, PyFloat_FromDouble((double)elements[ielement].dark[0])); PyTuple_SetItem(tuple, 1, PyFloat_FromDouble((double)elements[ielement].dark[1])); PyTuple_SetItem(tuple, 2, PyFloat_FromDouble((double)elements[ielement].dark[2])); return(tuple); } } else /* set */ { if (r < 0.0 || r > 1.0 || g < 0.0 || g > 1.0 || b < 0.0 || b > 1.0) { PyErr_SetString(PyExc_ValueError, "Value out of range"); return(NULL); } elements[ielement].dark[0]=r; elements[ielement].dark[1]=g; elements[ielement].dark[2]=b; } } Py_INCREF(Py_None); return(Py_None); } static PyObject *element_lightColor(PyObject *self, PyObject *args) { PyElementSpecObject *s; PyObject *tuple; float r=-1.0, g=-1.0, b=-1.0; int ielement; if (checkInterrupt()) return(NULL); if (self) { s=(PyElementSpecObject *)self; ielement=s->elementID; if (!PyArg_ParseTuple(args, "|fff", &r, &g, &b)) return(NULL); if (r == -1.0 && g == -1.0 && b == -1.0) /* get */ { if ((tuple=PyTuple_New(3))) { PyTuple_SetItem(tuple, 0, PyFloat_FromDouble((double)elements[ielement].light[0])); PyTuple_SetItem(tuple, 1, PyFloat_FromDouble((double)elements[ielement].light[1])); PyTuple_SetItem(tuple, 2, PyFloat_FromDouble((double)elements[ielement].light[2])); return(tuple); } } else /* set */ { if (r < 0.0 || r > 1.0 || g < 0.0 || g > 1.0 || b < 0.0 || b > 1.0) { PyErr_SetString(PyExc_ValueError, "Value out of range"); return(NULL); } elements[ielement].light[0]=r; elements[ielement].light[1]=g; elements[ielement].light[2]=b; } } Py_INCREF(Py_None); return(Py_None); } static PyObject *element_emissionColor(PyObject *self, PyObject *args) { PyElementSpecObject *s; PyObject *tuple; float r=-1.0, g=-1.0, b=-1.0; int ielement; if (checkInterrupt()) return(NULL); if (self) { s=(PyElementSpecObject *)self; ielement=s->elementID; if (!PyArg_ParseTuple(args, "|fff", &r, &g, &b)) return(NULL); if (r == -1.0 && g == -1.0 && b == -1.0) /* get */ { if ((tuple=PyTuple_New(3))) { PyTuple_SetItem(tuple, 0, PyFloat_FromDouble((double)elements[ielement].emission[0])); PyTuple_SetItem(tuple, 1, PyFloat_FromDouble((double)elements[ielement].emission[1])); PyTuple_SetItem(tuple, 2, PyFloat_FromDouble((double)elements[ielement].emission[2])); return(tuple); } } else /* set */ { if (r < 0.0 || r > 1.0 || g < 0.0 || g > 1.0 || b < 0.0 || b > 1.0) { PyErr_SetString(PyExc_ValueError, "Value out of range"); return(NULL); } elements[ielement].emission[0]=r; elements[ielement].emission[1]=g; elements[ielement].emission[2]=b; } } Py_INCREF(Py_None); return(Py_None); } static PyObject *element_ambientColor(PyObject *self, PyObject *args) { PyElementSpecObject *s; PyObject *tuple; float r=-1.0, g=-1.0, b=-1.0; int ielement; if (checkInterrupt()) return(NULL); if (self) { s=(PyElementSpecObject *)self; ielement=s->elementID; if (!PyArg_ParseTuple(args, "|fff", &r, &g, &b)) return(NULL); if (r == -1.0 && g == -1.0 && b == -1.0) /* get */ { if ((tuple=PyTuple_New(3))) { PyTuple_SetItem(tuple, 0, PyFloat_FromDouble((double)elements[ielement].ambient[0])); PyTuple_SetItem(tuple, 1, PyFloat_FromDouble((double)elements[ielement].ambient[1])); PyTuple_SetItem(tuple, 2, PyFloat_FromDouble((double)elements[ielement].ambient[2])); return(tuple); } } else /* set */ { if (r < 0.0 || r > 1.0 || g < 0.0 || g > 1.0 || b < 0.0 || b > 1.0) { PyErr_SetString(PyExc_ValueError, "Value out of range"); return(NULL); } elements[ielement].ambient[0]=r; elements[ielement].ambient[1]=g; elements[ielement].ambient[2]=b; } } Py_INCREF(Py_None); return(Py_None); } static PyObject *element_specularColor(PyObject *self, PyObject *args) { PyElementSpecObject *s; PyObject *tuple; float r=-1.0, g=-1.0, b=-1.0; int ielement; if (checkInterrupt()) return(NULL); if (self) { s=(PyElementSpecObject *)self; ielement=s->elementID; if (!PyArg_ParseTuple(args, "|fff", &r, &g, &b)) return(NULL); if (r == -1.0 && g == -1.0 && b == -1.0) /* get */ { if ((tuple=PyTuple_New(3))) { PyTuple_SetItem(tuple, 0, PyFloat_FromDouble((double)elements[ielement].specular[0])); PyTuple_SetItem(tuple, 1, PyFloat_FromDouble((double)elements[ielement].specular[1])); PyTuple_SetItem(tuple, 2, PyFloat_FromDouble((double)elements[ielement].specular[2])); return(tuple); } } else /* set */ { if (r < 0.0 || r > 1.0 || g < 0.0 || g > 1.0 || b < 0.0 || b > 1.0) { PyErr_SetString(PyExc_ValueError, "Value out of range"); return(NULL); } elements[ielement].specular[0]=r; elements[ielement].specular[1]=g; elements[ielement].specular[2]=b; } } Py_INCREF(Py_None); return(Py_None); } static PyObject *element_shininess(PyObject *self, PyObject *args) { PyElementSpecObject *s; float shininess=-1.0; int ielement; if (checkInterrupt()) return(NULL); if (self) { s=(PyElementSpecObject *)self; ielement=s->elementID; if (!PyArg_ParseTuple(args, "|f", &shininess)) return(NULL); if (shininess == -1.0) /* get */ return(PyFloat_FromDouble((double)elements[ielement].shininess)); else /* set */ { if (shininess < 0.0 || shininess > 128.0) { PyErr_SetString(PyExc_ValueError, "Value out of range"); return(NULL); } elements[ielement].shininess=shininess; } } Py_INCREF(Py_None); return(Py_None); } static PyObject *element_transperancy(PyObject *self, PyObject *args) { PyElementSpecObject *s; float transperancy=-1.0; int ielement; if (checkInterrupt()) return(NULL); if (self) { s=(PyElementSpecObject *)self; ielement=s->elementID; if (!PyArg_ParseTuple(args, "|f", &transperancy)) return(NULL); if (transperancy == -1.0) /* get */ return(PyFloat_FromDouble((double)elements[ielement].alpha)); else /* set */ { if (transperancy < 0.0 || transperancy > 1.0) { PyErr_SetString(PyExc_ValueError, "Value out of range"); return(NULL); } elements[ielement].alpha=transperancy; } } Py_INCREF(Py_None); return(Py_None); } static void element_dealloc(PyElementSpecObject *self) { if (!self) return; PyMem_DEL(self); } static PyObject *element_getattr(PyElementSpecObject *self, char *name) { return(Py_FindMethod(element_methods, (PyObject *)self, name)); } void initElementModule(void) { PyObject *module, *dict; static void *PyElement_API[PyElement_API_pointers]; PyElementSpec_Type.ob_type=&PyType_Type; module=Py_InitModule("element", element_methods); dict=PyModule_GetDict(module); PyElement_API[PyElementSpec_Type_NUM]=(void *)&PyElementSpec_Type; PyDict_SetItemString(dict, "_C_API", PyCObject_FromVoidPtr((void *)PyElement_API, NULL)); } viewmol-2.4.1/source/ellipse.c0100644000272700027270000000551407752675514014473 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * E L L I P S E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: ellipse.c,v 1.6 2003/11/07 11:00:28 jrh Exp $ * $Log: ellipse.c,v $ * Revision 1.6 2003/11/07 11:00:28 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:05:47 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:20 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:48:28 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:39 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:40:46 jrh * Initial revision * */ #include #include void ellipse(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, int n) { const double pi2=8.*atan(1.0); double step=pi2/(double)n; double vx1=x2-x1, vy1=y2-y1, vz1=z2-z1; double vx2=x3-x1, vy2=y3-y1, vz2=z3-z1; double a, b, tmat[4][4]; register double t, aa, bb; double vertex[3]; /* First build the transformation matrix for rotating a ellipse defined by the points (0,0,0), (a,0,0), and (0,b,0) to the desired position */ a=sqrt(vx1*vx1+vy1*vy1+vz1*vz1); b=sqrt(vx2*vx2+vy2*vy2+vz2*vz2); if (a > 1.0e-3 && b > 1.0e-3) { tmat[0][0]=vx1/a; tmat[1][0]=vy1/a; tmat[2][0]=vz1/a; tmat[0][1]=vx2/b; tmat[1][1]=vy2/b; tmat[2][1]=vz2/b; vertex[0]=a*tmat[0][0]+x1; vertex[1]=a*tmat[1][0]+y1; vertex[2]=a*tmat[2][0]+z1; glBegin(GL_LINE_LOOP); glVertex3dv(vertex); t=step; while (t < pi2) { aa=a*cos(t); bb=b*sin(t); vertex[0]=aa*tmat[0][0]+bb*tmat[0][1]+x1; vertex[1]=aa*tmat[1][0]+bb*tmat[1][1]+y1; vertex[2]=aa*tmat[2][0]+bb*tmat[2][1]+z1; t+=step; glVertex3dv(vertex); } glEnd(); } else if (a > 1.0e-3) { glBegin(GL_LINES); vertex[0]=vx1+x1; vertex[1]=vy1+y1; vertex[2]=vz1+z1; glVertex3dv(vertex); vertex[0]=x1-vx1; vertex[1]=y1-vy1; vertex[2]=z1-vz1; glVertex3dv(vertex); glEnd(); } else if (b > 1.0e-3) { glBegin(GL_LINES); vertex[0]=vx2+x1; vertex[1]=vy2+y1; vertex[2]=vz2+z1; glVertex3dv(vertex); vertex[0]=x1-vx2; vertex[1]=y1-vy2; vertex[2]=z1-vz2; glVertex3dv(vertex); glEnd(); } else return; } viewmol-2.4.1/source/energylevelmodule.c0100644000272700027270000002421607752675610016562 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * E N E R G Y L E V E L M O D U L E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: energylevelmodule.c,v 1.2 2003/11/07 11:01:28 jrh Exp $ * $Log: energylevelmodule.c,v $ * Revision 1.2 2003/11/07 11:01:28 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:05:56 jrh * Initial revision * */ #include #include #include #include #include #include #include "viewmol.h" #define PyEnergyLevel_API_pointers 1 #define PyEnergyLevelSpec_Type_NUM 0 extern void initSpectrum(Widget, caddr_t, caddr_t); extern void initMODiagram(Widget, caddr_t, caddr_t); extern void initHistory(Widget, caddr_t, caddr_t); extern void GetUnit(Widget, struct TOGGLE *, XmToggleButtonCallbackStruct *); extern void setMenuItem(int, int); extern void setupEnergyUnits(struct TOGGLE *); extern void drawMODiagram(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void selectMolecule(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void redraw(int); extern void saveDrawing(int, int, char *); extern int checkInterrupt(void); extern void quitMODiagram(Widget, caddr_t, XmAnyCallbackStruct *); PyEnergyLevelSpecObject *energylevels_new(void); static PyObject *energylevels_show(PyObject *, PyObject *); static PyObject *energylevels_unit(PyObject *, PyObject *); static PyObject *energylevels_resolution(PyObject *, PyObject *); static PyObject *energylevels_mode(PyObject *, PyObject *); static PyObject *energylevels_selectMO(PyObject *, PyObject *); static PyObject *energylevels_deselect(PyObject *, PyObject *); static PyObject *energylevels_saveDrawing(PyObject *, PyObject *); static PyObject *energylevels_getattr(PyEnergyLevelSpecObject *, char *); static void energylevels_dealloc(PyEnergyLevelSpecObject *); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern double denres; extern int nmolecule, showForces, showInertia, label; static char PyEnergyLevelSpec_Type__doc__[] = "Energy level specification"; statichere PyTypeObject PyEnergyLevelSpec_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "EnergyLevelSpec", /*tp_name*/ sizeof(PyEnergyLevelSpecObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)energylevels_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)energylevels_getattr, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ /* Space for future expansion */ 0L,0L, /* Documentation string */ PyEnergyLevelSpec_Type__doc__ }; static PyMethodDef energylevels_methods[] = { {"show", energylevels_show, 1}, {"unit", energylevels_unit, 1}, {"resolution", energylevels_resolution, 1}, {"mode", energylevels_mode, 1}, {"selectMO", energylevels_selectMO, 1}, {"deselect", energylevels_deselect, 1}, {"saveDrawing", energylevels_saveDrawing, 1}, {NULL, NULL} }; PyEnergyLevelSpecObject *energylevels_new(void) { PyEnergyLevelSpecObject *self; self=PyObject_NEW(PyEnergyLevelSpecObject, &PyEnergyLevelSpec_Type); if (self == NULL) { PyErr_NoMemory(); return(NULL); } self->energyLevelID=0; return(self); } static PyObject *energylevels_show(PyObject *self, PyObject *args) { PyEnergyLevelSpecObject *s; XmToggleButtonCallbackStruct data; int which, set_save; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyEnergyLevelSpecObject *)self; which=s->energyLevelID; if (windows[MO].widget == NULL) { set_save=windows[VIEWER].set; windows[VIEWER].set=which; initMODiagram((Widget)0, (caddr_t)0, (caddr_t)0); windows[VIEWER].set=set_save; } else { windows[MO].set=which; if (nmolecule > 1) { data.set=TRUE; (void)selectMolecule((Widget)0, (XtPointer)&(windows[MO].selectMenu[which]), &data); } redraw(MO); } Py_INCREF(Py_None); return(Py_None); } static PyObject *energylevels_unit(PyObject *self, PyObject *args) { PyEnergyLevelSpecObject *s; XmToggleButtonCallbackStruct data; struct TOGGLE toggle[4]; int which, unit=0, set_save; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|i", &unit)) return(NULL); s=(PyEnergyLevelSpecObject *)self; which=s->energyLevelID; if (unit == 0) /* get */ return(PyInt_FromLong((long)unit)); else /* set */ { if (unit != HARTREE && unit != KJ_MOL && unit != EV && unit != CM) { PyErr_SetString(PyExc_ValueError, "Unknown unit for energy levels"); return(NULL); } setupEnergyUnits(toggle); data.set=TRUE; set_save=windows[MO].set; windows[MO].set=which; GetUnit((Widget)0, &toggle[unit-1], &data); windows[MO].set=set_save; redraw(MO); Py_INCREF(Py_None); return(Py_None); } } static PyObject *energylevels_resolution(PyObject *self, PyObject *args) { double res=-1.0e0; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|d", &res)) return(NULL); if (res == -1.0e0) /* get */ return(PyFloat_FromDouble(denres)); else /* set */ { if (res < 0.0e0) { PyErr_SetString(PyExc_ValueError, "Resolution for density must be greater than zero"); return(NULL); } denres=res; redraw(MO); Py_INCREF(Py_None); return(Py_None); } } static PyObject *energylevels_mode(PyObject *self, PyObject *args) { int mode=0; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|i", &mode)) return(NULL); if (mode == 0) /* get */ return(PyInt_FromLong((long)windows[MO].mode)); else /* set */ { if (mode != DENSITY_OF_STATES && mode != ENERGY_LEVELS) { PyErr_SetString(PyExc_ValueError, "Unknown drawing mode for energy levels"); return(NULL); } windows[MO].mode=mode; drawMODiagram((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); redraw(MO); Py_INCREF(Py_None); return(Py_None); } } static PyObject *energylevels_selectMO(PyObject *self, PyObject *args) { PyEnergyLevelSpecObject *s; int which, set_save, i, j=0; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "i|i", &i, &j)) return(NULL); s=(PyEnergyLevelSpecObject *)self; which=s->energyLevelID; i--; j--; if (i < 0 || i > molecules[which].nbasfu || j < -1 || j > molecules[which].nbasfu) { PyErr_SetString(PyExc_ValueError, "Number of MO out of range"); return(NULL); } if (j != (-1)) { molecules[which].imo=j; molecules[which].imosave=i; } else molecules[which].imo=i; set_save=windows[MO].set; windows[MO].set=which; redraw(MO); windows[MO].set=set_save; Py_INCREF(Py_None); return(Py_None); } static PyObject *energylevels_deselect(PyObject *self, PyObject *args) { PyEnergyLevelSpecObject *s; int which, set_save; if (checkInterrupt()) return(NULL); s=(PyEnergyLevelSpecObject *)self; which=s->energyLevelID; molecules[which].imo=(-1); molecules[which].imosave=(-1); set_save=windows[MO].set; windows[MO].set=which; redraw(MO); windows[MO].set=set_save; Py_INCREF(Py_None); return(Py_None); } static PyObject *energylevels_saveDrawing(PyObject *self, PyObject *args) { int format; char *filename; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "is", &format, &filename)) return NULL; if (!access(filename, F_OK)) { PyErr_SetString(PyExc_IOError, "File already exists"); return(NULL); } if (format != TIFFFILE && format != PNGFILE && format != HPGL && format != POSTSCRIPT) { PyErr_SetString(PyExc_ValueError, "Format not recognised"); return(NULL); } saveDrawing(MO, format, filename); Py_INCREF(Py_None); return(Py_None); } static void energylevels_dealloc(PyEnergyLevelSpecObject *self) { if (!self) return; PyMem_DEL(self); quitMODiagram((Widget)0, (caddr_t)0, (XmAnyCallbackStruct *)0); (void)checkInterrupt(); } static PyObject *energylevels_getattr(PyEnergyLevelSpecObject *self, char *name) { return(Py_FindMethod(energylevels_methods, (PyObject *)self, name)); } void initEnergyLevelModule(void) { PyObject *module, *dict; static void *PyEnergyLevel_API[PyEnergyLevel_API_pointers]; PyEnergyLevelSpec_Type.ob_type=&PyType_Type; module=Py_InitModule("energylevels", energylevels_methods); dict=PyModule_GetDict(module); PyEnergyLevel_API[PyEnergyLevelSpec_Type_NUM]=(void *)&PyEnergyLevelSpec_Type; PyDict_SetItemString(dict, "_C_API", PyCObject_FromVoidPtr((void *)PyEnergyLevel_API, NULL)); PyDict_SetItemString(dict, "HARTREE", PyInt_FromLong((long)HARTREE)); PyDict_SetItemString(dict, "KJ/MOL", PyInt_FromLong((long)KJ_MOL)); PyDict_SetItemString(dict, "EV", PyInt_FromLong((long)EV)); PyDict_SetItemString(dict, "1/CM", PyInt_FromLong((long)CM)); PyDict_SetItemString(dict, "DENSITY_OF_STATES", PyInt_FromLong((long)DENSITY_OF_STATES)); PyDict_SetItemString(dict, "ENERGY_LEVELS", PyInt_FromLong((long)ENERGY_LEVELS)); } viewmol-2.4.1/source/eof.c0100644000272700027270000000227307752675616013611 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * E O F . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: eof.c,v 1.4 2003/11/07 11:01:34 jrh Exp $ * $Log: eof.c,v $ * Revision 1.4 2003/11/07 11:01:34 jrh * Release 2.4 * * Revision 1.3 2000/12/10 15:06:50 jrh * Release 2.3 * * Revision 1.2 1999/05/24 01:25:22 jrh * Release 2.2.1 * * Revision 1.1 1999/02/07 21:48:36 jrh * Initial revision * */ #include #include void eof(char *type, char *file, int terminate) { printf("$error %s %d %s\n", type, terminate, file); printf("$end\n"); exit(0); } viewmol-2.4.1/source/fallbacks.h0100644000272700027270000011622010134224202014726 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * F A L L B A C K S . H * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: fallbacks.h,v 1.7 2004/08/29 14:50:37 jrh Exp $ * $Log: fallbacks.h,v $ * Revision 1.7 2004/08/29 14:50:37 jrh * Release 2.4.1 * * Revision 1.6 2003/11/07 12:48:48 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:06:57 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:24 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:48:55 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:41 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:45:31 jrh * Initial revision * */ static String fallbacks[] = { "Viewmol.webBrowser: mozilla %s", "Viewmol.Moloch: moloch", "Viewmol.Raytracer: x-povray +I%s +O%s +W%d +H%d", "Viewmol.DisplayImage: xv %s", /* the following three resources are necessary to get the Indigo Magic Desktop look-and-feel */ "Viewmol*sgiMode: True", "Viewmol*useSchemes: all", "Viewmol*SgNuseEnhancedFSB: True", /* end of SGI specfic stuff */ "Viewmol.geometry: 500x500+50+50", "Viewmol.history.geometry: 500x250+50+590", "Viewmol.spectrum.geometry: 500x250+50+590", "Viewmol.MODiagram.geometry: 250x500+565+50", "Viewmol.model: wire", "Viewmol.drawingMode: surface", "Viewmol.bondType: conjugated", "Viewmol.sphereResolution: 20", "Viewmol.lineWidth: 0", "Viewmol.simplifyWhileRotating: False", "Viewmol.interpolation: linear", "Viewmol.bondLength: %7.4f Ang", "Viewmol.bondAngle: %7.2f deg", "Viewmol.torsionAngle: %7.2f deg", "Viewmol.wavenumbers: 0:5000", "Viewmol.isosurface: 0.05", "Viewmol.densityResolution: 0.01", "Viewmol.reservedColors: 0", "Viewmol.hydrogenBondThreshold: 2.0", "Viewmol.automaticRecalculation: False", "Viewmol.thermoUnits: joules", "Viewmol*spectrumForm*amplitudeSlider.decimalPoints: 2", "Viewmol*spectrumForm*amplitudeSlider.minimum: -250", "Viewmol*spectrumForm*amplitudeSlider.maximum: 250", "Viewmol*spectrumForm*scaleSlider.decimalPoints: 2", "Viewmol*spectrumForm*scaleSlider.minimum: 50", "Viewmol*spectrumForm*scaleSlider.maximum: 150", "Viewmol*thermoForm*pressureSlider.decimalPoints: 2", "Viewmol*thermoForm*pressureSlider.minimum: 1", "Viewmol*thermoForm*pressureSlider.maximum: 1000", "Viewmol*wavefunctionForm*level.decimalPoints: 3", "Viewmol*wavefunctionForm*level.minimum: 1", "Viewmol*wavefunctionForm*level.maximum: 100", "Viewmol*wavefunctionForm*grid.minimum: 4", "Viewmol*wavefunctionForm*grid.maximum: 40", "Viewmol*wavefunctionForm*grid.value: 20", "Viewmol*MODiagramForm*resolution.minimum: 1", "Viewmol*MODiagramForm*resolution.maximum: 1000", "Viewmol*MODiagramForm*resolution.decimalPoints: 3", "Viewmol*unitcellForm*avalue.minimum: 10", "Viewmol*unitcellForm*avalue.maximum: 50", "Viewmol*unitcellForm*avalue.decimalPoints: 1", "Viewmol*unitcellForm*bvalue.minimum: 10", "Viewmol*unitcellForm*bvalue.maximum: 50", "Viewmol*unitcellForm*bvalue.decimalPoints: 1", "Viewmol*unitcellForm*cvalue.minimum: 10", "Viewmol*unitcellForm*cvalue.maximum: 50", "Viewmol*unitcellForm*cvalue.decimalPoints: 1", "Viewmol*unitcellForm*hvalue.minimum: -5", "Viewmol*unitcellForm*hvalue.maximum: 5", "Viewmol*unitcellForm*kvalue.minimum: -5", "Viewmol*unitcellForm*kvalue.maximum: 5", "Viewmol*unitcellForm*lvalue.minimum: -5", "Viewmol*unitcellForm*lvalue.maximum: 5", "Viewmol*bondForm*thresholdSlider.minimum: 100", "Viewmol*bondForm*thresholdSlider.maximum: 250", "Viewmol*bondForm*thresholdSlider.decimalPoints: 2", "Viewmol*bondForm*scaleRadius.minimum: 1", "Viewmol*bondForm*scaleRadius.maximum: 200", "Viewmol*bondForm*scaleRadius.decimalPoints: 2", "Viewmol*infoForm*text*rows: 6", "Viewmol*infoForm*text*columns: 80", "Viewmol*annotation.highlightThickness: 0", "Viewmol.paperSize: A4", "Viewmol.elementSortOrder: C,H,N,O,S", "Viewmol.viewer.font: variable", "Viewmol.spectrum.spectrum.font: variable", "Viewmol.history.history.font: variable", "Viewmol.MODiagram.MODiagram.font: variable", "Viewmol.MODiagram.MODiagram.greekFont: -adobe-symbol-medium-r-normal--14-*", "Viewmol.viewer.delay: 0", "Viewmol.viewer.background: white", "Viewmol.viewer.foreground: gray75", "Viewmol.spectrum.spectrum.background: white", "Viewmol.spectrum.spectrum.foreground: black", "Viewmol.history.history.background: white", "Viewmol.history.history.foreground: blue", "Viewmol.MODiagram.MODiagram.background: white", "Viewmol.MODiagram.MODiagram.foreground: black", "Viewmol*foreground: black", "Viewmol.hasLZW: False", "Viewmol.language: en_US", "Viewmol.title: Viewmol", "Viewmol.by: by", "Viewmol.version: Version", "Viewmol.history.title: Optimization History (%s)", "Viewmol.spectrum.title: Spectrum (%s)", "Viewmol.spectrum.title1: All modes (%s)", "Viewmol.spectrum.title2: IR spectrum (%s)", "Viewmol.spectrum.title3: Raman spectrum (%s)", "Viewmol.spectrum.title4: INS spectrum (%s)", "Viewmol.MODiagram.title: Energy level diagram (%s)", "Viewmol*_popup.molecule.labelString: Molecule", "Viewmol*loadMolecule.labelString: Load molecule ...", "Viewmol*saveMolecule.labelString: Save molecule ...", "Viewmol*saveSelected.labelString: Save selected atoms ...", "Viewmol*deleteMolecule.labelString: Delete molecule", "Viewmol*newMolecule.labelString: New molecule ...", "Viewmol*buildMolecule.labelString: Modify molecule ...", "Viewmol*_popup.wire_model.labelString: Wire model", "Viewmol*_popup.wire_model.mnemonic: W", "Viewmol*_popup.wire_model.accelerator: MetaW", "Viewmol*_popup.stick_model.labelString: Stick model", "Viewmol*_popup.stick_model.mnemonic: t", "Viewmol*_popup.stick_model.accelerator: MetaT", "Viewmol*_popup.ball_and_stick_model.labelString: Ball and stick model", "Viewmol*_popup.ball_and_stick_model.mnemonic: a", "Viewmol*_popup.ball_and_stick_model.accelerator: MetaA", "Viewmol*_popup.cpk_model.labelString: CPK model", "Viewmol*_popup.cpk_model.mnemonic: C", "Viewmol*_popup.cpk_model.accelerator: MetaC", "Viewmol*pseForm_popup*title: Modify molecule", "Viewmol*change.labelString: Change geometry", "Viewmol*add.labelString: Add atom", "Viewmol*delete.labelString: Delete atom", "Viewmol*replace.labelString: Replace atom", "Viewmol*create.labelString: Create bond", "Viewmol*remove.labelString: Remove bond", "Viewmol*order.labelString: Change bond order", "Viewmol*torsionDefault.labelString: Torsion angles default to", "Viewmol*trans.labelString: trans", "Viewmol*cis.labelString: cis", "Viewmol*gauche.labelString: gauche", "Viewmol*-gauche.labelString: -gauche", "Viewmol*bondOrderLabel.labelString: Bonds are", "Viewmol*pseForm_popup*fractional.labelString: Van der Waals", "Viewmol*pseForm_popup*single.labelString: single", "Viewmol*pseForm_popup*double.labelString: double", "Viewmol*pseForm_popup*triple.labelString: triple", "Viewmol*localGeometry.labelString: Deleting atoms changes local geometry", "Viewmol*_popup.geometry_menu.labelString: Geometry ...", "Viewmol*clear_all.labelString: Clear all", "Viewmol*clear_all.accelerator: CtrlA", "Viewmol*clear_all.acceleratorText: Ctrl+A", "Viewmol*clear_last.labelString: Clear last", "Viewmol*clear_last.accelerator: CtrlL", "Viewmol*clear_last.acceleratorText: Ctrl+L", "Viewmol*undo.labelString: Undo geometry change", "Viewmol*undo.accelerator: CtrlU", "Viewmol*undo.acceleratorText: Ctrl+U", "Viewmol*bondForm_popup.title: Bonds", "Viewmol*_popup.bondType_menu.labelString: Bonds ...", "Viewmol*bondForm*single.labelString: single only", "Viewmol*bondForm*multiple.labelString: multiple", "Viewmol*bondForm*conjugated.labelString: conjugated", "Viewmol*bondForm*select.labelString: Scale radius for", "Viewmol*bondForm*all.labelString: all", "Viewmol*bondForm*atoms.labelString: atoms by", "Viewmol*showHydrogenBonds.labelString: Show hydrogen bonds", "Viewmol*HydrogenBondLabel.labelString: Threshold for hydrogen bonds [Ang]", "Viewmol*_popup.wave_function.labelString: Wave function ...", "Viewmol*_popup.wave_function.mnemonic: v", "Viewmol*_popup.wave_function.accelerator: MetaV", "Viewmol*_popup.energy_level_diagram.labelString: Energy level diagram", "Viewmol*_popup.energy_level_diagram.mnemonic: E", "Viewmol*_popup.energy_level_diagram.accelerator: MetaE", "Viewmol*_popup.optimization_history.labelString: Optimization history", "Viewmol*_popup.optimization_history.mnemonic: O", "Viewmol*_popup.optimization_history.accelerator: MetaO", "Viewmol*_popup.show_forces.labelString: Show forces", "Viewmol*_popup.show_forces.mnemonic: f", "Viewmol*_popup.show_forces.accelerator: MetaF", "Viewmol*_popup.spectrum.labelString: Spectrum", "Viewmol*_popup.spectrum.mnemonic: S", "Viewmol*_popup.spectrum.accelerator: MetaS", "Viewmol*_popup.thermodynamics.labelString: Thermodynamics", "Viewmol*_popup.thermodynamics.mnemonic: y", "Viewmol*_popup.thermodynamics.accelerator: MetaY", "Viewmol*_popup.show_unit_cell.labelString: Unit cell ...", "Viewmol*_popup.show_unit_cell.mnemonic: n", "Viewmol*_popup.show_unit_cell.accelerator: MetaN", "Viewmol*_popup.show_ellipsoid_of_inertia.labelString: Show ellipsoid of inertia", "Viewmol*_popup.show_ellipsoid_of_inertia.mnemonic: i", "Viewmol*_popup.show_ellipsoid_of_inertia.accelerator: MetaI", "Viewmol*_popup.drawing_modes.labelString: Drawing modes ...", "Viewmol*_popup.drawing_modes.mnemonic: m", "Viewmol*_popup.drawing_modes.accelerator: MetaM", "Viewmol*_popup.background_color.labelString: Background color ...", "Viewmol*_popup.background_color.mnemonic: B", "Viewmol*_popup.background_color.accelerator: MetaB", "Viewmol*_popup.foreground_color.labelString: Ground color ...", "Viewmol*_popup.foreground_color.mnemonic: G", "Viewmol*_popup.foreground_color.accelerator: MetaG", "Viewmol*_popup.label_atoms.labelString: Label atoms", "Viewmol*_popup.label_atoms.mnemonic: L", "Viewmol*_popup.label_atoms.accelerator: MetaL", "Viewmol*_popup.annotate.labelString: Annotate", "Viewmol*_popup.annotate.accelerator: CtrlN", "Viewmol*_popup.annotate.acceleratorText: Ctrl+N", "Viewmol*_popup.runScript.labelString: Run script", "Viewmol*select.labelString: Select ...", "Viewmol*select.accelerator: CtrlR", "Viewmol*select.acceleratorText: Ctrl+R", "Viewmol*_popup.hardcopy.labelString: Save drawing ...", "Viewmol*_popup.hardcopy.mnemonic: d", "Viewmol*_popup.hardcopy.accelerator: MetaD", "Viewmol*_popup.raytracing.labelString: Ray tracing", "Viewmol*_popup.raytracing.mnemonic: R", "Viewmol*_popup.raytracing.accelerator: MetaR", "Viewmol*_popup.manual.labelString: Help/Manual", "Viewmol*_popup.manual.mnemonic: H", "Viewmol*_popup.manual.accelerator: MetaH", "Viewmol*_popup.saveConfiguration.labelString: Configuration ...", "Viewmol*_popup.quit.labelString: Quit", "Viewmol*_popup.quit.mnemonic: Q", "Viewmol*_popup.quit.accelerator: MetaQ", "Viewmol*_popup.select_molecule.labelString: Select molecule", "Viewmol*all.labelString: All", "Viewmol*spectrumForm_popup.title: Settings for spectrum", "Viewmol.spectrum*_popup.settings_spectrum.labelString: Settings for spectrum ...", "Viewmol.spectrum*_popup.settings_spectrum.mnemonic: S", "Viewmol.spectrum*_popup.settings_spectrum.accelerator: MetaS", "Viewmol.spectrum*_popup.observed_spectrum.labelString: Read observed spectrum ...", "Viewmol.spectrum*_popup.observed_spectrum.mnemonic: R", "Viewmol.spectrum*_popup.observed_spectrum.accelerator: MetaR", "Viewmol.spectrum*_popup.delete_spectrum.labelString: Delete observed spectrum ...", "Viewmol.spectrum*_popup.delete_spectrum.mnemonic: e", "Viewmol.spectrum*_popup.delete_spectrum.accelerator: MetaE", "Viewmol.spectrum*_popup.imaginary_wave_numbers.labelString: Imaginary wave numbers ...", "Viewmol.spectrum*_popup.zoom_out.labelString: Zoom out", "Viewmol.spectrum*_popup.zoom_out.mnemonic: Z", "Viewmol.spectrum*_popup.zoom_out.accelerator: MetaZ", "Viewmol.spectrum*_popup.hardcopy.labelString: Save drawing ...", "Viewmol.spectrum*_popup.hardcopy.mnemonic: d", "Viewmol.spectrum*_popup.hardcopy.accelerator: MetaD", "Viewmol.spectrum*_popup.foreground_color.labelString: Foreground color ...", "Viewmol.spectrum*_popup.foreground_color.mnemonic: F", "Viewmol.spectrum*_popup.foreground_color.accelerator: MetaF", "Viewmol.spectrum*_popup.background_color.labelString: Background color ...", "Viewmol.spectrum*_popup.background_color.mnemonic: B", "Viewmol.spectrum*_popup.background_color.accelerator: MetaB", "Viewmol.spectrum*_popup.quit_spectrum.labelString: Quit spectrum", "Viewmol.spectrum*_popup.quit_spectrum.mnemonic: Q", "Viewmol.spectrum*_popup.quit_spectrum.accelerator: MetaQ", "Viewmol*thermoForm_popup.title: Thermodynamics", #ifdef IRIX "Viewmol*tabs*fontList: -adobe-helvetica-medium-r-normal--14-*=DEFAULT,-adobe-helvetica-medium-r-normal--8-*=INDEX", "Viewmol*tabs.TabBookClip*fontList: -adobe-helvetica-bold-r-normal--14-*=DEFAULT,-adobe-helvetica-bold-r-normal--8-*=INDEX,-adobe-symbol-medium-r-normal--14-*=SYMBOL", #else "Viewmol*tabs*fontList: -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1=DEFAULT,-misc-fixed-medium-r-normal--8-80-75-75-c-50-iso8859-1=INDEX", "Viewmol*tabs.TabBookClip*fontList: -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1=DEFAULT,-misc-fixed-medium-r-normal--8-80-75-75-c-50-iso8859-1=INDEX,-adobe-symbol-medium-r-normal--12-120-75-75-p-74-adobe-fontspecific=SYMBOL", #endif "Viewmol*thermoForm*molecules.labelString: Molecules", "Viewmol*thermoForm*reactions.labelString: Reactions", "Viewmol*thermoForm*moleculeMass: Mass %.2f g/mol", "Viewmol*thermoForm*solidDensity: Density %.2f g/cm^3", "Viewmol*thermoForm*symmetryNumber: Symmetry number %d", "Viewmol*thermoForm*rotationalConstants: Rotational constants %.3f %.3f %.3f 1/cm", "Viewmol*joules: J", "Viewmol*calories: cal", "Viewmol*format: %.3f", "Viewmol*thermoForm*enthalphy.labelString: H/[k%s/mol]", "Viewmol*thermoForm*entropy.labelString: S/[%s/(mol K)]", "Viewmol*thermoForm*gibbsEnergy.labelString: G/[k%s/mol]", "Viewmol*thermoForm*heatCapacity.labelString: C_v/[%s/(mol K)]", "Viewmol*thermoForm*reactant.labelString: Reactant", "Viewmol*thermoForm*notInvolved.labelString: Not part of reaction", "Viewmol*thermoForm*product.labelString: Product", "Viewmol*thermoForm*allReactions.labelString: All reactions", "Viewmol*thermoForm*noReaction: No reaction defined.", "Viewmol*thermoForm*missingAtoms: (No such reaction is possible)", "Viewmol*thermoForm*cantBalance: (Unable to balance reaction)", "Viewmol*thermoForm*inconsistentType: \"Reactant/Product\" and \"All Reactions\" cannot be mixed.", "Viewmol*thermoForm*translation.labelString: Translation", "Viewmol*thermoForm*pv.labelString: pV", "Viewmol*thermoForm*rotation.labelString: Rotation", "Viewmol*thermoForm*vibration.labelString: Vibration", "Viewmol*thermoForm*total.labelString: Total", "Viewmol*thermoForm*electronicEnergy.labelString: Electronic reaction energy", "Viewmol*thermoForm*statisticalEnergy.labelString: Statistical mechanical reaction energy", "Viewmol*thermoForm*reactionEnergy.labelString: Total reaction energy", "Viewmol*thermoForm*reactionEntropy.labelString: Reaction entropy", "Viewmol*thermoForm*reactionGibbsEnergy.labelString: Gibbs energy of reaction", "Viewmol*thermoForm*reactionHeatCapacity.labelString: Heat capacity of reaction", "Viewmol*thermoForm*equilibriumConstant.labelString: Logarithm of equilibrium constant (log K)", "Viewmol*thermoForm*previous.labelString: Previous reaction", "Viewmol*thermoForm*next.labelString: Next reaction", "Viewmol*kiloperMole: % 15.2f k%s/mol", "Viewmol*perMoleandK: % 15.2f %s/(mol K)", "Viewmol*noUnit: % 15.2f", "Viewmol*thermoForm*unitlabel.labelString: Use", "Viewmol*thermoForm*joules.labelString: Joules", "Viewmol*thermoForm*calories.labelString: Calories", "Viewmol*thermoForm*thermocalories.labelString: Thermochemical calories", "Viewmol*thermoForm*temperature.labelString: Temperature/[K]", "Viewmol*thermoForm*pressure.labelString: Pressure/[atm]", "Viewmol*balanceForm_popup.title: Balance reaction manually", #ifdef IRIX "Viewmol*balanceForm*fontList: -adobe-helvetica-bold-r-normal--14-*=DEFAULT,-adobe-helvetica-bold-r-normal--8-*=INDEX,-adobe-symbol-medium-r-normal--14-*=SYMBOL", #else "Viewmol*balanceForm*fontList: -adobe-times-bold-r-normal--14-140-75-75-p-77-iso8859-1=DEFAULT,-adobe-times-bold-r-normal--10-100-75-75-p-57-iso8859-1=INDEX,-adobe-symbol-medium-r-normal--14-140-75-75-p-85-adobe-fontspecific=SYMBOL", #endif "Viewmol*historyForm_popup.title: Settings for history", "Viewmol.history*_popup.settings_history.labelString: Settings for history ...", "Viewmol.history*_popup.settings_history.mnemonic: S", "Viewmol.history*_popup.settings_history.accelerator: MetaS", "Viewmol.history*_popup.animate_history.labelString: Animate", "Viewmol.history*_popup.animate_history.mnemonic: A", "Viewmol.history*_popup.animate_history.accelerator: MetaA", "Viewmol.history*_popup.hardcopy.labelString: Save drawing ...", "Viewmol.history*_popup.hardcopy.mnemonic: d", "Viewmol.history*_popup.hardcopy.accelerator: MetaD", "Viewmol.history*_popup.energy_color.labelString: Color for energy...", "Viewmol.history*_popup.energy_color.mnemonic: e", "Viewmol.history*_popup.energy_color.accelerator: MetaE", "Viewmol.history*_popup.gradient_color.labelString: Color for gradient...", "Viewmol.history*_popup.gradient_color.mnemonic: g", "Viewmol.history*_popup.gradient_color.accelerator: MetaG", "Viewmol.history*_popup.background_color.labelString: Background color ...", "Viewmol.history*_popup.background_color.mnemonic: B", "Viewmol.history*_popup.background_color.accelerator: MetaB", "Viewmol.history*_popup.quit_history.labelString: Quit optimization history", "Viewmol.history*_popup.quit_history.mnemonic: Q", "Viewmol.history*_popup.quit_history.accelerator: MetaQ", "Viewmol.MODiagram*_popup.settings_modiagram.labelString: Settings for energy level diagram ...", "Viewmol.MODiagram*_popup.settings_modiagram.mnemonic: S", "Viewmol.MODiagram*_popup.settings_modiagram.accelerator: MetaS", "Viewmol.MODiagram*_popup.transition.labelString: Transition", "Viewmol.MODiagram*_popup.transition.mnemonic: T", "Viewmol.MODiagram*_popup.transition.accelerator: MetaT", "Viewmol.MODiagram*_popup.zoom_out.labelString: Zoom out", "Viewmol.MODiagram*_popup.zoom_out.mnemonic: Z", "Viewmol.MODiagram*_popup.zoom_out.accelerator: MetaZ", "Viewmol.MODiagram*_popup.hardcopy.labelString: Save drawing ...", "Viewmol.MODiagram*_popup.hardcopy.mnemonic: d", "Viewmol.MODiagram*_popup.hardcopy.accelerator: MetaD", "Viewmol.MODiagram*_popup.energy_levels.labelString: Draw density of states", "Viewmol.MODiagram*_popup.energy_levels.mnemonic: e", "Viewmol.MODiagram*_popup.energy_levels.accelerator: MetaE", "Viewmol.MODiagram*_popup.foreground_color.labelString: Foreground color ...", "Viewmol.MODiagram*_popup.foreground_color.mnemonic: F", "Viewmol.MODiagram*_popup.foreground_color.accelerator: MetaF", "Viewmol.MODiagram*_popup.background_color.labelString: Background color ...", "Viewmol.MODiagram*_popup.background_color.mnemonic: B", "Viewmol.MODiagram*_popup.background_color.accelerator: MetaB", "Viewmol.MODiagram*_popup.quit_modiagram.labelString: Quit energy level diagram", "Viewmol.MODiagram*_popup.quit_modiagram.mnemonic: Q", "Viewmol.MODiagram*_popup.quit_modiagram.accelerator: MetaQ", "Viewmol*messageForm_popup*exit.labelString: Exit", "Viewmol*messageForm_popup*title: Note", "Viewmol*basisForm_popup.title: Basis functions", "Viewmol*basisForm_popup.basisForm.rowcolumn.atomname.labelString: Basis functions of atom %s%d", "Viewmol*infoForm_popup.title: Python", "Viewmol.fileSelectionBox_popup.title: File selection", "Viewmol*fileSelectionBox.dirListLabelString: Directories", "Viewmol*fileSelectionBox.fileListLabelString: Files", "Viewmol*fileSelectionBox.filterLabelString: Path", "Viewmol*fileSelectionBox.applyLabelString: Filter", "Viewmol*fileSelectionBox.okLabelString: OK", "Viewmol*fileSelectionBox.cancelLabelString: Cancel", "Viewmol*fileSelectionBox.selectionLabelString: Selection", "Viewmol*ok.labelString: OK", "Viewmol*cancel.labelString: Cancel", "Viewmol*continue.labelString: Continue", "Viewmol*save.labelString: Save", "Viewmol*optimizationForm_popup*title: Optimization history", "Viewmol*optimizationForm*energies.labelString: Energies", "Viewmol*optimizationForm*norms.labelString: Gradient norm", "Viewmol*optimizationForm*scales.labelString: Scales", "Viewmol*spectrumForm*all_modes.labelString: All modes", "Viewmol*spectrumForm*ir_modes.labelString: IR active modes", "Viewmol*spectrumForm*raman_modes.labelString: Raman active modes", "Viewmol*spectrumForm*ins_modes.labelString: Inelastic neutron scattering", "Viewmol*spectrumForm*animate.labelString: Animate", "Viewmol*spectrumForm*draw_arrows.labelString: Draw arrows", "Viewmol*spectrumForm*distort.labelString: Distort", "Viewmol*spectrumForm*line_spectrum.labelString: Line spectrum", "Viewmol*spectrumForm*gaussian_spectrum.labelString: Gaussian spectrum", "Viewmol*spectrumForm*setins.labelString: Set weights for inelastic neutron scattering", "Viewmol*spectrumForm*axisTop.labelString: Wave numbers shown on top", "Viewmol*spectrumForm*showGrid.labelString: Show grid", "Viewmol*spectrumForm*lineWidthLabel.labelString: Line width", "Viewmol*spectrumForm*temperature.labelString: Temperature", "Viewmol*spectrumForm*amplitude.labelString: Amplitude", "Viewmol*spectrumForm*scale.labelString: Scale wave\\nnumbers", "Viewmol*wavefunctionForm_popup.title: Wave function", "Viewmol*wavefunctionForm*all_off.labelString: All off", "Viewmol*wavefunctionForm*basis_function.labelString: Basis function", "Viewmol*wavefunctionForm*basis_in_mo.labelString: Basis function in MO", "Viewmol*wavefunctionForm*molecular_orbital.labelString: Molecular orbital", "Viewmol*wavefunctionForm*electron_density.labelString: Electron density", "Viewmol*wavefunctionForm*interpolationLabel.labelString: Interpolation", "Viewmol*wavefunctionForm*none.labelString: None", "Viewmol*wavefunctionForm*linear.labelString: Linear", "Viewmol*wavefunctionForm*logarithmic.labelString: Logarithmic", "Viewmol*wavefunctionForm*levelLabel.labelString: Isosurface", "Viewmol*wavefunctionForm*gridLabel.labelString: Resolution of grid", "Viewmol*wavefunctionForm*automatic.labelString: Automatic recalculation", "Viewmol*MODiagramForm_popup.title: Settings", "Viewmol*MODiagramForm*hartrees.labelString: Hartrees", "Viewmol*MODiagramForm*kj_mol.labelString: kJ/mol", "Viewmol*MODiagramForm*ev.labelString: eV", "Viewmol*MODiagramForm*cm.labelString: cm^-1", "Viewmol*MODiagramForm*resolutionlabel.labelString: Resolution", "Viewmol*printForm_popup.title: Save Drawing", "Viewmol*printForm*hpgl.labelString: HPGL", "Viewmol*printForm*postscript.labelString: PostScript", "Viewmol*printForm*raytracer.labelString: Povray", "Viewmol*printForm*tiff.labelString: TIFF", "Viewmol*printForm*png.labelString: PNG", "Viewmol*printForm*landscape.labelString: Landscape", "Viewmol*printForm*portrait.labelString: Portrait", "Viewmol*printForm*papersize.labelString: Paper size", "Viewmol*printForm*a5.labelString: A5", "Viewmol*printForm*a4.labelString: A4", "Viewmol*printForm*a3.labelString: A3", "Viewmol*printForm*letter.labelString: Letter", "Viewmol*printForm*legal.labelString: Legal", "Viewmol*printForm*userdefined.labelString: User defined", "Viewmol*printForm*lzw.labelString: LZW", "Viewmol*printForm*mac.labelString: Macintosh", "Viewmol*printForm*none.labelString: None", "Viewmol*printForm*compressionlabel.labelString: TIFF compression", "Viewmol*printForm*transparent.labelString: Background transparent", "Viewmol*printForm*widthlabel.labelString: Paper width in mm", "Viewmol*printForm*heightlabel.labelString: Paper height in mm", "Viewmol*printForm*file.labelString: File", "Viewmol*printForm*select.labelString: Select", "Viewmol*drawingModeForm_popup.title: Drawing Modes", "Viewmol*drawingModeForm*dots.labelString: with dots", "Viewmol*drawingModeForm*lines.labelString: with lines", "Viewmol*drawingModeForm*surfaces.labelString: with surface", "Viewmol*drawingModeForm*simplify.labelString: Lines while rotating", "Viewmol*drawingModeForm*onOffLabel.labelString: Lights on/off", "Viewmol*drawingModeForm*molecule.labelString: Move molecule", "Viewmol*drawingModeForm*viewpoint.labelString: Move view point", "Viewmol*drawingModeForm*light0.labelString: Move light 1", "Viewmol*drawingModeForm*light1.labelString: Move light 2", "Viewmol*drawingModeForm*projectionLabel.labelString: Projection", "Viewmol*drawingModeForm*orthographic.labelString: Orthographic", "Viewmol*drawingModeForm*perspective.labelString: Perspective", "Viewmol*drawingModeForm*light0OnOff.labelString: Light 1", "Viewmol*drawingModeForm*light1OnOff.labelString: Light 2", "Viewmol*drawingModeForm*sphereResolutionLabel.labelString: Resolution of spheres", "Viewmol*drawingModeForm*lineWidthLabel.labelString: Line width", "Viewmol*colorEditor_popup.title: Color Editor", "Viewmol*colorEditor*smoothRed.labelString: Smooth", "Viewmol*colorEditor*smoothGreen.labelString: Smooth", "Viewmol*colorEditor*smoothBlue.labelString: Smooth", "Viewmol*doRaytracing.labelString: Start raytracing", "Viewmol*stopRaytracing.labelString: Don't start raytracing", "Viewmol*saveMoleculeForm_popup*title: Save molecule", "Viewmol*saveMoleculeForm*car.labelString: MSI car-file", "Viewmol*saveMoleculeForm*arc.labelString: MSI arc-file", "Viewmol*saveMoleculeForm*gauss.labelString: Gaussian 98 input file", "Viewmol*saveMoleculeForm*mol.labelString: MDL mol-file", "Viewmol*saveMoleculeForm*tm.labelString: Turbomole file", "Viewmol*unitcellForm_popup.title: Unit cell", "Viewmol*unitcellForm*visible.labelString: visible", "Viewmol*unitcellForm*avalue.titleString: a", "Viewmol*unitcellForm*bvalue.titleString: b", "Viewmol*unitcellForm*cvalue.titleString: c", "Viewmol*unitcellForm*miller.labelString: Show Miller plane", "Viewmol*unitcellForm*hvalue.titleString: h", "Viewmol*unitcellForm*kvalue.titleString: k", "Viewmol*unitcellForm*lvalue.titleString: l", "Viewmol*configurationForm_popup*title: Configuration", "Viewmol*configurationForm*en_US.labelString: English", "Viewmol*configurationForm*fr.labelString: French", "Viewmol*configurationForm*de.labelString: German", "Viewmol*configurationForm*hu.labelString: Hungarian", "Viewmol*configurationForm*pl.labelString: Polish", "Viewmol*configurationForm*ru.labelString: Russian", "Viewmol*configurationForm*es.labelString: Spanish", "Viewmol*configurationForm*tr.labelString: Turkish", "Viewmol*configurationForm*browserLabel.labelString: Location of Web browser", "Viewmol*configurationForm*molochLabel.labelString: Location of Moloch", "Viewmol*configurationForm*raytracerLabel.labelString: Location of Povray", "Viewmol*configurationForm*displayImageLabel.labelString: Location of display program for images", "Viewmol.unknownParameter: Unknown command line parameter: %s", "Viewmol.selectFormat: Please select format.", "Viewmol.selectCompression: Please select compression method.", "Viewmol.TIFFSaved: Drawing saved to TIFF file %s.", "Viewmol.PNGSaved: Drawing saved to PNG file %s.", "Viewmol.HPGLSaved: Drawing saved to HPGL file %s.", "Viewmol.PostscriptSaved: Drawing saved to Postscript file %s.", "Viewmol.RaytracerSaved: Drawing saved to Rayshade file %s.", "Viewmol.MoleculeSaved: Molecule saved to file %s.", "Viewmol.ConfigurationSaved: Configuration saved to file $HOME/.Xdefaults.", "Viewmol.noControlFile: There is no control file in the current directory.", "Viewmol.unableToOpen: Unable to open file %s.", "Viewmol.molochFailed: Moloch failed.", "Viewmol.noMolochOutput: Moloch output does not exist.", "Viewmol.errorOnLine: Error on line %d of %s.", "Viewmol.noColors: Unable to allocate sufficient number of colors.", "Viewmol.noInputFilter: No input filter specified in %s.", "Viewmol.noDefaultFilter: No default input filter found.", "Viewmol.noFile: File %s not found.", "Viewmol.cannotOpen: Unable to open file %s.", "Viewmol.FileExists: File %s already exists.", "Viewmol.cannotExecute: Cannot execute: %s.", "Viewmol.notConverged: MOs in %s are not converged.", "Viewmol.noBrowser: Cannot find Web browser for the manual.\\n%s does not exist. Put a line\\n'Viewmol.webBrowser: '\\ninto your $HOME/.Xdefaults file.", "Viewmol.noManual: Manual file %s\\ndoes not exist.", "Viewmol.cannotDisplay: Unable to display manual.\nWeb browser does not start.", "Viewmol.noVisual: Unable to find a window suitable for OpenGL drawing.\\nThere might be an installation problem with OpenGL\\nor the X server has not been started with the\\ncorrect extensions.", "Viewmol.noRayshade: No location for Rayshade specified in resources.", "Viewmol.noDisplay: No display program for images specified in resources.", "Viewmol.unableToWriteFeedback: Cannot allocate enough memory to write drawing to file.", "Viewmol.wavenumberTitle: %s mode, %.6g cm-1", "Viewmol.selectAtomTitle: Please select atom by clicking on it.", "Viewmol.selectINSTitle: Click on atom to set INS weight to %f.", "Viewmol.basisfunctionTitle: Basis function %d: %s%d %s", "Viewmol.basisfunctionInMOTitle: Basis function %d in MO %d: %s%d %.7f*%s", "Viewmol.molecularOrbitalTitle: Molecular orbital %d: %s, energy %f Hartree", "Viewmol.electronDensityTitle: Electron density", "Viewmol.isosurfaceLabel: isosurface: ", "Viewmol.isosurfaceLevel: %.3f ", "Viewmol.historyTitle: Cycle %d Energy %18.10f Hartree, |dE/dxyz| %10.6f", "Viewmol.wavenumber: Wave numbers (cm**-1)", "Viewmol.intensity: Intensity (%)", "Viewmol.energy: Energy", "Viewmol.gradientNorm: Gradient norm", "Viewmol.animateSave: You cannot plot an animated molecule.", "Viewmol.noNormalModes: Normal modes have not been read in.", "Viewmol.GaussianProblem: The Gaussian output contains %c functions.\\nThis combination is currently not supported.", "Viewmol.unknownResource: The value %s is not allowed for\\nthe resource %s.", "Viewmol.unsupportedVersion: Files of version %s are not supported.", "Viewmol.wrongFiletype: File %s is of wrong file type.", "Viewmol.wrongReference: File referenced in %s as 'type=car' is of wrong file type.", "Viewmol.onlySymmetricBasis: Input file contains basis sets only for non-symmetry\\nequivalent atoms. Assuming that the basis set is the\\nsame for all atoms of the same element.", "Viewmol.unknownErrorMessage: Input filter sent unknown error message:\\n%s.", "Viewmol.noCoordinates: Cannot find coordinates in file %s.", "Viewmol.noEnergy: Cannot find energy in file %s.", "Viewmol.noMOselected: There is no MO selected for %s.\\nPlease select a MO in the energy level\\ndiagram, then try again.", "Viewmol.notChangeable: This coordinate cannot be changed\\nsince it is part of a ring.", "Viewmol.notDefined: This internal coordinate is not defined.", "Viewmol.formatNotRecognized: Cannot recognize format of file %s.", "Viewmol.wrongBrowser: Web browser cannot be found at specified location.", "Viewmol.wrongMoloch: Moloch cannot be found at specified location.", "Viewmol.differentMolecules: Internal coordinates cannot be measured between different molecules.", "Viewmol.BusError: A bus error occured. Viewmol\\ncannot continue.", "Viewmol.FloatingPointException: A floating exception occured.\\nViewmol cannot continue.", "Viewmol.SegmentationViolation: A segmentation fault occured.\\nViewmol cannot continue.", "Viewmol.deleteAll: Do you really want to delete\\nall molecules ?", "Viewmol.deleteOne: Do you really want to delete\\n%s ?", "Viewmol.unknownElement: Element %s is not known.", "Viewmol.unknownElements: Elements %s are not known.", "Viewmol.missingBasisset: The basis set for the atom(s) %s has not been specified.", "Viewmol.elementMenuPrefix: ", "Viewmol.wrongPNGversion: Version %s of the PNG library is not supported. At least version 1.4 is needed.", NULL }; viewmol-2.4.1/source/feedback.c0100644000272700027270000006201207752675640014556 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * F E E D B A C K . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: feedback.c,v 1.5 2003/11/07 11:01:52 jrh Exp $ * $Log: feedback.c,v $ * Revision 1.5 2003/11/07 11:01:52 jrh * Release 2.4 * * Revision 1.4 2000/12/10 15:07:06 jrh * Release 2.3 * * Revision 1.3 1999/05/24 01:25:26 jrh * Release 2.2.1 * * Revision 1.2 1999/02/07 21:49:06 jrh * Release 2.2 * * Revision 1.1 1998/01/26 00:34:59 jrh * Initial revision * */ #include #include #include #include "viewmol.h" /* OpenGL's GL_3D_COLOR feedback vertex format. */ typedef struct _Feedback3Dcolor { GLfloat x; GLfloat y; GLfloat z; GLfloat red; GLfloat green; GLfloat blue; GLfloat alpha; } Feedback3Dcolor; typedef struct _Feedback3DindexedColor { GLfloat x; GLfloat y; GLfloat z; GLfloat color; } Feedback3DindexedColor; typedef struct _DepthIndex { GLfloat *ptr; GLfloat depth; } DepthIndex; void (*setRGBColor)(FILE *, GLfloat, GLfloat, GLfloat); void (*moveto)(FILE *, int, GLfloat, GLfloat); void (*lineto)(FILE *, int, GLfloat, GLfloat); void (*triangle)(FILE *, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); void (*triangleColor)(FILE *, GLfloat, GLfloat, GLfloat); void (*point)(FILE *, int, GLfloat, GLfloat); void (*lineStipple)(FILE *, GLushort); void (*showString)(FILE *, int, GLfloat, GLfloat); void feedbackString(char *, double, double, double, double, GLuint, char); void feedbackLineStipple(GLint, GLushort); void feedbackLineWidth(GLfloat); void feedbackDisable(GLenum); double visibility(GLfloat *); extern void PostscriptSetRGBColor(FILE *, GLfloat, GLfloat, GLfloat); extern void PostscriptMoveto(FILE *, int, GLfloat, GLfloat); extern void PostscriptLineto(FILE *, int, GLfloat, GLfloat); extern void PostscriptTriangle(FILE *, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); extern void PostscriptTriangleColor(FILE *, GLfloat, GLfloat, GLfloat); extern void PostscriptPoint(FILE *, int, GLfloat, GLfloat); extern void PostscriptLineStipple(FILE *, GLushort); extern void PostscriptShowString(FILE *, int, GLfloat, GLfloat); extern void hpglSetRGBColor(FILE *, GLfloat, GLfloat, GLfloat); extern void hpglMoveto(FILE *, int, GLfloat, GLfloat); extern void hpglLineto(FILE *, int, GLfloat, GLfloat); extern void hpglTriangle(FILE *, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); extern void hpglTriangleColor(FILE *, GLfloat, GLfloat, GLfloat); extern void hpglPoint(FILE *, int, GLfloat, GLfloat); extern void hpglLineStipple(FILE *, GLushort); extern void hpglShowString(FILE *, int, GLfloat, GLfloat); extern void *getmem(size_t, size_t); extern void fremem(void **); extern void getRGBColor(Widget, Pixel, GLfloat *, GLfloat *, GLfloat *); extern void vectorProduct(double *, double *, double *); extern double scalarProduct(double *, double *); extern struct WINDOW windows[]; extern int rgbMode; extern char *text, *textPointer; static GLfloat lastred, lastgreen, lastblue; GLfloat *writePrimitives(FILE *file, GLfloat *loc, int window, int format, int portrait) { int token; int nvertices, i; GLfloat red, green, blue, alpha=0.0, dr, dg, db; int smooth, triOffset; Feedback3Dcolor *vertexC=(Feedback3Dcolor *)0; Feedback3DindexedColor *vertexI=(Feedback3DindexedColor *)0; token=*loc; loc++; switch (token) { case GL_LINE_RESET_TOKEN: case GL_LINE_TOKEN: if (rgbMode) { vertexC=(Feedback3Dcolor *)loc; if (vertexC[1].alpha != 1.0) (*setRGBColor)(file, vertexC[1].alpha, vertexC[1].alpha, vertexC[1].alpha); else (*setRGBColor)(file, vertexC[1].red, vertexC[1].green, vertexC[1].blue); (*moveto)(file, portrait, vertexC[0].x, vertexC[0].y); (*lineto)(file, portrait, vertexC[1].x, vertexC[1].y); loc+=14; /* Each vertex element in the feedback buffer is 7 GLfloats. */ } else { vertexI=(Feedback3DindexedColor *)loc; getRGBColor(windows[window].widget, (Pixel)vertexI[1].color, &red, &green, &blue); (*setRGBColor)(file, red, green, blue); (*moveto)(file, portrait, vertexI[0].x, vertexI[0].y); (*lineto)(file, portrait, vertexI[1].x, vertexI[1].y); loc+=8; /* Each vertex element in the feedback buffer is 4 GLfloats. */ } if (format == POSTSCRIPT) fprintf(file, "stroke\n"); break; case GL_POLYGON_TOKEN: nvertices=*loc; loc++; if (nvertices > 0) { if (rgbMode) { vertexC=(Feedback3Dcolor *)loc; red=vertexC[0].red; green=vertexC[0].green; blue=vertexC[0].blue; alpha=vertexC[0].alpha; } else { vertexI=(Feedback3DindexedColor *)loc; getRGBColor(windows[window].widget, (Pixel)vertexI[0].color, &red, &green, &blue); } smooth=FALSE; if (alpha == 1.0) { for (i=1; idepth-p1->depth; if (diff > 0.0) return(1); else if (diff < 0.0) return(-1); else return(0); } void writeFeedback(FILE * file, GLint size, GLfloat *buffer, int window, int format, int smooth, int portrait) { GLfloat *loc, *end; Feedback3Dcolor *vertexC; Feedback3DindexedColor *vertexI; GLfloat depthSum, visible, addDepth=0.0, textDepth=0.0; DepthIndex *prims; int token, nprimitives, item, checkVisibility=TRUE; int nvertices; register int i; switch (format) { case HPGL: setRGBColor=hpglSetRGBColor; moveto=hpglMoveto; lineto=hpglLineto; triangle=hpglTriangle; triangleColor=hpglTriangleColor; point=hpglPoint; lineStipple=hpglLineStipple; showString=hpglShowString; break; case POSTSCRIPT: setRGBColor=PostscriptSetRGBColor; moveto=PostscriptMoveto; lineto=PostscriptLineto; triangle=PostscriptTriangle; triangleColor=PostscriptTriangleColor; point=PostscriptPoint; lineStipple=PostscriptLineStipple; showString=PostscriptShowString; break; } end=buffer+size; textPointer=text; lastred=lastgreen=lastblue=(-1.); /* Count how many primitives there are. */ nprimitives=0; loc=buffer; if (smooth) { while (loc < end) { token = *loc; loc++; switch (token) { case GL_LINE_TOKEN: case GL_LINE_RESET_TOKEN: if (rgbMode) loc+=14; else loc+=8; nprimitives++; break; case GL_POLYGON_TOKEN: nvertices=*loc; loc++; if (rgbMode) loc+=(7*nvertices); else loc+=(4*nvertices); nprimitives++; break; case GL_POINT_TOKEN: if (rgbMode) loc+=7; else loc+=4; nprimitives++; break; case GL_BITMAP_TOKEN: case GL_COPY_PIXEL_TOKEN: case GL_DRAW_PIXEL_TOKEN: if (rgbMode) loc+=7; else loc+=4; nprimitives++; break; case GL_PASS_THROUGH_TOKEN: loc+=1; nprimitives++; break; default: /* If we arrive here OpenGL has been changed. */ break; } } /* Allocate an array of pointers that will point back at primitives in the feedback buffer. There will be one entry per primitive. This array is also where we keep the primitive's average depth. There is one entry per primitive in the feedback buffer. */ prims=(DepthIndex *)getmem(nprimitives, sizeof(DepthIndex)); item=0; loc=buffer; while (loc < end) { prims[item].ptr=loc; /* Save this primitive's location. */ token=*loc; loc++; visible=(-1.0); switch (token) { case GL_LINE_TOKEN: case GL_LINE_RESET_TOKEN: if (rgbMode) { vertexC=(Feedback3Dcolor *)loc; depthSum=vertexC[0].z+vertexC[1].z; loc+=14; } else { vertexI=(Feedback3DindexedColor *)loc; depthSum=vertexI[0].z+vertexI[1].z; loc+=8; } prims[item].depth=depthSum*0.5+addDepth; break; case GL_POLYGON_TOKEN: nvertices=*loc; loc++; if (checkVisibility) visible=visibility(loc); if (rgbMode) { vertexC=(Feedback3Dcolor *)loc; depthSum=vertexC[0].z; for (i=1; i #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" extern void *getmem(size_t, size_t); #ifdef AIX extern int alphasort(struct dirent **, struct dirent **); #endif static void GetFilename(Widget, char **, XmFileSelectionBoxCallbackStruct *); static void Cancel(Widget, char **, caddr_t); extern void MapBox(Widget, caddr_t, XmAnyCallbackStruct *); #if defined LINUX || defined DARWIN static int matchFileNames(const struct dirent *); static int matchDirNames(const struct dirent *); #else static int matchFileNames(struct dirent *); static int matchDirNames(struct dirent *); #endif static void searchFile(Widget, XtPointer); static void searchDir(Widget, XtPointer); extern XtAppContext app; extern Widget topShell, fileBox; extern int rgbMode; static int cont; static char *string, *directory, *mask; void createFileselect(void) { Visual *vi; Pixel bg; Widget helpbutton; Arg args[7]; /* This function creates the file selection box */ XtVaGetValues(topShell, XmNvisual, &vi, XmNbackground, &bg, NULL); XtSetArg(args[0], XmNautoUnmanage, False); XtSetArg(args[1], XmNdefaultPosition, False); XtSetArg(args[2], XmNmwmDecorations, MWM_DECOR_RESIZEH | MWM_DECOR_TITLE); XtSetArg(args[3], XmNfileTypeMask, XmFILE_REGULAR); XtSetArg(args[4], XmNfileSearchProc, searchFile); XtSetArg(args[5], XmNdirSearchProc, searchDir); XtSetArg(args[6], XmNvisual, vi); fileBox=XmCreateFileSelectionDialog(topShell, "fileSelectionBox", args, XtNumber(args)); XtAddCallback(fileBox, XmNokCallback, (XtCallbackProc)GetFilename, &string); XtAddCallback(fileBox, XmNcancelCallback, (XtCallbackProc)Cancel, &string); XtAddCallback(fileBox, XmNmapCallback, (XtCallbackProc)MapBox, NULL); helpbutton=XmFileSelectionBoxGetChild(fileBox, XmDIALOG_HELP_BUTTON); XtUnmanageChild(helpbutton); } char *selectFile(char *filter, char *deflt, int apply) { XEvent event; XmString text; if (apply) { text=XmStringCreateSimple(filter); XtVaSetValues(fileBox, XmNpattern, text, NULL); XmStringFree(text); text=XmStringCreateSimple(deflt); XtVaSetValues(fileBox, XmNtextString, text, NULL); XmStringFree(text); } XtManageChild(fileBox); cont=TRUE; while (cont) { XtAppNextEvent(app, &event); XtDispatchEvent(&event); } XtUnmanageChild(fileBox); return(string); } static void GetFilename(Widget button, char **client_data, XmFileSelectionBoxCallbackStruct *call_data) { char *text; XmStringGetLtoR(call_data->value, XmFONTLIST_DEFAULT_TAG, &text); *client_data=text; cont=FALSE; } static void Cancel(Widget button, char **client_data, caddr_t call_data) { *client_data=(char *)NULL; cont=FALSE; } #if defined LINUX || defined DARWIN int matchFileNames(const struct dirent *d) #else int matchFileNames(struct dirent *d) #endif { struct stat buffer; char filename[FILENAME_MAX]; strcpy(filename, directory); if (filename[strlen(filename)-1] != '/') strcat(filename, "/"); strcat(filename, d->d_name); if (fnmatch(mask, filename, FNM_PATHNAME | FNM_PERIOD)) return(0); if (stat(filename, &buffer) == -1) return(0); if ((buffer.st_mode & S_IFMT) == S_IFDIR) return(0); return(1); } #if defined LINUX || defined DARWIN int matchDirNames(const struct dirent *d) #else int matchDirNames(struct dirent *d) #endif { struct stat buffer; char filename[FILENAME_MAX]; strcpy(filename, directory); if (filename[strlen(filename)-1] != '/') strcat(filename, "/"); strcat(filename, d->d_name); if (strcmp(d->d_name, "..")) { if (fnmatch(mask, filename, FNM_PATHNAME | FNM_PERIOD)) return(0); } if (stat(filename, &buffer) == -1) return(0); if ((buffer.st_mode & S_IFMT) == S_IFDIR) return(1); return(0); } static void searchFile(Widget w, XtPointer s) { XmFileSelectionBoxCallbackStruct *search=(XmFileSelectionBoxCallbackStruct *)s; struct dirent **namelist; XmString *names; int n=0; char filename[FILENAME_MAX]; register int i; if (!XmStringGetLtoR(search->dir, XmFONTLIST_DEFAULT_TAG, &directory)) return; if (!XmStringGetLtoR(search->mask, XmFONTLIST_DEFAULT_TAG, &mask)) return; if ((n=scandir(directory, &namelist, matchFileNames, alphasort)) == -1) return; if (n) { names=(XmString *)getmem((size_t)n, sizeof(XmString)); for (i=0; id_name); names[i]=XmStringCreateLocalized(filename); free(namelist[i]); } free(namelist); XtVaSetValues(w, XmNfileListItems, names, XmNfileListItemCount, n, XmNdirSpec, search->dir, XmNlistUpdated, True, NULL); while (i > 0) XmStringFree(names[--i]); free(names); } else { XtVaSetValues(w, XmNfileListItems, NULL, XmNfileListItemCount, 0, XmNlistUpdated, True, NULL); } XtFree(mask); XtFree(directory); } static void searchDir(Widget w, XtPointer s) { XmFileSelectionBoxCallbackStruct *search=(XmFileSelectionBoxCallbackStruct *)s; struct dirent **namelist; XmString *names; int n=0; char filename[FILENAME_MAX]; register int i; if (!XmStringGetLtoR(search->dir, XmFONTLIST_DEFAULT_TAG, &directory)) return; if (!XmStringGetLtoR(search->mask, XmFONTLIST_DEFAULT_TAG, &mask)) return; if ((n=scandir(directory, &namelist, matchDirNames, alphasort)) == -1) { XtVaSetValues(w, XmNdirectoryValid, False, NULL); return; } names=(XmString *)getmem((size_t)n, sizeof(XmString)); for (i=0; id_name); names[i]=XmStringCreateLocalized(filename); free(namelist[i]); } free(namelist); if (n) { XtVaSetValues(w, XmNdirListItems, names, XmNdirListItemCount, n, XmNlistUpdated, True, XmNdirectoryValid, True, XmNdirSpec, search->dir, NULL); while (i > 0) XmStringFree(names[--i]); free(names); } else { XtVaSetValues(w, XmNdirListItems, NULL, XmNdirListItemCount, 0, XmNlistUpdated, True, XmNdirectoryValid, True, NULL); } XtFree(mask); XtFree(directory); } viewmol-2.4.1/source/getmachine0100755000272700027270000003247710114370151014703 0ustar jrhjrh#!/bin/sh #******************************************************************************* # * # Viewmol * # * # G E T M A C H I N E * # * # Copyright (c) Joerg-R. Hill, October 2003 * # * #******************************************************************************* # # $Id: getmachine,v 1.6 2003/11/07 12:53:43 jrh Exp $ # $Log: getmachine,v $ # Revision 1.6 2003/11/07 12:53:43 jrh # Release 2.4 # # Revision 1.5 2000/12/10 15:07:25 jrh # Release 2.3 # # Revision 1.4 1999/05/24 01:25:38 jrh # Release 2.2.1 # # Revision 1.3 1999/02/07 22:02:47 jrh # Release 2.2 # # Revision 1.2 1998/01/26 00:47:46 jrh # Release 2.1 # # Revision 1.1 1996/12/10 18:46:19 jrh # Initial revision # # This shell script adapts the Makefile in dependence # of the machine and the operating system you use. # It is called from 'make viewmol' before the compiler # is invoked. # makedir() { if [ ! -d "$dir" ] then mkdir "$dir" fi cd $dir } givehint() { if [ $hint -eq 1 ] then echo 'If you want to use environment variables in any of the following' echo 'paths, do it like this: $(HOME)' hint=0 fi } findProcessor() { # Try -p option first, but since this option is not always # available use -m option if -p option fails or return "unknown" processor=`uname -p 2> /dev/null` if [ "$processor" = "" -o "$processor" = "unknown" ] then processor=`uname -m` fi } target=$1 os=`uname -s` # Check, whether configuration file is up to date if [ -f .config.$os ] then grep PNGINCLUDE .config.$os > /dev/null 2> /dev/null ret=$? if [ $ret -eq 1 ] then rm -f .config.$os fi fi if [ ! -f .config.$os ] then hint=1 # TIFF library if [ -f /usr/lib/libtiff.a ] then libtiff="-L/usr/lib" elif [ -f /usr/local/lib/libtiff.a ] then libtiff="-L/usr/local/lib" else givehint echo -n "Please enter the name of the directory where libtiff.a can be found: " read libtiff if [ "$libtiff" != "" ] then libtiff="-L${libtiff}" fi fi echo "LIBTIFF = ${libtiff}" > .config.$os # TIFF include file if [ -f /usr/include/tiff.h ] then case $os in CYGWIN*) tiffinclude="." ;; *) tiffinclude="/usr/include" ;; esac elif [ -f /usr/local/include/tiff.h ] then tiffinclude="/usr/local/include" else givehint echo -n "Please enter the name of the directory where the include file for libtiff can be found: " read tiffinclude fi echo "TIFFINCLUDE = $tiffinclude" >> .config.$os # PNG library if [ -f /usr/lib/libpng.a -o -f /usr/lib/libpng12.a ] then libpng="-L/usr/lib" elif [ -f /usr/local/lib/libpng.a ] then libpng="-L/usr/local/lib" else givehint echo -n "Please enter the name of the directory where libpng.a can be found: " read libpng if [ "$libpng" != "" ] then libpng="-L${libpng}" fi fi echo "LIBPNG = ${libpng}" >> .config.$os # PNG include file if [ -f /usr/include/png.h ] then pnginclude="/usr/include" elif [ -f /usr/include/libpng12/png.h ] then pnginclude="/usr/include/libpng12" elif [ -f /usr/local/include/png.h ] then pnginclude="/usr/local/include" else givehint echo -n "Please enter the name of the directory where the include file for libpng can be found: " read pnginclude fi echo "PNGINCLUDE = $pnginclude" >> .config.$os # Python list=`find /usr -name Python.h -print 2> /dev/null` version=`(for i in $list do dir=\`dirname $i\` echo \`basename $dir\` done) | sort | tail -1` if [ "$version" != "" ] then pythoninclude=`dirname \`(for i in $list do echo $i | grep $version done)\`` pythonversion=$version else givehint echo -n "Please enter the name of the directory where the include files for Python can be found: " read pythoninclude pythonversion=`basename $pythoninclude` fi echo "PYTHONVERSION = $pythonversion" >> .config.$os echo "PYTHONINCLUDE = $pythoninclude" >> .config.$os if [ "$version" != "" ] then pythonlib=`dirname \`find /usr -name "lib${version}*.a" -print 2> /dev/null | grep "$version/"\`` else givehint echo -n "Please enter the name of the directory where the Python library can be found: " read pythonlib fi echo "LIBPYTHON = $pythonlib" >> .config.$os fi PYTHON="python2" if [ $os = "FreeBSD" ] then PYTHON="python2.2" else PYTHON=`which python2 2> /dev/null` ret=$? if [ $ret -ne 0 ] then PYTHON=`which python 2> /dev/null` ret=$? if [ $ret -ne 0 ] then echo "Cannot find Python." exit fi fi fi LINKFORSHARED=`$PYTHON - < makefile echo 'COMPILER=cc' >> makefile echo 'OPT=-O2' >> makefile echo 'CFLAGS=-DAIX' >> makefile echo "LDFLAGS=$LINKFORSHARED" >> makefile echo 'SCANDIR=' >> makefile echo 'INCLUDE=/usr/lpp/OpenGL/include -I$(TIFFINCLUDE) -I$(PNGINCLUDE) -I$(PYTHONINCLUDE)' >> makefile echo 'LIBRARY=-L/usr/lpp/OpenGL/lib $(LIBTIFF) $(LIBPNG) -L$(LIBPYTHON)' >> makefile echo 'LIBS=-l${PYTHONVERSION} -ltiff -lpng -lz -lGLU -lGL -lXm -lXmu -lXi -lXext -lXt -lX11 -lm' >> makefile ;; # # This is a Silicon Graphics. # IRIX*) dir="${os}_`hinv | awk '/CPU:/ {print $3}' | cut -d/ -f2`" makedir cat ../.config.$os > makefile echo 'COMPILER=cc' >> makefile echo 'OPT=-O2' >> makefile if [ "$dir" = "IRIX_R4400" -o "$dir" = "IRIX_R4600" -o "$dir" = "IRIX_R5000" ] then echo 'CFLAGS=-DIRIX -n32' >> makefile echo "LDFLAGS=-n32 -Wl,-woff,85,-woff,134 $LINKFORSHARED" >> makefile elif [ "$dir" = "IRIX64_R8000" -o "$dir" = "IRIX64_R10000" -o "$dir" = "IRIX64_R12000" ] then # # uses -n32 since libtiff is not available in a 64 bit version on SGIs # echo 'CFLAGS=-DIRIX -n32' >> makefile echo "LDFLAGS=-n32 -Wl,-woff,85,-woff,134 $LINKFORSHARED" >> makefile else echo 'CFLAGS=-DIRIX' >> makefile echo "LDFLAGS=-Wl,-woff,85,-woff,134 $LINKFORSHARED" >> makefile fi echo 'SCANDIR=' >> makefile echo 'INCLUDE=$(TIFFINCLUDE) -I$(PNGINCLUDE) -I$(PYTHONINCLUDE)' >> makefile echo 'LIBRARY=$(LIBTIFF) $(LIBPNG) -L$(LIBPYTHON)' >> makefile echo 'LIBS=-l${PYTHONVERSION} -ltiff -lpng -lz -lGLU -lGL -lXm -lXmu -lXi -lXt -lX11 -lpthread -lm -lCsup' >> makefile ;; # # This is Linux. # Linux) dir="$os" makedir cat ../.config.$os > makefile use_icc=`type icc 2> /dev/null` if [ "$use_icc" = "" ] then findProcessor echo 'COMPILER=gcc' >> makefile echo "OPT=-O6 -mcpu=$processor -fomit-frame-pointer -ffast-math -malign-double" >> makefile echo 'CFLAGS=-Wall -I/usr/X11R6/include -DLINUX -Wno-strict-aliasing' >> makefile echo "LDFLAGS=$LINKFORSHARED" >> makefile else echo 'COMPILER=icc' >> makefile echo 'OPT=-O2 -ipo' >> makefile echo 'CFLAGS=-I/opt/intel/compiler50/ia32/include -I/usr/X11R6/include -DLINUX' >> makefile echo "LDFLAGS=$LINKFORSHARED -ipo" >> makefile fi echo 'SCANDIR=' >> makefile echo 'INCLUDE=$(TIFFINCLUDE) -I$(PNGINCLUDE) -I$(PYTHONINCLUDE)' >> makefile echo 'LIBRARY=$(LIBTIFF) $(LIBPNG) -L$(LIBPYTHON)' >> makefile echo 'LIBS=-L/usr/local/lib -l${PYTHONVERSION} -ltiff -lpng -lz -lGLU -lGL -L/usr/X11R6/lib -lXm -lXmu -lXp -lXi -lXext -lXt -lX11 -lpthread -lutil -ldl -lm' >> makefile ;; # # This is FreeBSD # FreeBSD) dir="$os" makedir cat ../.config.$os > makefile findProcessor echo 'COMPILER=cc' >> makefile echo "OPT=-O6 -mcpu=$processor -fomit-frame-pointer -ffast-math -malign-double" >> makefile echo 'CFLAGS=-Wall -I/usr/X11R6/include -DFREEBSD' >> makefile echo "LDFLAGS=$LINKFORSHARED" >> makefile echo 'SCANDIR=' >> makefile echo 'INCLUDE=$(TIFFINCLUDE) -I$(PNGINCLUDE) -I$(PYTHONINCLUDE)' >> makefile echo 'LIBRARY=$(LIBTIFF) $(LIBPNG) -L$(LIBPYTHON)' >> makefile echo 'LIBS=-l${PYTHONVERSION} -ltiff -lpng -lz -lGLU -lGL -L/usr/X11R6/lib -lXm -lXmu -lXi -lXext -lXt -lX11 -lutil -lm' >> makefile ;; # # This is Mac OS X # Darwin) dir="$os" makedir cat ../.config.$os > makefile echo 'COMPILER=gcc' >> makefile echo 'OPT=-O2 -fomit-frame-pointer' >> makefile echo 'CFLAGS=-Wall -DDARWIN -I/usr/X11R6/include' >> makefile echo "LDFLAGS=-bind_at_load $LINKFORSHARED" >> makefile echo 'SCANDIR=' >> makefile echo 'INCLUDE=$(TIFFINCLUDE) -I$(PNGINCLUDE) -I$(PYTHONINCLUDE)' >> makefile echo 'LIBRARY=$(LIBTIFF) $(LIBPNG) -L$(LIBPYTHON) -L/usr/X11R6/lib' >> makefile echo 'LIBS=-l${PYTHONVERSION} -ltiff -lpng -lz -lGLU -lGL -lXm -lXmu -lXi -lXext -lXt -lX11 -lm' >> makefile ;; # # This is OSF1 # OSF1) dir="$os" makedir cat ../.config.$os > makefile echo 'COMPILER=cc' >> makefile echo 'OPT=-O2 -Olimit 615' >> makefile echo 'CFLAGS=-ieee_with_no_inexact' >> makefile echo "LDFLAGS=$LINKFORSHARED" >> makefile echo 'SCANDIR=' >> makefile echo 'INCLUDE=$(TIFFINCLUDE) -I$(PNGINCLUDE) -I$(PYTHONINCLUDE)' >> makefile echo 'LIBRARY=$(LIBTIFF) $(LIBPNG) -L$(LIBPYTHON)' >> makefile echo 'LIBS=-l${PYTHONVERSION} -lXm -lXmu -lXi -lXt -lGLU -lGL -lX11 -ltiff -lpng -lz -lm' >> makefile ;; # # This is HP-UX # HP-UX) dir="$os" makedir cat ../.config.$os > makefile echo 'COMPILER=cc' >> makefile echo 'OPT=-O2' >> makefile echo 'CFLAGS=-Aa -D_HPUX_SOURCE' >> makefile echo "LDFLAGS=$LINKFORSHARED" >> makefile echo 'SCANDIR=' >> makefile echo 'INCLUDE=$(TIFFINCLUDE) -I$(PNGINCLUDE) -I/usr/include/Motif1.2 -I/usr/include/X11R5 -I$(PYTHONINCLUDE)' >> makefile echo 'LIBRARY=$(LIBTIFF) $(LIBPNG) -L/usr/lib/Motif1.2 -L/usr/lib/X11R5 -L$(LIBPYTHON)' >> makefile echo 'LIBS=-l${PYTHONVERSION} -lXm -lXmu -lXi -lXt -lGLU -lGL -lX11 -ltiff -lpng -lz -lm' >> makefile ;; # # This is SunOS # SunOS) dir="$os" makedir cat ../.config.$os > makefile use_gcc=`type gcc 2> /dev/null` if [ "$use_gcc" = "" ] then echo 'COMPILER=cc' >> makefile echo 'OPT=-xO4 -native' >> makefile echo 'CFLAGS= -DSunOS -xlibmil' >> makefile echo "LDFLAGS=-L/usr/dt/lib $LINKFORSHARED" >> makefile else echo 'COMPILER=gcc' >> makefile echo "OPT=-O6 -fomit-frame-pointer -ffast-math" >> makefile echo 'CFLAGS=-Wall -I/usr/X11R6/include' >> makefile echo "LDFLAGS=$LINKFORSHARED" >> makefile fi echo 'SCANDIR=scandir.o' >> makefile echo 'INCLUDE=$(TIFFINCLUDE) -I$(PNGINCLUDE) -I$(PYTHONINCLUDE)' >> makefile echo 'LIBRARY=$(LIBTIFF) $(LIBPNG) -L$(LIBPYTHON)' >> makefile echo 'LIBS=-l${PYTHONVERSION} -lXm -lXmu -lXi -lXt -lGLU -lGL -lX11 -lm -Bstatic -ltiff -lpng -lz -Bdynamic ' >> makefile ;; # # This is Windows with Cygwin # CYGWIN*) dir="$os" makedir cat ../.config.$os > makefile findProcessor echo 'COMPILER=cc' >> makefile echo "OPT=-mcpu=$processor -fomit-frame-pointer -ffast-math -malign-double" >> makefile echo 'CFLAGS=-DSYS_NMLN=20 -Wall -I/usr/X11R6/include -DLINUX' >> makefile echo "LDFLAGS=-L/usr/local/lib/w32api/ $LINKFORSHARED" >> makefile echo 'SCANDIR=' >> makefile echo 'INCLUDE=$(TIFFINCLUDE) -I$(PNGINCLUDE) -I$(PYTHONINCLUDE)' >> makefile echo 'LIBRARY=$(LIBTIFF) $(LIBPNG) -L$(LIBPYTHON)' >> makefile echo 'LIBS=-L/usr/local/BerkeleyDB.4.0/lib -L/usr/local/lib -l${PYTHONVERSION} -ltiff -lpng12 -lz -lGLU -lGL -L/usr/X11R6/lib -lXmu -lXm -lXp -lXi -lXext -lXt -lX11 -lpthread -lm -lSM -lICE' >> makefile ;; # # This is a (not yet) known operating system. # *) echo "Sorry, I don't know the operating system '$os'." echo "Edit 'getmachine' to include the required options." exit 1 ;; esac cat ../Makefile >> makefile make ${target}_ rm -f makefile viewmol-2.4.1/source/getmem.c0100644000272700027270000000333607752675657014324 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * G E T M E M . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: getmem.c,v 1.6 2003/11/07 11:02:07 jrh Exp $ * $Log: getmem.c,v $ * Revision 1.6 2003/11/07 11:02:07 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:07:30 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:40 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:49:25 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:48 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:40:58 jrh * Initial revision * */ #include #include void *getmem(size_t number, size_t size) { void *pointer; pointer=calloc(number, size); if (pointer == NULL) { fprintf(stderr, "ERROR: Unable to allocate memory: "); perror(NULL); exit(1); } return(pointer); } void fremem(void **pointer) { free(*pointer); *pointer=NULL; } void *expmem(void *pointer, size_t number, size_t size) { pointer=realloc(pointer, number*size); if (pointer == NULL) { fprintf(stderr, "ERROR: Unable to change size of allocated memory: "); perror(NULL); exit(1); } return(pointer); } viewmol-2.4.1/source/getrc.c0100644000272700027270000004622710135460013014117 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * G E T R C . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: getrc.c,v 1.6 2003/11/07 11:02:15 jrh Exp $ * $Log: getrc.c,v $ * Revision 1.6 2003/11/07 11:02:15 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:07:37 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:42 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:49:34 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:51 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:41:02 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" #include "isotopes.h" void getPrimitive(char *, int *, int); int getColor(GLfloat *p); void unknownResource(char *, char *); void storeCommand(char *, char *, char *); void setBond(struct MOLECULE *); void checkProgram(char *, char *); void getFormats(void); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern char *getStringResource(Widget, char *); extern int getIntResource(Widget, char *); extern void getRGBColor(Widget, Pixel, float *, float *, float *); extern int checkFile(char **); extern XVisualInfo *getVisualInfo(Display *, Visual *); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern void osname(char *); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern void loadAtomColors(XVisualInfo *, Colormap); extern void GetPapersize(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern struct MOLECULE *molecules; extern struct ELEMENT *elements; extern struct WINDOW windows[]; extern struct OPTION *options; extern struct OPTION *output; extern Pixel stdcol[9]; extern char webbrowser[MAXLENLINE], moloch[MAXLENLINE], raytracer[MAXLENLINE], displayImage[MAXLENLINE]; extern int ne, nopt, noutput; extern double bndfac, temp, sphereres, denres, lineWidth; extern double paperHeight, paperWidth; extern int debug, label; extern int lines, thermoUnits; extern int primitive, bondType, unit, automaticRecalculate; extern double level, hbondThreshold; extern char *formBondLength, *formBondAngle, *formTorsionAngle; extern int rgbMode, simplify, interp, showWarning; extern Widget topShell; extern XtAppContext app; static char viewmolpath[MAXLENLINE]; #define DEFAULTPATH "/usr/local/lib/viewmol" int getrc(void) { struct OPTION *oldOptions; FILE *file; static struct PushButtonRow buttons1[] = {{"exit", GetMessageBoxButton, (XtPointer)0, NULL}}; const char *locale; char line[MAXLENLINE], rcfile[MAXLENLINE], *word; #ifdef DARWIN char os[_SYS_NAMELEN+12]; #else char os[SYS_NMLN+12]; #endif size_t mne=115; int nline=0, error, i; debug=0; label=FALSE; locale=setlocale(LC_ALL, "C"); /* Find default model */ word=getStringResource(topShell, "model"); if (strstr(word, "wire")) windows[VIEWER].mode=WIREMODEL; else if (strstr(word, "stick")) windows[VIEWER].mode=STICKMODEL; else if (strstr(word, "ball")) windows[VIEWER].mode=BALLMODEL; else if (strstr(word, "cpk")) windows[VIEWER].mode=CUPMODEL; else { unknownResource("Viewmol.model", word); windows[VIEWER].mode=WIREMODEL; } /* Find default drawing primitive */ word=getStringResource(topShell, "drawingMode"); if (strstr(word, "dot")) primitive=GLU_POINT; else if (strstr(word, "line")) primitive=GLU_LINE; else if (strstr(word, "surface")) primitive=GLU_FILL; else { unknownResource("Viewmol.drawingMode", word); primitive=GLU_FILL; } /* Find default sphere/cylinder/arrow resolution and line width for wire model */ sphereres=(double)getIntResource(topShell, "sphereResolution"); lineWidth=(double)getIntResource(topShell, "lineWidth"); word=getStringResource(topShell, "bondType"); if (strstr(word, "single")) bondType=SINGLE_BONDS; else if (strstr(word, "multiple")) bondType=MULTIPLE_BONDS; else if (strstr(word, "conjugated")) bondType=CONJUGATION; else { unknownResource("Viewmol.bondType", word); bondType=CONJUGATION; } word=getStringResource(topShell, "simplifyWhileRotating"); if (!strcmp(word, "True")) simplify=TRUE; else simplify=FALSE; word=getStringResource(topShell, "automaticRecalculation"); if (!strcmp(word, "True")) automaticRecalculate=TRUE; else automaticRecalculate=FALSE; word=getStringResource(topShell, "interpolation"); if (!strcmp(word, "none")) interp=IP_NONE; else if (!strcmp(word, "linear")) interp=IP_LINEAR; else if (!strcmp(word, "logarithmic")) interp=IP_LOG; else { unknownResource("Viewmol.interpolation", word); interp=IP_LINEAR; } hbondThreshold=atof(getStringResource(topShell, "hydrogenBondThreshold")); /* Default units for thermodynamics */ word=getStringResource(topShell, "thermoUnits"); if (!strcmp(word, "joules")) thermoUnits=JOULES; else if (!strcmp(word, "calories")) thermoUnits=CALORIES; else if (!strcmp(word, "thermochemical calories")) thermoUnits=THERMOCALORIES; else { unknownResource("Viewmol.thermoUnits", word); thermoUnits=JOULES; } temp=298.15; lines=TRUE; windows[SPECTRUM].foreground=stdcol[BLACK]; windows[SPECTRUM].background=stdcol[WHITE]; windows[SPECTRUM].mode=SPECTRUM_IR; word=getStringResource(topShell, "wavenumbers"); windows[SPECTRUM].left=atof(strtok(word, ":")); windows[SPECTRUM].right=atof(strtok(NULL, ":")); windows[SPECTRUM].bottom=100.0; windows[SPECTRUM].top=0.0; windows[SPECTRUM].near=0.0; windows[SPECTRUM].far=1.0; windows[HISTORY].foreground=stdcol[BLUE]; windows[HISTORY].background=stdcol[WHITE]; windows[HISTORY].mode=SCALES | ENERGY | GNORM; windows[HISTORY].left=1.0; windows[HISTORY].bottom=0.0; windows[HISTORY].near=0.0; windows[HISTORY].far=1.0; unit=HARTREE; windows[MO].foreground=stdcol[BLACK]; windows[MO].background=stdcol[WHITE]; windows[MO].mode=ENERGY_LEVELS; windows[MO].left=0.0; windows[MO].right=1.0; windows[MO].near=0.0; windows[MO].far=1.0; level=atof(getStringResource(topShell, "isosurface")); denres=atof(getStringResource(topShell, "densityResolution")); getFormats(); /* Get commands to start Web browser, Moloch, Rayshade, and display program for images and check if programs are accessible */ word=getStringResource(topShell, "webBrowser"); checkProgram(webbrowser, word); word=getStringResource(topShell, "Moloch"); checkProgram(moloch, word); word=getStringResource(topShell, "Raytracer"); checkProgram(raytracer, word); word=getStringResource(topShell, "DisplayImage"); checkProgram(displayImage, word); /* Get paper size */ word=getStringResource(topShell, "paperSize"); if (strchr(word, 'x') != NULL) { paperWidth=atof(strtok(word, "x")); paperHeight=atof(strtok(NULL, "x")); /* We have to call GetPapersize to set the paper variable in printform */ GetPapersize((Widget)0, (caddr_t)USER, (XmToggleButtonCallbackStruct *)0); } else { if (strstr(word, "A5") != NULL) GetPapersize((Widget)0, (caddr_t)A5, (XmToggleButtonCallbackStruct *)0); else if (strstr(word, "A4") != NULL) GetPapersize((Widget)0, (caddr_t)A4, (XmToggleButtonCallbackStruct *)0); else if (strstr(word, "A3") != NULL) GetPapersize((Widget)0, (caddr_t)A3, (XmToggleButtonCallbackStruct *)0); else if (strstr(word, "Letter") != NULL) GetPapersize((Widget)0, (caddr_t)LETTER, (XmToggleButtonCallbackStruct *)0); else if (strstr(word, "Legal") != NULL) GetPapersize((Widget)0, (caddr_t)LEGAL, (XmToggleButtonCallbackStruct *)0); else { unknownResource("Viewmol.paperSize", word); GetPapersize((Widget)0, (caddr_t)A4, (XmToggleButtonCallbackStruct *)0); } } elements=(struct ELEMENT *)getmem(mne, sizeof(struct ELEMENT)); if (getenv("VIEWMOLPATH") == NULL) { sprintf(viewmolpath, "VIEWMOLPATH=%s", DEFAULTPATH); putenv(viewmolpath); } strcpy(rcfile, "viewmolrc"); if ((file=fopen(rcfile, "r")) == NULL) { if ((word=getenv("HOME")) != NULL) { strcpy(rcfile, word); strcat(rcfile, "/.viewmolrc"); } if ((file=fopen(rcfile, "r")) == NULL) { if ((word=getenv("VIEWMOLPATH")) != NULL) { strcpy(rcfile, word); strcat(rcfile, "/viewmolrc"); } if ((file=fopen(rcfile, "r")) == NULL) { word=getStringResource(topShell, "unableToOpen"); sprintf(line, word, "viewmolrc"); messgb(topShell, 3, line, buttons1, 1); exit(-1); } } } ne=0; osname(os); while (fgets(line, MAXLENLINE, file) != NULL) { nline++; error=FALSE; if (line[0] != '#') { if (strstr(line, "debug")) { word=strtok(line, "="); word=strtok(NULL, "="); debug=atoi(word); } else if (strstr(line, "option")) { if (options == NULL) options=(struct OPTION *)getmem(nopt+1, sizeof(struct OPTION)); else { oldOptions=options; options=(struct OPTION *)expmem((void *)options, nopt+1, sizeof(struct OPTION)); if (oldOptions != options) { /* Move pointer to identifier if expanding memory caused a move of the entire options structure */ for (i=0; i= mne) { mne+=10; elements=(struct ELEMENT *)expmem((void *)elements, mne, sizeof(struct ELEMENT)); } } /* end of "if (strstr(line ..." */ } /* end of "if (line[0] ... " */ } /* end of "while (fgets ..." */ if (nopt == 0) { word=getStringResource(topShell, "noInputFilter"); sprintf(line, word, rcfile); messgb(topShell, 3, line, buttons1, 1); exit(-1); } fclose(file); (void)setlocale(LC_ALL, locale); return(TRUE); } void setAtom(struct MOLECULE *mol) { static struct PushButtonRow buttons[] = {{"exit", GetMessageBoxButton, (XtPointer)0, NULL}, {"continue", GetMessageBoxButton, (XtPointer)1, NULL}}; XVisualInfo *visualInfo; Visual *vi; Colormap colormap; char *word, line[MAXLENLINE]; char *missing=NULL, test[5]; register int i, j, k; k=1; for (i=0; ina; i++) { for (j=0; jatoms[i].name, elements[j].symbol, 2)) { mol->atoms[i].rad=elements[j].rad; mol->atoms[i].radScale=1.0; mol->atoms[i].element=&elements[j]; break; } } if (mol->atoms[i].element == NULL) { if (missing == NULL) { k+=4; missing=(char *)getmem((size_t)k, sizeof(char)); strncat(missing, mol->atoms[i].name, 2); strncat(missing, ", ", 2); } else { strcpy(test, mol->atoms[i].name); strcat(test, ", "); if (!strstr(missing, test)) { k+=4; missing=(char *)expmem((void *)missing, (size_t)k, sizeof(char)); strncat(missing, mol->atoms[i].name, 2); strncat(missing, ", ", 2); } } mol->atoms[i].radScale=1.0; mol->atoms[i].mass=0.0; mol->atoms[i].nelectrons=0; mol->atoms[i].neutronScatterfac=0.0; for (j=0; jatoms[i].element=&elements[j]; mol->atoms[i].rad=elements[j].rad;; break; } } } for (j=0; jatoms[i].name, pse[j], 2)) { mol->atoms[i].mass=isotope[j][0]; mol->atoms[i].nelectrons=electrons[j]; mol->atoms[i].neutronScatterfac=0.0; break; } } } if (k > 1) { if (showWarning) { if (k > 5) word=getStringResource(topShell, "unknownElements"); else word=getStringResource(topShell, "unknownElement"); missing[strlen(missing)-2]='\0'; sprintf(line, word, missing); fremem((void **)&missing); if (!messgb(topShell, 3, line, buttons, 2)) exit(-1); } } if (mol->unitcell) { for (i=0; iunitcell->nc; j++) mol->unitcell->corners[j].element=&elements[i]; } setBond(mol); if (!rgbMode) { XtVaGetValues(topShell, XtNvisual, &vi, XmNcolormap, &colormap, NULL); visualInfo=getVisualInfo(XtDisplay(topShell), vi); loadAtomColors(visualInfo, colormap); } } void setBond(struct MOLECULE *mol) { register int i; for (i=0; ibondRadius=elements[i].rad; mol->bondStyle=&elements[i]; } } } void getPrimitive(char *line, int *primitive, int deflt) { if (strstr(line, "dot")) *primitive=GLU_POINT; else if (strstr(line, "line")) *primitive=GLU_LINE; else if (strstr(line, "surface")) *primitive=GLU_FILL; else *primitive=deflt; } int getColor(GLfloat *p) { char *word; if ((word=strtok(NULL, " \t")) == NULL) return(TRUE); p[0]=(float)atof(word); if (p[0] < 0.0) p[0]=0.0; if (p[0] > 1.0) p[0]=1.0; if ((word=strtok(NULL, " \t")) == NULL) return(TRUE); p[1]=(float)atof(word); if (p[1] < 0.0) p[1]=0.0; if (p[1] > 1.0) p[1]=1.0; if ((word=strtok(NULL, " \t")) == NULL) return(TRUE); p[2]=(float)atof(word); if (p[2] < 0.0) p[2]=0.0; if (p[2] > 1.0) p[2]=1.0; p[3]=0.0; return(FALSE); } void unknownResource(char *resource, char *value) { static struct PushButtonRow buttons[] = {{"exit", GetMessageBoxButton, (XtPointer)0, NULL}, {"continue", GetMessageBoxButton, (XtPointer)1, NULL}}; char *word, line[MAXLENLINE]; word=getStringResource(topShell, "unknownResource"); sprintf(line, word, value, resource); if (!messgb(topShell, 3, line, buttons, 2)) exit(-1); } void storeCommand(char *target, char *value, char *replacement) { char *p=value, *t=target; while (*p) { if (*p != '$') *t++=*p++; else { if (!strncmp(p, "$OSNAME", 7)) { strcpy(t, replacement); p+=7; t+=strlen(replacement); } else if (!strncmp(p, "${OSNAME}", 9)) { strcpy(t, replacement); p+=9; t+=strlen(replacement); } else *t++=*p++; } } *t='\0'; } void checkProgram(char *program, char *word) { char line[MAXLENLINE]; strncpy(program, word, MAXLENLINE); if ((word=strtok(program, " \t"))) { strcpy(line, strchr(program, '\0')+1); if (checkFile(&word)) { strncpy(program, word, MAXLENLINE); strcat(program, " "); strcat(program, line); return; } } program[0]='\0'; } void getFormats(void) { /* Get format strings for bond lengths, bond angles, and torsion angles */ formBondLength=getStringResource(topShell, "bondLength"); if (strstr(formBondLength, "pm")) bndfac=100.0; if (strstr(formBondLength, "bohr") || strstr(formBondLength, "au")) bndfac=1.0/0.52917706; formBondAngle=getStringResource(topShell, "bondAngle"); formTorsionAngle=getStringResource(topShell, "torsionAngle"); } viewmol-2.4.1/source/hardcopy.c0100644000272700027270000005223007752675705014646 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * H A R D C O P Y . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: hardcopy.c,v 1.6 2003/11/07 11:02:29 jrh Exp $ * $Log: hardcopy.c,v $ * Revision 1.6 2003/11/07 11:02:29 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:08:16 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:46 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:50:02 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:54 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:41:06 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "tiffio.h" #include "viewmol.h" #include "dialog.h" char *saveTiff(int, char *, int); char *saveVectorFile(int, char *, int); void writeTiff(TIFF *, unsigned char *, int, int, XColor *); char *savePng(int, char *, int); char *savePostScriptBitmap(int, char *); unsigned char *getImage(int, Dimension *, Dimension *, int *, int *, XColor *, int); int rle_encode(char *, char *, int); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern char *getStringResource(Widget, char *); extern FILE *hpglInit(char *, double, double, double, double, double, double, int); extern FILE *PostscriptInit(char *, double, double, double, int, int); extern void PostscriptClose(FILE *); extern void (*drawString)(char *, double, double, double, double, GLuint, char); extern FILE *raytraceInit(char *, Dimension, Dimension); extern void raytraceClose(FILE *); extern void setDrawingDevice(int); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern void redraw(int); extern void hpglClose(FILE *); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern int StringWidth(XFontStruct *, char *); extern int StringHeight(XFontStruct *); extern void setWindowColor(int, Pixel, const float *); extern void writeFeedback(FILE *, int, GLfloat *, int, int, int, int); extern XVisualInfo *getVisualInfo(Display *, Visual *); extern Widget topShell; extern struct MOLECULE *molecules; extern struct WINDOW windows[]; extern Pixel stdcol[9]; extern double paperWidth, paperHeight, sphereres; /* extern char title[]; */ extern char *text, *textPointer; /* extern int na, nb; */ extern int iwavef, shadows, ground; extern int rgbMode, swapBuffers, primitive, debug; char *saveTiff(int window, char *file, int compression) { static struct PushButtonRow buttons[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; FILE *f; TIFF *tif; struct passwd *entry; Dimension width, height; XColor *colors=NULL; unsigned char *image; char str[MAXLENLINE], *word; int ncolors, colorDepth, imol; register long rps; if (windows[window].set >= 0) imol=windows[window].set; else imol=0; if (&molecules[imol] == (struct MOLECULE *)NULL) return(NULL); /* Try to open file to catch possible problems with permissions before using TIFF library to open file */ if ((f=fopen(file, "w")) == NULL) { word=getStringResource(topShell, "unableToOpen"); sprintf(str, word, file); messgb(topShell, 1, str, buttons, 1); return(NULL); } else { fclose(f); if ((tif=TIFFOpen(file, "w")) == NULL) { word=getStringResource(topShell, "unableToOpen"); sprintf(str, word, file); messgb(topShell, 1, str, buttons, 1); return(NULL); } } image=getImage(window, &width, &height, &ncolors, &colorDepth, colors, FALSE); TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, width); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, height); TIFFSetField(tif, TIFFTAG_COMPRESSION, compression); rps=(long)8*1024/TIFFScanlineSize(tif); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rps == 0 ? 1L : rps); TIFFSetField(tif, TIFFTAG_XRESOLUTION, 1.0); TIFFSetField(tif, TIFFTAG_YRESOLUTION, 1.0); TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, 1); TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG); TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_BOTLEFT); entry=getpwuid(getuid()); TIFFSetField(tif, TIFFTAG_ARTIST, entry->pw_gecos); TIFFSetField(tif, TIFFTAG_IMAGEDESCRIPTION, molecules[imol].title); strcpy(str, PROGRAM); strcat(str, " "); strcat(str, VERSION); TIFFSetField(tif, TIFFTAG_SOFTWARE, str); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 3); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); writeTiff(tif, image, width, height, colors); TIFFClose(tif); if (colors != NULL) free((void *)colors); free((void *)image); word=getStringResource(topShell, "TIFFSaved"); return(word); } void writeTiff(TIFF *tif, unsigned char *image, int width, int height, XColor *colors) { unsigned char *scanline=NULL; unsigned char *ssc=NULL; unsigned int *ssi=NULL; register unsigned int v; register int i, j; register unsigned char *pp; if (colors) ssi=(unsigned int *)image; else ssc=image; if (colors) scanline=(unsigned char *)malloc(TIFFScanlineSize(tif)); for (j = 0; j < height; j++) { if (!colors) { scanline=(unsigned char *)ssc; ssc += 3*width; } else { pp = scanline; for (i = 0; i < width; i++) { v = *ssi; pp[0]=(char)colors[v].red; pp[1]=(char)colors[v].green; pp[2]=(char)colors[v].blue; pp += 3; ssi++; } } if (TIFFWriteScanline(tif, scanline, j, 0) < 0) break; } if (colors) free(scanline); } char *saveVectorFile(int window, char *file, int format) { static struct PushButtonRow buttons[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; FILE *f=NULL; Dimension width, height; int modeSave=windows[window].mode, nentries=(-1), size, shadowsSave; int imol; GLfloat *feedbackBuffer; double fontSizeX, fontSizeY; /*const float black[4] = {0.0, 0.0, 0.0, 0.0};*/ int portrait, smooth=FALSE, ntrials=5; char *word=NULL, str[MAXLENLINE]; const char *locale; if (windows[window].set >= 0) imol=windows[window].set; else imol=0; glXMakeCurrent(XtDisplay(windows[window].widget), XtWindow(windows[window].widget), windows[window].context); swapBuffers=FALSE; shadowsSave=shadows; if (format != POSTSCRIPT) shadows=FALSE; strcpy(str, PROGRAM); strcat(str, " "); strcat(str, VERSION); strcat(str, ": "); strcat(str, molecules[imol].title); XtVaGetValues(windows[window].widget, XtNwidth, &width, XtNheight, &height, NULL); portrait=paperWidth < paperHeight ? TRUE : FALSE; fontSizeX=(double)StringWidth((windows[window].font), "1000."); fontSizeY=(double)StringHeight(windows[window].font); locale=setlocale(LC_ALL, "C"); switch (format) { case HPGL: f=hpglInit(file, (double)width, (double)height, paperWidth, paperHeight, fontSizeX/110., fontSizeY/40., portrait); ground=FALSE; break; case POSTSCRIPT: if (window == VIEWER && (windows[window].mode != WIREMODEL || iwavef != ALL_OFF) && primitive == GLU_FILL) smooth=TRUE; f=PostscriptInit(file, paperWidth, paperHeight, fontSizeY, window, smooth); break; case RAYTRACER: f=raytraceInit(file, width, height); if (windows[window].mode == WIREMODEL) windows[window].mode=STICKMODEL; break; } if (f != NULL) { setDrawingDevice(format); if (format == RAYTRACER) redraw(window); else { size=(size_t)(molecules[imol].na*(sphereres/10.+0.1)*(sphereres/10.+0.1) *4152+molecules[imol].nb*1000.*sphereres/10.); feedbackBuffer=getmem(size, sizeof(GLfloat)); text=(char *)getmem(200, sizeof(char)); textPointer=text; while (nentries < 0 && ntrials) { glFeedbackBuffer(size, GL_3D_COLOR, feedbackBuffer); (void)glRenderMode(GL_FEEDBACK); redraw(window); /* setWindowColor(FOREGROUND, stdcol[BLACK], black); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(windows[window].left, windows[window].right, windows[window].bottom, windows[window].top, windows[window].near, windows[window].far); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); (*drawString)(str, windows[window].right, windows[window].bottom, windows[window].near, 1.0, windows[window].GLfontId, 'l'); glPopMatrix(); */ nentries=glRenderMode(GL_RENDER); if (debug) printf("Size of feedback buffer: %d, used: %d\n", size, nentries); if (nentries > 0) writeFeedback(f, nentries, feedbackBuffer, window, format, smooth, portrait); else { size*=2; feedbackBuffer=expmem((void *)feedbackBuffer, (size_t)size, sizeof(GLfloat)); ntrials--; } } fremem((void *)&feedbackBuffer); fremem((void *)&text); if (!ntrials) { word=getStringResource(topShell, "unableToWriteFeedback"); messgb(topShell, 1, word, buttons, 1); } } setDrawingDevice(SCREEN); } else { word=getStringResource(topShell, "unableToOpen"); sprintf(str, word, file); messgb(topShell, 1, str, buttons, 1); swapBuffers=TRUE; shadows=shadowsSave; return(NULL); } switch (format) { case HPGL: hpglClose(f); word=getStringResource(topShell, "HPGLSaved"); ground=TRUE; break; case POSTSCRIPT: PostscriptClose(f); word=getStringResource(topShell, "PostscriptSaved"); break; case RAYTRACER: raytraceClose(f); word=getStringResource(topShell, "RaytracerSaved"); windows[window].mode=modeSave; break; } swapBuffers=TRUE; shadows=shadowsSave; (void)setlocale(LC_ALL, locale); return(word); } char *savePng(int window, char *file, int transparentBackground) { static struct PushButtonRow buttons[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; char str[MAXLENLINE], *word; #ifdef PNG_MAX_PALETTE_LENGTH FILE *f; png_structp pngStruct; png_infop pngInfo; png_colorp palette=(png_colorp)NULL; png_time modTime; png_color_16 background; png_text text[4]; png_byte *image; png_bytepp rowPointers; struct passwd *entry; Dimension width, height; XColor *colors=NULL; int ncolors, colorDepth, imol; register png_uint_32 i; if (windows[window].set >= 0) imol=windows[window].set; else imol=0; if (&molecules[imol] == (struct MOLECULE *)NULL) return(NULL); if (!(pngStruct=png_create_write_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, NULL, NULL))) { return(NULL); } if (!(pngInfo=png_create_info_struct(pngStruct))) { png_destroy_write_struct(&pngStruct, (png_infopp)NULL); return(NULL); } if (setjmp(png_jmpbuf(pngStruct))) { png_destroy_write_struct(&pngStruct, &pngInfo); return(NULL); } if ((f=fopen(file, "wb")) == NULL) { png_destroy_write_struct(&pngStruct, &pngInfo); word=getStringResource(topShell, "unableToOpen"); sprintf(str, word, file); messgb(topShell, 1, str, buttons, 1); return(NULL); } png_init_io(pngStruct, f); image=(png_byte *)getImage(window, &width, &height, &ncolors, &colorDepth, colors, FALSE); if (colorDepth < 8) colorDepth=8; png_set_IHDR(pngStruct, pngInfo, (png_uint_32)width, (png_uint_32)height, colorDepth, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); if (colors != NULL) { palette=(png_colorp)png_malloc(pngStruct, PNG_MAX_PALETTE_LENGTH*sizeof(png_color)); for (i=0; ipw_gecos; text[1].compression=PNG_TEXT_COMPRESSION_NONE; strcpy(str, PROGRAM); strcat(str, " "); strcat(str, VERSION); text[2].key="Software"; text[2].text=str; text[2].compression=PNG_TEXT_COMPRESSION_NONE; text[3].key="Creation Time"; text[3].text=png_convert_to_rfc1123(pngStruct, &modTime); text[3].compression=PNG_TEXT_COMPRESSION_NONE; png_set_text(pngStruct, pngInfo, text, 4); png_write_end(pngStruct, pngInfo); if (colors != NULL) { png_free(pngStruct, palette); fremem((void *)colors); } fremem((void *)&image); fremem((void *)&rowPointers); png_destroy_write_struct(&pngStruct, &pngInfo); fclose(f); word=getStringResource(topShell, "PNGSaved"); return(word); #else word=getStringResource(topShell, "wrongPNGversion"); sprintf(str, word, PNG_LIBPNG_VER_STRING); messgb(topShell, 1, str, buttons, 1); return(NULL); #endif } char *savePostScriptBitmap(int window, char *file) { static struct PushButtonRow buttons[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; FILE *f; char str[MAXLENLINE], *word; Dimension width, height; XColor *colors=NULL; double fontSizeY; int ncolors, colorDepth, imol, icount, i, j; const char *locale; unsigned char *image; if (windows[window].set >= 0) imol=windows[window].set; else imol=0; if (&molecules[imol] == (struct MOLECULE *)NULL) return(NULL); fontSizeY=(double)StringHeight(windows[window].font); f=PostscriptInit(file, paperWidth, paperHeight, fontSizeY, window, FALSE); if (f == NULL) { word=getStringResource(topShell, "unableToOpen"); sprintf(str, word, file); messgb(topShell, 1, str, buttons, 1); return(NULL); } image=getImage(window, &width, &height, &ncolors, &colorDepth, colors, FALSE); locale=setlocale(LC_ALL, "C"); icount=0; for (i=0; i= 78) { /* Limit line length to 80 characters maximum */ fprintf(f, "\n"); icount=0; } } } fremem((void *)&image); fprintf(f, "\n"); locale=setlocale(LC_ALL, locale); PostscriptClose(f); word=getStringResource(topShell, "PostscriptSaved"); return(word); } unsigned char *getImage(int window, Dimension *width, Dimension *height, int *ncolors, int *colorDepth, XColor *colors, int separate) { Colormap colormap; Visual *vi; XVisualInfo *visualInfo; unsigned char *image, *pimage; int i, offset; XtVaGetValues(windows[window].widget, XmNwidth, width, XmNheight, height, XmNcolormap, &colormap, NULL); if (*width % 4 != 0) *width-=(*width % 4); XtVaGetValues(topShell, XtNvisual, &vi, NULL); visualInfo=getVisualInfo(XtDisplay(windows[window].widget), vi); *ncolors=visualInfo->colormap_size; *colorDepth=visualInfo->bits_per_rgb; glXMakeCurrent(XtDisplay(windows[window].widget), XtWindow(windows[window].widget), windows[window].context); if (rgbMode) { image=(unsigned char *)getmem((*width+1)*(*height+1), 3*sizeof(unsigned char)); if (separate) { pimage=image; offset=(*width+1)*(*height+1); glReadPixels((GLint)0, (GLint)0, (GLsizei)(*width), (GLsizei)(*height), GL_RED, GL_UNSIGNED_BYTE, pimage); pimage+=offset; glReadPixels((GLint)0, (GLint)0, (GLsizei)(*width), (GLsizei)(*height), GL_GREEN, GL_UNSIGNED_BYTE, pimage); pimage+=offset; glReadPixels((GLint)0, (GLint)0, (GLsizei)(*width), (GLsizei)(*height), GL_BLUE, GL_UNSIGNED_BYTE, pimage); } else glReadPixels((GLint)0, (GLint)0, (GLsizei)(*width), (GLsizei)(*height), GL_RGB, GL_UNSIGNED_BYTE, image); } else { image=(unsigned char *)getmem((*width+1)*(*height+1), sizeof(unsigned int)); glReadPixels((GLint)0, (GLint)0, (GLsizei)(*width), (GLsizei)(*height), GL_COLOR_INDEX, GL_UNSIGNED_INT, image); colors=(XColor *)getmem(*ncolors, sizeof(XColor)); for (i=0; i<*ncolors; i++) colors[i].pixel=(long)i; XQueryColors(XtDisplay(windows[window].widget), colormap, colors, *ncolors); for (i=0; i<*ncolors; i++) { colors[i].red >>= 8; colors[i].green >>= 8; colors[i].blue >>= 8; } } return(image); } #if 0 int rle_encode(char *scanline, char *rleline, int wide) { /* generates a rle-compressed version of the scan line. * rle is encoded as such: * # 'run' of count+1 equal pixels * # count+1 non-equal pixels * * count can range between 0 and 127 * * returns length of the rleline vector */ int i, j, blocklen, isrun, rlen; char block[256], pix; blocklen = isrun = rlen = 0; for (i=0; i1) { /* we have a run block to flush */ rleline[rlen++] = blocklen-1; rleline[rlen++] = block[0]; block[0] = pix; /* start new run block with pix */ blocklen = 1; } else { isrun = 0; /* blocklen<=1, turn into non-run */ block[blocklen++] = pix; } } } else { /* not a run */ if (pix == block[blocklen-1]) { /* case 3: non-run, prev==cur */ if (blocklen>1) { /* have a non-run block to flush */ rleline[rlen++] = (blocklen-1) | 0x80; for (j=0; j #include #include #include #include #include #include "viewmol.h" #define PyHistory_API_pointers 1 #define PyHistorySpec_Type_NUM 0 extern void initSpectrum(Widget, caddr_t, caddr_t); extern void initMODiagram(Widget, caddr_t, caddr_t); extern void initHistory(Widget, caddr_t, caddr_t); extern void drawHistory(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void GetDiagram(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void setMenuItem(int, int); extern void setHistoryAnimation(Widget, caddr_t, XmAnyCallbackStruct *); extern void selectMolecule(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void redraw(int); extern void setGeometry(int); extern void saveDrawing(int, int, char *); extern int checkInterrupt(void); extern void quitHistory(Widget, caddr_t, XmAnyCallbackStruct *); extern void getScreenCoordinates(double, double, double, double *, double *, double *); PyHistorySpecObject *history_new(void); static PyObject *history_show(PyObject *, PyObject *); static PyObject *history_showEnergy(PyObject *, PyObject *); static PyObject *history_showGradient(PyObject *, PyObject *); static PyObject *history_showScales(PyObject *, PyObject *); static PyObject *history_animate(PyObject *, PyObject *); static PyObject *history_iteration(PyObject *, PyObject *); static PyObject *history_saveDrawing(PyObject *, PyObject *); static PyObject *history_getattr(PyHistorySpecObject *, char *); static void history_dealloc(PyHistorySpecObject *); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern int nmolecule, showForces, showInertia, label; static char PyHistorySpec_Type__doc__[] = "History specification"; statichere PyTypeObject PyHistorySpec_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "HistorySpec", /*tp_name*/ sizeof(PyHistorySpecObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)history_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)history_getattr, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ /* Space for future expansion */ 0L,0L, /* Documentation string */ PyHistorySpec_Type__doc__ }; #include "menudef.h" static PyMethodDef history_methods[] = { {"show", history_show, 1}, {"showEnergy", history_showEnergy, 1}, {"showGradient", history_showGradient, 1}, {"showScales", history_showScales, 1}, {"animate", history_animate, 1}, {"iteration", history_iteration, 1}, {"saveDrawing", history_saveDrawing, 1}, {NULL, NULL} }; PyHistorySpecObject *history_new(void) { PyHistorySpecObject *self; self=PyObject_NEW(PyHistorySpecObject, &PyHistorySpec_Type); if (self == NULL) { PyErr_NoMemory(); return(NULL); } self->historyID=0; return(self); } static PyObject *history_show(PyObject *self, PyObject *args) { PyHistorySpecObject *s; XmToggleButtonCallbackStruct data; int which, set_save; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyHistorySpecObject *)self; which=s->historyID; if (windows[HISTORY].widget == NULL) { set_save=windows[VIEWER].set; windows[VIEWER].set=which; initHistory((Widget)0, (caddr_t)0, (caddr_t)0); windows[VIEWER].set=set_save; } else { windows[HISTORY].set=which; if (nmolecule > 1) { data.set=TRUE; (void)selectMolecule((Widget)0, (XtPointer)&(windows[HISTORY].selectMenu[which]), &data); } redraw(HISTORY); } Py_INCREF(Py_None); return(Py_None); } static PyObject *history_showEnergy(PyObject *self, PyObject *args) { XmToggleButtonCallbackStruct data; PyHistorySpecObject *s; int status, which, set_save; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "i", &status)) return(NULL); if (status != TRUE && status != FALSE) { PyErr_SetString(PyExc_ValueError, "Status must be ON or OFF"); return(NULL); } s=(PyHistorySpecObject *)self; which=s->historyID; set_save=windows[HISTORY].set; windows[HISTORY].set=which; data.set=status; GetDiagram((Widget)0, (caddr_t)ENERGY, &data); windows[HISTORY].set=set_save; redraw(HISTORY); Py_INCREF(Py_None); return(Py_None); } static PyObject *history_showGradient(PyObject *self, PyObject *args) { XmToggleButtonCallbackStruct data; PyHistorySpecObject *s; int status, which, set_save; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "i", &status)) return(NULL); if (status != TRUE && status != FALSE) { PyErr_SetString(PyExc_ValueError, "Status must be ON or OFF"); return(NULL); } s=(PyHistorySpecObject *)self; which=s->historyID; set_save=windows[HISTORY].set; windows[HISTORY].set=which; data.set=status; GetDiagram((Widget)0, (caddr_t)GNORM, &data); windows[HISTORY].set=set_save; redraw(HISTORY); Py_INCREF(Py_None); return(Py_None); } static PyObject *history_showScales(PyObject *self, PyObject *args) { XmToggleButtonCallbackStruct data; PyHistorySpecObject *s; int status, which, set_save; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "i", &status)) return(NULL); if (status != TRUE && status != FALSE) { PyErr_SetString(PyExc_ValueError, "Status must be ON or OFF"); return(NULL); } s=(PyHistorySpecObject *)self; which=s->historyID; set_save=windows[HISTORY].set; windows[HISTORY].set=which; data.set=status; GetDiagram((Widget)0, (caddr_t)SCALES, &data); windows[HISTORY].set=set_save; redraw(HISTORY); Py_INCREF(Py_None); return(Py_None); } static PyObject *history_animate(PyObject *self, PyObject *args) { int status; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "i", &status)) return(NULL); if (status != TRUE && status != FALSE) { PyErr_SetString(PyExc_ValueError, "Status must be ON or OFF"); return(NULL); } if (status) { setHistoryAnimation((Widget)0, (caddr_t)1, (XmAnyCallbackStruct *)0); /* XtVaSetValues(historyMenu[HISTORY_ANIMATE & 0xff].widget, XmNset, True, NULL);*/ } else { setHistoryAnimation((Widget)0, (caddr_t)2, (XmAnyCallbackStruct *)0); /* XtVaSetValues(historyMenu[HISTORY_ANIMATE & 0xff].widget, XmNset, False, NULL);*/ } redraw(HISTORY); Py_INCREF(Py_None); return(Py_None); } static PyObject *history_iteration(PyObject *self, PyObject *args) { PyHistorySpecObject *s; double xw, yw, zw; int which, set_save, i=(-1); if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|i", &i)) return(NULL); s=(PyHistorySpecObject *)self; which=s->historyID; if (i == -1) /* get */ return(PyInt_FromLong((long)molecules[which].cycle)); else /* set */ { if (i < 1 || i > molecules[which].nhist) { PyErr_SetString(PyExc_ValueError, "Number of iteration out of range"); return(NULL); } molecules[which].cycle=i; set_save=windows[HISTORY].set; windows[HISTORY].set=which; setGeometry(TRUE); drawHistory((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); getScreenCoordinates((double)(i), 0.0, 0.0, &xw, &yw, &zw); windows[HISTORY].mouseX=(int)xw; drawHistory((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); windows[HISTORY].set=set_save; redraw(HISTORY); Py_INCREF(Py_None); return(Py_None); } } static PyObject *history_saveDrawing(PyObject *self, PyObject *args) { int format; char *filename; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "is", &format, &filename)) return NULL; if (!access(filename, F_OK)) { PyErr_SetString(PyExc_IOError, "File already exists."); return(NULL); } if (format != TIFFFILE && format != PNGFILE && format != HPGL && format != POSTSCRIPT) { PyErr_SetString(PyExc_ValueError, "Format not recognised."); return(NULL); } saveDrawing(HISTORY, format, filename); Py_INCREF(Py_None); return(Py_None); } static void history_dealloc(PyHistorySpecObject *self) { if (!self) return; PyMem_DEL(self); quitHistory((Widget)0, (caddr_t)0, (XmAnyCallbackStruct *)0); (void)checkInterrupt(); } static PyObject *history_getattr(PyHistorySpecObject *self, char *name) { return(Py_FindMethod(history_methods, (PyObject *)self, name)); } void initHistoryModule(void) { PyObject *module, *dict; static void *PyHistory_API[PyHistory_API_pointers]; PyHistorySpec_Type.ob_type=&PyType_Type; module=Py_InitModule("history", history_methods); dict=PyModule_GetDict(module); PyHistory_API[PyHistorySpec_Type_NUM]=(void *)&PyHistorySpec_Type; PyDict_SetItemString(dict, "_C_API", PyCObject_FromVoidPtr((void *)PyHistory_API, NULL)); } viewmol-2.4.1/source/hpgl.c0100644000272700027270000003670207752675727014001 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * H P G L . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: hpgl.c,v 1.6 2003/11/07 11:02:47 jrh Exp $ * $Log: hpgl.c,v $ * Revision 1.6 2003/11/07 11:02:47 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:08:55 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:49 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:50:09 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:47:56 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:41:12 jrh * Initial revision * */ #include #include #include #include #include "viewmol.h" #include "dialog.h" extern char *textPointer; static double fsx, fsy, stipple[8*sizeof(GLushort)]; static GLfloat pointSize, xold, yold; static int nstipple=0, lastpen=0; FILE *hpglInit(char *, double, double, double, double, double, double, int); void hpglClose(FILE *); void hpglSetRGBColor(FILE *, GLfloat, GLfloat, GLfloat); void hpglMoveto(FILE *, int, GLfloat, GLfloat); void hpglLineto(FILE *, int, GLfloat, GLfloat); void hpglTriangle(FILE *, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); void hpglTriangleColor(FILE *, GLfloat, GLfloat, GLfloat); void hpglPoint(FILE *, int, GLfloat, GLfloat); void hpglLineStipple(FILE *, GLushort); void hpglShowString(FILE *, int, GLfloat, GLfloat); FILE *hpglInit(char *filename, double width, double height, double paperWidth, double paperHeight, double fontSizeX, double fontSizeY, int portrait) { FILE *file; register double xs, ys, offset; if ((file=fopen(filename, "w")) == NULL) return(NULL); fprintf(file, "IN;\n"); if (paperHeight*width/height > paperWidth) { xs=width; if (portrait) { ys=paperHeight*width/paperWidth; offset=0.5*(height-ys); fprintf(file, "SC%f,%f,0.0,%f;\n", ys+offset, offset, xs); } else { ys=paperWidth*height/paperHeight; offset=0.5*(height-ys); fprintf(file, "SC0.0,%f,%f,%f;\n", xs, offset, ys+offset); } } else { ys=height; if (portrait) { xs=paperHeight*width/paperWidth; offset=0.5*(width-xs); fprintf(file, "SC%f,0.0,%f,%f;\n", ys, offset, xs+offset); } else { xs=paperWidth*height/paperHeight; offset=0.5*(width-xs); fprintf(file, "SC%f,%f,0.0,%f;\n", offset, xs+offset, ys); } } fsx=fontSizeX; fsy=fontSizeY; lastpen=0; glGetFloatv(GL_POINT_SIZE, &pointSize); return(file); } void hpglClose(FILE *file) { fprintf(file, "SP0;"); fclose(file); } void hpglSetRGBColor(FILE *file, GLfloat red, GLfloat green, GLfloat blue) { static GLfloat pens[16][3]; register int i; for (i=0; i x && xv > 0.0) || (xold < x && xv < 0.0)) { xold=x; loop=FALSE; } if ((yold > y && yv > 0.0) || (yold < y && yv < 0.0)) { yold=y; loop=FALSE; } if (portrait) j+=fprintf(file, "%s%f,%f;", pen, yold, xold); else j+=fprintf(file, "%s%f,%f;", pen, xold, yold); if (j > 80) { fprintf(file, "\n"); j=0; } if (!loop) break; if (pen == pd) pen=pu; else pen=pd; } } } else { if (portrait) fprintf(file, "PD%f,%f;\n", y, x); else fprintf(file, "PD%f,%f;\n", x, y); } } void hpglTriangle(FILE *file, GLfloat x1, GLfloat x2, GLfloat x3, GLfloat y1, GLfloat y2, GLfloat y3) { } void hpglTriangleColor(FILE *file, GLfloat red, GLfloat green, GLfloat blue) { } void hpglPoint(FILE *file, int portrait, GLfloat x, GLfloat y) { if (portrait) fprintf(file, "PU%f,%f;\nPD;AA%f,%f,360,0;\n", y-pointSize*0.5, x, y, x); else fprintf(file, "PU%f,%f;\nPD;AA%f,%f,360,0;\n", x-pointSize*0.5, y, x, y); } void hpglLineStipple(FILE *file, GLushort style) { int last; register int i, j; if (style == 0xffff) nstipple=0; else { j=0; stipple[j]=1; last=style & 0x1; for (i=1; i<8*sizeof(GLushort); i++) { if (((style & (0x1 << i)) >> i) == last) stipple[j]++; else { last=(style & (0x1 << i)) >> i; stipple[++j]=1; } } nstipple=j; } } void hpglShowString(FILE *file, int portrait, GLfloat x, GLfloat y) { /* This subroutine plots the string pointed to by textPointer scaled with sf starting at the position x, y, and 0.0. Plotting is done to the file pointed to by file. */ /* Character data */ static short chr[]={ /* ! */ 28,8,11,8,15,8,15,12,15,12,15,12,11,12,11,8,11,10,20,5,40,5,40,16,40,16,40, 10,20, /* " */ 24,3,40,8,40,8,40,8,30,8,30,3,40,13,40,18,40,18,40,18,30,18,30,13,40, /* # */ 16,3,22,19,22,3,30,19,30,7,18,7,34,15,18,15,34, /* $ */ 48,3,15,7,11,7,11,14,11,14,11,18,15,18,15,18,22,18,22,14,26,14,26,7,26,7,26, 3,30,3,30,3,36,3,36,7,40,7,40,14,40,14,40,18,36,11,40,11,11, /* % */ 36,3,11,18,40,3,40,10,40,10,40,10,33,10,33,3,33,3,33,3,40,11,18,18,18,18,18, 18,11,18,11,11,11,11,11,11,18, /* & */ 48,18,22,14,22,14,22,14,15,14,15,10,11,10,11,7,11,7,11,3,15,3,15,3,22,3,22, 14,30,14,30,14,36,14,36,10,40,10,40,5,36,5,36,5,30,5,30,18,11, /* ' */ 12,8,40,13,40,13,40,13,30,13,30,8,40, /* ( */ 12,6,11,3,20,3,20,3,31,3,31,6,40, /* ) */ 12,15,11,18,20,18,20,18,31,18,31,15,40, /* * */ 16,3,26,19,26,11,18,11,34,3,18,19,34,3,34,19,18, /* + */ 8,3,26,19,26,11,18,11,34, /* , */ 24,8,15,8,20,8,20,12,20,12,20,12,15,12,15,9,11,9,11,10,15,10,15,8,15, /* - */ 4,3,26,18,26, /* . */ 16,8,11,8,15,8,15,12,15,12,15,12,11,12,11,8,11, /* / */ 4,3,11,18,40, /* 0 */ 36,3,15,3,36,3,36,7,40,7,40,14,40,14,40,18,36,18,36,18,15,18,15,14,11,14,11, 7,11,7,11,3,15,3,15,18,36, /* 1 */ 8,3,26,11,40,11,40,11,11, /* 2 */ 28,3,30,3,36,3,36,7,40,7,40,14,40,14,40,18,36,18,36,18,30,18,30,3,11,3,11,18, 11, /* 3 */ 32,3,40,18,40,18,40,11,26,11,26,14,26,14,26,18,22,18,22,18,15,18,15,14,11,14, 11,7,11,7,11,3,15, /* 4 */ 12,3,15,14,40,14,20,14,11,3,15,18,15, /* 5 */ 32,3,15,7,11,7,11,14,11,14,11,18,15,18,15,18,22,18,22,14,26,14,26,3,26,3,26, 3,40,3,40,18,40, /* 6 */ 44,3,22,7,26,7,26,14,26,14,26,18,22,18,22,18,15,18,15,14,11,14,11,7,11,7,11, 3,15,3,15,3,36,3,36,7,40,7,40,14,40,14,40,18,36, /* 7 */ 8,3,40,18,40,18,40,7,11, /* 8 */ 60,3,15,3,22,3,22,7,26,7,26,14,26,14,26,18,30,18,30,18,36,18,36,14,40,14,40, 7,40,7,40,3,36,3,36,3,30,3,30,7,26,14,26,18,22,18,22,18,15,18,15,14,11,14,11, 7,11,7,11,3,15, /* 9 */ 40,3,15,7,11,7,11,14,11,14,11,18,15,18,15,18,36,18,36,14,40,14,40,7,40,7,40, 3,36,3,36,3,30,3,30,7,26,7,26,18,26, /* : */ 32,8,25,8,30,8,30,12,30,12,30,12,25,12,25,8,25,8,15,8,20,8,20,12,20,12,20,12, 15,12,15,8,15, /* ; */ 40,8,25,8,30,8,30,12,30,12,30,12,25,12,25,8,25,8,15,8,20,8,20,12,20,12,20,12, 15,12,15,9,11,9,11,10,15,10,15,8,15, /* < */ 8,10,16,3,23,3,23,10,30, /* = */ 8,3,29,18,29,18,23,3,23, /* > */ 8,11,30,18,23,18,23,11,16, /* ? */ 48,8,11,8,15,8,15,12,15,12,15,12,11,12,11,8,11,8,20,18,30,18,30,18,36,18,36, 14,40,14,40,7,40,7,40,3,36,3,36,10,36,10,36,13,33,13,33,8,20, /* @ */ 0, /* A */ 24,3,11,3,36,3,36,7,40,7,40,14,40,14,40,18,36,18,36,18,11,18,26,3,26, /* B */ 40,3,11,3,40,3,40,14,40,14,40,18,36,18,36,18,30,18,30,14,26,14,26,3,26,14,26, 18,22,18,22,18,15,18,15,14,11,14,11,3,11, /* C */ 28,18,15,14,11,14,11,7,11,7,11,3,15,3,15,3,36,3,36,7,40,7,40,14,40,14,40,18, 36, /* D */ 24,3,11,3,40,3,40,14,40,14,40,18,36,18,36,18,15,18,15,14,11,14,11,3,11, /* E */ 16,3,11,3,40,3,40,18,40,14,26,3,26,3,11,18,11, /* F */ 12,3,11,3,40,3,40,18,40,14,26,3,26, /* G */ 36,11,26,18,26,18,26,18,15,18,15,14,11,14,11,7,11,7,11,3,15,3,15,3,36,3,36, 7,40,7,40,14,40,14,40,18,36, /* H */ 12,3,11,3,40,18,40,18,11,18,26,3,26, /* I */ 12,7,11,14,11,11,11,11,40,7,40,14,40, /* J */ 16,3,15,7,11,7,11,14,11,14,11,18,15,18,15,18,40, /* K */ 16,3,11,3,40,18,40,11,26,11,26,3,26,11,26,18,11, /* L */ 8,3,40,3,11,3,11,18,11, /* M */ 16,3,11,3,40,3,40,11,26,11,26,18,40,18,40,18,11, /* N */ 12,3,11,3,40,3,40,18,11,18,11,18,40, /* O */ 32,3,15,3,36,3,36,7,40,7,40,14,40,14,40,18,36,18,36,18,15,18,15,14,11,14,11, 7,11,7,11,3,15, /* P */ 24,3,11,3,40,3,40,14,40,14,40,18,36,18,36,18,30,18,30,14,26,14,25,3,26, /* Q */ 36,3,15,3,36,3,36,7,40,7,40,14,40,14,40,18,36,18,36,18,15,18,15,14,11,14,11, 7,11,7,11,3,15,14,15,18,11, /* R */ 28,3,11,3,40,3,40,14,40,14,40,18,36,18,36,18,30,18,30,14,26,14,26,3,26,14, 26,18,11, /* S */ 44,3,15,7,11,7,11,14,11,14,11,18,15,18,15,18,22,18,22,14,26,14,26,7,26,7, 26,3,30,3,30,3,36,3,36,7,40,7,40,14,40,14,40,18,36, /* T */ 8,11,11,11,40,3,40,18,40, /* U */ 20,3,40,3,15,3,15,7,11,7,11,14,11,14,11,18,15,18,15,18,40, /* V */ 8,3,40,11,11,11,11,18,40, /* W */ 24,3,40,3,15,3,15,7,11,7,11,11,15,11,15,14,11,14,11,18,15,18,15,18,40, /* X */ 8,3,40,18,11,3,11,18,40, /* Y */ 12,3,40,11,26,11,26,18,40,11,26,11,11, /* Z */ 12,3,40,18,40,18,40,3,11,3,11,18,11, /* [ */ 0, /* \ */ 4,3,40,18,11, /* ] */ 0, /* ^ */ 0, /* _ */ 4,3,11,18,11, /* ` */ 0, /* a */ 32,3,15,3,22,3,22,7,26,7,26,14,26,14,26,18,22,18,26,18,11,18,15,14,11,14, 11,7,11,7,11,3,15, /* b */ 32,3,11,3,40,3,22,7,26,7,26,14,26,14,26,18,22,18,22,18,15,18,15,14,11,14, 11,7,11,7,11,3,15, /* c */ 28,18,15,14,11,14,11,7,11,7,11,3,15,3,15,3,22,3,22,7,26,7,26,14,26,14,26, 18,22, /* d */ 32,18,15,14,11,14,11,7,11,7,11,3,15,3,15,3,22,3,22,7,26,7,26,14,26,14,26, 18,22,18,40,18,11, /* e */ 36,18,15,14,11,14,11,7,11,7,11,3,15,3,15,3,22,3,22,7,26,7,26,14,26,14,26, 18,22,18,22,18,18,18,18,3,18, /* f */ 20,7,11,7,36,7,36,11,40,11,40,14,40,14,40,18,36,11,26,3,26, /* g */ 44,3,5,7,1,7,1,14,1,14,1,18,5,18,5,18,26,18,22,14,26,14,26,7,26,7,26,3,22, 3,22,3,15,3,15,7,11,7,11,14,11,14,11,18,15, /* h */ 20,3,11,3,40,3,22,7,26,7,26,14,26,14,26,18,22,18,22,18,11, /* i */ 16,7,11,14,11,11,11,11,26,11,26,7,26,11,31,11,34, /* j */ 20,5,5,9,1,9,1,12,1,12,1,16,5,16,5,16,26,16,31,16,34, /* k */ 12,3,11,3,40,18,27,3,19,3,19,18,11, /* l */ 12,7,11,14,11,11,11,11,40,11,40,7,40, /* m */ 28,3,11,3,26,3,22,7,26,7,26,11,22,11,22,11,11,11,22,15,26,15,26,19,22,19, 22,19,11, /* n */ 20,3,11,3,26,3,22,7,26,7,26,14,26,14,26,18,22,18,22,18,11, /* o */ 32,3,15,3,22,3,22,7,26,7,26,14,26,14,26,18,22,18,22,18,15,18,15,14,11,14, 11,7,11,7,11,3,15, /* p */ 32,3,1,3,26,3,22,7,26,7,26,14,26,14,26,18,22,18,22,18,15,18,15,14,11,14, 11,7,11,7,11,3,15, /* q */ 32,18,15,14,11,14,11,7,11,7,11,3,15,3,15,3,22,3,22,7,26,7,26,14,26,14, 26,18,22,18,26,18,1, /* r */ 16,3,11,3,26,3,22,7,26,7,26,14,26,14,26,18,22, /* s */ 36,3,15,7,11,7,11,14,11,14,11,18,15,18,15,14,19,14,19,6,19,6,19,3,22,3, 22,7,26,7,26,14,26,14,26,18,22, /* t */ 20,18,15,14,11,14,11,10,11,10,11,6,15,6,15,6,40,3,26,9,26, /* u */ 20,3,26,3,15,3,15,7,11,7,11,14,11,14,11,18,15,18,11,18,26, /* v */ 12,3,26,10,11,10,11,11,11,11,11,18,26, /* w */ 24,3,26,3,15,3,15,7,11,7,11,11,15,11,15,15,11,15,11,19,15,19,15,19,26, /* x */ 8,3,26,18,11,3,11,18,26, /* y */ 32,3,5,7,1,7,1,14,1,14,1,18,5,18,5,18,26,3,26,3,15,3,15,7,11,7,11,14, 11,14,11,18,15, /* z */ 12,3,26,18,26,18,26,3,11,3,11,18,11, /* { */ 0, /* | */ 4,10,11,10,40, /* } */ 0, /* ~ */ 0, /* ° */ 32,3,29,3,36,3,36,7,40,7,40,14,40,14,40,18,36,18,36,18,29,18,29,14,25,14, 25,7,25,7,25,3,29, /* Ä (Adiaeresis) */ 32,3,11,3,36,3,36,7,40,7,40,14,40,14,40,18,36,18,36,18,11,18,26,3,26,7, 43,7,46,14,43,14,46, /* Ö (Odiaeresis) */ 40,3,15,3,36,3,36,7,40,7,40,14,40,14,40,18,36,18,36,18,15,18,15,14,11, 14,11,7,11,7,11,3,15,7,43,7,46,14,43,14,46, /* Ü (Udiaeresis) */ 28,3,40,3,15,3,15,7,11,7,11,14,11,14,11,18,15,18,15,18,40,7,43,7,46,14, 43,14,46, /* ß (ssharp) */ 44,3,1,3,36,3,36,7,40,7,40,14,40,14,40,18,36,18,36,18,30,18,30,14,26,14, 26,11,26,14,26,18,22,18,22,18,15,18,15,14,11,14,11,7,11, /* ä (adiaeresis) */ 40,3,15,3,22,3,22,7,26,7,26,14,26,14,26,18,22,18,26,18,11,18,15,14,11, 14,11,7,11,7,11,3,15,7,28,7,31,14,28,14,31, /* ö (odiaeresis) */ 40,3,15,3,22,3,22,7,26,7,26,14,26,14,26,18,22,18,22,18,15,18,15,14,11, 14,11,7,11,7,11,3,15,7,28,7,31,14,28,14,31, /* ü (udiaeresis) */ 28,3,26,3,15,3,15,7,11,7,11,14,11,14,11,18,15,18,11,18,26,7,28,7,31,14, 28,14,31}; double x1, y1; int chrstart; unsigned char ic, *p; register int j, k; switch (textPointer[0]) { /* text shall be output right aligned at position x, y */ case 'r': x-=22.*fsx*(double)strlen(textPointer+1); break; /* text shall be output centered at position x, y */ case 'c': x-=11.*fsx*(double)strlen(textPointer+1); break; } /* now print text one letter at a time */ for (p=(unsigned char *)textPointer+1; *p!=(unsigned char)0; p++) { if (*p != ' ') { ic=(*p)-'!'; if (ic > 93) { switch (ic) { case 143: ic=94; break; case 163: ic=95; break; case 181: ic=96; break; case 187: ic=97; break; case 190: ic=98; break; case 195: ic=99; break; case 213: ic=100; break; case 219: ic=101; break; } } chrstart=0; k=0; for (j=0; j #include #include "viewmol.h" void tql(double *, int, double *, int, int); extern void thermo(struct MOLECULE *); extern struct MOLECULE *molecules; extern int debug; void inert(struct MOLECULE *mol) { /* This subroutine calculates the tensor of inertia of a molecule and diagonalizes it. */ const double h=6.626176e-34, c=2.99792458e10, u=1.6605655e-27; double tensor[3][3], eigvec[3][3], tmax; double cgx, cgy, cgz, mass, x, y, z; register double d, fac, pi; register int i, j; for (i=0; i<3; i++) { for (j=0; j<3; j++) tensor[i][j]=0.0; } /* Find center of gravity */ cgx=0.0; cgy=0.0; cgz=0.0; mass=0.0; for (i=0; ina; i++) { cgx+=mol->atoms[i].mass*mol->atoms[i].x; cgy+=mol->atoms[i].mass*mol->atoms[i].y; cgz+=mol->atoms[i].mass*mol->atoms[i].z; mass+=mol->atoms[i].mass; } cgx/=mass; cgy/=mass; cgz/=mass; /* Calculate tensor of inertia */ for (i=0; ina; i++) { fac=mol->atoms[i].mass; x=mol->atoms[i].x-cgx; y=mol->atoms[i].y-cgy; z=mol->atoms[i].z-cgz; tensor[0][0]+=fac*(y*y+z*z); tensor[0][1]-=fac*x*y; tensor[0][2]-=fac*x*z; tensor[1][1]+=fac*(x*x+z*z); tensor[1][2]-=fac*y*z; tensor[2][2]+=fac*(x*x+y*y); } tensor[1][0]=tensor[0][1]; tensor[2][0]=tensor[0][2]; tensor[2][1]=tensor[1][2]; if (debug > 0) { printf("Tensor of inertia:\n"); printf("%15.8f%15.8f%15.8f\n", tensor[0][0], tensor[0][1], tensor[0][2]); printf(" %15.8f%15.8f\n", tensor[1][1], tensor[1][2]); printf(" %15.8f\n", tensor[2][2]); } /* Diagonalize it */ tql(&tensor[0][0], 3, &eigvec[0][0], 3, 3); /* and convert its eigenvalues to 1/cm */ pi=4.0*atan((double)1.0); fac=h/(8.0e-20*pi*pi*c*u); if (tensor[0][0] != 0.0) mol->rotConstants[0]=fac/tensor[0][0]; if (tensor[1][1] != 0.0) mol->rotConstants[1]=fac/tensor[1][1]; if (tensor[2][2] != 0.0) mol->rotConstants[2]=fac/tensor[2][2]; if (debug > 0) { printf("eigenvalues: %15.8f%15.8f%15.8f\n", tensor[0][0], tensor[1][1], tensor[2][2]); printf("eigenvectors:%10.5f %10.5f %10.5f\n", eigvec[0][0], eigvec[1][0], eigvec[2][0]); printf(" %10.5f %10.5f %10.5f\n", eigvec[0][1], eigvec[1][1], eigvec[2][1]); printf(" %10.5f %10.5f %10.5f\n", eigvec[0][2], eigvec[1][2], eigvec[2][2]); printf("Rotational constants (1/cm):%10.6f %10.6f %10.6f\n", mol->rotConstants[0], mol->rotConstants[1], mol->rotConstants[2]); } tmax=tensor[0][0] > tensor[1][1] ? tensor[0][0] : tensor[1][1]; tmax=tmax > tensor[2][2] ? tmax : tensor[2][2]; for (i=0; i<3; i++) { d=sqrt(eigvec[i][0]*eigvec[i][0]+eigvec[i][1]*eigvec[i][1]+eigvec[i][2] *eigvec[i][2]); fac=2.0*tensor[i][i]/(tmax*d); for (j=0; j<3; j++) mol->tinert[i][j]=fac*eigvec[i][j]; } thermo(mol); } /* tql.f -- translated by f2c (version 19950110). You must link the resulting object file with the libraries: -lf2c -lm (in that order) */ void tql(double *a, int n, double *c, int l1, int l2) { /* Initialized data */ const double pzahl = (double)1e-31; const double bit = (double)1e-15; /* System generated locals */ int a_dim1, a_offset, c_dim1, c_offset, i__1, i__2, i__3; double r__1, r__2; /* Local variables */ static int inda; static double d[3], e[3], f, g, h; static int i, j, k, l, m; static double p, q, r, s; static int index; static double cc, hh; static int ll, mm; static double tol; /* This subroutine diagonalizes the matrix a by the TQL algorithm and */ /* puts the eigenvectors in c and the eigenvalues in the diagonal of */ /* a */ /* Parameter adjustments */ c_dim1 = l1; c_offset = c_dim1 + 1; c -= c_offset; a_dim1 = l1; a_offset = a_dim1 + 1; a -= a_offset; /* Function Body */ if (n == 1) { d[0] = a[a_dim1 + 1]; c[c_dim1 + 1] = (double)1.; return; } tol = pzahl / bit; i__1 = n; for (i = 1; i <= i__1; ++i) { i__2 = i; for (j = 1; j <= i__2; ++j) { a[i + j * a_dim1] = a[j + i * a_dim1]; /* L1: */ c[i + j * c_dim1] = a[i + j * a_dim1]; } } index = n + 1; i__2 = n; for (i = 2; i <= i__2; ++i) { --index; inda = index - 1; l = index - 2; f = c[index + inda * c_dim1]; g = (double)0.; if (l == 0) { goto L5; } i__1 = l; for (k = 1; k <= i__1; ++k) { /* L4: */ /* Computing 2nd power */ r__1 = c[index + k * c_dim1]; g += r__1 * r__1; } L5: h = g + f * f; if (g > tol) { goto L6; } e[index - 1] = f; h = (double)0.; goto L2; L6: g = sqrt(h); if (f >= (double)0.) { g = -(double)g; } e[index - 1] = g; h -= f * g; c[index + inda * c_dim1] = f - g; f = (double)0.; ++l; i__1 = l; for (j = 1; j <= i__1; ++j) { c[j + index * c_dim1] = c[index + j * c_dim1] / h; g = (double)0.; i__3 = j; for (k = 1; k <= i__3; ++k) { /* L8: */ g += c[j + k * c_dim1] * c[index + k * c_dim1]; } if (j == l) { goto L9; } ll = j + 1; i__3 = l; for (k = ll; k <= i__3; ++k) { /* L10: */ g += c[k + j * c_dim1] * c[index + k * c_dim1]; } L9: e[j - 1] = g / h; /* L7: */ f += g * c[j + index * c_dim1]; } hh = f / (h + h); i__1 = l; for (j = 1; j <= i__1; ++j) { f = c[index + j * c_dim1]; g = e[j - 1] - hh * f; e[j - 1] = g; i__3 = j; for (k = 1; k <= i__3; ++k) { /* L11: */ c[j + k * c_dim1] = c[j + k * c_dim1] - f * e[k - 1] - g * c[ index + k * c_dim1]; } } L2: d[index - 1] = h; } e[0] = (double)0.; d[0] = c[c_dim1 + 1]; c[c_dim1 + 1] = (double)1.; i__2 = n; for (i = 2; i <= i__2; ++i) { l = i - 1; if (d[i - 1] == (double)0.) { goto L13; } i__3 = l; for (j = 1; j <= i__3; ++j) { g = (double)0.; i__1 = l; for (k = 1; k <= i__1; ++k) { /* L15: */ g += c[i + k * c_dim1] * c[k + j * c_dim1]; } i__1 = l; for (k = 1; k <= i__1; ++k) { /* L14: */ c[k + j * c_dim1] -= g * c[k + i * c_dim1]; } } L13: d[i - 1] = c[i + i * c_dim1]; c[i + i * c_dim1] = (double)1.; i__1 = l; for (j = 1; j <= i__1; ++j) { c[i + j * c_dim1] = (double)0.; /* L12: */ c[j + i * c_dim1] = (double)0.; } } i__1 = n; for (i = 2; i <= i__1; ++i) { /* L16: */ e[i - 2] = e[i - 1]; } e[n - 1] = (double)0.; f = (float)0.; hh = (float)0.; i__1 = n; for (l = 1; l <= i__1; ++l) { h = bit * ((r__1 = d[l - 1], fabs(r__1)) + (r__2 = e[l - 1], fabs( r__2))); if (hh < h) { hh = h; } inda = l + 1; i__2 = n; for (m = l; m <= i__2; ++m) { if ((r__1 = e[m - 1], fabs(r__1)) <= hh) { goto L19; } /* L18: */ } m = n; L19: if (m == l) { goto L17; } L25: g = d[l - 1]; p = (d[inda - 1] - g) / (e[l - 1] * (double)2.); r = sqrt(p * p + (double)1.); if (p < (double)0.) { r = -(double)r; } d[l - 1] = e[l - 1] / (p + r); h = g - d[l - 1]; if (l == n) { goto L20; } i__2 = n; for (i = inda; i <= i__2; ++i) { /* L21: */ d[i - 1] -= h; } L20: f += h; p = d[m - 1]; cc = (double)1.; s = (double)0.; ll = m; i__2 = m; for (i = inda; i <= i__2; ++i) { mm = ll; --ll; q = e[ll - 1]; g = cc * q; h = cc * p; if (fabs(p) < fabs(q)) { goto L23; } cc = q / p; r = sqrt(cc * cc + (double)1.); e[mm - 1] = s * p * r; s = cc / r; cc = (double)1. / r; goto L24; L23: cc = p / q; r = sqrt(cc * cc + (double)1.); e[mm - 1] = s * q * r; s = (double)1. / r; cc /= r; L24: p = cc * d[ll - 1] - s * g; d[mm - 1] = h + s * (cc * g + s * d[ll - 1]); i__3 = n; for (k = 1; k <= i__3; ++k) { h = c[k + mm * c_dim1]; c[k + mm * c_dim1] = s * c[k + ll * c_dim1] + cc * h; /* L22: */ c[k + ll * c_dim1] = cc * c[k + ll * c_dim1] - s * h; } } e[l - 1] = s * p; d[l - 1] = cc * p; if ((r__1 = e[l - 1], fabs(r__1)) > hh) { goto L25; } L17: d[l - 1] += f; } inda = n - 1; i__1 = inda; for (i = 1; i <= i__1; ++i) { k = i; p = d[i - 1]; l = i + 1; i__3 = n; for (j = l; j <= i__3; ++j) { if (d[j - 1] >= p) { goto L27; } k = j; p = d[j - 1]; L27: ; } if (k == i) { goto L26; } d[k - 1] = d[i - 1]; d[i - 1] = p; i__3 = n; for (j = 1; j <= i__3; ++j) { p = c[j + i * c_dim1]; c[j + i * c_dim1] = c[j + k * c_dim1]; /* L28: */ c[j + k * c_dim1] = p; } L26: ; } i__1 = n; for (i = 1; i <= i__1; ++i) { /* L29: */ a[i + i * a_dim1] = d[i - 1]; } } viewmol-2.4.1/source/infoform.c0100644000272700027270000000601707752676017014653 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * I N F O F O R M . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: infoform.c,v 1.2 2003/11/07 11:03:43 jrh Exp $ * $Log: infoform.c,v $ * Revision 1.2 2003/11/07 11:03:43 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:09:10 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dialog.h" extern Widget CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern void MapBox(Widget, caddr_t, XmAnyCallbackStruct *); extern Widget initShell(Widget, char *, Widget *, Widget *); void infoForm(void); void infoFormExit(Widget, caddr_t, caddr_t); void infoSetText(char *); static Widget dialog, text=NULL; static XmTextPosition position=0; extern Widget topShell; void infoForm(void) { Widget board, form, scrolledWindow; static struct PushButtonRow buttons[] = { { "cancel", infoFormExit, (XtPointer)0, NULL }, }; dialog=initShell(topShell, "infoForm", &board, &form); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XmAnyCallbackStruct *)NULL); text=XmCreateScrolledText(form, "text", NULL, 0); scrolledWindow=XtParent(text); XtVaSetValues(scrolledWindow, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); XtVaSetValues(text, XmNeditMode, XmMULTI_LINE_EDIT, XmNcolumns, 80, XmNrows, 10, XmNeditable, False, XmNwordWrap, True, XmNcursorPositionVisible, False, XmNscrollHorizontal, False, NULL); position=0; CreatePushButtonRow(form, buttons, XtNumber(buttons)); XtManageChild(text); XtManageChild(form); XtManageChild(board); } void infoFormExit(Widget button, caddr_t dummy, caddr_t call_data) { text=NULL; XtDestroyWidget(dialog); } void infoSetText(char *str) { if (text == NULL) infoForm(); XmTextInsert(text, position, str); position+=strlen(str); } viewmol-2.4.1/source/init.c0100644000272700027270000007677310114366620013775 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * I N I T . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: init.c,v 1.7 2004/08/29 14:52:00 jrh Exp $ * $Log: init.c,v $ * Revision 1.7 2004/08/29 14:52:00 jrh * Release 2.4.1 * * Revision 1.6 2003/11/07 11:04:56 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:09:19 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:52 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:50:24 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:00 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:41:22 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #define TEXTURE_WIDTH 64 #define TEXTURE_HEIGHT 64 void makeWindow(int, char *, void *func()); Widget makeViewerMenu(Widget); void initSpectrum(Widget, caddr_t, caddr_t); void makeSpectrumMenu(void); void initMODiagram(Widget, caddr_t, caddr_t); void makeMODiagramMenu(void); void initHistory(Widget, caddr_t, caddr_t); void makeHistoryMenu(void); void setCursor(Widget, unsigned int); void setMenuItem(int, int); void blendToPicture(void); struct MenuItem *makeMoleculesMenu(struct MenuItem *, int); struct MenuItem *makeScriptsMenu(struct MenuItem *); #if defined LINUX || defined DARWIN int matchScripts(const struct dirent *); #else int matchScripts(struct dirent *); #endif void setMenu(struct MOLECULE *); void initPython(int, char **); extern char *getStringResource(Widget, char *); extern void createFileselect(void); extern int input(int, char **); extern void setWindowTitle(Widget, char *); extern void setAtom(struct MOLECULE *); extern void inert(struct MOLECULE *); extern int makeConnectivity(struct MOLECULE *, int, int); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern void storeColor(Pixel, struct WINDOW *, int); extern void redraw(int); extern void drawBackground(int, Pixel, double); extern int StringWidth(XFontStruct *, char *); extern void deleteFontList(GLuint, XFontStruct *); extern XFontStruct *makeRasterFont(Display *, char *, GLuint *); extern void drawSpectrum(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void drawHistory(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void drawMODiagram(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void reshape(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void hardcopyCallback(Widget, caddr_t, XmAnyCallbackStruct *); extern Widget makeMenu(Widget, int, char *, struct MenuItem *); extern void processInput(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void (*drawString)(char *, double, double, double, double, GLuint, char); extern void setWindowColor(int, Pixel, const float *); extern void getImaginaryMode(Widget, caddr_t, caddr_t); extern void selectMolecule(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void setGeometry(int); extern void setBondType(Widget, caddr_t, caddr_t); extern XVisualInfo *getVisualInfo(Display *, Visual *); extern Colormap getRGBcolormap(Display *, int, XVisualInfo *); extern int checkZoom(int); extern void setCellSliders(struct MOLECULE *); extern void setWindowSize(double); extern void initViewmolModule(void); extern void initMoleculeModule(void); extern void initAtomModule(void); extern void initElementModule(void); extern void initSpectrumModule(void); extern void initHistoryModule(void); extern void initEnergyLevelModule(void); extern void initLightModule(void); extern void initLabelModule(void); extern void runScript(Widget, caddr_t, XmAnyCallbackStruct *); extern void startModule(Widget, caddr_t, XmAnyCallbackStruct *); extern void addBoundaryAtoms(struct MOLECULE *); extern void getScreenCoordinates(double, double, double, double *, double *, double *); extern struct MOLECULE *molecules; extern struct WINDOW windows[]; extern Pixel stdcol[9]; extern int rgbMode, projectionMode; extern Widget topShell; extern float *transObject, *rotObject; extern int nmolecule; extern int label, showForces, noutput, nUndo; extern int showUnitCell, showInertia, swapBuffers; extern char language[], *moduleName; extern XVisualInfo *vi; #include "menudef.h" int initViewer(int argc, char **argv, Widget widget) { struct MOLECULE *mol; double box; GLubyte texture[TEXTURE_WIDTH][TEXTURE_HEIGHT][3]; char def[]="variable", *string; register int i, j; setCursor(widget, XC_watch); if ((string=getStringResource(widget, "font")) == NULL) string=def; windows[VIEWER].font=makeRasterFont(XtDisplay(widget), string, &windows[VIEWER].GLfontId); createFileselect(); transObject=(float *)getmem(MOLECULES, 3*sizeof(float)); rotObject=(float *)getmem(MOLECULES, 4*sizeof(float)); rotObject[4*VIEWPOINT+3]=1.0; rotObject[4*LIGHTNO0+3]=1.0; rotObject[4*LIGHTNO1+3]=1.0; rotObject[4*WORLD+3]=1.0; for (i=0; iunitcell) addBoundaryAtoms(mol); if (!makeConnectivity(mol, TRUE, TRUE)) return(FALSE); box=windows[VIEWER].far > box ? windows[VIEWER].far : box; if (!mol->unitcell) showUnitCell=FALSE; } setWindowSize(box); setWindowTitle(windows[VIEWER].widget, molecules[windows[VIEWER].set].title); windows[VIEWER].menu=makeViewerMenu(windows[VIEWER].widget); blendToPicture(); setCursor(widget, XC_top_left_arrow); return(TRUE); } Widget makeViewerMenu(Widget widget) { static struct MenuItem *moleculesMenu=NULL; static struct MenuItem *scriptsMenu=NULL; Widget menu; struct MOLECULE *mol; register int i; if (nmolecule > 1) { moleculesMenu=makeMoleculesMenu(moleculesMenu, VIEWER); i=VIEWER_SELECT; viewerMenu[i & 0xff].subitems=moleculesMenu; } scriptsMenu=makeScriptsMenu(scriptsMenu); i=VIEWER_RUNSCRIPT; viewerMenu[i & 0xff].subitems=scriptsMenu; menu=makeMenu(widget, XmMENU_POPUP, "viewmol", viewerMenu); if (molecules == NULL) mol=NULL; else { if (windows[VIEWER].set >= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; } if (windows[VIEWER].mode == WIREMODEL) { setMenuItem(VIEWER_WIRE, False); setMenuItem(VIEWER_RAYTRACING, False); } if (windows[VIEWER].mode == STICKMODEL) setMenuItem(VIEWER_STICK, False); if (windows[VIEWER].mode == BALLMODEL) setMenuItem(VIEWER_BALL, False); if (windows[VIEWER].mode == CUPMODEL) setMenuItem(VIEWER_CPK, False); if (nmolecule == 1) setMenuItem(VIEWER_SELECT, False); if (projectionMode == ORTHO) setMenuItem(VIEWER_FOREGROUND, False); if (noutput == 0) setMenuItem(VIEWER1_SAVE, False); if (nUndo == 0) setMenuItem(VIEWER2_UNDO, False); setMenu(mol); return(menu); } void initSpectrum(Widget w, caddr_t client_data, caddr_t call_data) { Pixel pixel; char t[7], *string, line[MAXLENLINE]; makeWindow(SPECTRUM, "spectrum", (void *(*)())drawSpectrum); string=getStringResource(windows[SPECTRUM].widget, "font"); windows[SPECTRUM].font=makeRasterFont(XtDisplay(windows[SPECTRUM].widget), string, &windows[SPECTRUM].GLfontId); if (windows[VIEWER].set >= 0) windows[SPECTRUM].set=windows[VIEWER].set; else windows[SPECTRUM].set=0; makeSpectrumMenu(); XtVaGetValues(windows[SPECTRUM].widget, XmNbackground, &pixel, NULL); storeColor(pixel, &windows[SPECTRUM], BACKGROUND); XtVaGetValues(windows[SPECTRUM].widget, XmNforeground, &pixel, NULL); storeColor(pixel, &windows[SPECTRUM], FOREGROUND); sprintf(t, "title%.1d", windows[SPECTRUM].mode); string=getStringResource(XtParent(windows[SPECTRUM].widget), t); sprintf(line, string, molecules[windows[SPECTRUM].set].title); setWindowTitle(windows[SPECTRUM].widget, line); } void makeSpectrumMenu(void) { static struct MenuItem *submenu1=NULL, *submenu2=NULL; struct MOLECULE *mol; char *label; int imol; register int i; imol=windows[SPECTRUM].set; mol=&molecules[imol]; if (mol->imag != 0) { if (submenu1 != NULL) fremem((void **)&submenu1); submenu1=(struct MenuItem *)getmem(mol->imag+1, sizeof(struct MenuItem)); label=(char *)getmem(mol->imag, 10); for (i=0; iimag; i++) { sprintf(&label[10*i], "%7.2f i", -mol->normal_modes[i].wavenumber); submenu1[i].label=&label[10*i]; submenu1[i].class=&xmPushButtonGadgetClass; submenu1[i].callback=getImaginaryMode; submenu1[i].callback_data=(XtPointer)i; submenu1[i].widget=(Widget)NULL; submenu1[i].subitems=NULL; } submenu1[i].label=NULL; i=SPECTRUM_IMAGINARY; spectrumMenu[i & 0xff].subitems=submenu1; } if (nmolecule > 1) { submenu2=makeMoleculesMenu(submenu2, SPECTRUM); i=SPECTRUM_SELECT; spectrumMenu[i & 0xff].subitems=submenu2; } windows[SPECTRUM].menu=makeMenu(windows[SPECTRUM].widget, XmMENU_POPUP, "spectrum_menu", spectrumMenu); setMenuItem(VIEWER_SPECTRUM, False); if (nmolecule <= 1) setMenuItem(SPECTRUM_SELECT, False); else { for (i=0; iimag == 0) setMenuItem(SPECTRUM_IMAGINARY, False); setMenuItem(SPECTRUM_DELETE, False); if (!checkZoom(SPECTRUM)) setMenuItem(SPECTRUM_ZOOMOUT, False); } void initHistory(Widget w, caddr_t client_data, caddr_t call_data) { Pixel pixel; double xs, ys, zs; char *string, line[MAXLENLINE]; makeWindow(HISTORY, "history", (void *(*)())drawHistory); string=getStringResource(windows[HISTORY].widget, "font"); windows[HISTORY].font=makeRasterFont(XtDisplay(windows[HISTORY].widget), string, &windows[HISTORY].GLfontId); if (windows[VIEWER].set >= 0) windows[HISTORY].set=windows[VIEWER].set; else windows[HISTORY].set=0; makeHistoryMenu(); XtVaGetValues(windows[HISTORY].widget, XmNbackground, &pixel, NULL); storeColor(pixel, &windows[HISTORY], BACKGROUND); XtVaGetValues(windows[HISTORY].widget, XmNforeground, &pixel, NULL); storeColor(pixel, &windows[HISTORY], FOREGROUND); storeColor(stdcol[GREEN], &windows[HISTORY], GNORM); setGeometry(TRUE); string=getStringResource(XtParent(windows[HISTORY].widget), "title"); sprintf(line, string, molecules[windows[HISTORY].set].title); setWindowTitle(windows[HISTORY].widget, line); redraw(HISTORY); getScreenCoordinates((double)(molecules[windows[HISTORY].set].nhist), 0.0, 0.0, &xs, &ys, &zs); windows[HISTORY].mouseX=(int)xs; redraw(VIEWER); } void makeHistoryMenu(void) { static struct MenuItem *submenu=NULL; int i; if (nmolecule > 1) { submenu=makeMoleculesMenu(submenu, HISTORY); i=HISTORY_SELECT; historyMenu[i & 0xff].subitems=submenu; } windows[HISTORY].menu=makeMenu(windows[HISTORY].widget, XmMENU_POPUP, "history_menu", historyMenu); setMenuItem(VIEWER_OPTIMIZATION, False); if (nmolecule <= 1) { setMenuItem(HISTORY_SELECT, False); windows[HISTORY].set=0; } else { for (i=nmolecule; i>=0; i--) { if (molecules[i].history == NULL) XtVaSetValues(submenu[i].widget, XmNsensitive, False, NULL); else windows[HISTORY].set=i; } for (i=0; i= 0) windows[MO].set=windows[VIEWER].set; else windows[MO].set=0; makeMODiagramMenu(); XtVaGetValues(windows[MO].widget, XmNbackground, &pixel, NULL); storeColor(pixel, &windows[MO], BACKGROUND); XtVaGetValues(windows[MO].widget, XmNforeground, &pixel, NULL); storeColor(pixel, &windows[MO], FOREGROUND); if ((string=getStringResource(topShell, "MO-energy")) == NULL) { windows[MO].bottom=1.05*molecules[windows[MO].set].orbitals[0].energy; windows[MO].top=1.05*molecules[windows[MO].set].orbitals[molecules[windows[MO].set].nbasfu-1].energy; } else { windows[MO].bottom=atof(strtok(string, ":")); windows[MO].top=atof(strtok(NULL, ":")); } windows[MO].horizontalMargin=0; windows[MO].verticalMargin=0; string=getStringResource(XtParent(windows[MO].widget), "title"); sprintf(line, string, molecules[windows[MO].set].title); setWindowTitle(windows[MO].widget, line); } void makeMODiagramMenu(void) { static struct MenuItem *submenu=NULL; int i; if (nmolecule > 1) { submenu=makeMoleculesMenu(submenu, MO); i=MO_SELECT; MODiagramMenu[i & 0xff].subitems=submenu; } windows[MO].menu=makeMenu(windows[MO].widget, XmMENU_POPUP, "MODiagram_menu", MODiagramMenu); setMenuItem(MO_TRANSITION, False); setMenuItem(MO_ZOOMOUT, False); setMenuItem(VIEWER_ENERGYLEVEL, False); if (nmolecule <= 1) setMenuItem(MO_SELECT, False); else { for (i=0; i> 8) { case VIEWER: m=viewerMenu; break; case SPECTRUM: m=spectrumMenu; break; case MO: m=MODiagramMenu; break; case HISTORY: m=historyMenu; break; case VIEWER1: m=moleculeMenu; break; case VIEWER2: m=geometryMenu; break; } XtVaSetValues(m[item & 0xff].widget, XmNsensitive, disable, NULL); } void blendToPicture(void) { /* Switch smoothly from title to picture */ Dimension width, height; GLsizei incx, incy, ngrid=5; register int i, j, k; XtVaGetValues(windows[VIEWER].widget, XmNwidth, &width, XmNheight, &height, NULL); incx=(GLsizei)width/ngrid; incy=(GLsizei)height/ngrid; if (width % ngrid != 0) incx++; if (height % ngrid !=0) incy++; swapBuffers=FALSE; redraw(VIEWER); swapBuffers=TRUE; glReadBuffer(GL_BACK); glDrawBuffer(GL_FRONT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D((double)0.0, (double)width, (double)0.0, (double)height); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); i=0; j=0; for (k=ngrid-1; k>0; k--) { while (ingrid-k-1) { glRasterPos2i((GLint)(i*incx), (GLint)(j*incy)); glCopyPixels((GLint)(i*incx), (GLint)(j*incy), incx, incy, GL_COLOR); i--; } while (j>ngrid-k) { glRasterPos2i((GLint)(i*incx), (GLint)(j*incy)); glCopyPixels((GLint)(i*incx), (GLint)(j*incy), incx, incy, GL_COLOR); j--; } glXWaitGL(); } glRasterPos2i((GLint)(i*incx), (GLint)(j*incy)); glCopyPixels((GLint)(i*incx), (GLint)(j*incy), incx, incy, GL_COLOR); glXWaitGL(); glDrawBuffer(GL_BACK); } struct MenuItem *makeMoleculesMenu(struct MenuItem *submenu, int window) { static char all[]="all", sep[]="sep"; int offset; register int i; if (submenu != NULL) fremem((void **)&submenu); if (windows[window].selectMenu != NULL) fremem((void **)&windows[window].selectMenu); offset=nmolecule; if (window == VIEWER) offset+=2; submenu=(struct MenuItem *)getmem(offset+1, sizeof(struct MenuItem)); windows[window].selectMenu=(struct MENUDATA *)getmem(offset, sizeof(struct MENUDATA)); offset=0; if (window == VIEWER) { submenu[0].label=all; submenu[0].class=&xmToggleButtonGadgetClass; submenu[0].callback=selectMolecule; windows[window].selectMenu[0].submenu=submenu; windows[window].selectMenu[0].window=window; windows[window].selectMenu[0].which=(-1); submenu[0].callback_data=(XtPointer)(&windows[window].selectMenu[0]); submenu[0].widget=(Widget)NULL; submenu[0].subitems=NULL; submenu[1].label=sep; submenu[1].class=&xmSeparatorGadgetClass; submenu[1].callback=NULL; submenu[1].callback_data=(XtPointer)NULL; submenu[1].widget=(Widget)NULL; submenu[1].subitems=NULL; offset=2; } for (i=0; i 0) { submenu=(struct MenuItem *)getmem(n+3, sizeof(struct MenuItem)); j=0; for (i=0; id_name, PATH_MAX-1); word=strstr(module, ".py"); if (word) *word='\0'; sprintf(cmd, "try:\n import %s\nexcept:\n print \"Error loading module %s.\"\nelse:\n module%2.2d=%s.%s()\n module%2.2d.register(\"%s\")\n", module, module, i, module, module, i, language); moduleName='\0'; PyRun_SimpleString(cmd); if (moduleName) { submenu[j].label=moduleName; submenu[j].class=&xmPushButtonGadgetClass; submenu[j].callback=startModule; submenu[j].callback_data=(XtPointer)j; submenu[j].widget=(Widget)NULL; submenu[j++].subitems=NULL; } } submenu[j].label=sep; submenu[j].class=&xmSeparatorGadgetClass; submenu[j].callback=(XtPointer)0; submenu[j].callback_data=(XtPointer)0; submenu[j].widget=(Widget)NULL; submenu[j++].subitems=NULL; } else { submenu=(struct MenuItem *)getmem(1, sizeof(struct MenuItem)); j=0; } } else { submenu=(struct MenuItem *)getmem(1, sizeof(struct MenuItem)); j=0; } submenu[j].label=sel; submenu[j].class=&xmPushButtonGadgetClass; submenu[j].callback=runScript; submenu[j].callback_data=(XtPointer)0; submenu[j].widget=(Widget)NULL; submenu[j++].subitems=NULL; submenu[j].label=NULL; fremem((void **)&namelist); return(submenu); } #if defined LINUX || defined DARWIN int matchScripts(const struct dirent *d) #else int matchScripts(struct dirent *d) #endif { return(!fnmatch("*.py", d->d_name, 0)); } void setMenu(struct MOLECULE *mol) { if (!mol) { setMenuItem(VIEWER_BONDTYPE, False); setMenuItem(VIEWER_THERMODYNAMICS, False); setMenuItem(VIEWER_INERTIA, False); setMenuItem(VIEWER_LABEL, False); setMenuItem(VIEWER_ANNOTATE, False); } else { setMenuItem(VIEWER_BONDTYPE, True); setMenuItem(VIEWER_THERMODYNAMICS, True); setMenuItem(VIEWER_INERTIA, True); setMenuItem(VIEWER_LABEL, True); setMenuItem(VIEWER_ANNOTATE, True); } if (!mol || (mol->basisset == NULL && mol->gridObjects == NULL)) setMenuItem(VIEWER_WAVEFUNCTION, False); else setMenuItem(VIEWER_WAVEFUNCTION, True); if (!mol || mol->orbitals == NULL || windows[MO].widget) setMenuItem(VIEWER_ENERGYLEVEL, False); else setMenuItem(VIEWER_ENERGYLEVEL, True); if (!mol || mol->nhist < 2 || windows[HISTORY].widget) setMenuItem(VIEWER_OPTIMIZATION, False); else setMenuItem(VIEWER_OPTIMIZATION, True); if (!mol || mol->history == NULL) setMenuItem(VIEWER_FORCES, False); else setMenuItem(VIEWER_FORCES, True); if (!mol || mol->nmodes == 0 || windows[SPECTRUM].widget) setMenuItem(VIEWER_SPECTRUM, False); else setMenuItem(VIEWER_SPECTRUM, True); if (!mol || !mol->unitcell) setMenuItem(VIEWER_UNITCELL, False); else { setMenuItem(VIEWER_UNITCELL, True); setCellSliders(mol); } if (!mol || mol->ninternal == 0) { setMenuItem(VIEWER2_ALL, False); setMenuItem(VIEWER2_LAST, False); } else { setMenuItem(VIEWER2_ALL, True); setMenuItem(VIEWER2_LAST, True); } } Widget initShell(Widget parent, char *name, Widget *board, Widget *form) { Arg args[5]; Visual *vi; Colormap colormap; Pixel bg; Widget dialog; char line[MAXLENLINE]; XtVaGetValues(topShell, XmNvisual, &vi, XmNcolormap, &colormap, XmNbackground, &bg, NULL); XtSetArg(args[0], XmNautoUnmanage, False); XtSetArg(args[1], XmNdefaultPosition, False); XtSetArg(args[2], XmNvisual, vi); XtSetArg(args[3], XmNcolormap, colormap); if (XmIsMotifWMRunning(topShell)) XtSetArg(args[4], XmNmwmDecorations, MWM_DECOR_RESIZEH | MWM_DECOR_TITLE); else XtSetArg(args[4], (char *)NULL, 0); strcpy(line, name); strcat(line, "_popup"); dialog=XmCreateDialogShell(parent, line, args, XtNumber(args)); *board=XtVaCreateWidget(name, xmFormWidgetClass, dialog, XmNautoUnmanage, False, XmNdefaultPosition, False, NULL); *form=XtVaCreateWidget("rowcolumn", xmRowColumnWidgetClass, *board, XmNorientation, XmVERTICAL, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); return(dialog); } void initPython(int argc, char **argv) { Py_SetProgramName(argv[0]); Py_Initialize(); PySys_SetArgv(argc, argv); initViewmolModule(); initMoleculeModule(); initAtomModule(); initElementModule(); initSpectrumModule(); initHistoryModule(); initEnergyLevelModule(); initLightModule(); initLabelModule(); } viewmol-2.4.1/source/input.c0100644000272700027270000014274510114366711014163 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * I N P U T . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: input.c,v 1.7 2004/08/29 14:52:57 jrh Exp $ * $Log: input.c,v $ * Revision 1.7 2004/08/29 14:52:57 jrh * Release 2.4.1 * * Revision 1.6 2003/11/07 11:05:02 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:09:24 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:25:54 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:50:31 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:07 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:41:26 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" #define MAX(a, b) (a) > (b) ? (a) : (b) #define MIN(a, b) (a) < (b) ? (a) : (b) int input(int, char **); int load(Widget, caddr_t, XmAnyCallbackStruct *); char *findFileType(char *, char *); int readFile(char *, char *); double *readMOs(struct MOLECULE *, FILE *, int, int *, char *); int readOccupation(struct MOLECULE *, FILE *, int, char *); void relint(struct MOLECULE *); int assignBasisset(struct MOLECULE *, int, char *); int moveBasissetData(struct MOLECULE *, struct BASISSET *, int, int); void changeExponentPointers(struct BASISSET *, long, int); void sortBasis(struct MOLECULE *); int compar(const void *, const void *); struct SAVE *saveGeometry(struct MOLECULE *); void wrbas(struct MOLECULE *); struct MOLECULE *initMolecule(int); void deleteMolecule(Widget, caddr_t, XmAnyCallbackStruct *); void reformat(char *, char *); PyMoleculeSpecObject *molecule_new(void); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern char *selectFile(char *, char *, int); extern char *getStringResource(Widget, char *); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern int makeConnectivity(struct MOLECULE *, int, int); extern void makeUnitCell(double, double, double, double, double, double, double *, int); extern void shiftUnitCell(struct MOLECULE *); extern int getNumber(char *, int *); extern void cnorm(int); extern void modcmo(struct MOLECULE *, int); extern void assignBasisName(int); extern int checkFile(char **); extern void setWindowTitle(Widget, char *); extern void setAtom(struct MOLECULE *); extern void setMenuItem(int, int); extern void setMenu(struct MOLECULE *); extern void redraw(int); extern void inert(struct MOLECULE *); extern void setBond(struct MOLECULE *); extern Widget makeViewerMenu(Widget); extern void makeSpectrumMenu(void); extern void makeMODiagramMenu(void); extern void makeHistoryMenu(void); extern void setWindow(int); extern void showTitle(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void drawMolecule(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void quitSpectrum(Widget, caddr_t, XmAnyCallbackStruct *); extern void quitHistory(Widget, caddr_t, XmAnyCallbackStruct *); extern void quitMODiagram(Widget, caddr_t, XmAnyCallbackStruct *); extern void selectMolecule(Widget, XtPointer, XmToggleButtonCallbackStruct *); extern void runScript(Widget, caddr_t, XmAnyCallbackStruct *); extern void readGrid(struct GRIDOBJECT *, FILE *, char *); extern void adjustMONumbers(struct MOLECULE *); extern void addBoundaryAtoms(struct MOLECULE *); extern void getSumFormula(struct MOLECULE *, char *, int); extern struct MOLECULE *molecules; extern struct OPTION *options; extern struct WINDOW windows[]; extern float *transObject, *rotObject; extern int nopt, nmolecule, imol, moveItem; extern int showWarning, debug; extern Widget topShell; int input(int argc, char **argv) { static struct PushButtonRow buttons1[] = {{"exit", GetMessageBoxButton, (XtPointer)0, NULL}}; const char *locale; char command[MAXLENLINE], line[MAXLENLINE]; char *word=NULL; int readNext, n; register int i; if (argc > 1) { /* we got an option */ n=1; while (n < argc) { if (*argv[n] == '-') { argv[n]++; readNext=TRUE; for (i=0; i", molecules[imol].title, nmolecule); strncpy(molecules[imol].title, line, MAXLENLINE); break; } } } if (molecules[imol].unitcell) addBoundaryAtoms(&molecules[imol]); makeConnectivity(&molecules[imol], TRUE, TRUE); inert(&molecules[imol]); moveItem=imol+MOLECULES; setMenuItem(VIEWER1_SAVE, True); setMenuItem(VIEWER1_DELETE, True); setMenuItem(VIEWER1_BUILD, True); windows[VIEWER].menu=makeViewerMenu(windows[VIEWER].widget); setWindow(imol); button.set=TRUE; if (windows[SPECTRUM].widget != NULL && nmolecule > 1) { if (molecules[imol].nmodes > 0) { windows[SPECTRUM].set=imol; makeSpectrumMenu(); (void)selectMolecule((Widget)0, (XtPointer)&windows[SPECTRUM].selectMenu[imol], &button); } } if (windows[MO].widget != NULL && nmolecule > 1) { if (molecules[imol].nbasfu > 0) { windows[MO].set=imol; makeMODiagramMenu(); (void)selectMolecule((Widget)0, (XtPointer)&windows[MO].selectMenu[imol], &button); } } if (windows[HISTORY].widget != NULL && nmolecule > 1) { if (molecules[imol].nhist > 0) { windows[HISTORY].set=imol; makeHistoryMenu(); (void)selectMolecule((Widget)0, (XtPointer)&windows[HISTORY].selectMenu[imol], &button); } } XtRemoveAllCallbacks(windows[VIEWER].widget, XmNexposeCallback); XtAddCallback(windows[VIEWER].widget, XmNexposeCallback, (XtCallbackProc)drawMolecule, NULL); redraw(VIEWER); return(TRUE); } return(FALSE); } char *findFileType(char *command, char *filename) { FILE *file; static struct PushButtonRow buttons[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; static char *temp; char *buffer, *word; register int i; if ((file=fopen(filename, "r")) == NULL) { word=getStringResource(topShell, "noFile"); sprintf(command, word, filename); messgb(topShell, 3, command, buttons, 1); return(NULL); } buffer=(char *)getmem((size_t)1025, sizeof(char)); fread((void *)buffer, sizeof(char), (size_t)1024, file); fclose(file); buffer[1024]='\0'; for (i=0; iatoms[i].name, fixed); mol->atoms[i].x=x*radfac; mol->atoms[i].y=y*radfac; mol->atoms[i].z=z*radfac; mol->atoms[i].name[0]=toupper(mol->atoms[i].name[0]); mol->atoms[i].name[1]=tolower(mol->atoms[i].name[1]); mol->atoms[i].ref=i; mol->atoms[i].flags=ORIGINAL; if (strpbrk(fixed, "xX")) mol->atoms[i].flags|=X_FIXED; if (strpbrk(fixed, "yY")) mol->atoms[i].flags|=Y_FIXED; if (strpbrk(fixed, "zZ")) mol->atoms[i].flags|=Z_FIXED; mol->atoms[i].basis=NULL; mol->atoms[i].basisname[0]='\0'; if (++i >= mna) { mna+=20; mol->atoms=(struct ATOM *)expmem((void *)mol->atoms, mna, sizeof(struct ATOM)); } } mol->na=i; mna=i; mol->atoms=(struct ATOM *)expmem((void *)mol->atoms, mol->na, sizeof(struct ATOM)); readNext=FALSE; } else if (strstr(line, "$title")) { fgets(line, MAXLENLINE, file); if (line[0] != '$') { word=line+strlen(line)-1; while (*word == '\n' || *word == ' ') { *word='\0'; word--; } if (line[0] != '\0') strcpy(mol->title, line); readNext=TRUE; } else readNext=FALSE; } else if (strstr(line, "$vibrational normal modes")) { mol->cnm=(double *)getmem(mnn*mnn, sizeof(double)); i=0; while (fgets(line, MAXLENLINE, file) != NULL) { if (strchr(line, '$')) break; word=strtok(line, " \t"); if (strlen(word) < 3) word=strtok(NULL, " \t"); while ((word=strtok(NULL, " \t")) != NULL) { mol->cnm[i]=atof(word); if (++i >= mnn*mnn) { mnn+=60; mol->cnm=(double *)expmem((void *)mol->cnm, mnn*mnn, sizeof(double)); } } } readNext=FALSE; } else if (strstr(line, "$vibrational spectrum")) { mol->normal_modes=(struct NORMAL_MODE *)getmem(mnn, sizeof(struct NORMAL_MODE)); i=0; while (fgets(line, MAXLENLINE, file) != NULL) { if (strchr(line, '$')) break; sscanf(line, "%s%lf%lf%lf", mol->normal_modes[i].sym, &(mol->normal_modes[i].wavenumber), &(mol->normal_modes[i].ir_intensity), &(mol->normal_modes[i].raman_intensity)); if (++i >= mnn) { mnn+=60; mol->normal_modes=(struct NORMAL_MODE *)expmem((void *)mol->normal_modes, mnn, sizeof(struct NORMAL_MODE)); } } mol->nmodes=i; if (mol->nmodes > 0) { mol->normal_modes=(struct NORMAL_MODE *)expmem((void *)mol->normal_modes, mol->nmodes, sizeof(struct NORMAL_MODE)); relint(mol); } readNext=FALSE; } else if (strstr(line, "$grad") && !strstr(line, "$grad_")) { if (radfac < 0.0) { (void)strtok(line, " \t\n"); if ((word=strtok(NULL, " \t\n")) != NULL) { radfac=strtod(word, &p); if (p == word) radfac=1.0; } else radfac=1.0; } mol->history=(struct COORDS *)getmem(mnh*mna, sizeof(struct COORDS)); mol->optimization=(struct OPTIMIZATION *)getmem(mnh, sizeof(struct OPTIMIZATION)); i=j=k=0; namax=0; m=0; while (fgets(line, MAXLENLINE, file) != NULL) { if (strchr(line, '$')) break; if (strstr(line, "cycle")) { strtok(line, "="); strtok(NULL, "="); mol->optimization[i].energy=atof(strtok(NULL, "=")); mol->optimization[i].gnorm=atof(strtok(NULL, "=")); mol->optimization[i].coords=j; if (namax < m) { namax=m; mol->cycle=i; } if (i > 0) mol->optimization[i-1].natoms=m; m=0; if (++i >= mnh) { mnh+=50; mol->history=(struct COORDS *)expmem((void *)mol->history, mnh*mna, sizeof(struct COORDS)); mol->optimization=(struct OPTIMIZATION *)expmem((void *)mol->optimization, mnh, sizeof(struct OPTIMIZATION)); } } else if (strstr(line, "unitcell")) { if (strstr(line, "vectors")) { fgets(line, MAXLENLINE, file); bravaisMatrix[0]=radfac*atof(strtok(line, " \t")); bravaisMatrix[1]=radfac*atof(strtok(NULL, " \t")); bravaisMatrix[2]=radfac*atof(strtok(NULL, " \t")); fgets(line, MAXLENLINE, file); bravaisMatrix[3]=radfac*atof(strtok(line, " \t")); bravaisMatrix[4]=radfac*atof(strtok(NULL, " \t")); bravaisMatrix[5]=radfac*atof(strtok(NULL, " \t")); fgets(line, MAXLENLINE, file); bravaisMatrix[6]=radfac*atof(strtok(line, " \t")); bravaisMatrix[7]=radfac*atof(strtok(NULL, " \t")); bravaisMatrix[8]=radfac*atof(strtok(NULL, " \t")); aopt=-1.0; } else { word=strtok(line, " \t"); aopt=atof(strtok(NULL, " \t")); bopt=atof(strtok(NULL, " \t")); copt=atof(strtok(NULL, " \t")); alphaopt=atof(strtok(NULL, " \t")); betaopt=atof(strtok(NULL, " \t")); gammaopt=atof(strtok(NULL, " \t")); mol->optimization[i-1].coords=j; } makeUnitCell(radfac*aopt, radfac*bopt, radfac*copt, alphaopt, betaopt, gammaopt, bravaisMatrix, FALSE); } else { sscanf(line, "%lf%lf%lf", &x, &y, &z); strtok(line, " \t"); strtok(NULL, " \t"); strtok(NULL, " \t"); if (strtok(NULL, " \t") != NULL) { mol->history[j].x=x; mol->history[j].y=y; mol->history[j].z=z; m++; if (++j >= mnh*mna) { mna+=20; mol->history=(struct COORDS *)expmem((void *)mol->history, mnh*mna, sizeof(struct COORDS)); } } else { mol->history[k].gx=x; mol->history[k].gy=y; mol->history[k++].gz=z; } } } if (i > 0) { mol->nhist=i; mol->cycle=i; mol->optimization[i-1].natoms=m; if (namax < m) { namax=m; mol->cycle=i; } mol->atoms=(struct ATOM *)expmem((void *)mol->atoms, namax+1, sizeof(struct ATOM)); if (j > 0) mol->history=(struct COORDS *)expmem((void *)mol->history, j, sizeof(struct COORDS)); if (mol->nhist > 0) mol->optimization=(struct OPTIMIZATION *)expmem((void *)mol->optimization, mol->nhist, sizeof(struct OPTIMIZATION)); mol->emax=mol->emin=mol->optimization[0].energy; mol->gmax=mol->optimization[0].gnorm; for (i=1; inhist; i++) { mol->emax=MAX(mol->emax, mol->optimization[i].energy); mol->emin=MIN(mol->emin, mol->optimization[i].energy); mol->gmax=MAX(mol->gmax, mol->optimization[i].gnorm); } if (mol->gmax == 0.0) windows[HISTORY].mode=SCALES | ENERGY; } else { fremem((void **)&mol->history); fremem((void **)&mol->optimization); } readNext=FALSE; } else if (strstr(line, "$scfmo")) { if (strstr(line, "symmetrized")) mol->needMoloch=TRUE; if (strstr(line, "gaussian")) mol->gaussian=TRUE; cmo=readMOs(mol, file, ALPHAANDBETA, &ncoeff, line); readNext=FALSE; } else if (strstr(line, "$uhfmo_alpha")) { if (strstr(line, "symmetrized")) mol->needMoloch=TRUE; if (strstr(line, "gaussian")) mol->gaussian=TRUE; cmo=readMOs(mol, file, ALPHA, &ncoeff, line); readNext=FALSE; } else if (strstr(line, "$uhfmo_beta")) { if (strstr(line, "symmetrized")) mol->needMoloch=TRUE; if (strstr(line, "gaussian")) mol->gaussian=TRUE; cmo=readMOs(mol, file, BETA, &ncoeff, line); readNext=FALSE; } else if (strstr(line, "$grid")) { if (mol->gridObjects == NULL) mol->gridObjects=(struct GRIDOBJECT *)getmem((size_t)1, sizeof(struct GRIDOBJECT)); else mol->gridObjects=(struct GRIDOBJECT *)expmem((void *)mol->gridObjects, (size_t)(mol->ngridobjects+1), sizeof(struct GRIDOBJECT)); readGrid(&mol->gridObjects[mol->ngridobjects], file, line); mol->ngridobjects++; readNext=FALSE; } else if (strstr(line, "$closed shells")) { readNext=FALSE; if (!readOccupation(mol, file, ALPHAANDBETA, line)) continue; } else if (strstr(line, "$alpha shells")) { readNext=FALSE; if (!readOccupation(mol, file, ALPHA, line)) continue; } else if (strstr(line, "$beta shells")) { readNext=FALSE; if (!readOccupation(mol, file, BETA, line)) continue; } else if (strstr(line, "$atoms")) { while (fgets(line, MAXLENLINE, file) != NULL) { if (strchr(line, '$')) break; w=strrchr(line, '\\'); word=strtok(line, " \t"); word=strtok(NULL, " \t"); help=(int *)getmem(mna, sizeof(int)); i=getNumber(word, help); while (w != NULL) { fgets(line, MAXLENLINE, file); w=strrchr(line, '\\'); if (strstr(line, "basis") != NULL) { word=strtok(line, "="); word=strtok(NULL, "\\\n"); p=word+strlen(word); while (*(--p) == ' '); k=(int)(p-word)+1; k=k < MAXLENBASISNAME-1 ? k : MAXLENBASISNAME-1; for (j=0; jatoms[help[j]-1].basisname, word, k); mol->atoms[help[j]-1].basisname[k]='\0'; } } } fremem((void **)&help); } readNext=FALSE; } else if (strstr(line, "$basis")) { ierror=FALSE; mns=100; mnp=200; if (mol->basisset == NULL) mol->basisset=(struct BASISSET *)getmem(mns, sizeof(struct BASISSET)); if (mol->exponents == NULL) mol->exponents=(double *)getmem(mnp, 2*sizeof(double)); shell=0; primitive=0; while (fgets(line, MAXLENLINE, file) != NULL) { if (strchr(line, '*')) { newSet: if (shell != 0) mol->basisset[shell-1].next=(struct BASISSET *)NULL; fgets(line, MAXLENLINE, file); if (strchr(line, '$')) break; if (!assignBasisset(mol, shell, line)) { /* This basis set is not assigned to any atom, skip it */ istar=0; while (fgets(line, MAXLENLINE, file) != NULL) { if (strchr(line, '$')) break; if (strchr(line, '*')) istar++; if (istar > 1) goto newSet; } break; } fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); } mol->basisset[shell].first=&mol->exponents[primitive]; word=strtok(line, " \t"); mol->basisset[shell].nprim=atoi(word); word=strtok(NULL, " \t"); if (isdigit(*word)) mol->basisset[shell].ang=atoi(word); else { switch (*word) { case 's': mol->basisset[shell].ang=0; break; case 'p': mol->basisset[shell].ang=1; break; case 'd': mol->basisset[shell].ang=2; break; default: mol->basisset[shell].ang=(*word)-'c'; break; } } for (j=0; jbasisset[shell].nprim; j++) { fgets(line, MAXLENLINE, file); word=strtok(line, " \t"); mol->exponents[primitive++]=atof(word); word=strtok(NULL, " \t"); mol->exponents[primitive++]=atof(word); if (primitive >= mnp) { mnp+=100; oldexponents=mol->exponents; mol->exponents=(double *)expmem((void *)mol->exponents, mnp, 2*sizeof(double)); if (mol->exponents != oldexponents) changeExponentPointers(mol->basisset, mol->exponents-oldexponents, shell); } } if (++shell >= mns) { mns+=100; oldbasisset=mol->basisset; mol->basisset=(struct BASISSET *)getmem(mns, sizeof(struct BASISSET)); ierror|=moveBasissetData(mol, oldbasisset, shell, FALSE); fremem((void **)&oldbasisset); } mol->basisset[shell-1].next=&mol->basisset[shell]; } /* end of "while (fgets(line, MAXLENLINE, file) != NULL)" */ readNext=FALSE; oldexponents=mol->exponents; if (primitive > 0) mol->exponents=(double *)expmem((void *)mol->exponents, primitive, sizeof(double)); if (mol->exponents != oldexponents) changeExponentPointers(mol->basisset, mol->exponents-oldexponents, shell); oldbasisset=mol->basisset; if (shell > 0) { mol->basisset=(struct BASISSET *)getmem(shell, sizeof(struct BASISSET)); ierror|=moveBasissetData(mol, oldbasisset, shell, TRUE); fremem((void **)&oldbasisset); } if (ierror) { fremem((void **)&mol->basisset); fremem((void **)&mol->exponents); } else { if (debug == 2) wrbas(mol); cnorm(nmolecule); } } else if (strstr(line, "$unitcell")) { if (strstr(line, "vectors")) { fgets(line, MAXLENLINE, file); bravaisMatrix[0]=atof(strtok(line, " \t")); bravaisMatrix[1]=atof(strtok(NULL, " \t")); bravaisMatrix[2]=atof(strtok(NULL, " \t")); fgets(line, MAXLENLINE, file); bravaisMatrix[3]=atof(strtok(line, " \t")); bravaisMatrix[4]=atof(strtok(NULL, " \t")); bravaisMatrix[5]=atof(strtok(NULL, " \t")); fgets(line, MAXLENLINE, file); bravaisMatrix[6]=atof(strtok(line, " \t")); bravaisMatrix[7]=atof(strtok(NULL, " \t")); bravaisMatrix[8]=atof(strtok(NULL, " \t")); a=-1.0; } else { word=strtok(line, " \t"); a=atof(strtok(NULL, " \t")); b=atof(strtok(NULL, " \t")); c=atof(strtok(NULL, " \t")); alpha=atof(strtok(NULL, " \t")); beta=atof(strtok(NULL, " \t")); gamma=atof(strtok(NULL, " \t")); } readNext=TRUE; } else if (strstr(line, "$pople")) { if (strstr(line, "6d")) mol->pured=FALSE; if (strstr(line, "10f")) mol->puref=FALSE; if (strstr(line, "15g")) mol->pureg=FALSE; readNext=TRUE; } else if (strstr(line, "$symmetry")) { word=strtok(line, " \t\n"); if ((word=strtok(NULL, " \t\n")) != NULL) { strcpy(mol->pgroup, word); word=mol->pgroup; while (*word && word < mol->pgroup+5) { *word=tolower(*word); word++; } } readNext=TRUE; } else if (strstr(line, "$error")) { word=strtok(line, " \t"); word=strtok(NULL, " \t"); if ((w=getStringResource(topShell, word)) == NULL) { w=getStringResource(topShell, "unknownErrorMessage"); i=TRUE; } else { /* Get severity of error */ i=atoi(strtok(NULL, " \t")); word=strtok(NULL, " \t\n"); } sprintf(label, w, word); if (i) { if (showWarning) messgb(topShell, 3, label, buttons1, 1); return(FALSE); } else { if (showWarning) if (!messgb(topShell, 3, label, buttons2, 2)) return(FALSE); } readNext=TRUE; } else if (strstr(line, "$end")) { pclose(file); if (mol->basisset != NULL) { if (!mol->gaussian) sortBasis(mol); assignBasisName(nmolecule); } if (mol->orbitals != NULL && ncoeff != 0) { if (mol->basisset != NULL && !mol->needMoloch) { modcmo(mol, mol->gaussian); fremem((void **)&cmo); } } if (mol->orbitals != NULL && mol->ngridobjects > 0) adjustMONumbers(mol); if (a != 0.0) { if (a < 0.0) { for (i=0; i<9; i++) bravaisMatrix[i]*=radfac; } makeUnitCell(a*radfac, b*radfac, c*radfac, alpha, beta, gamma, bravaisMatrix, frac); for (i=0; iunitcell->nc; i++) { mol->unitcell[0].corners[i].x=mol->unitcell[mol->nhist].corners[i].x; mol->unitcell[0].corners[i].y=mol->unitcell[mol->nhist].corners[i].y; mol->unitcell[0].corners[i].z=mol->unitcell[mol->nhist].corners[i].z; } mol->unitcell[0].a=mol->unitcell[mol->nhist].a; mol->unitcell[0].b=mol->unitcell[mol->nhist].b; mol->unitcell[0].c=mol->unitcell[mol->nhist].c; mol->unitcell[0].alpha=mol->unitcell[mol->nhist].alpha; mol->unitcell[0].beta=mol->unitcell[mol->nhist].beta; mol->unitcell[0].gamma=mol->unitcell[mol->nhist].gamma; shiftUnitCell(mol); if (mol->unitcell) mol->thermoSettings&=~(TRANSLATION | ROTATION); } if (mol->history != NULL) { radfac1=1.0/radfac; for (i=0; inhist*mol->na; i++) { mol->history[i].x*=radfac; mol->history[i].y*=radfac; mol->history[i].z*=radfac; mol->history[i].gx*=radfac1; mol->history[i].gy*=radfac1; mol->history[i].gz*=radfac1; } } if (mol->cnm != NULL) { for (i=0; inmodes*mol->nmodes; i++) mol->cnm[i]*=radfac; } else mol->thermoSettings&=~VIBRATION; /* if (na != namax && namax != 0) setGeometry(FALSE); */ imol=nmolecule; nmolecule++; return(TRUE); } else readNext=TRUE; if (readNext) word=fgets(line, MAXLENLINE, file); else word=line; } /* end of "while (word != ..." */ if (mol->na == 0) { word=getStringResource(topShell, "noCoordinates"); sprintf(label, word, filename); messgb(topShell, 3, label, buttons1, 1); return(FALSE); } return(TRUE); } double *readMOs(struct MOLECULE *mol, FILE *file, int spin, int *ncoeff, char *line) { GLdouble energy; double *cmo=NULL, *oldcmo, *coeff, e, occ; size_t mno=100, mnc=2000; int n=0; char sym[4], *word, *w; long offset; register int i, j, k, l, m; if (mol->orbitals == NULL) { mol->orbitals=(struct ORBITAL *)getmem(mno, sizeof(struct ORBITAL)); cmo=(double *)getmem(mnc, sizeof(double)); *ncoeff=i=j=0; } else { mno=mol->nbasfu+100; mol->orbitals=(struct ORBITAL *)expmem((void *)mol->orbitals, mno, sizeof(struct ORBITAL)); mnc=mol->nbasfu*mol->nbasfu+mnc, cmo=(double *)expmem((void *)cmo, mnc, sizeof(double)); i=j=mol->nbasfu; } while (TRUE) { fgets(line, MAXLENLINE, file); if (line[0] == '$') break; if ((word=strtok(line, " \t")) != NULL) { word=strtok(NULL, " \t"); strcpy(mol->orbitals[i].symmetry, word); word=strtok(NULL, "="); word=strtok(NULL, " \t"); mol->orbitals[i].energy=atof(word); mol->orbitals[i].spin=spin; mol->orbitals[i].occupation=0.0; word=strtok(NULL, "="); word=strtok(NULL, " \t"); n=atoi(word); (*ncoeff)+=n; } if (n != 0) { mol->orbitals[i].coeff=&cmo[j]; do { fgets(line, MAXLENLINE, file); if ((word=strrchr(line, '\n')) != NULL) *word='\0'; if ((word=strtok(line, " \t")) != NULL) { cmo[j]=atof(word); n--; if (++j >= mnc) { mnc+=2000; oldcmo=cmo; cmo=(double *)expmem((void *)cmo, mnc, sizeof(double)); if (oldcmo != cmo) { offset=(char *)cmo-(char *)oldcmo; for (l=0; l<=i; l++) { w=(char *)mol->orbitals[l].coeff+offset; mol->orbitals[l].coeff=(double *)w; } } } } while ((word=strtok(NULL, " \t")) != NULL) { cmo[j]=atof(word); n--; if (++j >= mnc) { mnc+=2000; oldcmo=cmo; cmo=(double *)expmem((void *)cmo, mnc, sizeof(double)); if (oldcmo != cmo) { offset=(char *)cmo-(char *)oldcmo; for (l=0; l<=i; l++) { w=(char *)mol->orbitals[l].coeff+offset; mol->orbitals[l].coeff=(double *)w; } } } } } while (n > 0); } if (++i >= mno) { mno+=100; mol->orbitals=(struct ORBITAL *)expmem((void *)mol->orbitals, mno, sizeof(struct ORBITAL)); } } /* end of "while (TRUE)" */ mol->nbasfu=i; if (mol->nbasfu > 0) mol->orbitals=(struct ORBITAL *)expmem((void *)mol->orbitals, (size_t)mol->nbasfu, sizeof(struct ORBITAL)); oldcmo=cmo; if (j > 0) { cmo=(double *)expmem((void *)cmo, (size_t)j, sizeof(double)); if (oldcmo != cmo) { k=(char *)cmo-(char *)oldcmo; for (l=0; lorbitals[l].coeff+k; mol->orbitals[l].coeff=(double *)m; } } } for (i=0; inbasfu; i++) { e=mol->orbitals[i].energy; k=i; for (j=i+1; jnbasfu; j++) { if (mol->orbitals[j].energy < e) { e=mol->orbitals[j].energy; k=j; } } if (k != i) { energy=mol->orbitals[k].energy; occ=mol->orbitals[k].occupation; coeff=mol->orbitals[k].coeff; l=mol->orbitals[k].spin; strcpy(sym, mol->orbitals[k].symmetry); mol->orbitals[k].energy=mol->orbitals[i].energy; mol->orbitals[k].occupation=mol->orbitals[i].occupation; mol->orbitals[k].coeff=mol->orbitals[i].coeff; mol->orbitals[k].spin=mol->orbitals[i].spin; strcpy(mol->orbitals[k].symmetry, mol->orbitals[i].symmetry); mol->orbitals[i].energy=energy; mol->orbitals[i].occupation=occ; mol->orbitals[i].coeff=coeff; mol->orbitals[i].spin=l; strcpy(mol->orbitals[i].symmetry, sym); } } return(cmo); } int readOccupation(struct MOLECULE *mol, FILE *file, int spin, char *line) { int i, j, *help; char *word, *w; if (mol->nbasfu == 0) { word=fgets(line, MAXLENLINE, file); return(FALSE); } help=(int *)getmem(mol->nbasfu, sizeof(int)); while (fgets(line, MAXLENLINE, file) != NULL) { if (strchr(line, '$')) break; word=strtok(line, " \t"); w=strtok(NULL, " \t"); i=getNumber(w, help); for (j=0; jnbasfu; j++) { if (!strcmp(mol->orbitals[j].symmetry, word) && mol->orbitals[j].spin == spin) { if (spin == ALPHAANDBETA) mol->orbitals[j].occupation=2.0; else mol->orbitals[j].occupation=1.0; if (--i == 0) break; } } } fremem((void **)&help); return(TRUE); } void relint(struct MOLECULE *mol) { double wimax=0.0, rmimax=0.0; register int i; /* Compute relative intensities (0 - 100 %) */ for (i=0; inmodes; i++) { if (mol->normal_modes[i].ir_intensity < 0.0) mol->normal_modes[i].ir_intensity=0.0; if (mol->normal_modes[i].raman_intensity < 0.0) mol->normal_modes[i].raman_intensity=0.0; wimax=MAX(wimax, mol->normal_modes[i].ir_intensity); rmimax=MAX(rmimax, mol->normal_modes[i].raman_intensity); if (mol->normal_modes[i].wavenumber < 0.0) mol->imag++; } if (wimax > 0.0) wimax=100./wimax; else wimax=1.0; if (rmimax > 0.0) rmimax=100./rmimax; else rmimax=1.0; for (i=0; inmodes; i++) { mol->normal_modes[i].rel_ir_intensity=mol->normal_modes[i].ir_intensity*wimax; mol->normal_modes[i].rel_raman_intensity=mol->normal_modes[i].raman_intensity*rmimax; mol->normal_modes[i].rel_ins_intensity=0.0; } } int getNumber(char *str, int *array) { register int i=0, j, cont=FALSE; register char *start, *p; start=p=str; while (*p) { if (*p == '-') { cont=TRUE; *p='\0'; array[i++]=atoi(start); start=p+1; } else if (*p == ',') { *p='\0'; if (cont) { for (j=array[i-1]+1; j<=atoi(start); j++) array[i++]=j; cont=FALSE; } else array[i++]=atoi(start); start=p+1; } p++; } if (cont) { for (j=array[i-1]+1; j<=atoi(start); j++) array[i++]=j; } else array[i++]=atoi(start); return(i); } int assignBasisset(struct MOLECULE *mol, int shell, char *label) { int found=FALSE; register char *p; register int i; p=label+strlen(label)-1; while (*p == '\n' || *p == ' ') p--; *(p+1)='\0'; p=label; while (*p == ' ') p++; for (i=0; ina; i++) { if (!strcmp(mol->atoms[i].basisname, p)) { mol->atoms[i].basis=&mol->basisset[shell]; *(mol->atoms[i].basisname)='\0'; found=TRUE; } } return(found); } int moveBasissetData(struct MOLECULE *mol, struct BASISSET *old, int shell, int notify) { static struct PushButtonRow buttons[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; size_t k; char *missing=NULL, number[10], *str; int ierror, count=0; register long offset; register int i, j; register char *p; ierror=FALSE; offset=(char *)(mol->basisset)-(char *)old; k=0; for (j=0; jna; j++) { if (mol->atoms[j].basis != NULL) { p=(char *)mol->atoms[j].basis+offset; mol->atoms[j].basis=(struct BASISSET *)p; } else { if (notify) { k+=12; if (j < 1000000) sprintf(number, "%s(%d)", mol->atoms[j].name, j+1); else sprintf(number, "%s", mol->atoms[j].name); if (missing == NULL) { missing=(char *)getmem(k, sizeof(char)); count=0; } else { missing=(char *)expmem((void *)missing, k, sizeof(char)); strcat(missing, ", "); count+=12; if (count > 60) { count=0; missing[strlen(missing)-1]='\n'; } } strcat(missing, number); } } } if (k > 0 && showWarning) { ierror=TRUE; p=getStringResource(topShell, "missingBasisset"); if (!p) p="The basis set for the atom(s) %s has not been specified."; str=(char *)getmem((size_t)(strlen(p)+strlen(missing)+1), sizeof(char)); sprintf(str, p, missing); messgb(topShell, 1, str, buttons, 1); fremem((void **)&str); fremem((void **)&missing); } for (i=0; ibasisset[i].first=old[i].first; mol->basisset[i].nprim=old[i].nprim; mol->basisset[i].ang=old[i].ang; mol->basisset[i].next=old[i].next; if (mol->basisset[i].next != NULL) { p=(char *)(mol->basisset[i].next)+offset; mol->basisset[i].next=(struct BASISSET *)p; } } return(ierror); } void changeExponentPointers(struct BASISSET *basisset, long offset, int shell) { register int i; for (i=0; i<=shell; i++) basisset[i].first+=offset; } void sortBasis(struct MOLECULE *mol) { struct BASISSET *shell1, *shell2, *sorted; int type; register int i, j, k; for (i=0; ina; i++) { j=0; shell1=mol->atoms[i].basis; while (shell1 != NULL) { j++; shell1=shell1->next; } sorted=(struct BASISSET *)getmem(j, sizeof(struct BASISSET)); k=0; shell1=mol->atoms[i].basis; while (shell1 != NULL) { type=shell1->ang; if (type != -1) { shell2=shell1; while (shell2 != NULL) { if (shell2->ang == type) { sorted[k].first=shell2->first; sorted[k].ang=shell2->ang; sorted[k++].nprim=shell2->nprim; shell2->ang=(-1); } shell2=shell2->next; } } shell1=shell1->next; } k=0; shell1=mol->atoms[i].basis; while (shell1 != NULL) { shell1->first=sorted[k].first; shell1->ang=sorted[k].ang; shell1->nprim=sorted[k++].nprim; shell1=shell1->next; } free(sorted); } } int compar(const void *first, const void *second) { struct BASISSET *f=(struct BASISSET *)first, *s=(struct BASISSET *)second; return(f->ang - s->ang); } struct SAVE *saveGeometry(struct MOLECULE *mol) { struct SAVE *coord; register int i; coord=(struct SAVE*)getmem(mol->na, sizeof(struct SAVE)); for (i=0; ina; i++) { coord[i].x=mol->atoms[i].x; coord[i].y=mol->atoms[i].y; coord[i].z=mol->atoms[i].z; strcpy(coord[i].name, mol->atoms[i].name); } return(coord); } void wrbas(struct MOLECULE *mol) { /* dump basis set for debugging */ struct BASISSET *shell; int *done; register int i, j; register char ang; register double *p; done=(int *)getmem((size_t)mol->na, sizeof(int)); for (i=0; ina; i++) { if (done[i]) continue; printf("Atom(s) %d", i+1); done[i]=TRUE; shell=mol->atoms[i].basis; for (j=i+1; jna; j++) { if (mol->atoms[j].basis == shell) { printf(", %d", j+1); done[j]=TRUE; } } printf("\n"); do { switch (shell->ang) { case 0: ang='s'; break; case 1: ang='p'; break; case 2: ang='d'; break; default: ang=shell->ang+'c'; break; } printf("%4d %c\n", shell->nprim, ang); p=shell->first; for (j=0; jnprim; j++) { printf("%f %f\n", *p, *(p+1)); p+=2; } shell=shell->next; } while (shell != NULL); } fremem((void **)&done); } struct MOLECULE *initMolecule(int mna) { PyMoleculeSpecObject *newMolecule; struct MOLECULE *mol; register int i, j; if (molecules) molecules=(struct MOLECULE *)expmem((void *)molecules, (size_t)(nmolecule+1), sizeof(struct MOLECULE)); else molecules=(struct MOLECULE *)getmem((size_t)1, sizeof(struct MOLECULE)); mol=&molecules[nmolecule]; if ((newMolecule=molecule_new()) != NULL) { newMolecule->moleculeID=nmolecule; mol->pyObject=newMolecule; } mol->atoms=(struct ATOM *)getmem(mna, sizeof(struct ATOM)); mol->bonds=NULL; mol->unitcell=NULL; mol->normal_modes=NULL; mol->history=NULL; mol->internals=NULL; mol->optimization=NULL; mol->orbitals=NULL; mol->gridObjects=NULL; mol->basisset=NULL; mol->cnm=NULL; mol->exponents=NULL; mol->coord=NULL; setBond(mol); mol->addedBonds=NULL; mol->deletedBonds=NULL; mol->bondShift=0.0; mol->transx=0.0; mol->transy=0.0; mol->transz=0.0; mol->rotConstants[0]=0.0; mol->rotConstants[1]=0.0; mol->rotConstants[2]=0.0; for (i=0; i<3;i++) { for (j=0; j<3; j++) mol->tinert[i][j]=0.0; } /*mol->cellFactor[0]=1.0; mol->cellFactor[1]=1.0; mol->cellFactor[2]=1.0; */ mol->na=0; mol->nb=0; mol->nbAdded=0; mol->nbDeleted=0; mol->nmodes=0; mol->nhist=0; mol->ninternal=0; mol->nbasfu=0; mol->ngridobjects=0; mol->pured=TRUE; mol->puref=TRUE; mol->pureg=TRUE; mol->reaction=NOTHING; mol->stoichioNumber=0; mol->imag=0; mol->mode=(-1); mol->imo=(-1); mol->imosave=(-1); mol->ibasfu=(-1); mol->needMoloch=FALSE; mol->gaussian=FALSE; mol->thermoSettings=TRANSLATION | PV | ROTATION | VIBRATION; /*mol->showMiller=FALSE; mol->miller[0]=0; mol->miller[1]=mol->miller[2]=1; mol->nmiller=0; */ mol->title[0]='\0'; /*sprintf(mol->title, "Molecule %d", nmolecule+1); */ sprintf(mol->pgroup, "c1"); transObject=(float *)expmem((void *)transObject, nmolecule+MOLECULES+1, 3*sizeof(float)); i=3*(nmolecule+MOLECULES); transObject[i]=transObject[i+1]=transObject[i+2]=0.0; rotObject=(float *)expmem((void *)rotObject, nmolecule+MOLECULES+1, 4*sizeof(float)); i=4*(nmolecule+MOLECULES); rotObject[i]=rotObject[i+1]=rotObject[i+2]=0.0; rotObject[i+3]=1.0; return(mol); } void deleteMolecule(Widget w, caddr_t interactive, XmAnyCallbackStruct *callbackData) { static struct PushButtonRow buttons[] = {{"ok", GetMessageBoxButton, (XtPointer)TRUE, NULL}, {"cancel", GetMessageBoxButton, (XtPointer)FALSE, NULL}}; int first, last; char *word, line[MAXLENLINE]; register struct MOLECULE *mol; register int i, j; first=windows[VIEWER].set; last=first+1; if ((int)interactive) { if (first == -1) { first=0; last=nmolecule; word=getStringResource(topShell, "deleteAll"); if (!messgb(topShell, 2, word, buttons, 2)) return; } else { word=getStringResource(topShell, "deleteOne"); sprintf(line, word, molecules[first].title); if (!messgb(topShell, 2, line, buttons, 2)) return; } } for (i=first; ipyObject); fremem((void **)&mol->atoms); if (mol->bonds != NULL) fremem((void **)&(mol->bonds)); if (mol->unitcell != NULL) fremem((void **)&(mol->unitcell)); if (mol->normal_modes != NULL) fremem((void **)&(mol->normal_modes)); if (mol->history != NULL) fremem((void **)&(mol->history)); if (mol->internals != NULL) fremem((void **)&(mol->internals)); if (mol->optimization != NULL) fremem((void **)&(mol->optimization)); if (mol->orbitals != NULL) fremem((void **)&(mol->orbitals)); if (mol->gridObjects != NULL) fremem((void **)&(mol->gridObjects)); if (mol->basisset != NULL) fremem((void **)&(mol->basisset)); if (mol->coord != NULL) fremem((void **)&(mol->coord)); if (mol->cnm != NULL) fremem((void **)&(mol->cnm)); if (mol->exponents != NULL) fremem((void **)&(mol->exponents)); if (mol->addedBonds != NULL) fremem((void **)&(mol->addedBonds)); if (mol->deletedBonds != NULL) fremem((void **)&(mol->deletedBonds)); /* PyMem_DEL(mol->pyObject);*/ if (first != nmolecule-1) { for (j=first+1; jmoleculeID=j-1; transObject[3*(j+MOLECULES-1)]=transObject[3*(j+MOLECULES)]; transObject[3*(j+MOLECULES-1)+1]=transObject[3*(j+MOLECULES)+1]; transObject[3*(j+MOLECULES-1)+2]=transObject[3*(j+MOLECULES)+2]; rotObject[4*(j+MOLECULES-1)]=rotObject[4*(j+MOLECULES)]; rotObject[4*(j+MOLECULES-1)+1]=rotObject[4*(j+MOLECULES)+1]; rotObject[4*(j+MOLECULES-1)+2]=rotObject[4*(j+MOLECULES)+2]; rotObject[4*(j+MOLECULES-1)+3]=rotObject[4*(j+MOLECULES)+3]; } } nmolecule--; if (nmolecule) molecules=(struct MOLECULE *)expmem((void *)molecules, (size_t)nmolecule, sizeof(struct MOLECULE)); else fremem((void **)&molecules); transObject=(float *)expmem((void *)transObject, (size_t)(nmolecule+MOLECULES), 3*sizeof(float)); rotObject=(float *)expmem((void *)rotObject, (size_t)(nmolecule+MOLECULES), 4*sizeof(float)); windows[VIEWER].set=nmolecule-1; } windows[VIEWER].menu=makeViewerMenu(windows[VIEWER].widget); if (nmolecule < 2) setMenuItem(VIEWER_SELECT, False); if (nmolecule == 0) { setMenu((struct MOLECULE *)NULL); setMenuItem(VIEWER1_SAVE, False); setMenuItem(VIEWER1_DELETE, False); setMenuItem(VIEWER1_BUILD, False); for (i=VIEWER_GEOMETRY; i #include "viewmol.h" extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern double temp; void makeINSIntensity(void) { struct MOLECULE *mol; double pi, h, c, bk, amu, cotfac, qfac; int na; register double f, rll, smax; register int i, j, k; /* This subroutine computes inelastic neutron scattering intensities */ mol=&molecules[windows[SPECTRUM].set]; pi=4.0*atan(1.0); h=6.626176e-34; c=2.99792458e10; bk=1.380662e-23; amu=1.6605655e-27; if (temp > 0.0) cotfac=h*c/(2.0*bk*temp); else cotfac=h*c/(2.0*bk*0.001); qfac=h*1.e20/(4.0*pi*pi*c*amu); smax=0.0; na=0; for (i=0; ina; i++) { if (mol->atoms[i].flags & ORIGINAL) na++; } for (i=0; i<3*na; i++) { mol->normal_modes[i].ins_intensity=0.0; if (mol->normal_modes[i].wavenumber > 10.0) { f=sqrt(qfac/(2.0*mol->normal_modes[i].wavenumber) /tanh(cotfac*mol->normal_modes[i].wavenumber)); k=0; for (j=0; jcnm[i+mol->nmodes*k]*mol->cnm[i+mol->nmodes*k] +mol->cnm[i+mol->nmodes*(k+1)]*mol->cnm[i+mol->nmodes*(k+1)] +mol->cnm[i+mol->nmodes*(k+2)]*mol->cnm[i+mol->nmodes*(k+2)]); k+=3; mol->normal_modes[i].ins_intensity+=mol->atoms[j].neutronScatterfac*rll; } mol->normal_modes[i].ins_intensity*=f; smax=smax > mol->normal_modes[i].ins_intensity ? smax : mol->normal_modes[i].ins_intensity; } } for (i=0; i<3*na; i++) { if (smax == 0.0) mol->normal_modes[i].rel_ins_intensity=0.0; else mol->normal_modes[i].rel_ins_intensity=100.0*mol->normal_modes[i].ins_intensity/smax; } } viewmol-2.4.1/source/install0100755000272700027270000000527410132002767014245 0ustar jrhjrh#!/bin/sh #******************************************************************************* # * # Viewmol * # * # I N S T A L L * # * # Copyright (c) Joerg-R. Hill, October 2003 * # * #******************************************************************************* # # $Id: install,v 1.2 2004/08/29 14:53:37 jrh Exp $ # $Log: install,v $ # Revision 1.2 2004/08/29 14:53:37 jrh # Release 2.4.1 # # Revision 1.1 2003/11/07 13:05:40 jrh # Initial revision # if [ "$1" = "" ] then prgname=`basename $0` echo "${prgname}: ERROR: Usage: $prgname ." exit 1 fi ROOT=$1 # find name of directory for execuatable os=`uname -s` case $os in AIX) if [ `uname -m | cut -c9-10` = "70" ] then dir="${os}_POWER2" else dir="${os}_POWER" fi dirorig="AIX_POWER2" ;; IRIX*) dir="${os}_`hinv | awk '/CPU:/ {print $3}' | cut -d/ -f2`" dirorig="IRIX_R5000" ;; *) dir="$os" dirorig="$os" ;; esac # install executable in $ROOT/bin if [ ! -d $ROOT/bin ] then mkdir -p $ROOT/bin chmod 755 $ROOT/bin fi cp $dirorig/viewmol $ROOT/bin chmod 711 $ROOT/bin/viewmol # install other files needed in $ROOT/lib/viewmol if [ ! -d $ROOT/lib/viewmol/$dir ] then mkdir -p $ROOT/lib/viewmol/$dir chmod 755 $ROOT/lib/viewmol/$dir fi cd $dirorig cp tm bio readgamess readgauss readmopac readpdb $ROOT/lib/viewmol/$dir chmod 711 $ROOT/lib/viewmol/$dir/* cd ../.. cp readdmol readdmol.awk readgulp readpqs writecar writegauss.py writemol writetm $ROOT/lib/viewmol chmod 755 $ROOT/lib/viewmol/* cp -r doc examples locale scripts tests $ROOT/lib/viewmol find $ROOT/lib/viewmol -type f -exec chmod a+r {} \; find $ROOT/lib/viewmol -type d -exec chmod a+rx {} \; sed 's/\/source//g' viewmolrc > $ROOT/lib/viewmol/viewmolrc chmod -R 644 $ROOT/lib/viewmol/viewmolrc if [ -d /usr/X11R6/lib/X11/app-defaults ] then locale=`echo $LANG | cut -c1-2` if [ "$locale" = "en" ] then locale="${locale}_US" elif [ "$locale" = "C" ] then # The C locale is defined by default for rpm builds, overwrite it locale="en_US" fi cp locale/${locale}/Viewmol /usr/X11R6/lib/X11/app-defaults chmod a+r /usr/X11R6/lib/X11/app-defaults/Viewmol fi viewmol-2.4.1/source/intern.c0100644000272700027270000002301010051667006014303 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * I N T E R N . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: intern.c,v 1.6 2003/11/07 11:05:17 jrh Exp $ * $Log: intern.c,v $ * Revision 1.6 2003/11/07 11:05:17 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:09:37 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:04 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:51:39 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:12 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:41:35 jrh * Initial revision * */ #include #include #include "viewmol.h" double bondAverage(struct MOLECULE *, int); double bondLength(struct ATOM *, int, int); double bondAngle(struct ATOM *, int, int, int); double torsionAngle(struct ATOM *, int, int, int, int); double dist(double, double, double, double, double, double); double angle(double, double, double, double, double, double, double, double, double); double torsion(double, double, double, double, double, double, double, double, double, double, double, double); extern struct MOLECULE *molecules; extern double bndfac; extern int debug; int calcInternal(struct MOLECULE *mol, int n) { int uc; register int i, j, k, l; uc=0; for (i=0; i<4; i++) if (mol->internals[n].atoms[i] != -1 && (mol->internals[n].atoms[i] & 0x20000000)) uc++; switch (mol->internals[n].type) { case BONDAVERAGE: if (uc == 0) { mol->internals[n].value=bndfac*bondAverage(mol, mol->internals[n].atoms[0]); i=mol->internals[n].atoms[0]; mol->internals[n].x=mol->atoms[i].x+0.05; mol->internals[n].y=mol->atoms[i].y+0.05; mol->internals[n].z=mol->atoms[i].z+0.05; } else return(FALSE); break; case BONDLENGTH: i=mol->internals[n].atoms[0]; j=mol->internals[n].atoms[1]; switch (uc) { /* previous use: case 4 ??? */ case 2: i&=0x1fffffff; j&=0x1fffffff; mol->internals[n].value=bndfac*bondLength(mol->unitcell->corners, i, j); mol->internals[n].x=(mol->unitcell->corners[i].x+mol->unitcell->corners[j].x)*0.5+0.05; mol->internals[n].y=(mol->unitcell->corners[i].y+mol->unitcell->corners[j].y)*0.5+0.05; mol->internals[n].z=(mol->unitcell->corners[i].z+mol->unitcell->corners[j].z)*0.5+0.05; break; case 0: mol->internals[n].value=bndfac*bondLength(mol->atoms, i, j); mol->internals[n].x=(mol->atoms[i].x+mol->atoms[j].x)*0.5+0.05; mol->internals[n].y=(mol->atoms[i].y+mol->atoms[j].y)*0.5+0.05; mol->internals[n].z=(mol->atoms[i].z+mol->atoms[j].z)*0.5+0.05; break; default: return(FALSE); } break; case ANGLE: i=mol->internals[n].atoms[0]; j=mol->internals[n].atoms[1]; k=mol->internals[n].atoms[2]; switch (uc) { /* previous use: case 4 ??? */ case 3: i&=0x1fffffff; j&=0x1fffffff; k&=0x1fffffff; mol->internals[n].value=bondAngle(mol->unitcell->corners, i, j, k); mol->internals[n].x=mol->unitcell->corners[j].x+0.05; mol->internals[n].y=mol->unitcell->corners[j].y+0.05; mol->internals[n].z=mol->unitcell->corners[j].z+0.05; break; case 0: mol->internals[n].value=bondAngle(mol->atoms, i, j, k); mol->internals[n].x=mol->atoms[j].x+0.05; mol->internals[n].y=mol->atoms[j].y+0.05; mol->internals[n].z=mol->atoms[j].z+0.05; break; default: return(FALSE); } break; case TORSION: i=mol->internals[n].atoms[0]; j=mol->internals[n].atoms[1]; k=mol->internals[n].atoms[2]; l=mol->internals[n].atoms[3]; switch (uc) { case 4: i&=0x1fffffff; j&=0x1fffffff; k&=0x1fffffff; l&=0x1fffffff; mol->internals[n].value=torsionAngle(mol->unitcell->corners, i, j, k, l); mol->internals[n].x=(mol->unitcell->corners[j].x+mol->unitcell->corners[k].x)*0.5+0.05; mol->internals[n].y=(mol->unitcell->corners[j].y+mol->unitcell->corners[k].y)*0.5+0.05; mol->internals[n].z=(mol->unitcell->corners[j].z+mol->unitcell->corners[k].z)*0.5+0.05; break; case 0: mol->internals[n].value=torsionAngle(mol->atoms, i, j, k, l); mol->internals[n].x=(mol->atoms[j].x+mol->atoms[k].x)*0.5+0.05; mol->internals[n].y=(mol->atoms[j].y+mol->atoms[k].y)*0.5+0.05; mol->internals[n].z=(mol->atoms[j].z+mol->atoms[k].z)*0.5+0.05; break; default: return(FALSE); } if (mol->internals[n].value > 360.) return(FALSE); break; } if (debug) printf("Internal coordinate %d: %d-%d-%d-%d, %f\n", n, mol->internals[n].atoms[0], mol->internals[n].atoms[1], mol->internals[n].atoms[2], mol->internals[n].atoms[3], mol->internals[n].value); return(TRUE); } double bondAverage(struct MOLECULE *mol, int i) { register double value=0.0; register int j, k=0; for (j=0; jnb; j++) { if (mol->bonds[j].first == i || mol->bonds[j].second == i) { value+=bondLength(mol->atoms, mol->bonds[j].first, mol->bonds[j].second); k++; } } if (k > 0) value/=(double)k; else value=0.0; return(value); } double bondLength(struct ATOM *atoms, int i, int j) { return(dist(atoms[i].x, atoms[i].y, atoms[i].z, atoms[j].x, atoms[j].y, atoms[j].z)); } double bondAngle(struct ATOM *atoms, int i, int j, int k) { return(angle(atoms[i].x, atoms[i].y, atoms[i].z, atoms[j].x, atoms[j].y, atoms[j].z, atoms[k].x, atoms[k].y, atoms[k].z)); } double torsionAngle(struct ATOM *atoms, int i, int j, int k, int l) { return(torsion(atoms[i].x, atoms[i].y, atoms[i].z, atoms[j].x, atoms[j].y, atoms[j].z, atoms[k].x, atoms[k].y, atoms[k].z, atoms[l].x, atoms[l].y, atoms[l].z)); } double dist(double x1, double y1, double z1, double x2, double y2, double z2) { return(sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2))); } double angle(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3) { double todeg=45.0/atan(1.0); double xa, ya, za, xb, yb, zb, r; xa=x1-x2; ya=y1-y2; za=z1-z2; xb=x3-x2; yb=y3-y2; zb=z3-z2; r=dist(x1, y1, z1, x2, y2, z2)*dist(x3, y3, z3, x2, y2, z2); r=(xa*xb+ya*yb+za*zb)/r; r=r > 1.0 ? 1.0 : r < -1.0 ? -1.0 : r; return(todeg*acos(r)); } double torsion(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3, double x4, double y4, double z4) { double todeg=45.0/atan(1.0); double xa, ya, za, xb, yb, zb, xc, yc, zc, xd, yd, zd, xe, ye, ze, xf, yf, zf; double sgn, r; xa=x1-x2; ya=y1-y2; za=z1-z2; xb=x3-x2; yb=y3-y2; zb=z3-z2; xc=x4-x3; yc=y4-y3; zc=z4-z3; xd=ya*zb-yb*za; yd=xb*za-xa*zb; zd=xa*yb-xb*ya; xe=yc*zb-yb*zc; ye=xb*zc-xc*zb; ze=xc*yb-xb*yc; xf=yd*ze-ye*zd; yf=xe*zd-xd*ze; zf=xd*ye-xe*yd; sgn=xf*xb+yf*yb+zf*zb; r=sqrt((xd*xd+yd*yd+zd*zd)*(xe*xe+ye*ye+ze*ze)); /* The torsion angle is undefined (linear arrangement of atoms), return 400.0 as torsion angle which is outside the expected range */ if (fabs(r) < 1.0e-6) return((double)400.); r=(xd*xe+yd*ye+zd*ze)/r; if (fabs(r) > 1.0) r/=fabs(r); if (sgn < 0.0) return(-todeg*acos(r)); else return(todeg*acos(r)); } viewmol-2.4.1/source/isotopes.h0100644000272700027270000003371207752712316014701 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * I S O T O P E S . H * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: isotopes.h,v 1.6 2003/11/07 12:49:18 jrh Exp $ * $Log: isotopes.h,v $ * Revision 1.6 2003/11/07 12:49:18 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:09:45 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:06 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:51:49 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:14 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:45:37 jrh * Initial revision * Atomic masses of isotopes isotopes[atomic number][abundancy]: isotopic abundancy or lifetime, respectively, 0 average, 1 most common, 2 second most common ... Average atomic masses from Pure & Appl. Chem., 1996, 68, 2339-2359. Atomic masses and selection of isotopes from: J. Emsley "The Elements" Oxford, 1991 */ #define LASTELEMENT 109 double isotope[LASTELEMENT][9] = { /* 1H 2H 3H */ {1.00794, 1.007825, 2.01410, 3.01605, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 4He 3He */ {4.002602, 4.00260, 3.01603, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 7Li 6Li */ {6.941, 7.016003, 6.015121, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 9Be 10Be 7Be */ {9.012182, 9.012182, 10.013534, 7.016928, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 11B 10B */ {10.811, 11.009305, 10.012937, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 12C 13C 14C 11C */ {12.0107, 12., 13.003355, 14.003241, 11.011430, 0.0, 0.0, 0.0, 0.0}, /* 14N 15N */ {14.00674, 14.003074, 15.000108, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 16O 18O 17O */ {15.9994, 15.994915, 17.999160, 16.999131, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 19F 18F */ {18.9984032, 18.9984033, 18.000937, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 20Ne 22Ne 21Ne */ {20.1797, 19.992435, 21.991383, 20.993843, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 23Na 22Na 24Na */ {22.989770, 22.9897697, 21.994434, 23.990961, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 24Mg 26Mg 25Mg 28Mg */ {24.3050, 23.985042, 25.982593, 24.985837, 27.983876, 0.0, 0.0, 0.0, 0.0}, /* 27Al 26Al */ {26.981538, 26.981540, 25.986892, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 28Si 29Si 30Si 32Si */ {28.0855, 27.976927, 28.976495, 29.973770, 31.974148, 0.0, 0.0, 0.0, 0.0}, /* 31P 32P 33P */ {30.973761, 30.973762, 31.973907, 32.971725, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 32S 34S 33S 36S 35S */ {32.066, 31.972070, 33.967866, 32.971456, 35.967080, 34.969031, 0.0, 0.0, 0.0}, /* 35Cl 37Cl 36Cl */ {35.4527, 34.968852, 36.965903, 35.968306, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 40Ar 36Ar 38Ar 39Ar 37Ar */ {39.948, 39.962384, 35.967545, 37.962732, 38.962314, 36.966776, 0.0, 0.0, 0.0}, /* 39K 41K 40K 43K 42K */ {39.0983, 38.963707, 40.961825, 39.963999, 42.960717, 41.962402, 0.0, 0.0, 0.0}, /* 40Ca 44Ca 42Ca 48Ca 43Ca 46Ca 45Ca 47Ca */ {40.078, 39.962591, 43.955480, 41.958618, 47.952533, 42.958766, 45.953689, 44.955480, 46.954543}, /* 45Sc 46Sc 47Sc 44Sc */ {44.955910, 44.955910, 45.955170, 46.952408, 43.959404, 0.0, 0.0, 0.0, 0.0}, /* 48Ti 46Ti 47Ti 49Ti 50Ti 44Ti */ {47.867, 47.947947, 45.952629, 46.951764, 48.947871, 49.944792, 43.959689, 0.0, 0.0}, /* 51V 50V 49V 48V */ {50.9415, 50.943962, 49.947161, 48.948517, 47.952257, 0.0, 0.0, 0.0, 0.0}, /* 52Cr 53Cr 50Cr 54Cr 51Cr */ {51.9961, 51.940509, 52.940651, 49.946046, 53.938882, 50.944768, 0.0, 0.0, 0.0}, /* 55Mn 53Mn 54Mn 56Mn */ {54.938049, 54.938047, 52.941291, 53.940361, 55.938906, 0.0, 0.0, 0.0, 0.0}, /* 56Fe 54Fe 57Fe 58Fe 60Fe 55Fe 59Fe 52Fe */ {55.845, 55.934939, 53.939612, 56.935396, 57.933277, 59.934080, 54.938296, 58.934877, 51.948114}, /* 59Co 60Co 57Co 56Co 58Co */ {58.933200, 58.933198, 59.933819, 56.936294, 55.939841, 57.935755, 0.0, 0.0, 0.0}, /* 58Ni 60Ni 62Ni 61Ni 64Ni 59Ni 63Ni */ {58.6934, 57.935346, 59.930788, 61.928346, 60.931058, 63.927968, 58.934349, 62.929669, 0.0}, /* 63Cu 65Cu 67Cu 64Cu */ {63.546, 62.939598, 64.927793, 66.927747, 63.929765, 0.0, 0.0, 0.0, 0.0}, /* 64Zn 66Zn 68Zn 67Zn 70Zn 65Zn 69Zn */ {65.39, 63.929145, 65.926034, 67.924846, 66.927129, 69.925325, 64.929243, 69.926552, 0.0}, /* 69Ga 71Ga 67Ga 72Ga */ {69.723, 68.925580, 70.924700, 66.928420, 71.926365, 0.0, 0.0, 0.0, 0.0}, /* 74Ge 72Ge 70Ge 73Ge 76Ge 68Ge 71Ge 77Ge */ {72.61, 73.921177, 71.922079, 69.924250, 72.923463, 75.921401, 67.928096, 70.924250, 76.923548}, /* 75As 73As 76As 74As */ {74.92160, 74.921594, 72.923827, 75.922393, 73.923827, 0.0, 0.0, 0.0, 0.0}, /* 80Se 78Se 82Se 76Se 77Se 74Se 75Se */ {78.96, 79.916520, 77.917308, 81.916698, 75.919212, 76.919912, 73.922475, 74.922521, 0.0}, /* 79Br 81Br 77Br 82Br */ {79.904, 78.918336, 80.916289, 76.921378, 81.914802, 0.0, 0.0, 0.0, 0.0}, /* 84Kr 86Kr 82Kr 83Kr 80Kr 78Kr 85Kr */ {83.80, 83.911507, 85.910616, 81.913482, 82.914135, 79.916380, 77.920400, 84.912531, 0.0}, /* 85Rb */ {85.4678, 84.9117, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 88Sr 84Sr 86Sr 87Sr */ {87.62, 87.9056, 83.9134, 85.9094, 86.9089, 0.0, 0.0, 0.0, 0.0}, /* 89Y */ {88.90585, 88.9054, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 90Zr 91Zr 92Zr 94Zr */ {91.224, 89.9043, 90.9053, 91.9046, 93.9061, 0.0, 0.0, 0.0, 0.0}, /* 93Nb */ {92.90638, 92.9060, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 98Mo 92Mo 95Mo 96Mo */ {95.94, 97.9055, 91.9063, 94.90584, 95.9046, 0.0, 0.0, 0.0, 0.0}, /* Tc */ {98.9063, 98.9062, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 102Ru 99Ru 100Ru 104Ru */ {101.07, 101.9037, 98.9061, 99.9030, 103.9055, 0.0, 0.0, 0.0, 0.0}, /* 103Rh */ {102.90550, 102.9048, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 106Pd 104Pd 105Pd 108Pd */ {106.42, 105.9032, 103.9036, 104.9046, 107.90389, 0.0, 0.0, 0.0, 0.0}, /* 107Ag 109Ag */ {107.8682, 106.90509, 108.9047, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 114Cd 110Cd 111Cd 112Cd */ {112.411, 113.9036, 109.9030, 110.9042, 111.9028, 0.0, 0.0, 0.0, 0.0}, /* 115In 113In */ {14.818, 114.9041, 112.9043, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 118Sn 116Sn 117Sn 119Sn */ {118.710, 117.9018, 115.9021, 116.9031, 118.9034, 0.0, 0.0, 0.0, 0.0}, /* 121Sb 123Sb */ {121.760, 120.9038, 122.9041, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 130Te 125Te 126Te 128Te */ {127.60, 129.9067, 124.9044, 125.9032, 127.9047, 0.0, 0.0, 0.0, 0.0}, /* 127I */ {126.90447, 126.9004, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 132Xe 129Xe 131Xe 134Xe */ {131.29, 131.9042, 128.9048, 130.9051, 133.9054, 0.0, 0.0, 0.0, 0.0}, /* 134Cs */ {132.90545, 133.9051, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 138Ba 134Ba 135Ba 136Ba */ {137.327, 137.9050, 133.9043, 134.9056, 135.9044, 0.0, 0.0, 0.0, 0.0}, /* 139La 138La */ {138.9055, 138.9061, 137.9068, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 140Ce 138Ce 142Ce */ {140.116, 139.9053, 137.9057, 141.9090, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 141Pr */ {140.90765, 140.9074, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 142Nd 143Nd 144Nd 146Nd */ {144.24, 141.9075, 142.9096, 143.9099, 145.9127, 0.0, 0.0, 0.0, 0.0}, /* Pm */ {144.9127, 145.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 152Sm 147Sm 149Sm 154Sm */ {150.36, 151.9195, 146.9146, 148.9169, 153.9220, 0.0, 0.0, 0.0, 0.0}, /* 153Eu 151Eu */ {151.964, 152.9209, 150.9196, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 158Gd 156Gd 157Gd 160Gd */ {157.25, 157.9241, 155.9221, 156.9339, 159.9271, 0.0, 0.0, 0.0, 0.0}, /* 159Tb 151Tb */ {158.92534, 158.9250, 150.9230, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 164Dy 161Dy 162Dy 163Dy */ {162.50, 163.9288, 160.9266, 161.9265, 162.9284, 0.0, 0.0, 0.0, 0.0}, /* 165Ho */ {164.93032, 164.9303, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 166Er 167Er 168Er 170Er */ {167.26, 165.9304, 166.9320, 167.9324, 169.9355, 0.0, 0.0, 0.0, 0.0}, /* 169Tm */ {168.93421, 168.9344, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 174Yb 171Yb 172Yb 173Yb */ {173.04, 173.9390, 170.9365, 171.9366, 172.9383, 0.0, 0.0, 0.0, 0.0}, /* 175Lu */ {174.967, 174.9409, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 180Hf 177Hf 178Hf 179Hf */ {178.49, 179.9468, 176.9435, 177.9439, 178.9460, 0.0, 0.0, 0.0, 0.0}, /* 181Ta 180Ta */ {180.9479, 180.9480, 179.9415, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 184W 182W 183W 186W */ {183.84, 183.9510, 181.9483, 182.9503, 185.9543, 0.0, 0.0, 0.0, 0.0}, /* 187Re 185Re */ {186.207, 186.9560, 184.9530, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 190Os 188Os 189Os */ {190.23, 189.9586, 187.9560, 188.9586, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 193Ir 191Ir */ {192.217, 192.9633, 190.9609, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 195Pt 194Pt 196Pt 198Pt */ {195.078, 194.9648, 193.9628, 195.9650, 197.9675, 0.0, 0.0, 0.0, 0.0}, /* 197Au */ {196.96655, 196.9666, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 202Hg 199Hg 200Hg 201Hg */ {200.59, 201.9706, 198.9683, 199.9683, 200.9703, 0.0, 0.0, 0.0, 0.0}, /* 205Tl 203Tl */ {204.3833, 204.9745, 202.9723, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 208Pb 204Pb 206Pb 207Pb */ {207.2, 207.9766, 203.9730, 205.9745, 206.9759, 0.0, 0.0, 0.0, 0.0}, /* 209Bi 211Bi */ {208.98038, 208.9804, 210.9873, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 209Po 206Po 207Po 208Po */ {208.9824, 208.9825, 205.9805, 206.9816, 207.9813, 0.0, 0.0, 0.0, 0.0}, /* 211At */ {209.9871, 210.9875, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 222Rn 210Rn 211Rn 212Rn */ {222.0176, 222.0175, 209.9897, 210.9906, 211.9907, 0.0, 0.0, 0.0, 0.0}, /* 223Fr 212Fr 221Fr */ {223.0197, 223.0198, 211.9960, 221.0142, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 226Ra */ {226.0254, 226.0254, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 227Ac */ {227.0277, 227.0278, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 232Th 228Th 229Th 230Th */ {232.0381, 232.0382, 228.0287, 229.0316, 230.0331, 0.0, 0.0, 0.0, 0.0}, /* 231Pa 234Pa */ {231.03588, 231.0359, 234.0430, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 238U 234U 235U 236U */ {238.0289, 238.0508, 234.0409, 235.0439, 236.0457, 0.0, 0.0, 0.0, 0.0}, /* 237Np 236Np */ {237.0482, 237.0480, 236.0466, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 242Pu 239Pu 240Pu */ {244.0642, 242.0587, 239.0522, 240.0540, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 243Am 241Am */ {243.0614, 243.0614, 241.0567, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 246Cm 245Cm */ {247.0703, 246.0674, 245.0653, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 247Bk */ {247.0703, 247.0702, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 249Cf 250Cf */ {251.0796, 249.0748, 250.0766, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 252Es 253Es 254Es */ {252.0830, 252.0829, 253.0847, 254.0881, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 252Fm 250Fm 254Fm */ {257.0951, 252.0827, 250.0795, 254.0870, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 255Md */ {258.0984, 255.0906, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 259No */ {259.1011, 259.100931, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 260Lr */ {262.110, 260.105320, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 261Rf 257Rf 259Rf */ {261.1089, 261.108690, 257.102950, 259.105530, 0.0, 0.0, 0.0, 0.0, 0.0}, /* 262Db 258Db */ {262.1144, 262.113760, 258.109020, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* Sg */ {263.1186, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* Bh */ {264.12, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* Hs */ {265.1306, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, /* Mt */ {268.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; char pse[LASTELEMENT][2] = { "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt"}; int electrons[LASTELEMENT] = { 1, 0,-1,-1,-1, 4, 5, 6, 7, 0,-1,-1,-1, 4, 5, 6, 7, 0,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, 4, -1,-1, 7, 0,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1, 7, 0,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1, 0,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1}; viewmol-2.4.1/source/labelmodule.c0100644000272700027270000001603107752676166015323 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * L A B E L M O D U L E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: labelmodule.c,v 1.2 2003/11/07 11:05:26 jrh Exp $ * $Log: labelmodule.c,v $ * Revision 1.2 2003/11/07 11:05:26 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:09:56 jrh * Initial revision * */ #include #include #include #include "viewmol.h" #define PyLabel_API_pointers 1 #define PyLabelSpec_Type_NUM 0 extern int makeAnnotation(int, int, float, float, float, int, const GLfloat *, int, int, char *); extern void deleteAnnotation(int *); extern void getRGBColor(Widget, Pixel, float *, float *, float *); extern void pixelToWorld(int, double *, double *); extern int checkInterrupt(void); extern struct WINDOW windows[]; extern struct ANNOTATION *annotation; extern Pixel stdcol[9]; PyLabelSpecObject *label_new(void); static PyObject *label_label(PyObject *, PyObject *); static PyObject *label_text(PyObject *, PyObject *); static PyObject *label_translate(PyObject *, PyObject *); static PyObject *label_setColor(PyObject *, PyObject *); static PyObject *label_delete(PyObject *, PyObject *); static PyObject *label_getattr(PyLabelSpecObject *, char *); static void label_dealloc(PyLabelSpecObject *); static char PyLabelSpec_Type__doc__[] = "Label specification"; statichere PyTypeObject PyLabelSpec_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "LabelSpec", /*tp_name*/ sizeof(PyLabelSpecObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)label_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)label_getattr, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ /* Space for future expansion */ 0L,0L, /* Documentation string */ PyLabelSpec_Type__doc__ }; static PyMethodDef label_methods[] = { {"label", label_label, 1}, {"text", label_text, 1}, {"translate", label_translate, 1}, {"setColor", label_setColor, 1}, {"delete", label_delete, 1}, {NULL, NULL} }; static PyObject *label_translate(PyObject *self, PyObject *args) { PyLabelSpecObject *s; Dimension width, height; int x, y, z, which; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "iii", &x, &y, &z)) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyLabelSpecObject *)self; which=s->labelID; XtVaGetValues(windows[VIEWER].widget, XtNwidth, &width, XtNheight, &height, NULL); annotation[which].x=2.0*(double)x/(double)width-1.0; annotation[which].y=2.0*(double)y/(double)height-1.0; annotation[which].z=z; Py_INCREF(Py_None); return(Py_None); } static PyObject *label_setColor(PyObject *self, PyObject *args) { PyLabelSpecObject *s; Pixel color=(Pixel)0; float r, g, b, a, rs, gs, bs, diff, d; int which, i; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "ffff", &r, &g, &b, &a)) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyLabelSpecObject *)self; which=s->labelID; diff=10.0; for (i=0; i<9; i++) { getRGBColor(windows[VIEWER].widget, stdcol[i], &rs, &gs, &bs); d=(rs-r)*(rs-r)+(gs-g)*(gs-g)+(bs-b)*(bs-b); if (d < diff) { color=stdcol[i]; diff=d; } } annotation[which].color=color; annotation[which].color_rgb[0]=r; annotation[which].color_rgb[1]=g; annotation[which].color_rgb[2]=b; annotation[which].color_rgb[3]=a; Py_INCREF(Py_None); return(Py_None); } static PyObject *label_label(PyObject *self, PyObject *args) { const float black[4] = {0.0, 0.0, 0.0, 1.0}; int mode=EDITABLE | MOVEABLE, which; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|i", &mode)) return(NULL); which=makeAnnotation((-1), COORDINATES, 0.0, 0.0, 0.0, stdcol[BLACK], black, mode, 0, ""); return((PyObject *)annotation[which].pyObject); } PyLabelSpecObject *label_new(void) { PyLabelSpecObject *self; self=PyObject_NEW(PyLabelSpecObject, &PyLabelSpec_Type); if (self == NULL) { PyErr_NoMemory(); return(NULL); } self->labelID=0; return((PyLabelSpecObject *)self); } static PyObject *label_text(PyObject *self, PyObject *args) { PyLabelSpecObject *s; int which; char *text=NULL; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|s", &text)) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyLabelSpecObject *)self; which=s->labelID; if (text == NULL) /* get */ return(PyString_FromString(annotation[which].text)); else /* set */ { strncpy(annotation[which].text, text, MAXLENLINE-1); Py_INCREF(Py_None); return(Py_None); } } static PyObject *label_delete(PyObject *self, PyObject *args) { PyLabelSpecObject *s; int which; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyLabelSpecObject *)self; which=s->labelID; deleteAnnotation(&which); Py_INCREF(Py_None); return(Py_None); } static void label_dealloc(PyLabelSpecObject *self) { /* This has to be a dummy function, since labels are handled in Viewmol PyMem_DEL(self); */ } static PyObject *label_getattr(PyLabelSpecObject *self, char *name) { return(Py_FindMethod(label_methods, (PyObject *)self, name)); } void initLabelModule(void) { PyObject *module, *dict; static void *PyLabel_API[PyLabel_API_pointers]; PyLabelSpec_Type.ob_type=&PyType_Type; module=Py_InitModule("label", label_methods); dict=PyModule_GetDict(module); PyLabel_API[PyLabelSpec_Type_NUM]=(void *)&PyLabelSpec_Type; PyDict_SetItemString(dict, "_C_API", PyCObject_FromVoidPtr((void *)PyLabel_API, NULL)); PyDict_SetItemString(dict, "EDITABLE", PyInt_FromLong((long)(EDITABLE))); PyDict_SetItemString(dict, "MOVABLE", PyInt_FromLong((long)(MOVEABLE))); } viewmol-2.4.1/source/lightmodule.c0100644000272700027270000001113107752676176015350 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * L I G H T M O D U L E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: lightmodule.c,v 1.2 2003/11/07 11:05:34 jrh Exp $ * $Log: lightmodule.c,v $ * Revision 1.2 2003/11/07 11:05:34 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:10:17 jrh * Initial revision * */ #include #include #include #include "viewmol.h" #define PyLight_API_pointers 1 #define PyLightSpec_Type_NUM 0 PyLightSpecObject *light_new(void); static PyObject *light_rotate(PyObject *, PyObject *); static PyObject *light_switch(PyObject *, PyObject *); static PyObject *light_getattr(PyLightSpecObject *, char *); static void light_dealloc(PyLightSpecObject *); extern void getRotation(int, int, int, int); extern int checkInterrupt(void); extern float *rotObject; extern int moveItem, rotateXY, rotateZ, lights; static char PyLightSpec_Type__doc__[] = "Light specification"; statichere PyTypeObject PyLightSpec_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "LightSpec", /*tp_name*/ sizeof(PyLightSpecObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)light_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)light_getattr, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ /* Space for future expansion */ 0L,0L, /* Documentation string */ PyLightSpec_Type__doc__ }; static PyMethodDef light_methods[] = { {"rotate", light_rotate, 1}, {"switch", light_switch, 1}, {NULL, NULL} }; static PyObject *light_rotate(PyObject *self, PyObject *args) { PyLightSpecObject *s; int moveItem_save, which, x, y, z; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "iii", &x, &y, &z)) return(NULL); s=(PyLightSpecObject *)self; which=s->lightID; rotObject[4*which]=rotObject[4*which+1]=rotObject[4*which+2]=0.0; rotObject[4*which+3]=1.0; moveItem_save=moveItem; moveItem=which; getRotation(x, y, z, 1); moveItem=moveItem_save; Py_INCREF(Py_None); return(Py_None); } static PyObject *light_switch(PyObject *self, PyObject *args) { PyLightSpecObject *s; int which, i, mode; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "i", &mode)) return(NULL); if (mode != TRUE && mode != FALSE) { PyErr_SetString(PyExc_ValueError, "Mode must be ON or OFF"); return(NULL); } s=(PyLightSpecObject *)self; which=s->lightID-1; i=1 << which; if (mode) lights|=i; else lights&=~i; Py_INCREF(Py_None); return(Py_None); } PyLightSpecObject *light_new(void) { PyLightSpecObject *self; self=PyObject_NEW(PyLightSpecObject, &PyLightSpec_Type); if (self == NULL) { PyErr_NoMemory(); return(NULL); } self->lightID=0; return((PyLightSpecObject *)self); } static void light_dealloc(PyLightSpecObject *self) { if (!self) return; PyMem_DEL(self); } static PyObject *light_getattr(PyLightSpecObject *self, char *name) { return(Py_FindMethod(light_methods, (PyObject *)self, name)); } void initLightModule(void) { PyObject *module, *dict; static void *PyLight_API[PyLight_API_pointers]; PyLightSpec_Type.ob_type=&PyType_Type; module=Py_InitModule("light", light_methods); dict=PyModule_GetDict(module); PyLight_API[PyLightSpec_Type_NUM]=(void *)&PyLightSpec_Type; PyDict_SetItemString(dict, "_C_API", PyCObject_FromVoidPtr((void *)PyLight_API, NULL)); } viewmol-2.4.1/source/makeTranslations0100755000272700027270000000212010114367014016100 0ustar jrhjrh#!/bin/sh #******************************************************************************* # * # Viewmol * # * # M A K E T R A N S L A T I O N S * # * # Copyright (c) Joerg-R. Hill, October 2003 * # * #******************************************************************************* # # $Id: makeTranslations,v 1.2 2004/08/29 14:54:04 jrh Exp $ # $Log: makeTranslations,v $ # Revision 1.2 2004/08/29 14:54:04 jrh # Release 2.4.1 # # Revision 1.1 2003/11/07 12:54:29 jrh # Initial revision # wd=`pwd` for i in ../locale/* do if [ "$i" != "../locale/CVS" ] then cd $i/LC_MESSAGES msgfmt Viewmol.po -o Viewmol.mo cd $wd fi done viewmol-2.4.1/source/makemenu.c0100644000272700027270000001107307752676203014631 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M A K E M E N U . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: makemenu.c,v 1.6 2003/11/07 11:05:39 jrh Exp $ * $Log: makemenu.c,v $ * Revision 1.6 2003/11/07 11:05:39 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:10:32 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:08 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:50:51 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:17 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:41:41 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include "menu.h" extern Widget topShell; extern int rgbMode; /* Build popup, option and pulldown menus, depending on the menu_type. * It may be XmMENU_PULLDOWN, XmMENU_OPTION or XmMENU_POPUP. Pulldowns * return the CascadeButton that pops up the menu. Popups return the menu. * Option menus are created, but the RowColumn that acts as the option * "area" is returned unmanaged. (The user must manage it.) * Pulldown menus are built from cascade buttons, so this function * also builds pullright menus. The function also adds the right * callback for PushButton or ToggleButton menu items. */ Widget makeMenu(Widget parent, int menu_type, char *label, struct MenuItem *items) { Visual *vi; Colormap colormap; Pixel bg; Widget menu, cascade=NULL; Arg args[3]; register int i; XtVaGetValues(topShell, XmNvisual, &vi, XmNcolormap, &colormap, XmNbackground, &bg, NULL); XtSetArg(args[0], XmNvisual, vi); XtSetArg(args[1], XmNcolormap, colormap); if (menu_type == XmMENU_PULLDOWN || menu_type == XmMENU_OPTION) menu=XmCreatePulldownMenu(parent, "_pulldown", args, 2); else if (menu_type == XmMENU_POPUP) menu=XmCreatePopupMenu(parent, "_popup", args, 2); else { XtWarning("Invalid menu type passed to makeMenu()"); return(NULL); } /* Pulldown menus require a cascade button to be made */ if (menu_type == XmMENU_PULLDOWN) { cascade=XtVaCreateManagedWidget(label, xmCascadeButtonGadgetClass, parent, XmNsubMenuId, menu, NULL); } else if (menu_type == XmMENU_OPTION) { /* Option menus are a special case, but not hard to handle */ XtSetArg(args[0], XmNsubMenuId, menu); /* This really isn't a cascade, but this is the widget handle we're going to return at the end of the function. */ cascade=XmCreateOptionMenu(parent, label, args, 1); } /* Now add the menu items */ for (i = 0; items[i].label != NULL; i++) { /* If subitems exist, create the pull-right menu by calling this function recursively. Since the function returns a cascade button, the widget returned is used. */ if (items[i].subitems) if (menu_type == XmMENU_OPTION) { XtWarning("You can't have submenus from option menu items."); continue; } else items[i].widget=makeMenu(menu, XmMENU_PULLDOWN, items[i].label, items[i].subitems); else items[i].widget=XtVaCreateManagedWidget(items[i].label, *items[i].class, menu, NULL); if (items[i].callback) XtAddCallback(items[i].widget, (items[i].class == &xmToggleButtonWidgetClass || items[i].class == &xmToggleButtonGadgetClass) ? XmNvalueChangedCallback : /* ToggleButton class */ XmNactivateCallback, /* PushButton class */ items[i].callback, items[i].callback_data); } /* for popup menus, just return the menu; pulldown menus, return the cascade button; option menus, return the thing returned from XmCreateOptionMenu(). This isn't a menu, or a cascade button! */ return(menu_type == XmMENU_POPUP? menu : cascade); } viewmol-2.4.1/source/maketics.c0100644000272700027270000000367407752676257014650 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M A K E T I C S . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: maketics.c,v 1.6 2003/11/07 11:06:23 jrh Exp $ * $Log: maketics.c,v $ * Revision 1.6 2003/11/07 11:06:23 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:10:39 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:10 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:50:58 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:19 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:41:45 jrh * Initial revision * */ #include #include #include double dbl_raise(double x, int y) { register int i; double val; val=1.0e0; for (i=0; i= 0.0 ) ? (int)logr : ((int)logr-1))); if (r <= 2.0e0) tic=0.2e0; else if (r <= 5.0e0) tic=0.5e0; else tic=1.0e0; if (logr > 0.0e0) sprintf(format, "%%%dg", (int)logr+2); else sprintf(format, "%%.%dg", (int)(-logr)+(tmin == 0.0e0 ? 0 : (int)log10(fabs(tmin))+2)); tic*=dbl_raise(10.0e0, (logr >= 0.0 ) ? (int)logr : ((int)logr-1)); *start=tic*ceil(tmin/tic); return(tic); } viewmol-2.4.1/source/manual.c0100644000272700027270000000517107752676265014316 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M A N U A L . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: manual.c,v 1.6 2003/11/07 11:06:29 jrh Exp $ * $Log: manual.c,v $ * Revision 1.6 2003/11/07 11:06:29 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:10:45 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:28:34 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:51:05 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:22 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:41:54 jrh * Initial revision * */ #include #include #include #if !defined LINUX && !defined IRIX && !defined _HPUX_SOURCE && !defined DARWIN && !defined FREEBSD #include #endif #include #include "viewmol.h" #include "dialog.h" extern Widget topShell; extern pid_t manual_pid; extern char webbrowser[]; extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern char *getStringResource(Widget, char *); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern int runProg(char *, int, char *, char *, char *, pid_t *); void manual(Widget widget, caddr_t client_data, caddr_t call_data) { static struct PushButtonRow buttons[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; char command[MAXLENLINE], manualfile[MAXLENLINE], *word; if (*webbrowser == '\0') { word=getStringResource(topShell, "noBrowser"); sprintf(manualfile, word, getStringResource(topShell, "webBrowser")); messgb(topShell, 1, manualfile, buttons, 1); return; } strcpy(manualfile, getenv("VIEWMOLPATH")); strcat(manualfile, "/doc/viewmol.html"); if (access(manualfile, 0)) { word=getStringResource(topShell, "noManual"); sprintf(command, word, manualfile); messgb(topShell, 1, command, buttons, 1); return; } sprintf(command, webbrowser, manualfile); if (runProg(command, FALSE, "/dev/null", "/dev/null", "/dev/null", &manual_pid)) { word=getStringResource(topShell, "cannotDisplay"); messgb(topShell, 1, word, buttons, 1); } } viewmol-2.4.1/source/marcub.c0100644000272700027270000006621307752676274014316 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M A R C U B . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: marcub.c,v 1.6 2003/11/07 11:06:36 jrh Exp $ * $Log: marcub.c,v $ * Revision 1.6 2003/11/07 11:06:36 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:10:52 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:15 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:51:14 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:24 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:41:59 jrh * Initial revision * * * This function implements the drawing of the basic patterns of the improved * marching cube algorithm as described in W. Heiden, T. Goetze, and J. Brick- * mann: J. Comp. Chem. 14 (1993), 246-250. The calculation of the grid has to be * done in a separate function. The parameters passed to this function are: * xstart, ystart, and zstart - the cartesian coordinates of the lower left front * corner of the volume which is used to draw the isosurface (the origin of the * grid); grid - a pointer to an array which contains the values of the function * at each grid point, three dimensional, stored row by row, step - the distance * between two grid points; xres, yres, and zres - the number of times step has * to be added to xstart, ystart, or zstart to walk through the whole grid, is * equal to the number of grid points minus one in each direction; level - a * floating point number which determines which isosurface to select; * begin, end, vert, and normal - pointers to the drawing functions. * The numbering of the cube's corners is as follows: * * 7+------+6 * y /| /| * ^ z 3+------+2| * | / |4+----|-+5 * |/ |/ |/ * +----> x 0+------+1 * * */ #include #include #include #include "marcub.h" #include "viewmol.h" #define FALSE 0 #define TRUE 1 #define index(i, j, k) ((grid->ngridpoints[1]+1)*(grid->ngridpoints[2]+1)*(k)+(grid->ngridpoints[2]+1)*(j)+(i)) /* static double norms[27][3], vertices[27][3]; static int vcount=0, recordit=FALSE; */ /* Prototypes */ void set_vertex(double, double, double, int, int, struct GRIDOBJECT *, int, int, int, int, void (*)(), void (*)()); /* Global variables */ static int corner[] = { 0, 1, 0, 3, 0, 4, /* 1 */ 1, 5, 1, 2, 1, 0, 0, 3, 0, 4, 1, 2, 1, 5, 3, 7, 3, 0, 3, 2, 0, 4, 0, 1, 3, 7, 3, 2, /* 5 */ 1, 2, 1, 0, 1, 5, -1, 3, 2, 3, 7, 3, 0, 0, 4, 1, 5, 3, 7, 1, 2, 3, 2, 2, 3, 2, 1, 2, 6, 0, 1, 0, 3, 0, 4, -1, 2, 3, 2, 1, 2, 6, 1, 5, 2, 6, 1, 0, 2, 3, /* 10 */ 1, 5, 2, 6, 0, 4, 2, 3, 0, 3, 2, 6, 3, 7, 2, 1, 3, 0, 3, 7, 0, 4, 2, 6, 0, 1, 2, 1, 2, 6, 3, 7, 1, 5, 3, 0, 1, 0, 1, 5, 2, 6, 0, 4, 3, 7, /* 15 */ 4, 5, 4, 0, 4, 7, 0, 3, 4, 7, 0, 1, 4, 5, 1, 0, 1, 5, 1, 2, -1, 4, 5, 4, 0, 4, 7, 0, 3, 4, 7, 1, 2, 4, 5, 1, 5, 3, 2, 3, 7, 3, 0, -1, 4, 5, 4, 0, 4, 7, /* 20 */ 0, 1, 3, 2, 4, 5, 3, 7, 4, 7, 1, 0, 1, 5, 1, 2, -1, 3, 2, 3, 7, 3, 0, -1, 4, 5, 4, 0, 4, 7, 1, 5, 1, 2, 4, 5, 3, 2, 4, 7, 3, 7, 2, 3, 2, 1, 2, 6, -1, 4, 5, 4, 0, 4, 7, 0, 3, 4, 7, 0, 1, 4, 5, -1, 2, 3, 2, 1, 2, 6, /* 25 */ 1, 5, 2, 6, 1, 0, 2, 3, -1, 4, 5, 4, 0, 4, 7, 2, 6, 2, 3, 1, 5, 0, 3, 4, 7, -1, 1, 5, 4, 7, 4, 5, 2, 6, 3, 7, 2, 1, 3, 0, -1, 4, 5, 4, 0, 4, 7, 2, 6, 3, 7, 2, 1, 4, 5, 0, 1, -1, 3, 7, 4, 7, 4, 5, 4, 5, 4, 0, 4, 7, -1, 2, 6, 3, 7, 1, 5, 3, 0, 1, 0, /* 30 */ 6, 2, 7, 3, 5, 1, 7, 4, 5, 4, 5, 4, 5, 6, 5, 1, 0, 1, 0, 3, 0, 4, -1, 5, 4, 5, 6, 5, 1, 1, 2, 1, 0, 5, 6, 5, 4, 1, 2, 0, 3, 5, 6, 0, 4, 5, 4, /* 35 */ 3, 2, 3, 7, 3, 0, -1, 5, 4, 5, 6, 5, 1, 0, 4, 0, 1, 3, 7, 3, 2, -1, 5, 4, 5, 6, 5, 1, 1, 2, 1, 0, 5, 6, 5, 4, -1, 3, 2, 3, 7, 3, 0, 3, 7, 0, 4, 3, 2, 5, 6, 1, 2, -1, 0, 4, 5, 4, 5, 6, 2, 3, 2, 1, 2, 6, -1, 5, 4, 5, 6, 5, 1, /* 40 */ 0, 1, 0, 3, 0, 4, -1, 2, 3, 2, 1, 2, 6, -1, 5, 4, 5, 6, 5, 1, 1, 0, 5, 4, 2, 3, 5, 6, 2, 6, 0, 4, 5, 4, 0, 3, 5, 6, 2, 3, 2, 6, 2, 6, 3, 7, 2, 1, 3, 0, -1, 5, 4, 5, 6, 5, 1, 5, 4, 5, 6, 5, 1, -1, 3, 7, 0, 4, 2, 6, 0, 1, 2, 1, /* 45 */ 3, 7, 3, 0, 2, 6, 1, 0, 5, 4, -1, 2, 6, 5, 4, 5, 6, 7, 3, 4, 0, 6, 2, 4, 5, 6, 5, 4, 0, 4, 7, 5, 1, 5, 6, 4, 7, 5, 6, 0, 3, 5, 1, 0, 1, 5, 6, 1, 2, 4, 7, 1, 0, 4, 0, /* 50 */ 1, 2, 0, 3, 5, 6, 4, 7, 4, 0, 4, 7, 5, 1, 5, 6, -1, 3, 2, 3, 7, 3, 0, 3, 2, 3, 7, 0, 1, 4, 7, 5, 6, -1, 0, 1, 5, 6, 5, 1, 3, 2, 3, 7, 3, 0, -1, 5, 6, 1, 2, 4, 7, 1, 0, 4, 0, 6, 5, 2, 1, 7, 4, 2, 3, 7, 3, /* 55 */ 4, 0, 4, 7, 5, 1, 5, 6, -1, 2, 3, 2, 1, 2, 6, 2, 3, 2, 1, 2, 6, -1, 4, 7, 5, 6, 0, 3, 5, 1, 0, 1, 2, 3, 1, 0, 2, 6, 4, 7, 5, 6, -1, 1, 0, 4, 0, 4, 7, 7, 4, 6, 5, 3, 0, 6, 2, 3, 2, 2, 6, 3, 7, 2, 1, 3, 0, -1, 4, 0, 4, 7, 5, 1, 5, 6, /* 60 */ 5, 6, 1, 5, 4, 7, 0, 1, 3, 7, 1, 2, 2, 6, 3, 7, 0, 3, 2, 6, 0, 1, 5, 6, 0, 4, 4, 7, 6, 2, 7, 3, 6, 5, 7, 4, 7, 6, 7, 4, 7, 3, 0, 1, 0, 3, 0, 4, -1, 7, 6, 7, 4, 7, 3, /* 65 */ 1, 0, 1, 5, 1, 2, -1, 7, 6, 7, 4, 7, 3, 0, 4, 1, 5, 0, 3, 1, 2, -1, 7, 6, 7, 4, 7, 3, 3, 0, 3, 2, 7, 4, 7, 6, 3, 2, 7, 6, 0, 1, 7, 4, 0, 4, 3, 0, 3, 2, 7, 4, 7, 6, -1, 1, 0, 1, 5, 1, 2, /* 70 */ 1, 5, 1, 2, 0, 4, 3, 2, 7, 6, -1, 0, 4, 7, 6, 7, 4, 2, 3, 2, 1, 2, 6, -1, 7, 6, 7, 4, 7, 3, 0, 1, 0, 3, 0, 4, -1, 2, 3, 2, 1, 2, 6, -1, 7, 6, 7, 4, 7, 3, 1, 5, 2, 6, 1, 0, 2, 3, -1, 7, 6, 7, 4, 7, 3, 7, 6, 7, 4, 7, 3, -1, 1, 5, 2, 6, 0, 4, 2, 3, 0, 3, /* 75 */ 3, 0, 2, 1, 7, 4, 2, 6, 7, 6, 0, 4, 0, 1, 7, 4, 2, 1, 7, 6, 2, 6, 1, 5, 2, 6, 1, 0, 7, 4, 3, 0, -1, 2, 6, 7, 6, 7, 4, 5, 1, 6, 2, 4, 0, 6, 7, 4, 7, 4, 0, 7, 3, 4, 5, 7, 6, /* 80 */ 4, 5, 0, 1, 7, 6, 0, 3, 7, 3, 4, 0, 7, 3, 4, 5, 7, 6, -1, 1, 0, 1, 5, 1, 2, 1, 2, 0, 3, 1, 5, 7, 6, 4, 5, -1, 0, 3, 7, 3, 7, 6, 7, 6, 4, 5, 3, 2, 4, 0, 3, 0, 3, 2, 7, 6, 0, 1, 4, 5, /* 85 */ 1, 0, 1, 5, 1, 2, -1, 7, 6, 4, 5, 3, 2, 4, 0, 3, 0, 6, 7, 5, 4, 2, 3, 5, 1, 2, 1, 4, 0, 7, 3, 4, 5, 7, 6, -1, 2, 3, 2, 1, 2, 6, 2, 3, 2, 1, 2, 6, -1, 4, 5, 0, 1, 7, 6, 0, 3, 7, 3, 1, 5, 2, 6, 1, 0, 2, 3, -1, 4, 0, 7, 3, 4, 5, 7, 6, /* 90 */ 2, 6, 2, 3, 1, 5, 0, 3, 4, 5, 3, 7, 6, 7, 2, 1, 2, 6, 3, 0, 7, 6, 4, 5, -1, 3, 0, 4, 5, 4, 0, 5, 4, 1, 0, 6, 7, 1, 2, 6, 2, 4, 5, 0, 4, 6, 7, 0, 3, 2, 6, 0, 1, 1, 5, 5, 1, 6, 2, 5, 4, 6, 7, /* 95 */ 5, 4, 5, 6, 5, 1, -1, 7, 6, 7, 4, 7, 3, 0, 1, 0, 3, 0, 4, -1, 5, 4, 5, 6, 5, 1, -1, 7, 6, 7, 4, 7, 3, 1, 2, 1, 0, 5, 6, 5, 4, -1, 7, 6, 7, 4, 7, 3, 7, 6, 7, 4, 7, 3, -1, 1, 2, 0, 3, 5, 6, 0, 4, 5, 4, 3, 0, 3, 2, 7, 4, 7, 6, -1, 5, 4, 5, 6, 5, 1, /* 100 */ 5, 4, 5, 6, 5, 1, -1, 3, 2, 7, 6, 0, 1, 7, 4, 0, 4, 1, 2, 1, 0, 5, 6, 5, 4, -1, 3, 0, 3, 2, 7, 4, 7, 6, 6, 7, 4, 7, 2, 3, 0, 4, 1, 2, 4, 5, 5, 6, 2, 3, 2, 1, 2, 6, -1, 5, 4, 5, 6, 5, 1, -1, 7, 6, 7, 4, 7, 3, 0, 1, 0, 3, 0, 4, -1, 2, 3, 2, 1, 2, 6, -1, 5, 4, 5, 6, 5, 1, -1, 7, 6, 7, 4, 7, 3, /* 105 */ 7, 6, 7, 4, 7, 3, -1, 1, 0, 5, 4, 2, 3, 5, 6, 2, 6, 3, 0, 4, 0, 3, 2, 4, 5, 3, 7, 4, 7, -1, 6, 7, 6, 5, 6, 2, 5, 4, 5, 6, 5, 1, -1, 3, 0, 2, 1, 7, 4, 2, 6, 7, 6, 1, 5, 4, 5, 1, 2, 4, 7, 0, 1, 0, 4, -1, 6, 7, 6, 5, 6, 2, 4, 5, 6, 5, 0, 1, 6, 2, 0, 3, 6, 7, 4, 7, /* 110 */ 4, 5, 6, 5, 4, 0, 6, 2, 4, 7, 6, 7, 4, 0, 7, 3, 5, 1, 7, 6, 5, 6, 0, 3, 7, 3, 0, 1, 7, 6, 5, 1, 5, 6, 1, 2, 1, 0, 5, 6, 4, 0, 7, 3, -1, 5, 6, 7, 3, 7, 6, 2, 1, 3, 0, 6, 5, 3, 7, 6, 7, /* 115 */ 3, 2, 7, 6, 3, 0, 5, 1, 4, 0, -1, 7, 6, 5, 6, 5, 1, 2, 3, 6, 7, 1, 0, 6, 5, 1, 5, 1, 2, 0, 1, 5, 6, 0, 4, 6, 7, 0, 3, 2, 3, 2, 1, 2, 3, 6, 5, 6, 7, 2, 3, 2, 1, 2, 6, -1, 4, 0, 7, 3, 5, 1, 7, 6, 5, 6, /* 120 */ 1, 0, 3, 0, 1, 5, 3, 7, 1, 2, 3, 2, -1, 6, 7, 6, 5, 6, 2, 3, 7, 6, 7, 0, 4, 5, 6, 0, 1, 2, 6, 2, 3, 2, 6, 2, 3, 5, 6, 0, 3, 6, 7, 3, 7, 1, 2, 2, 6, 0, 3, 6, 7, 0, 4, 5, 6, 1, 5, 1, 2, 6, 2, 1, 0, 6, 7, 1, 5, 6, 5, /* 125 */ 0, 1, 0, 4, 0, 3, -1, 6, 7, 6, 5, 6, 2, 6, 7, 6, 5, 6, 2, 6, 7, 6, 2, 6, 5, 0, 1, 0, 3, 0, 4, -1, 6, 7, 6, 2, 6, 5, 1, 0, 1, 5, 1, 2, -1, 6, 7, 6, 2, 6, 5, /* 130 */ 0, 4, 1, 5, 0, 3, 1, 2, -1, 6, 7, 6, 2, 6, 5, 3, 2, 3, 7, 3, 0, -1, 6, 7, 6, 2, 6, 5, 0, 4, 0, 1, 3, 7, 3, 2, -1, 6, 7, 6, 2, 6, 5, 1, 0, 1, 5, 1, 2, -1, 3, 2, 3, 7, 3, 0, -1, 6, 7, 6, 2, 6, 5, 6, 7, 6, 2, 6, 5, -1, 0, 4, 1, 5, 3, 7, 1, 2, 3, 2, /* 135 */ 2, 1, 6, 5, 2, 3, 6, 7, 2, 1, 6, 5, 2, 3, 6, 7, -1, 0, 1, 0, 3, 0, 4, 2, 3, 1, 0, 6, 7, 1, 5, 6, 5, 0, 4, 1, 5, 0, 3, 6, 7, 2, 3, -1, 1, 5, 6, 5, 6, 7, 2, 1, 6, 5, 3, 0, 6, 7, 3, 7, /* 140 */ 0, 4, 0, 1, 3, 7, 2, 1, 6, 5, -1, 3, 7, 6, 5, 6, 7, 1, 5, 6, 5, 1, 0, 6, 7, 3, 0, 3, 7, 4, 0, 5, 1, 7, 3, 5, 6, 7, 6, 4, 5, 4, 0, 4, 7, -1, 6, 7, 6, 2, 6, 5, 0, 3, 4, 7, 0, 1, 4, 5, -1, 6, 7, 6, 2, 6, 5, /* 145 */ 1, 0, 1, 5, 1, 2, -1, 4, 5, 4, 0, 4, 7, -1, 6, 7, 6, 2, 6, 5, 6, 7, 6, 2, 6, 5, -1, 0, 3, 4, 7, 1, 2, 4, 5, 1, 5, 3, 2, 3, 7, 3, 0, -1, 4, 5, 4, 0, 4, 7, -1, 6, 7, 6, 2, 6, 5, 6, 7, 6, 2, 6, 5, -1, 0, 1, 3, 2, 4, 5, 3, 7, 4, 7, 1, 0, 1, 5, 1, 2, -1, 3, 2, 3, 7, 3, 0, -1, 4, 5, 4, 0, 4, 7, -1, 6, 7, 6, 2, 6, 5, /* 150 */ 1, 5, 1, 2, 4, 5, 2, 3, 5, 6, 2, 6, -1, 7, 6, 7, 3, 7, 4, 2, 1, 6, 5, 2, 3, 6, 7, -1, 4, 5, 4, 0, 4, 7, 0, 3, 4, 7, 0, 1, 4, 5, -1, 2, 1, 6, 5, 2, 3, 6, 7, 4, 5, 4, 0, 4, 7, -1, 2, 3, 1, 0, 6, 7, 1, 5, 6, 5, 4, 7, 4, 5, 0, 3, 1, 5, 2, 3, 5, 6, 6, 7, /* 155 */ 4, 5, 4, 0, 4, 7, -1, 2, 1, 6, 5, 3, 0, 6, 7, 3, 7, 5, 6, 6, 7, 1, 2, 3, 7, 0, 1, 4, 7, 4, 5, 0, 1, 5, 1, 0, 3, 5, 6, 0, 4, 5, 4, -1, 7, 6, 7, 3, 7, 4, 5, 6, 6, 7, 1, 5, 3, 7, 4, 5, 4, 7, 5, 1, 5, 4, 6, 2, 6, 7, /* 160 */ 5, 1, 5, 4, 6, 2, 6, 7, -1, 0, 1, 0, 3, 0, 4, 5, 4, 6, 7, 1, 0, 6, 2, 1, 2, 0, 3, 0, 4, 1, 2, 5, 4, 6, 7, -1, 1, 2, 6, 7, 6, 2, 5, 1, 5, 4, 6, 2, 6, 7, -1, 3, 2, 3, 7, 3, 0, 0, 4, 0, 1, 3, 7, 3, 2, -1, 5, 1, 5, 4, 6, 2, 6, 7, /* 165 */ 3, 2, 3, 7, 3, 0, -1, 5, 4, 6, 7, 1, 0, 6, 2, 1, 2, 6, 7, 2, 6, 4, 5, 1, 2, 0, 4, 2, 3, 3, 7, 6, 7, 2, 3, 5, 4, 2, 1, 5, 1, 0, 1, 0, 3, 0, 4, -1, 6, 7, 2, 3, 5, 4, 2, 1, 5, 1, 2, 3, 1, 0, 6, 7, 5, 4, /* 170 */ 7, 6, 3, 2, 4, 5, 3, 0, 4, 0, 3, 0, 2, 1, 3, 7, 5, 4, 6, 7, -1, 2, 1, 5, 1, 5, 4, 0, 4, 0, 1, 3, 7, 1, 2, 6, 7, 1, 5, 4, 5, 4, 5, 7, 6, 0, 1, 7, 3, 0, 3, 4, 0, 4, 5, 7, 3, 7, 6, /* 175 */ 5, 1, 4, 0, 6, 2, 4, 7, 6, 7, 0, 3, 4, 7, 0, 1, 6, 2, 5, 1, -1, 4, 7, 6, 7, 6, 2, 1, 2, 1, 0, 6, 2, 4, 0, 6, 7, 4, 7, 3, 0, 7, 4, 2, 1, 7, 6, 2, 6, 3, 2, 3, 7, 3, 0, -1, 5, 1, 4, 0, 6, 2, 4, 7, 6, 7, /* 180 */ 2, 3, 3, 7, 0, 1, 4, 7, 1, 5, 6, 7, 2, 6, 0, 3, 2, 3, 0, 4, 2, 6, 0, 1, 1, 2, -1, 7, 6, 7, 3, 7, 4, 2, 3, 7, 3, 2, 1, 7, 4, 2, 6, 7, 6, 2, 3, 2, 1, 6, 7, 5, 1, 4, 0, -1, 6, 7, 4, 0, 4, 7, 2, 3, 1, 2, 6, 7, 1, 5, 4, 7, 0, 1, 0, 3, /* 185 */ 3, 2, 0, 1, 7, 6, 0, 4, 7, 4, 3, 0, 7, 4, 3, 2, 7, 6, 0, 4, 4, 7, 1, 5, 6, 7, 1, 2, 3, 7, 0, 3, 1, 0, 1, 2, 1, 5, -1, 7, 6, 7, 3, 7, 4, 3, 7, 0, 3, 6, 7, 0, 1, 4, 7, 0, 4, /* 190 */ 7, 6, 7, 3, 7, 4, 6, 2, 6, 5, 7, 3, 7, 4, 6, 2, 6, 5, 7, 3, 7, 4, -1, 0, 1, 0, 3, 0, 4, 6, 2, 6, 5, 7, 3, 7, 4, -1, 1, 0, 1, 5, 1, 2, 0, 4, 1, 5, 0, 3, 1, 2, -1, 6, 2, 6, 5, 7, 3, 7, 4, /* 195 */ 7, 4, 3, 0, 6, 5, 3, 2, 6, 2, 0, 1, 3, 2, 0, 4, 6, 5, 7, 4, -1, 3, 2, 6, 2, 6, 5, 1, 0, 1, 5, 1, 2, -1, 7, 4, 3, 0, 6, 5, 3, 2, 6, 2, 1, 5, 1, 2, 0, 4, 2, 3, 4, 7, 2, 6, 5, 6, 6, 5, 7, 4, 2, 1, 7, 3, 2, 3, /* 200 */ 0, 1, 0, 3, 0, 4, -1, 6, 5, 7, 4, 2, 1, 7, 3, 2, 3, 1, 0, 1, 5, 2, 3, 6, 5, 7, 4, -1, 2, 3, 7, 4, 7, 3, 4, 7, 3, 7, 5, 6, 2, 3, 1, 5, 0, 3, 0, 4, 3, 0, 2, 1, 7, 4, 6, 5, 5, 6, 4, 7, 1, 2, 4, 0, 1, 0, /* 205 */ 4, 7, 0, 3, 5, 6, 0, 1, 5, 1, 4, 0, 5, 1, 4, 7, 5, 6, 7, 3, 6, 2, 4, 0, 6, 5, 4, 5, 0, 1, 0, 3, 4, 5, 7, 3, 6, 2, -1, 4, 5, 6, 2, 6, 5, 1, 0, 1, 5, 1, 2, -1, 7, 3, 6, 2, 4, 0, 6, 5, 4, 5, /* 210 */ 2, 6, 5, 6, 3, 7, 4, 5, 0, 3, 1, 5, 1, 2, 3, 2, 6, 2, 3, 0, 6, 5, 4, 0, 4, 5, 1, 0, 2, 3, 5, 4, 2, 6, 5, 6, 1, 2, 0, 1, 2, 6, 0, 4, 2, 3, 0, 3, -1, 5, 4, 5, 1, 5, 6, 2, 6, 5, 6, 2, 3, 4, 5, 1, 2, 1, 5, /* 215 */ 2, 1, 6, 5, 2, 3, 4, 0, 7, 3,-1, 6, 5, 4, 5, 4, 0, 0, 1, 0, 3, 4, 5, 3, 7, 5, 6, 2, 3, 1, 2, 0, 1, 1, 5, 2, 3, 5, 6, 3, 7, 4, 5, 0, 4, 3, 2, 3, 0, 3, 7, -1, 5, 4, 5, 1, 5, 6, 1, 2, 5, 6, 0, 3, 5, 4, 0, 4, /* 220 */ 1, 2, 5, 6, 1, 0, 5, 4, 0, 1, 5, 1, 0, 3, 5, 6, 0, 4, 5, 4, 5, 4, 5, 1, 5, 6, 6, 2, 5, 1, 7, 3, 5, 4, 7, 4, 0, 1, 0, 3, 0, 4, -1, 6, 2, 5, 1, 7, 3, 5, 4, 7, 4, /* 225 */ 1, 0, 5, 4, 1, 2, 7, 3, 6, 2, -1, 5, 4, 7, 4, 7, 3, 0, 3, 0, 4, 1, 2, 4, 5, 2, 6, 4, 7, 3, 7, 3, 0, 3, 2, 7, 4, 6, 2, 5, 1, -1, 7, 4, 5, 1, 5, 4, 1, 5, 4, 5, 2, 6, 4, 7, 2, 3, 0, 4, 0, 1, 0, 3, 2, 3, 4, 7, 2, 6, 4, 5, 1, 2, 0, 1, /* 230 */ 2, 3, 2, 6, 2, 1, -1, 4, 5, 4, 7, 4, 0, 2, 3, 2, 1, 7, 3, 5, 1, 7, 4, 5, 4, 1, 0, 3, 0, 1, 5, 3, 7, 1, 2, 3, 2, -1, 4, 5, 4, 7, 4, 0, 0, 1, 4, 5, 3, 2, 4, 7, 3, 7, 3, 0, 4, 0, 3, 2, 4, 5, 3, 7, 4, 7, /* 235 */ 0, 3, 1, 2, 4, 7, 1, 5, 4, 5, 0, 4, 0, 1, 4, 7, 1, 2, 4, 5, 1, 5, 0, 3, 0, 1, 4, 7, 4, 5, 4, 5, 4, 7, 4, 0, 5, 1, 4, 0, 6, 2, 7, 3, /* 240 */ 2, 6, 1, 5, 3, 7, 1, 0, 3, 0, 3, 7, 2, 6, 0, 4, 2, 1, 0, 1, 2, 6, 2, 1, 3, 7, 3, 0, 1, 5, 0, 4, 2, 6, 0, 3, 2, 3, 1, 5, 1, 0, 2, 6, 2, 3, /* 245 */ 1, 2, 0, 1, 2, 6, 0, 4, 2, 3, 0, 3, 2, 3, 2, 6, 2, 1, 0, 4, 3, 7, 1, 5, 3, 2, 1, 2, 1, 0, 3, 0, 1, 5, 3, 7, 1, 2, 3, 2, 0, 4, 3, 7, 0, 1, 3, 2, /* 250 */ 3, 2, 3, 0, 3, 7, 0, 4, 0, 3, 1, 5, 1, 2, 1, 0, 1, 2, 1, 5, 0, 1, 0, 4, 0, 3}; static int count[] = {0, 0, 6, 12, 20, 26, 34, 47, 57, 63, 76, 84, 94, 102, 112, 122, 130, 136, 144, 157, 167, 180, 190, 210, 222, 235, 250, 265, 282, 297, 314, 331, 341, 347, 360, 368, 378, 391, 406, 421, 438, 451, 471, 481, 493, 508, 525, 542, 552, 560, 570, 580, 588, 603, 620, 637, 647, 662, 679, 696, 706, 723, 737, 751, 759, 765, 778, 791, 806, 814, 824, 839, 856, 869, 889, 904, 921, 931, 943, 960, 970, 978, 988, 1003, 1020, 1030, 1038, 1055, 1065, 1080, 1097, 1114, 1128, 1145, 1155, 1169, 1177, 1190, 1210, 1225, 1242, 1257, 1274, 1291, 1305, 1325, 1352, 1369, 1388, 1405, 1424, 1438, 1450, 1460, 1472, 1489, 1499, 1516, 1526, 1540, 1548, 1565, 1584, 1598, 1610, 1624, 1636, 1649, 1655, 1661, 1674, 1687, 1702, 1715, 1730, 1750, 1767, 1775, 1790, 1800, 1817, 1827, 1844, 1856, 1866, 1879, 1894, 1914, 1931, 1951, 1968, 1995, 2014, 2029, 2046, 2063, 2077, 2094, 2108, 2127, 2139, 2147, 2162, 2172, 2189, 2204, 2221, 2238, 2252, 2262, 2279, 2287, 2297, 2314, 2328, 2338, 2346, 2356, 2373, 2385, 2395, 2412, 2426, 2445, 2457, 2474, 2488, 2498, 2506, 2520, 2533, 2545, 2551, 2559, 2574, 2589, 2606, 2616, 2633, 2650, 2664, 2674, 2691, 2708, 2722, 2730, 2740, 2750, 2758, 2768, 2785, 2802, 2816, 2828, 2838, 2857, 2869, 2886, 2900, 2914, 2927, 2937, 2945, 2957, 2963, 2973, 2990, 3007, 3021, 3038, 3052, 3066, 3079, 3091, 3110, 3120, 3132, 3142, 3154, 3162, 3168, 3176, 3186, 3196, 3204, 3214, 3222, 3234, 3240, 3250, 3262, 3270, 3276, 3284, 3290, 3296}; static double cube[8], level; static int interpol; void marchingCube(struct GRIDOBJECT *grid, double surface, int primitive, void (*begin)(int), void (*end)(void), void (*vert)(double, double, double), void (*norm)(double, double, double), int ip, int debug) { register double x, y, z; int i, j, k, l, set, cc; register int ii, jj, kk; level=surface; interpol=ip; /*printf("%f %f %f\n", grid->start[0], grid->start[1], grid->start[2]); printf("%f %f %f\n", grid->step[0], grid->step[1], grid->step[2]);*/ for (k=0; knpoints[2]; k++) { kk=k % grid->ngridpoints[2]; for (j=0; jnpoints[1]; j++) { jj=j % grid->ngridpoints[1]; for (i=0; inpoints[0]; i++) { ii=i % grid->ngridpoints[0]; set=0; if (grid->grid[index(ii,jj,kk)] < level) set|=0x01; if (grid->grid[index(ii+1,jj,kk)] < level) set|=0x02; if (grid->grid[index(ii,jj+1,kk)] < level) set|=0x04; if (grid->grid[index(ii+1,jj+1,kk)] < level) set|=0x08; if (grid->grid[index(ii,jj,kk+1)] < level) set|=0x10; if (grid->grid[index(ii+1,jj,kk+1)] < level) set|=0x20; if (grid->grid[index(ii,jj+1,kk+1)] < level) set|=0x40; if (grid->grid[index(ii+1,jj+1,kk+1)] < level) set|=0x80; if (set == 0 || set == 255) continue; cube[0]=grid->grid[index(ii,jj,kk)]; cube[1]=grid->grid[index(ii+1,jj,kk)]; cube[2]=grid->grid[index(ii+1,jj+1,kk)]; cube[3]=grid->grid[index(ii,jj+1,kk)]; cube[4]=grid->grid[index(ii,jj,kk+1)]; cube[5]=grid->grid[index(ii+1,jj,kk+1)]; cube[6]=grid->grid[index(ii+1,jj+1,kk+1)]; cube[7]=grid->grid[index(ii,jj+1,kk+1)]; x=grid->vector1[0]*(double)i*grid->step[0] +grid->vector2[0]*(double)j*grid->step[1] +grid->vector3[0]*(double)k*grid->step[2]+grid->start[0]; y=grid->vector1[1]*(double)i*grid->step[0] +grid->vector2[1]*(double)j*grid->step[1] +grid->vector3[1]*(double)k*grid->step[2]+grid->start[1]; z=grid->vector1[2]*(double)i*grid->step[0] +grid->vector2[2]*(double)j*grid->step[1] +grid->vector3[2]*(double)k*grid->step[2]+grid->start[2]; /* glColor4f(0.0, 0.0, 0.0, 0.0); glBegin(GL_POINTS); glVertex3d(x, y, z); glEnd(); */ if (primitive == GL_TRIANGLE_STRIP) { (*begin)(primitive); for (l=count[set]; l 2) (*begin)(primitive); set_vertex(x, y, z, corner[l], corner[l+1], grid, ii, jj, kk, primitive, vert, norm); cc++; if (cc > 3) { set_vertex(x, y, z, corner[l-2], corner[l-1], grid, ii, jj, kk, primitive, vert, norm); set_vertex(x, y, z, corner[l-4], corner[l-3], grid, ii, jj, kk, primitive, vert, norm); cc+=2; } if (cc % 3 == 0) (*end)(); } } } } } } void set_vertex(double x, double y, double z, int c1, int c2, struct GRIDOBJECT *grid, int ig, int jg, int kg, int primitive, void (*vert)(double, double, double), void (*norm)(double, double, double)) { static double vertex[8][8][3]={{{0.0, 0.0, 0.0}, {0.5, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.5, 0.0}, {0.0, 0.0, 0.5}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}}, {{-0.5, 0.0, 0.0}, {0.0, 0.0, 0.0}, {1.0, 0.5, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {1.0, 0.0, 0.5}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}}, {{0.0, 0.0, 0.0}, {1.0, -0.5, 0.0}, {0.0, 0.0, 0.0}, {-0.5, 1.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {1.0, 1.0, 0.5}, {0.0, 0.0, 0.0}}, {{0.0, -0.5, 0.0}, {0.0, 0.0, 0.0}, {0.5, 1.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 1.0, 0.5}}, {{0.0, 0.0, -0.5}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.5, 0.0, 1.0}, {0.0, 0.0, 0.0}, {0.0, 0.5, 1.0}}, {{0.0, 0.0, 0.0}, {1.0, 0.0, -0.5}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {-0.5, 0.0, 1.0}, {0.0, 0.0, 0.0}, {1.0, 0.5, 1.0}, {0.0, 0.0, 0.0}}, {{0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {1.0, 1.0, -0.5}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {1.0, -0.5, 1.0}, {0.0, 0.0, 0.0}, {-0.5, 1.0, 1.0}}, {{0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 1.0, -0.5}, {0.0, -0.5, 1.0}, {0.0, 0.0, 0.0}, {0.5, 1.0, 1.0}, {0.0, 0.0, 0.0}}, }; double v[3], x1=cube[c1], x2=cube[c2], l=level, n1[3], n2[3]; int ii, jj, kk; register int i; switch (interpol) { case IP_NONE: v[0]=fabs(vertex[c1][c2][0]); v[1]=fabs(vertex[c1][c2][1]); v[2]=fabs(vertex[c1][c2][2]); break; case IP_LOG: if (x1 > 0.0) x1=log(x1); if (x2 > 0.0) x2=log(x2); if (l > 0.0) l=log(l); case IP_LINEAR: x1-=l; x2-=l; for (i=0; i<3; i++) { v[i]=vertex[c1][c2][i]; if (v[i] == 0.5) v[i]=fabs(x1)/(fabs(x1)+fabs(x2)); if (v[i] == -0.5) v[i]=1.0-fabs(x1)/(fabs(x1)+fabs(x2)); } break; } if (primitive == GL_TRIANGLE_STRIP) { ii=ig; jj=jg; kk=kg; switch (c1) { case 1: ii++; break; case 2: ii++; jj++; break; case 3: jj++; break; case 4: kk++; break; case 5: ii++; kk++; break; case 6: ii++; jj++; kk++; break; case 7: jj++; kk++; break; } if (ii >= grid->ngridpoints[0]-1) n1[0]=(grid->grid[index(ii-1, jj, kk)]-grid->grid[index(ii, jj, kk)])/grid->step[0]; else if (ii == 0) n1[0]=(grid->grid[index(ii+1, jj, kk)]-grid->grid[index(ii, jj, kk)])/grid->step[0]; else n1[0]=(grid->grid[index(ii-1, jj, kk)]-grid->grid[index(ii+1, jj, kk)])/(2.0*grid->step[0]); if (jj >= grid->ngridpoints[1]-1) n1[1]=(grid->grid[index(ii, jj-1, kk)]-grid->grid[index(ii, jj, kk)])/grid->step[1]; else if (jj == 0) n1[1]=(grid->grid[index(ii, jj+1, kk)]-grid->grid[index(ii, jj, kk)])/grid->step[1]; else n1[1]=(grid->grid[index(ii, jj-1, kk)]-grid->grid[index(ii, jj+1, kk)])/(2.0*grid->step[1]); if (kk >= grid->ngridpoints[2]-1) n1[2]=(grid->grid[index(ii, jj, kk-1)]-grid->grid[index(ii, jj, kk)])/grid->step[2]; else if (kk == 0) n1[2]=(grid->grid[index(ii, jj, kk+1)]-grid->grid[index(ii, jj, kk)])/grid->step[2]; else n1[2]=(grid->grid[index(ii, jj, kk-1)]-grid->grid[index(ii, jj, kk+1)])/(2.0*grid->step[2]); ii=ig; jj=jg; kk=kg; switch (c2) { case 1: ii++; break; case 2: ii++; jj++; break; case 3: jj++; break; case 4: kk++; break; case 5: ii++; kk++; break; case 6: ii++; jj++; kk++; break; case 7: jj++; kk++; break; } if (ii >= grid->ngridpoints[0]-1) n2[0]=(grid->grid[index(ii-1, jj, kk)]-grid->grid[index(ii, jj, kk)])/grid->step[0]; else if (ii == 0) n2[0]=(grid->grid[index(ii+1, jj, kk)]-grid->grid[index(ii, jj, kk)])/grid->step[0]; else n2[0]=(grid->grid[index(ii-1, jj, kk)]-grid->grid[index(ii+1, jj, kk)])/(2.0*grid->step[0]); if (jj >= grid->ngridpoints[1]-1) n2[1]=(grid->grid[index(ii, jj-1, kk)]-grid->grid[index(ii, jj, kk)])/grid->step[1]; else if (jj == 0) n2[1]=(grid->grid[index(ii, jj+1, kk)]-grid->grid[index(ii, jj, kk)])/grid->step[1]; else n2[1]=(grid->grid[index(ii, jj-1, kk)]-grid->grid[index(ii, jj+1, kk)])/(2.0*grid->step[1]); if (kk >= grid->ngridpoints[2]-1) n2[2]=(grid->grid[index(ii, jj, kk-1)]-grid->grid[index(ii, jj, kk)])/grid->step[2]; else if (kk == 0) n2[2]=(grid->grid[index(ii, jj, kk+1)]-grid->grid[index(ii, jj, kk)])/grid->step[2]; else n2[2]=(grid->grid[index(ii, jj, kk-1)]-grid->grid[index(ii, jj, kk+1)])/(2.0*grid->step[2]); n1[0]=0.5*(n1[0]+n2[0]); n1[1]=0.5*(n1[1]+n2[1]); n1[2]=0.5*(n1[2]+n2[2]); if (level > 0.0) l=sqrt(n1[0]*n1[0]+n1[1]*n1[1]+n1[2]*n1[2]); else l=-sqrt(n1[0]*n1[0]+n1[1]*n1[1]+n1[2]*n1[2]); n1[0]/=l; n1[1]/=l; n1[2]/=l; (*norm)(n1[0], n1[1], n1[2]); } /*recordit=TRUE; */ v[0]=x+v[0]*grid->vector1[0]*grid->step[0] +v[1]*grid->vector2[0]*grid->step[1] +v[2]*grid->vector3[0]*grid->step[2]; v[1]=y+v[0]*grid->vector1[1]*grid->step[0] +v[1]*grid->vector2[1]*grid->step[1] +v[2]*grid->vector3[1]*grid->step[2]; v[2]=z+v[0]*grid->vector1[2]*grid->step[0] +v[1]*grid->vector2[2]*grid->step[1] +v[2]*grid->vector3[2]*grid->step[2]; (*vert)(v[0], v[1], v[2]); /*printf("%f %f %f %f %f %f\n", v[0], v[1], v[2], n1[0], n1[1], n1[2]); */ } /* void testNorm(double x, double y, double z) { norms[vcount][0]=0.2*x; norms[vcount][1]=0.2*y; norms[vcount][2]=0.2*z; glNormal3d(x, y, z); } void testVertex(double x, double y, double z) { if (recordit) { vertices[vcount][0]=x; vertices[vcount][1]=y; vertices[vcount][2]=z; vcount++; } glVertex3d(x, y, z); } void testBegin(GLenum what) { vcount=0; glBegin(what); } void testEnd(void) { int i; glEnd(); if (recordit) { for (i=0; i 0.0) glColor4f(1.0, 0.0, 0.0, 0.0); else glColor4f(0.0, 0.0, 1.0, 0.0); } recordit=FALSE; } } */ viewmol-2.4.1/source/marcub.h0100644000272700027270000000230207752712325014274 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M A R C U B . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: marcub.h,v 1.6 2003/11/07 12:49:25 jrh Exp $ * $Log: marcub.h,v $ * Revision 1.6 2003/11/07 12:49:25 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:10:57 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:18 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:51:20 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:28 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:45:43 jrh * Initial revision * */ #define IP_NONE 1 #define IP_LINEAR 2 #define IP_LOG 3 viewmol-2.4.1/source/matrix.c0100644000272700027270000001170310114367050014312 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M A T R I X . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: matrix.c,v 1.6 2004/08/29 14:54:32 jrh Exp $ * $Log: matrix.c,v $ * Revision 1.6 2004/08/29 14:54:32 jrh * Release 2.4.1 * * Revision 1.5 2003/11/07 11:06:42 jrh * Release 2.4 * * Revision 1.4 2000/12/10 15:11:04 jrh * Release 2.3 * * Revision 1.3 1999/05/24 01:26:19 jrh * Release 2.2.1 * * Revision 1.2 1999/02/07 21:52:01 jrh * Release 2.2 * * Revision 1.1 1998/01/26 00:35:07 jrh * Initial revision * */ #include #include #include #include #include #include "viewmol.h" extern void quaternionToMatrix(GLenum, float *); void getMatrix(double matrix[4][4]); void multMatrix(double matrix1[4][4], double matrix2[4][4], double matrix3[4][4]); void transformCoordinates(int, float input[4], float output[4]); void makeMatrix(double, float, float, float, float mat[3][3]); extern struct WINDOW windows[]; extern float *rotObject; void getMatrix(double matrix[4][4]) { double mvmat[4][4], prmat[4][4]; glGetDoublev(GL_MODELVIEW_MATRIX, &mvmat[0][0]); glGetDoublev(GL_PROJECTION_MATRIX, &prmat[0][0]); multMatrix(mvmat, prmat, matrix); } void multMatrix(double matrix1[4][4], double matrix2[4][4], double matrix3[4][4]) { register int i, j, k; for (i=0; i<4; i++) { for (j=0; j<4; j++) { matrix3[i][j]=0.0; for (k=0; k<4; k++) matrix3[i][j]+=matrix1[i][k]*matrix2[k][j]; } } } void transposeMatrix(double matrix[4][4]) { double help; register int i, j; for (i=0; i<4; i++) { for (j=i+1; j<4; j++) { help=matrix[i][j]; matrix[i][j]=matrix[j][i]; matrix[j][i]=help; } } } void transformCoordinates(int which, float input[4], float output[4]) { float matrix[4][4]; glPushMatrix(); glLoadIdentity(); quaternionToMatrix(GL_MODELVIEW, &rotObject[4*which]); glGetFloatv(GL_MODELVIEW_MATRIX, &matrix[0][0]); glPopMatrix(); output[0]=matrix[0][0]*input[0]+matrix[1][0]*input[1]+matrix[2][0]*input[2]+matrix[3][0]*input[3]; output[1]=matrix[0][1]*input[0]+matrix[1][1]*input[1]+matrix[2][1]*input[2]+matrix[3][1]*input[3]; output[2]=matrix[0][2]*input[0]+matrix[1][2]*input[1]+matrix[2][2]*input[2]+matrix[3][2]*input[3]; output[3]=matrix[0][3]*input[0]+matrix[1][3]*input[1]+matrix[2][3]*input[2]+matrix[3][3]*input[3]; } void getScreenCoordinates(double xw, double yw, double zw, double *xs, double *ys, double *zs) { GLdouble mvMatrix[16], prMatrix[16]; GLint viewport[4]; glGetDoublev(GL_MODELVIEW_MATRIX, mvMatrix); glGetDoublev(GL_PROJECTION_MATRIX, prMatrix); glGetIntegerv(GL_VIEWPORT, viewport); gluProject(xw, yw, zw, mvMatrix, prMatrix, viewport, xs, ys, zs); *ys=(double)viewport[3]-(*ys); } void getWorldCoordinates(double xs, double ys, double zs, double *xw, double *yw, double *zw) { GLdouble mvMatrix[16], prMatrix[16]; GLint viewport[4]; glGetDoublev(GL_MODELVIEW_MATRIX, mvMatrix); glGetDoublev(GL_PROJECTION_MATRIX, prMatrix); glGetIntegerv(GL_VIEWPORT, viewport); gluUnProject(xs, ys, zs, mvMatrix, prMatrix, viewport, xw, yw, zw); } void rotateAxis(float axis[3], float about[3], double angle) { float mat[3][3], s1, s2; makeMatrix((-angle), about[0], about[1], about[2], mat); s1=axis[0]; s2=axis[1]; axis[0]=mat[0][0]*s1+mat[1][0]*s2+mat[2][0]*axis[2]; axis[1]=mat[0][1]*s1+mat[1][1]*s2+mat[2][1]*axis[2]; axis[2]=mat[0][2]*s1+mat[1][2]*s2+mat[2][2]*axis[2]; } void makeMatrix(double angle, float x, float y, float z, float mat[3][3]) { double torad=atan(1.0)/45.0; float mag, s, c; float xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c; angle*=torad; s=(float)sin(angle); c=(float)cos(angle); mag=1.0/sqrt(x*x+y*y+z*z); x*=mag; y*=mag; z*=mag; xx=x*x; yy=y*y; zz=z*z; xy=x*y; yz=y*z; zx=z*x; xs=x*s; ys=y*s; zs=z*s; one_c=1.0F-c; mat[0][0]=(one_c*xx)+c; mat[0][1]=(one_c*xy)-zs; mat[0][2]=(one_c*zx)+ys; mat[1][0]=(one_c*xy)+zs; mat[1][1]=(one_c*yy)+c; mat[1][2]=(one_c*yz)-xs; mat[2][0]=(one_c*zx)-ys; mat[2][1]=(one_c*yz)+xs; mat[2][2]=(one_c*zz)+c; } void printMatrix(int which) { double matrix[4][4]; int i; glGetDoublev(which, &matrix[0][0]); for (i=0; i<4; i++) printf("%f %f %f %f\n", matrix[i][0], matrix[i][1], matrix[i][2], matrix[i][3]); } viewmol-2.4.1/source/menu.h0100644000272700027270000000317307752712343013776 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M E N U . H * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: menu.h,v 1.6 2003/11/07 12:49:39 jrh Exp $ * $Log: menu.h,v $ * Revision 1.6 2003/11/07 12:49:39 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:11:11 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:28:42 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:52:09 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:30 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:45:49 jrh * Initial revision * */ struct MenuItem { char *label; /* the label for the item */ WidgetClass *class; /* pushbutton, label, separator... */ void (*callback)(); /* routine to call; NULL if none */ XtPointer callback_data; /* client_data for callback() */ Widget widget; /* the widget of the menu item */ struct MenuItem *subitems; /* pullright menu items, if not NULL */ }; struct MENUDATA { struct MenuItem *submenu; int window; int which; }; viewmol-2.4.1/source/menudef.h0100644000272700027270000002760707752712335014466 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M E N U D E F . H * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: menudef.h,v 1.6 2003/11/07 12:49:33 jrh Exp $ * $Log: menudef.h,v $ * Revision 1.6 2003/11/07 12:49:33 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:11:16 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:24 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:52:16 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:32 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:45:53 jrh * Initial revision * */ extern void load(Widget, caddr_t, XmAnyCallbackStruct *); extern void deleteMolecule(Widget, caddr_t, XmAnyCallbackStruct *); extern void ende(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void setModel(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void setDiagram(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void changeBoolean(Widget, int *, XmDrawingAreaCallbackStruct *); extern void clearGeometry(Widget, caddr_t, XmAnyCallbackStruct *); extern void undoGeometry(Widget, caddr_t, XmAnyCallbackStruct *); extern void spectrumDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void optimizationDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void MODiagramDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void wavefunctionDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void drawingModeDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void printDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void colorEditor(Widget, caddr_t, XmAnyCallbackStruct *); extern void readSpectrum(Widget, caddr_t, XmAnyCallbackStruct *); extern void deleteSpectrum(Widget, caddr_t, XmAnyCallbackStruct *); extern void quitSpectrum(Widget, caddr_t, XmAnyCallbackStruct *); extern void quitHistory(Widget, caddr_t, XmAnyCallbackStruct *); extern void quitMODiagram(Widget, caddr_t, XmAnyCallbackStruct *); extern void zoomOut(Widget, caddr_t, caddr_t); extern void manual(Widget, caddr_t, caddr_t); extern void saveMoleculeDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void configurationDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void thermoDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void raytrace(Widget, caddr_t, caddr_t); extern void setTransition(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void setAnnotation(Widget, int *, XmDrawingAreaCallbackStruct *); extern void unitcellDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void newMolecule(Widget, caddr_t, XmAnyCallbackStruct *); extern void pseDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void bondDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void setHistoryAnimation(Widget, caddr_t, XmAnyCallbackStruct *); extern void runScript(Widget, caddr_t, XmAnyCallbackStruct *); #ifdef INIT static struct MenuItem moleculeMenu[] = { { "loadMolecule", &xmPushButtonGadgetClass, load, (XtPointer)0, NULL, NULL }, { "saveMolecule", &xmPushButtonGadgetClass, saveMoleculeDialog, (XtPointer)1, NULL, NULL }, /*{ "saveSelected", &xmPushButtonGadgetClass, saveMoleculeDialog, (XtPointer)0, NULL, NULL },*/ { "deleteMolecule", &xmPushButtonGadgetClass, deleteMolecule, (XtPointer)TRUE, NULL, NULL }, { "newMolecule", &xmPushButtonGadgetClass, newMolecule, (XtPointer)0, NULL, NULL }, { "buildMolecule", &xmPushButtonGadgetClass, pseDialog, (XtPointer)0, NULL, NULL }, { NULL }}; static struct MenuItem geometryMenu[] = { { "clear_all", &xmPushButtonGadgetClass, clearGeometry, (XtPointer)ALL, NULL, NULL }, { "clear_last", &xmPushButtonGadgetClass, clearGeometry, (XtPointer)LAST, NULL, NULL }, { "sep", &xmSeparatorGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "undo", &xmPushButtonGadgetClass, undoGeometry, (XtPointer)0, NULL, NULL }, { NULL }}; static struct MenuItem viewerMenu[] = { { "molecule", &xmPushButtonGadgetClass, NULL, (XtPointer)0, NULL, moleculeMenu }, { "select_molecule", &xmPushButtonGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "sep1", &xmSeparatorGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "wire_model", &xmPushButtonGadgetClass, setModel, (XtPointer)WIREMODEL, NULL, NULL }, { "stick_model", &xmPushButtonGadgetClass, setModel, (XtPointer)STICKMODEL, NULL, NULL }, { "ball_and_stick_model", &xmPushButtonGadgetClass, setModel, (XtPointer)BALLMODEL, NULL, NULL }, { "cpk_model", &xmPushButtonGadgetClass, setModel, (XtPointer)CUPMODEL, NULL, NULL }, { "sep2", &xmSeparatorGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "geometry_menu", &xmPushButtonGadgetClass, NULL, (XtPointer)0, NULL, geometryMenu }, { "bondType_menu", &xmPushButtonGadgetClass, bondDialog, (XtPointer)0, NULL, NULL }, { "wave_function", &xmPushButtonGadgetClass, wavefunctionDialog, (XtPointer)0, NULL, NULL }, { "energy_level_diagram", &xmPushButtonGadgetClass, initMODiagram, (XtPointer)0, NULL, NULL }, { "optimization_history", &xmPushButtonGadgetClass, initHistory, (XtPointer)0, NULL, NULL }, { "show_forces", &xmToggleButtonGadgetClass, changeBoolean, (XtPointer)&showForces, NULL, NULL }, { "spectrum", &xmPushButtonGadgetClass, initSpectrum, (XtPointer)0, NULL, NULL }, { "thermodynamics", &xmPushButtonGadgetClass, thermoDialog, (XtPointer)0, NULL, NULL }, { "show_unit_cell", &xmPushButtonGadgetClass, unitcellDialog, (XtPointer)0, NULL, NULL }, { "show_ellipsoid_of_inertia", &xmToggleButtonGadgetClass, changeBoolean, (XtPointer)&showInertia, NULL, NULL }, { "sep3", &xmSeparatorGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "drawing_modes", &xmPushButtonGadgetClass, drawingModeDialog, (XtPointer)0, NULL, NULL }, { "foreground_color", &xmPushButtonGadgetClass, colorEditor, (XtPointer)(FOREGROUND*8+VIEWER), NULL, NULL}, { "background_color", &xmPushButtonGadgetClass, colorEditor, (XtPointer)(BACKGROUND*8+VIEWER), NULL, NULL}, { "label_atoms", &xmToggleButtonGadgetClass, changeBoolean, (XtPointer)&label, NULL, NULL }, { "annotate", &xmPushButtonGadgetClass, setAnnotation, (XtPointer)0, NULL, NULL }, { "runScript", &xmPushButtonGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "sep4", &xmSeparatorGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "hardcopy", &xmPushButtonGadgetClass, printDialog, (XtPointer)VIEWER, NULL, NULL }, { "raytracing", &xmPushButtonGadgetClass, raytrace, (XtPointer)0, NULL, NULL }, { "manual", &xmPushButtonGadgetClass, manual, (XtPointer)0, NULL, NULL }, { "sep5", &xmSeparatorGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "saveConfiguration", &xmPushButtonGadgetClass, configurationDialog,(XtPointer)0, NULL, NULL }, { "quit", &xmPushButtonGadgetClass, ende, (XtPointer)0, NULL, NULL }, { NULL } }; static struct MenuItem spectrumMenu[] = { { "settings_spectrum", &xmPushButtonGadgetClass, spectrumDialog, (XtPointer)0, NULL, NULL }, { "select_molecule", &xmPushButtonGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "imaginary_wave_numbers", &xmPushButtonGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "observed_spectrum", &xmPushButtonGadgetClass, readSpectrum, (XtPointer)0, NULL, NULL }, { "delete_spectrum", &xmPushButtonGadgetClass, deleteSpectrum, (XtPointer)0, NULL, NULL }, { "zoom_out", &xmPushButtonGadgetClass, zoomOut, (XtPointer)SPECTRUM, NULL, NULL }, { "hardcopy", &xmPushButtonGadgetClass, printDialog, (XtPointer)SPECTRUM, NULL, NULL }, { "sep", &xmSeparatorGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "foreground_color", &xmPushButtonGadgetClass, colorEditor, (XtPointer)(FOREGROUND*8+SPECTRUM), NULL, NULL}, { "background_color", &xmPushButtonGadgetClass, colorEditor, (XtPointer)(BACKGROUND*8+SPECTRUM), NULL, NULL}, { "sep", &xmSeparatorGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "quit_spectrum", &xmPushButtonGadgetClass, quitSpectrum, (XtPointer)SPECTRUM, NULL, NULL }, { NULL } }; /* #endif */ static struct MenuItem historyMenu[] = { { "settings_history", &xmPushButtonGadgetClass, optimizationDialog, (XtPointer)0, NULL, NULL }, { "select_molecule", &xmPushButtonGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "animate_history", &xmToggleButtonGadgetClass, setHistoryAnimation, (XtPointer)0, NULL, NULL }, { "hardcopy", &xmPushButtonGadgetClass, printDialog, (XtPointer)HISTORY, NULL, NULL }, { "sep", &xmSeparatorGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "energy_color", &xmPushButtonGadgetClass, colorEditor, (XtPointer)(ENERGY*8+HISTORY), NULL, NULL}, { "gradient_color", &xmPushButtonGadgetClass, colorEditor, (XtPointer)(GNORM*8+HISTORY), NULL, NULL}, { "background_color", &xmPushButtonGadgetClass, colorEditor, (XtPointer)(BACKGROUND*8+HISTORY), NULL, NULL}, { "sep", &xmSeparatorGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "quit_history", &xmPushButtonGadgetClass, quitHistory, (XtPointer)HISTORY, NULL, NULL }, { NULL } }; /* #ifdef INIT */ static struct MenuItem MODiagramMenu[] = { { "settings_modiagram", &xmPushButtonGadgetClass, MODiagramDialog, (XtPointer)0, NULL, NULL }, { "select_molecule", &xmPushButtonGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "transition", &xmToggleButtonGadgetClass, setTransition, (XtPointer)0, NULL, NULL }, { "zoom_out", &xmPushButtonGadgetClass, zoomOut, (XtPointer)MO, NULL, NULL }, { "hardcopy", &xmPushButtonGadgetClass, printDialog, (XtPointer)MO, NULL, NULL }, { "energy_levels", &xmToggleButtonGadgetClass, setDiagram, (XtPointer)0, NULL, NULL }, { "sep", &xmSeparatorGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "foreground_color", &xmPushButtonGadgetClass, colorEditor, (XtPointer)(FOREGROUND*8+MO), NULL, NULL}, { "background_color", &xmPushButtonGadgetClass, colorEditor, (XtPointer)(BACKGROUND*8+MO), NULL, NULL}, { "sep", &xmSeparatorGadgetClass, NULL, (XtPointer)0, NULL, NULL }, { "quit_modiagram", &xmPushButtonGadgetClass, quitMODiagram, (XtPointer)MO, NULL, NULL }, { NULL } }; #endif viewmol-2.4.1/source/messgb.c0100644000272700027270000001546107752676312014315 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M E S S G B . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: messgb.c,v 1.6 2003/11/07 11:06:50 jrh Exp $ * $Log: messgb.c,v $ * Revision 1.6 2003/11/07 11:06:50 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:11:26 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:28 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:52:26 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:34 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:42:04 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "dialog.h" Widget CreatePushButtonRow(Widget, struct PushButtonRow *, int); void MapBox(Widget, caddr_t, XmAnyCallbackStruct *); extern Widget initShell(Widget, char *, Widget *, Widget *); static Widget dialog; static int cont, ret; extern XtAppContext app; extern Widget topShell; Widget CreatePushButtonRow(Widget parent, struct PushButtonRow *buttons, int n) { Widget row; Dimension height, h; register int i; row=XtVaCreateManagedWidget("row", xmFormWidgetClass, parent, XmNfractionBase, 20*n-1, NULL); for (i=0; i rootW) windowX=rootW-w; if (windowY+h > rootH) windowY=rootH-h; XtVaSetValues(form, XmNx, windowX, XmNy, windowY, XmNminWidth, w, XmNminHeight, h, NULL); } int messgb(Widget parent, int serious, char *str, struct PushButtonRow *buttons, int n) { XEvent event; static Widget form; Widget form1, board, sign, label, sep; Pixmap pixmap; Pixel fg, bg; XmString text; int depth; #include "messgb.h" dialog=initShell(parent, "messageForm", &board, &form); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XmAnyCallbackStruct *)NULL); form1=XtVaCreateWidget("form1", xmFormWidgetClass, form, NULL); sep=XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, form, NULL); text=XmStringCreateLtoR(str, XmSTRING_DEFAULT_CHARSET); if (serious != 0) { XtVaGetValues(form1, XmNforeground, &fg, XmNbackground, &bg, NULL); XtVaGetValues(parent, XtNdepth, &depth, NULL); pixmap=XCreatePixmapFromBitmapData(XtDisplay(form1), RootWindowOfScreen(XtScreen(form1)), (char *)sign_data[serious-1], 64, 64, fg, bg, depth); sign=XtVaCreateManagedWidget("sign", xmLabelWidgetClass, form1, XmNlabelType, XmPIXMAP, XmNlabelPixmap, pixmap, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); label=XtVaCreateManagedWidget("text", xmLabelWidgetClass, form1, XmNlabelString, text, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, sign, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); } else label=XtVaCreateManagedWidget("text", xmLabelWidgetClass, form1, XmNlabelString, text, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); CreatePushButtonRow(form, buttons, n); XtManageChild(form1); XtManageChild(form); XtManageChild(board); cont=TRUE; while (cont) { XtAppNextEvent(app, &event); XtDispatchEvent(&event); } return(ret); } void GetMessageBoxButton(Widget button, XtPointer which, caddr_t call_data) { ret=(int)which; cont=FALSE; XtDestroyWidget(dialog); } viewmol-2.4.1/source/messgb.h0100644000272700027270000002531707752712352014316 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M E S S G B . H * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: messgb.h,v 1.6 2003/11/07 12:49:46 jrh Exp $ * $Log: messgb.h,v $ * Revision 1.6 2003/11/07 12:49:46 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:11:33 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:30 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:52:31 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:37 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:45:58 jrh * Initial revision * */ static unsigned char sign_bits1[] = { 0x00, 0x00, 0xf8, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0xf3, 0xff, 0xff, 0xcf, 0x00, 0x00, 0x00, 0x80, 0xf9, 0xff, 0xff, 0x9f, 0x01, 0x00, 0x00, 0xc0, 0xfc, 0xff, 0xff, 0x3f, 0x03, 0x00, 0x00, 0x60, 0xfe, 0xff, 0xff, 0x7f, 0x06, 0x00, 0x00, 0x30, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x00, 0x00, 0x98, 0xff, 0x07, 0xf0, 0xff, 0x19, 0x00, 0x00, 0xcc, 0xff, 0x03, 0xe0, 0xff, 0x33, 0x00, 0x00, 0xe6, 0xff, 0x03, 0xe0, 0xff, 0x67, 0x00, 0x00, 0xf3, 0xff, 0x03, 0xe0, 0xff, 0xcf, 0x00, 0x80, 0xf9, 0xff, 0x03, 0xe0, 0xff, 0x9f, 0x01, 0xc0, 0xfc, 0xff, 0x03, 0xe0, 0xff, 0x3f, 0x03, 0x60, 0xfe, 0xff, 0x03, 0xe0, 0xff, 0x7f, 0x06, 0x30, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x0c, 0x98, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0x19, 0xcc, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0x33, 0xe6, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0x67, 0xf3, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0xcf, 0xfb, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x07, 0xf0, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x67, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x33, 0x98, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x19, 0x30, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0c, 0x60, 0xfe, 0xff, 0x0f, 0xf8, 0xff, 0x7f, 0x06, 0xc0, 0xfc, 0xff, 0x07, 0xf0, 0xff, 0x3f, 0x03, 0x80, 0xf9, 0xff, 0x07, 0xf0, 0xff, 0x9f, 0x01, 0x00, 0xf3, 0xff, 0x07, 0xf0, 0xff, 0xcf, 0x00, 0x00, 0xe6, 0xff, 0x0f, 0xf8, 0xff, 0x67, 0x00, 0x00, 0xcc, 0xff, 0x0f, 0xf8, 0xff, 0x33, 0x00, 0x00, 0x98, 0xff, 0x3f, 0xfe, 0xff, 0x19, 0x00, 0x00, 0x30, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x00, 0x00, 0x60, 0xfe, 0xff, 0xff, 0x7f, 0x06, 0x00, 0x00, 0xc0, 0xfc, 0xff, 0xff, 0x3f, 0x03, 0x00, 0x00, 0x80, 0xf9, 0xff, 0xff, 0x9f, 0x01, 0x00, 0x00, 0x00, 0xf3, 0xff, 0xff, 0xcf, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x1f, 0x00, 0x00}; static unsigned char sign_bits2[] = { 0x00, 0x00, 0xf8, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0xf3, 0xff, 0xff, 0xcf, 0x00, 0x00, 0x00, 0x80, 0xf9, 0xff, 0xff, 0x9f, 0x01, 0x00, 0x00, 0xc0, 0xfc, 0xff, 0xff, 0x3f, 0x03, 0x00, 0x00, 0x60, 0xfe, 0xff, 0xff, 0x7f, 0x06, 0x00, 0x00, 0x30, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x00, 0x00, 0x98, 0xff, 0x0f, 0xf8, 0xff, 0x19, 0x00, 0x00, 0xcc, 0xff, 0x01, 0xc0, 0xff, 0x33, 0x00, 0x00, 0xe6, 0xff, 0x00, 0x80, 0xff, 0x67, 0x00, 0x00, 0xf3, 0x7f, 0xe0, 0x03, 0xff, 0xcf, 0x00, 0x80, 0xf9, 0x3f, 0xf8, 0x0f, 0xfe, 0x9f, 0x01, 0xc0, 0xfc, 0x1f, 0xfc, 0x1f, 0xfc, 0x3f, 0x03, 0x60, 0xfe, 0x0f, 0xfe, 0x3f, 0xf8, 0x7f, 0x06, 0x30, 0xff, 0x0f, 0xff, 0x7f, 0xf8, 0xff, 0x0c, 0x98, 0xff, 0x8f, 0xff, 0xff, 0xf8, 0xff, 0x19, 0xcc, 0xff, 0x87, 0xff, 0xff, 0xf0, 0xff, 0x33, 0xe6, 0xff, 0xc7, 0xff, 0xff, 0xf1, 0xff, 0x67, 0xf3, 0xff, 0xc7, 0xff, 0xff, 0xf1, 0xff, 0xcf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0x7f, 0xf8, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0x1f, 0xfc, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0x0f, 0xfe, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x7f, 0xc0, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x3f, 0xf8, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x67, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x33, 0x98, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x19, 0x30, 0xff, 0xff, 0x0f, 0xf8, 0xff, 0xff, 0x0c, 0x60, 0xfe, 0xff, 0x0f, 0xf8, 0xff, 0x7f, 0x06, 0xc0, 0xfc, 0xff, 0x07, 0xf0, 0xff, 0x3f, 0x03, 0x80, 0xf9, 0xff, 0x07, 0xf0, 0xff, 0x9f, 0x01, 0x00, 0xf3, 0xff, 0x07, 0xf0, 0xff, 0xcf, 0x00, 0x00, 0xe6, 0xff, 0x0f, 0xf8, 0xff, 0x67, 0x00, 0x00, 0xcc, 0xff, 0x0f, 0xf8, 0xff, 0x33, 0x00, 0x00, 0x98, 0xff, 0x3f, 0xfe, 0xff, 0x19, 0x00, 0x00, 0x30, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x00, 0x00, 0x60, 0xfe, 0xff, 0xff, 0x7f, 0x06, 0x00, 0x00, 0xc0, 0xfc, 0xff, 0xff, 0x3f, 0x03, 0x00, 0x00, 0x80, 0xf9, 0xff, 0xff, 0x9f, 0x01, 0x00, 0x00, 0x00, 0xf3, 0xff, 0xff, 0xcf, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x1f, 0x00, 0x00}; static unsigned char sign_bits3[] = { 0x00, 0x00, 0xf8, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0xf3, 0xff, 0xff, 0xcf, 0x00, 0x00, 0x00, 0x80, 0xf9, 0xff, 0xff, 0x9f, 0x01, 0x00, 0x00, 0xc0, 0xfc, 0xff, 0xff, 0x3f, 0x03, 0x00, 0x00, 0x60, 0xfe, 0xff, 0xff, 0x7f, 0x06, 0x00, 0x00, 0x30, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x00, 0x00, 0x98, 0xff, 0xff, 0xff, 0xff, 0x19, 0x00, 0x00, 0xcc, 0xff, 0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0xe6, 0xff, 0xff, 0xff, 0xff, 0x67, 0x00, 0x00, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xcf, 0x00, 0x80, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x9f, 0x01, 0xc0, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x03, 0x60, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x06, 0x30, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x98, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x19, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x33, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x67, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0x7b, 0x00, 0x0f, 0xe0, 0x03, 0xf8, 0x00, 0xde, 0x3b, 0x00, 0x0f, 0xe0, 0x01, 0xf0, 0x00, 0xdc, 0x3b, 0x00, 0x0f, 0xe0, 0xe1, 0xf0, 0x00, 0xdc, 0x3b, 0xfc, 0x7f, 0xfc, 0xf1, 0xf1, 0x78, 0xdc, 0x3b, 0xfe, 0x7f, 0xfc, 0xf1, 0xf1, 0x78, 0xdc, 0x3b, 0xfe, 0x7f, 0xfc, 0xf1, 0xf1, 0x78, 0xdc, 0x3b, 0xfe, 0x7f, 0xfc, 0xf1, 0xf1, 0x78, 0xdc, 0x3b, 0xfe, 0x7f, 0xfc, 0xf1, 0xf1, 0x78, 0xdc, 0x3b, 0xfe, 0x7f, 0xfc, 0xf1, 0xf1, 0x78, 0xdc, 0x3b, 0x80, 0x7f, 0xfc, 0xf1, 0xf1, 0x00, 0xdc, 0x3b, 0x00, 0x7f, 0xfc, 0xf1, 0xf1, 0x00, 0xdc, 0x7b, 0x00, 0x7f, 0xfc, 0xf1, 0xf1, 0x00, 0xde, 0xfb, 0x0f, 0x7f, 0xfc, 0xf1, 0xf1, 0xf8, 0xdf, 0xfb, 0x1f, 0x7f, 0xfc, 0xf1, 0xf1, 0xf8, 0xdf, 0xfb, 0x1f, 0x7f, 0xfc, 0xf1, 0xf1, 0xf8, 0xdf, 0xfb, 0x1f, 0x7f, 0xfc, 0xf1, 0xf1, 0xf8, 0xdf, 0xfb, 0x1f, 0x7f, 0xfc, 0xf1, 0xf1, 0xf8, 0xdf, 0xfb, 0x1f, 0x7f, 0xfc, 0xf1, 0xf1, 0xf8, 0xdf, 0xfb, 0x0f, 0x7f, 0xfc, 0xf1, 0xf1, 0xf8, 0xdf, 0x3b, 0x00, 0x7f, 0xfc, 0xe1, 0xf0, 0xf8, 0xdf, 0x3b, 0x00, 0x7f, 0xfc, 0x01, 0xf0, 0xf8, 0xdf, 0x3b, 0x80, 0x7f, 0xfc, 0x03, 0xf8, 0xf8, 0xdf, 0xfb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xdf, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x67, 0xcc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x33, 0x98, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x19, 0x30, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x60, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x06, 0xc0, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x03, 0x80, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x9f, 0x01, 0x00, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xcf, 0x00, 0x00, 0xe6, 0xff, 0xff, 0xff, 0xff, 0x67, 0x00, 0x00, 0xcc, 0xff, 0xff, 0xff, 0xff, 0x33, 0x00, 0x00, 0x98, 0xff, 0xff, 0xff, 0xff, 0x19, 0x00, 0x00, 0x30, 0xff, 0xff, 0xff, 0xff, 0x0c, 0x00, 0x00, 0x60, 0xfe, 0xff, 0xff, 0x7f, 0x06, 0x00, 0x00, 0xc0, 0xfc, 0xff, 0xff, 0x3f, 0x03, 0x00, 0x00, 0x80, 0xf9, 0xff, 0xff, 0x9f, 0x01, 0x00, 0x00, 0x00, 0xf3, 0xff, 0xff, 0xcf, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x1f, 0x00, 0x00}; static unsigned char *sign_data[4]= {sign_bits1, sign_bits2, sign_bits3}; viewmol-2.4.1/source/miller.c0100644000272700027270000001110407752676320014306 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M I L L E R . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: miller.c,v 1.2 2003/11/07 11:06:56 jrh Exp $ * $Log: miller.c,v $ * Revision 1.2 2003/11/07 11:06:56 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:11:39 jrh * Initial revision * * */ #include #include #include #include "viewmol.h" void millerPlane(void); extern void fractionalToCartesian(struct ATOM *, double, double, double, double, double, double, struct MOLECULE *, int, int); extern double bondLength(struct ATOM *, int, int); extern double bondAngle(struct ATOM *, int, int, int); extern void *getmem(size_t, size_t); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern struct ELEMENT *elements; extern int ne; /* need to delete added atoms once Miller plane display has been disabled */ void millerPlane(void) { struct MOLECULE *mol; struct ELEMENT *mp=NULL; double sx=0.0, sy=0.0, sz=0.0; int n; register int i, j, k; if (windows[VIEWER].set < 0) mol=&molecules[0]; else mol=&molecules[windows[VIEWER].set]; if (mol->unitcell) { for (i=0; iunitcell->nmiller == 0) { mol->unitcell->np=4; mol->unitcell->millerPlanes=(struct ATOM *)getmem((size_t)mol->unitcell->np, sizeof(struct ATOM)); } n=0; for (i=0; i<3; i++) { if (mol->unitcell->miller[i] != 0) { mol->unitcell->millerPlanes[n].x=0.0; mol->unitcell->millerPlanes[n].y=0.0; mol->unitcell->millerPlanes[n].z=0.0; mol->unitcell->millerPlanes[n].element=mp; switch (i) { case 0: mol->unitcell->millerPlanes[n].x=1.0/(double)(mol->unitcell->miller[i]); break; case 1: mol->unitcell->millerPlanes[n].y=1.0/(double)(mol->unitcell->miller[i]); break; case 2: mol->unitcell->millerPlanes[n].z=1.0/(double)(mol->unitcell->miller[i]); break; } n++; } } for (i=0; i<3; i++) { j=n; if (mol->unitcell->miller[i] == 0) { for (k=n-1; k>=0; k--) { mol->unitcell->millerPlanes[j].x=mol->unitcell->millerPlanes[k].x; mol->unitcell->millerPlanes[j].y=mol->unitcell->millerPlanes[k].y; mol->unitcell->millerPlanes[j].z=mol->unitcell->millerPlanes[k].z; mol->unitcell->millerPlanes[j].element=mp; switch (i) { case 0: mol->unitcell->millerPlanes[j].x+=1.0; break; case 1: mol->unitcell->millerPlanes[j].y+=1.0; break; case 2: mol->unitcell->millerPlanes[j].z+=1.0; break; } j++; } } n=j; } for (i=n-1; i>=0; i--) { if (mol->unitcell->millerPlanes[i].x < 0.0) sx=1.0; if (mol->unitcell->millerPlanes[i].y < 0.0) sy=1.0; if (mol->unitcell->millerPlanes[i].z < 0.0) sz=1.0; } for (i=n-1; i>=0; i--) { mol->unitcell->millerPlanes[i].x+=sx; mol->unitcell->millerPlanes[i].y+=sy; mol->unitcell->millerPlanes[i].z+=sz; } mol->unitcell->nmiller=n; fractionalToCartesian(mol->unitcell->millerPlanes, mol->unitcell->a, mol->unitcell->b, mol->unitcell->c, mol->unitcell->alpha, mol->unitcell->beta, mol->unitcell->gamma, NULL, 0, n); j=0; for (i=0; iunitcell->millerPlanes[i].x+=mol->unitcell->corners[0].x; mol->unitcell->millerPlanes[i].y+=mol->unitcell->corners[0].y; mol->unitcell->millerPlanes[i].z+=mol->unitcell->corners[0].z; /* printf("%f %f %f\n", mol->unitcell->millerPlanes[i].x, mol->unitcell->millerPlanes[i].y, mol->unitcell->millerPlanes[i].z); */ } } } viewmol-2.4.1/source/mkconn.c0100644000272700027270000003770410114367140014304 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M K C O N N . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: mkconn.c,v 1.7 2004/08/29 14:55:28 jrh Exp $ * $Log: mkconn.c,v $ * Revision 1.7 2004/08/29 14:55:28 jrh * Release 2.4.1 * * Revision 1.6 2003/11/07 11:07:02 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:11:48 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:32 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:52:40 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:40 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:42:09 jrh * Initial revision * */ #include #include #include #include #include #include "viewmol.h" #include "dialog.h" extern struct MOLECULE *molecules; extern struct WINDOW windows[]; extern double amplitude, forceScale, hbondThreshold, lineWidth; extern int nmolecule, ne; extern int debug, bondType; extern Widget topShell; double centerMolecule(struct MOLECULE *); void setWindowSize(double); extern struct SAVE *saveGeometry(struct MOLECULE *); extern double bondLength(struct ATOM *, int, int); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern char *getStringResource(Widget, char *); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern void bondOrder(struct MOLECULE *, struct BOND *, int *, int); extern void findConjugation(struct MOLECULE *, struct BOND *, int *, int, int); extern void calculateShift(struct MOLECULE *, struct BOND *, int *, int, int, int); extern void pixelToWorld(int, double *, double *); extern void redraw(int); extern clock_t getCPUTime(void); int makeConnectivity(struct MOLECULE *mol, int setWindow, int saveCoord) { Dimension width, height; double r1, r2, box, xpix, ypix; clock_t startTime=0; int *connectivity, maxBondsPerAtom=8, found, nbonds; size_t mnb=20; register int i, j, k, l; box=centerMolecule(mol); if (setWindow) setWindowSize(box); if (saveCoord) { if (mol->coord != NULL) fremem((void **)&(mol->coord)); mol->coord=saveGeometry(mol); } if (debug == 1) startTime=getCPUTime(); repeat: connectivity=(int *)getmem((size_t)(maxBondsPerAtom*mol->na), sizeof(int)); for (i=0; ina; i++) { mol->atoms[i].nbonds=0; mol->atoms[i].hbonds=0; for (j=0; jna; j++) { if (i != j) { r1=bondLength(mol->atoms, i, j); r2=mol->atoms[i].radScale*mol->atoms[i].rad +mol->atoms[j].radScale*mol->atoms[j].rad; if (r1 < r2 && strncmp(mol->atoms[i].element->symbol, "??", 2) && strncmp(mol->atoms[j].element->symbol, "??", 2)) { mol->atoms[i].nbonds++; if (mol->atoms[i].nbonds > maxBondsPerAtom) { maxBondsPerAtom+=5; fremem((void **)&connectivity); goto repeat; } connectivity[maxBondsPerAtom*i+mol->atoms[i].nbonds-1]=j; } else { if (((!strcmp(mol->atoms[i].name, "H") && strcmp(mol->atoms[j].name, "H") && strcmp(mol->atoms[j].name, "C")) || (!strcmp(mol->atoms[j].name, "H") && strcmp(mol->atoms[i].name, "H") && strcmp(mol->atoms[i].name, "C"))) && r1 < hbondThreshold && strncmp(mol->atoms[i].element->symbol, "??", 2) && strncmp(mol->atoms[j].element->symbol, "??", 2)) { mol->atoms[i].nbonds++; mol->atoms[i].hbonds++; if (mol->atoms[i].nbonds > maxBondsPerAtom) { maxBondsPerAtom+=5; fremem((void **)&connectivity); goto repeat; } connectivity[maxBondsPerAtom*i+mol->atoms[i].nbonds-1]=(-j); } } } } } if (debug == 1) { double clockTick; #if defined LINUX || defined DARWIN clockTick=(double)sysconf(_SC_CLK_TCK); #else clockTick=(double)CLK_TCK; #endif printf("Time to find bonds: %f ms\n", 1000.*(getCPUTime()-startTime)/clockTick); } XtVaGetValues(windows[VIEWER].widget, XtNwidth, &width, XtNheight, &height, NULL); if (mol->bondShift == 0.0) { pixelToWorld(VIEWER, &xpix, &ypix); if (lineWidth == 0.0) mol->bondShift=0.005*(double)(width+height)*xpix; else mol->bondShift=lineWidth*xpix; } /* Fill the bonds structure, but check whether user has deleted a particular bond. If an atom is only bond to one other atom assign bond order immediately since there can be no dependance on any other atom. */ if (mol->bonds) fremem((void **)&(mol->bonds)); mol->bonds=(struct BOND *)getmem(mnb, sizeof(struct BOND)); mol->nb=0; for (i=0; ina; i++) { nbonds=mol->atoms[i].nbonds; for (j=0; jnbDeleted; l++) { if ((mol->deletedBonds[2*l] == i && mol->deletedBonds[2*l+1] == abs(k)) || (mol->deletedBonds[2*l+1] == i && mol->deletedBonds[2*l] == abs(k))) { found=TRUE; break; } } if (!found) { mol->bonds[mol->nb].first=i; mol->bonds[mol->nb].second=abs(k); if (bondType != SINGLE_BONDS) { if (mol->atoms[i].nbonds == 1 || mol->atoms[abs(k)].nbonds == 1) bondOrder(mol, &(mol->bonds[mol->nb]), connectivity, maxBondsPerAtom); else mol->bonds[mol->nb].order=0; } else mol->bonds[mol->nb].order=1; if (k < 0) mol->bonds[mol->nb].order=(-1); /* Use the fraction of the bond length corresponding to the Van der Waals radius of the atom to color a bond according to the atom */ mol->bonds[mol->nb].frac=mol->atoms[i].rad/(mol->atoms[i].rad+mol->atoms[abs(k)].rad); if (++mol->nb >= mnb) { mnb+=20; mol->bonds=(struct BOND *)expmem((void *)mol->bonds, mnb, sizeof(struct BOND)); } } } } } /* Correct nbonds if bonds have been deleted. This cannot be done before since nbonds is used as indicator for the number of entries in connectivity. */ for (i=0; inbDeleted; i++) { mol->atoms[mol->deletedBonds[2*i]].nbonds--; mol->atoms[mol->deletedBonds[2*i+1]].nbonds--; } /* Add user defined bonds to the bonds array, but check whether that bond was already assigned by the previous loop. */ for (i=0; inbAdded; i++) { found=FALSE; for (j=0; jnb; j++) { if ((mol->addedBonds[3*i] == mol->bonds[j].first && mol->addedBonds[3*i+1] == mol->bonds[j].second) || (mol->addedBonds[3*i] == mol->bonds[j].second && mol->addedBonds[3*i+1] == mol->bonds[j].first)) { found=TRUE; mol->bonds[j].order=mol->addedBonds[3*i+2]; if (mol->bonds[j].order > 1) calculateShift(mol, &mol->bonds[j], connectivity, maxBondsPerAtom, mol->bonds[j].first, mol->bonds[j].second); break; } } if (!found) { mol->atoms[mol->addedBonds[3*i]].nbonds++; mol->atoms[mol->addedBonds[3*i+1]].nbonds++; mol->bonds[mol->nb].first=mol->addedBonds[3*i]; mol->bonds[mol->nb].second=mol->addedBonds[3*i+1]; mol->bonds[mol->nb].order=mol->addedBonds[3*i+2]; if (mol->addedBonds[3*i+2] > 1) calculateShift(mol, &mol->bonds[mol->nb], connectivity, maxBondsPerAtom, mol->addedBonds[3*i], mol->addedBonds[3*i+1]); mol->bonds[mol->nb++].frac=mol->atoms[mol->addedBonds[3*i]].rad /bondLength(mol->atoms, mol->addedBonds[3*i], mol->addedBonds[3*i+1]); if (mol->nb >= mnb) { mnb+=20; mol->bonds=(struct BOND *)expmem((void *)mol->bonds, mnb, sizeof(struct BOND)); } } } /* Assign bond orders for the remaining bonds */ for (i=0; inb; i++) { if (mol->bonds[i].order == 0) { if (bondType != SINGLE_BONDS) bondOrder(mol, &mol->bonds[i], connectivity, maxBondsPerAtom); else mol->bonds[i].order=1; } } /* Check if there are conjugated double bonds */ if (bondType == CONJUGATION) findConjugation(mol, mol->bonds, connectivity, maxBondsPerAtom, mol->nb); fremem((void **)&connectivity); if (mol->nb > 0) mol->bonds=(struct BOND *)expmem((void *)mol->bonds, mol->nb, sizeof(struct BOND)); /* Add unit cell edges */ if (mol->unitcell) { mol->unitcell->edges=(struct EDGE *)getmem(12, sizeof(struct EDGE)); mol->unitcell->ne=0; mol->unitcell->edges[mol->unitcell->ne].first=0; mol->unitcell->edges[mol->unitcell->ne++].second=1; mol->unitcell->edges[mol->unitcell->ne].first=0; mol->unitcell->edges[mol->unitcell->ne++].second=2; mol->unitcell->edges[mol->unitcell->ne].first=0; mol->unitcell->edges[mol->unitcell->ne++].second=3; mol->unitcell->edges[mol->unitcell->ne].first=1; mol->unitcell->edges[mol->unitcell->ne++].second=4; mol->unitcell->edges[mol->unitcell->ne].first=1; mol->unitcell->edges[mol->unitcell->ne++].second=7; mol->unitcell->edges[mol->unitcell->ne].first=2; mol->unitcell->edges[mol->unitcell->ne++].second=6; mol->unitcell->edges[mol->unitcell->ne].first=2; mol->unitcell->edges[mol->unitcell->ne++].second=7; mol->unitcell->edges[mol->unitcell->ne].first=3; mol->unitcell->edges[mol->unitcell->ne++].second=4; mol->unitcell->edges[mol->unitcell->ne].first=3; mol->unitcell->edges[mol->unitcell->ne++].second=6; mol->unitcell->edges[mol->unitcell->ne].first=4; mol->unitcell->edges[mol->unitcell->ne++].second=5; mol->unitcell->edges[mol->unitcell->ne].first=5; mol->unitcell->edges[mol->unitcell->ne++].second=6; mol->unitcell->edges[mol->unitcell->ne].first=5; mol->unitcell->edges[mol->unitcell->ne++].second=7; } if (debug == 1) { printf("Bonds:\n"); for (i=0; inb; i++) { printf("%d: %s(%d)-%s(%d) = %d, frac = %f", i, mol->atoms[mol->bonds[i].first].name, mol->bonds[i].first+1, mol->atoms[mol->bonds[i].second].name, mol->bonds[i].second+1, mol->bonds[i].order, mol->bonds[i].frac); if (abs(mol->bonds[i].order) != 1) printf(", multiple bond shift %f %f %f\n", mol->bonds[i].x, mol->bonds[i].y, mol->bonds[i].z); else printf("\n"); } if (mol->unitcell) { printf("Unit cell edges:\n"); for (i=0; iunitcell->ne; i++) printf("%d: %d-%d\n", i, mol->bonds[i].first+1, mol->bonds[i].second+1); } } return(TRUE); } double centerMolecule(struct MOLECULE *mol) { double mass, box, r; int i; /* Translate molecule so that it is centered at its center of gravity and determine the size of the cube enclosing it taking into account the van der Waals radii of the atoms */ mol->transx=0.0; mol->transy=0.0; mol->transz=0.0; mass=0.0; for (i=0; ina; i++) { mol->transx+=mol->atoms[i].mass*mol->atoms[i].x; mol->transy+=mol->atoms[i].mass*mol->atoms[i].y; mol->transz+=mol->atoms[i].mass*mol->atoms[i].z; mass+=mol->atoms[i].mass; } mol->transx=-mol->transx/mass; mol->transy=-mol->transy/mass; mol->transz=-mol->transz/mass; if (debug == 1) printf("Shifting molecule by %f %f %f.\n", mol->transx, mol->transy, mol->transz); box=0.0; for (i=0; ina; i++) { mol->atoms[i].x+=mol->transx; mol->atoms[i].y+=mol->transy; mol->atoms[i].z+=mol->transz; r=mol->atoms[i].radScale*mol->atoms[i].rad; box=fabs(mol->atoms[i].x)+r > box ? fabs(mol->atoms[i].x)+r : box; box=fabs(mol->atoms[i].y)+r > box ? fabs(mol->atoms[i].y)+r : box; box=fabs(mol->atoms[i].z)+r > box ? fabs(mol->atoms[i].z)+r : box; } if (mol->unitcell) { for (i=0; iunitcell->nc; i++) { mol->unitcell->corners[i].x+=mol->transx; mol->unitcell->corners[i].y+=mol->transy; mol->unitcell->corners[i].z+=mol->transz; r=mol->unitcell->corners[i].radScale*mol->unitcell->corners[i].rad; box=fabs(mol->unitcell->corners[i].x)+r > box ? fabs(mol->unitcell->corners[i].x)+r : box; box=fabs(mol->unitcell->corners[i].y)+r > box ? fabs(mol->unitcell->corners[i].y)+r : box; box=fabs(mol->unitcell->corners[i].z)+r > box ? fabs(mol->unitcell->corners[i].z)+r : box; } } if (box == 0.0) box=mol->atoms[0].rad; /* Add 5 % space and make it the space diagonal of the cube so that rotations do not move any atom out of the clipping volume */ box*=1.05*sqrt(3.); return(box); } void setBondType(Widget widget, caddr_t which, XmToggleButtonCallbackStruct *data) { register int i; if (data->set) { bondType=(int)which; for (i=0; i height) { r=((double)width/(double)height-1.0)*windows[VIEWER].near; windows[VIEWER].left=windows[VIEWER].near+r; windows[VIEWER].right=windows[VIEWER].far-r; windows[VIEWER].bottom=windows[VIEWER].near; windows[VIEWER].top=windows[VIEWER].far; } else { r=((double)height/(double)width-1.0)*windows[VIEWER].near; windows[VIEWER].left=windows[VIEWER].near; windows[VIEWER].right=windows[VIEWER].far; windows[VIEWER].bottom=windows[VIEWER].near+r; windows[VIEWER].top=windows[VIEWER].far-r; } } /* void deleteBond(struct MOLECULE *mol, int i, int j) { register int i; for (i=0; inb; i++) { if ((molecules[imol].bonds[i].first == clicked[0] && molecules[imol].bonds[i].second == clicked[1]) ||(molecules[imol].bonds[i].first == clicked[1] && molecules[imol].bonds[i].second == clicked[0])) { for (j=i+1; j #include #include #include "viewmol.h" #define MIN(a, b) (a) < (b) ? (a) : (b) #define THRESHOLD 1.0e-6 void makeUnitCell(double, double, double, double, double, double, double *, int); void fractionalToCartesian(struct ATOM *, double, double, double, double, double, double, struct MOLECULE *, int, int); double *cartesianToFractional(double, double, double, double, double, double, double *, double *, double *, int *, int); void expandCell(int, int); void addBoundaryAtoms(struct MOLECULE *); void shiftUnitCell(struct MOLECULE *); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern double forceScale; extern int makeConnectivity(struct MOLECULE *, int, int); extern double bondLength(struct ATOM *, int, int); extern double bondAngle(struct ATOM *, int, int, int); extern double dist(double, double, double, double, double, double); extern double angle(double, double, double, double, double, double, double, double, double); extern void millerPlane(void); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); void makeUnitCell(double a, double b, double c, double alpha, double beta, double gamma, double *bravaisMatrix, int frac) { /* This function computes from the unit cell lengths and angles the cartesian coordinates of the eight corners and stores them in corners[], if frac == TRUE the input coordinates are fractional coordinates and this function will convert them to cartesian coordinates */ struct MOLECULE *mol; static int icell=0; double torad; int n; if (windows[VIEWER].set >= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; if (mol->unitcell) { /* icell is incremented at the end of this function */ mol->unitcell=(struct UNITCELL *)expmem((void *)mol->unitcell, (size_t)(icell+1), sizeof(struct UNITCELL)); } else { mol->unitcell=(struct UNITCELL *)getmem((size_t)2, sizeof(struct UNITCELL)); icell=1; } if (a > 0.0) { mol->unitcell[icell].a=a; mol->unitcell[icell].b=b; mol->unitcell[icell].c=c; mol->unitcell[icell].alpha=alpha; mol->unitcell[icell].beta=beta; mol->unitcell[icell].gamma=gamma; } mol->unitcell[icell].nc=8; mol->unitcell[icell].showMiller=FALSE; mol->unitcell[icell].miller[0]=0; mol->unitcell[icell].miller[1]=mol->unitcell[icell].miller[2]=1; mol->unitcell[icell].nmiller=0; mol->unitcell[icell].corners=(struct ATOM *)getmem((size_t)mol->unitcell[icell].nc, sizeof(struct ATOM)); torad=atan(1.0)/45.0; n=0; mol->unitcell[icell].corners[n].x=0.0; mol->unitcell[icell].corners[n].y=0.0; mol->unitcell[icell].corners[n].z=0.0; mol->unitcell[icell].corners[n].ref=n; mol->unitcell[icell].corners[n++].flags=ORIGINAL; if (a < 0.0) { mol->unitcell[icell].corners[n].x=bravaisMatrix[0]; mol->unitcell[icell].corners[n].y=bravaisMatrix[1]; mol->unitcell[icell].corners[n].z=bravaisMatrix[2]; } else { mol->unitcell[icell].corners[n].x=a; mol->unitcell[icell].corners[n].y=0.0; mol->unitcell[icell].corners[n].z=0.0; } /*printf("%10.6f %10.6f %10.6f\n", mol->unitcell[icell].corners[n].x/0.52917706, mol->unitcell[icell].corners[n].y/0.52917706, mol->unitcell[icell].corners[n].z/0.52917706); */ mol->unitcell[icell].corners[n].ref=n; mol->unitcell[icell].corners[n++].flags=ORIGINAL; if (a < 0.0) { mol->unitcell[icell].corners[n].x=bravaisMatrix[3]; mol->unitcell[icell].corners[n].y=bravaisMatrix[4]; mol->unitcell[icell].corners[n].z=bravaisMatrix[5]; } else { mol->unitcell[icell].corners[n].x=b*cos(torad*gamma); mol->unitcell[icell].corners[n].y=sqrt(b*b-mol->unitcell[icell].corners[n].x* mol->unitcell[icell].corners[n].x); mol->unitcell[icell].corners[n].z=0.0; } /*printf("%10.6f %10.6f %10.6f\n", mol->unitcell[icell].corners[n].x/0.52917706, mol->unitcell[icell].corners[n].y/0.52917706, mol->unitcell[icell].corners[n].z/0.52917706); */ mol->unitcell[icell].corners[n].ref=n; mol->unitcell[icell].corners[n++].flags=ORIGINAL; if (a < 0.0) { mol->unitcell[icell].corners[n].x=bravaisMatrix[6]; mol->unitcell[icell].corners[n].y=bravaisMatrix[7]; mol->unitcell[icell].corners[n].z=bravaisMatrix[8]; } else { mol->unitcell[icell].corners[n].x=c*cos(torad*beta); mol->unitcell[icell].corners[n].y=(b*c*cos(torad*alpha)-mol->unitcell[icell].corners[n-1].x* mol->unitcell[icell].corners[n].x)/ mol->unitcell[icell].corners[n-1].y; mol->unitcell[icell].corners[n].z=sqrt(c*c-mol->unitcell[icell].corners[n].x* mol->unitcell[icell].corners[n].x -mol->unitcell[icell].corners[n].y* mol->unitcell[icell].corners[n].y); } /*printf("%10.6f %10.6f %10.6f\n", mol->unitcell[icell].corners[n].x/0.52917706, mol->unitcell[icell].corners[n].y/0.52917706, mol->unitcell[icell].corners[n].z/0.52917706); */ mol->unitcell[icell].corners[n].ref=n; mol->unitcell[icell].corners[n++].flags=ORIGINAL; mol->unitcell[icell].corners[n].x=mol->unitcell[icell].corners[n-1].x+ mol->unitcell[icell].corners[n-3].x; mol->unitcell[icell].corners[n].y=mol->unitcell[icell].corners[n-1].y+ mol->unitcell[icell].corners[n-3].y; mol->unitcell[icell].corners[n].z=mol->unitcell[icell].corners[n-1].z+ mol->unitcell[icell].corners[n-3].z; mol->unitcell[icell].corners[n].ref=n; mol->unitcell[icell].corners[n++].flags=ORIGINAL; mol->unitcell[icell].corners[n].x=mol->unitcell[icell].corners[n-1].x+ mol->unitcell[icell].corners[n-3].x; mol->unitcell[icell].corners[n].y=mol->unitcell[icell].corners[n-1].y+ mol->unitcell[icell].corners[n-3].y; mol->unitcell[icell].corners[n].z=mol->unitcell[icell].corners[n-1].z+ mol->unitcell[icell].corners[n-3].z; mol->unitcell[icell].corners[n].ref=n; mol->unitcell[icell].corners[n++].flags=ORIGINAL; mol->unitcell[icell].corners[n].x=mol->unitcell[icell].corners[n-4].x+ mol->unitcell[icell].corners[n-3].x; mol->unitcell[icell].corners[n].y=mol->unitcell[icell].corners[n-4].y+ mol->unitcell[icell].corners[n-3].y; mol->unitcell[icell].corners[n].z=mol->unitcell[icell].corners[n-4].z+ mol->unitcell[icell].corners[n-3].z; mol->unitcell[icell].corners[n].ref=n; mol->unitcell[icell].corners[n++].flags=ORIGINAL; mol->unitcell[icell].corners[n].x=mol->unitcell[icell].corners[n-6].x+ mol->unitcell[icell].corners[n-5].x; mol->unitcell[icell].corners[n].y=mol->unitcell[icell].corners[n-6].y+ mol->unitcell[icell].corners[n-5].y; mol->unitcell[icell].corners[n].z=mol->unitcell[icell].corners[n-6].z+ mol->unitcell[icell].corners[n-5].z; mol->unitcell[icell].corners[n].ref=n; mol->unitcell[icell].corners[n].flags=ORIGINAL; mol->unitcell[icell].factor[0]=mol->unitcell[icell].factor[1]=mol->unitcell[icell].factor[2]=1.0; (void)memcpy((void *)&(mol->unitcell[0]), (void *)&(mol->unitcell[icell]), sizeof(struct UNITCELL)); if (a < 0.0) { mol->unitcell[icell].a=bondLength(mol->unitcell[icell].corners, 0, 1); mol->unitcell[icell].b=bondLength(mol->unitcell[icell].corners, 0, 2); mol->unitcell[icell].c=bondLength(mol->unitcell[icell].corners, 0, 3); mol->unitcell[icell].alpha=bondAngle(mol->unitcell[icell].corners, 2, 0, 3); mol->unitcell[icell].beta=bondAngle(mol->unitcell[icell].corners, 1, 0, 3); mol->unitcell[icell].gamma=bondAngle(mol->unitcell[icell].corners, 1, 0, 2); } icell++; if (frac) fractionalToCartesian(mol->atoms, a, b, c, alpha, beta, gamma, mol, 0, mol->na); } void fractionalToCartesian(struct ATOM *atoms, double a, double b, double c, double alpha, double beta, double gamma, struct MOLECULE *mol, int from, int to) { double torad, x2, x3, y2, y3, z3; register int i, j, k; torad=atan(1.0)/45.0; alpha*=torad; beta*=torad; gamma*=torad; x2=b*cos(gamma); y2=sqrt(b*b-x2*x2); x3=c*cos(beta); y3=(b*c*cos(alpha)-x2*x3)/y2; z3=sqrt(c*c-x3*x3-y3*y3); for (i=from; inhist; i++) { k=i*to; x2=mol->unitcell->b*cos(mol->unitcell->gamma); y2=sqrt(mol->unitcell->b*mol->unitcell->b-x2*x2); x3=mol->unitcell->c*cos(mol->unitcell->beta); y3=(mol->unitcell->b*mol->unitcell->c*cos(mol->unitcell->alpha)-x2*x3)/y2; z3=sqrt(c*c-x3*x3-y3*y3); for (j=from; jhistory[k+j].x =mol->unitcell->a*mol->history[k+j].x +x2*mol->history[k+j].y +x3*mol->history[k+j].z; mol->history[k+j].y =y2*mol->history[k+j].y +y3*mol->history[k+j].z; mol->history[k+j].z*=z3; } } } } double *cartesianToFractional(double a, double b, double c, double alpha, double beta, double gamma, double *xmin, double *ymin, double *zmin, int *natoms, int shift) { struct MOLECULE *mol; double torad, x2, x3, y2, y3, z3; double *frac; register int i, j, n=0; /* Transform cartesian coordinates to fractional coordinates */ if (windows[VIEWER].set >= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; torad=atan(1.0)/45.0; alpha*=torad; beta*=torad; gamma*=torad; x2=b*cos(gamma); y2=sqrt(b*b-x2*x2); x3=c*cos(beta); y3=(b*c*cos(alpha)-x2*x3)/y2; z3=1.0/sqrt(c*c-x3*x3-y3*y3); y2=1.0/y2; frac=(double *)getmem((size_t)(3*mol->na), sizeof(double)); j=0; *xmin=0.0; *ymin=0.0; *zmin=0.0; for (i=0; ina; i++) { if (mol->atoms[i].flags & ORIGINAL) { frac[j+2]=mol->atoms[i].z*z3; frac[j+1]=(mol->atoms[i].y-frac[j+2]*y3)*y2; frac[j] =(mol->atoms[i].x-frac[j+1]*x2-frac[j+2]*x3)/a; *xmin=MIN(*xmin, frac[j]); *ymin=MIN(*ymin, frac[j+1]); *zmin=MIN(*zmin, frac[j+2]); j+=3; n++; } } if (shift) { j=0; for (i=0; i= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; n=0; for (i=0; ina; i++) if (mol->atoms[i].flags & ORIGINAL) n++; frac=cartesianToFractional(mol->unitcell[mol->nhist].a, mol->unitcell[mol->nhist].b, mol->unitcell[mol->nhist].c, mol->unitcell[mol->nhist].alpha, mol->unitcell[mol->nhist].beta, mol->unitcell[mol->nhist].gamma, &xmin, &ymin, &zmin, &n, TRUE); new=(struct NEW *)getmem((size_t)(n*ceil(mol->unitcell->factor[0])*ceil(mol->unitcell->factor[1]) *ceil(mol->unitcell->factor[2])), sizeof(struct NEW)); nnew=0; for (i=0; i<(int)ceil(mol->unitcell->factor[0]); i++) { for (j=0; j<(int)ceil(mol->unitcell->factor[1]); j++) { for (k=0; k<(int)ceil(mol->unitcell->factor[2]); k++) { if (i == 0 && j == 0 && k == 0) continue; l=0; for (m=0; munitcell->factor[0] && new[nnew].y <= mol->unitcell->factor[1] && new[nnew].z <= mol->unitcell->factor[2]) new[nnew++].ref=m; } } } } fremem((void *)&frac); /* Extend/shrink atoms structure */ mol->atoms=(struct ATOM *)expmem((void *)mol->atoms, (size_t)(n+nnew), sizeof(struct ATOM)); j=0; for (i=n; iatoms[i].x=new[j].x+xmin; mol->atoms[i].y=new[j].y+ymin; mol->atoms[i].z=new[j].z+zmin; k=new[j++].ref; mol->atoms[i].rad=mol->atoms[k].rad; mol->atoms[i].radScale=mol->atoms[k].radScale; mol->atoms[i].mass=mol->atoms[k].mass; mol->atoms[i].neutronScatterfac=mol->atoms[k].neutronScatterfac; mol->atoms[i].nbonds=mol->atoms[k].nbonds; mol->atoms[i].nelectrons=mol->atoms[k].nelectrons; mol->atoms[i].ref=k; mol->atoms[i].flags=mol->atoms[k].flags & ~ORIGINAL; mol->atoms[i].element=mol->atoms[k].element; mol->atoms[i].basis=mol->atoms[k].basis; strncpy(mol->atoms[i].name, mol->atoms[k].name, 7); strncpy(mol->atoms[i].basisname, mol->atoms[k].basisname, MAXLENBASISNAME-1); } fremem((void *)&new); fractionalToCartesian(mol->atoms, mol->unitcell[mol->nhist].a, mol->unitcell[mol->nhist].b, mol->unitcell[mol->nhist].c, mol->unitcell[mol->nhist].alpha, mol->unitcell[mol->nhist].beta, mol->unitcell[mol->nhist].gamma, NULL, n, n+nnew); mol->na=n+nnew; if (doConnectivity) { addBoundaryAtoms(mol); a=forceScale; /* setWindow should not be TRUE if expandCell is called due to the user moving to a different frame in the optimization history */ makeConnectivity(mol, setWindow, TRUE); forceScale=a; } if (mol->unitcell->nmiller != 0) millerPlane(); if (mol->ngridobjects) { for (i=0; ingridobjects; i++) { mol->gridObjects[i].npoints[0]=mol->gridObjects[i].ngridpoints[0]*mol->unitcell->factor[0]; mol->gridObjects[i].npoints[1]=mol->gridObjects[i].ngridpoints[1]*mol->unitcell->factor[1]; mol->gridObjects[i].npoints[2]=mol->gridObjects[i].ngridpoints[2]*mol->unitcell->factor[2]; } } } void addBoundaryAtoms(struct MOLECULE *mol) { double cellFactor[3]; int i, nlast; nlast=mol->na; cellFactor[0]=mol->unitcell->factor[0]; cellFactor[1]=mol->unitcell->factor[1]; cellFactor[2]=mol->unitcell->factor[2]; mol->unitcell->factor[0]+=THRESHOLD; mol->unitcell->factor[1]+=THRESHOLD; mol->unitcell->factor[2]+=THRESHOLD; expandCell(FALSE, FALSE); mol->unitcell->factor[0]=cellFactor[0]; mol->unitcell->factor[1]=cellFactor[1]; mol->unitcell->factor[2]=cellFactor[2]; for (i=nlast; ina; i++) { mol->atoms[i].flags|=DISPLAY_ONLY; /* printf("%f %f %f %s\n", mol->atoms[i].x, mol->atoms[i].y, mol->atoms[i].z, mol->atoms[i].name);*/ } } void shiftUnitCell(struct MOLECULE *mol) { double *frac; double xmin, ymin, zmin; double torad, alpha, beta, gamma; double x2, y2, x3, y3; int n, outside; register int i, j; n=0; for (i=0; ina; i++) if (mol->atoms[i].flags & ORIGINAL) n++; frac=cartesianToFractional(mol->unitcell->a, mol->unitcell->b, mol->unitcell->c, mol->unitcell->alpha, mol->unitcell->beta, mol->unitcell->gamma, &xmin, &ymin, &zmin, &n, FALSE); outside=FALSE; for (i=0; i<3*n; i++) { if (frac[i] < 0.0 || frac[i] > 1.0) { outside=TRUE; break; } } if (outside) { torad=atan(1.0)/45.0; alpha=torad*mol->unitcell->alpha; beta=torad*mol->unitcell->beta; gamma=torad*mol->unitcell->gamma; x2=mol->unitcell->b*cos(gamma); y2=sqrt(mol->unitcell->b*mol->unitcell->b-x2*x2); x3=mol->unitcell->c*cos(beta); y3=(mol->unitcell->b*mol->unitcell->c*cos(alpha)-x2*x3)/y2; xmin=mol->unitcell->a*xmin+x2*ymin+x3*zmin; ymin=y2*ymin+y3*zmin; zmin*=sqrt(mol->unitcell->c*mol->unitcell->c-x3*x3-y3*y3); for (i=0; inhist+1; i++) { for (j=0; junitcell[i].nc; j++) { mol->unitcell[i].corners[j].x+=xmin; mol->unitcell[i].corners[j].y+=ymin; mol->unitcell[i].corners[j].z+=zmin; } } } } viewmol-2.4.1/source/mo.c0100644000272700027270000007054607752676343013461 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M O . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: mo.c,v 1.6 2003/11/07 11:07:15 jrh Exp $ * $Log: mo.c,v $ * Revision 1.6 2003/11/07 11:07:15 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:12:04 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:35 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:53:01 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:45 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:42:19 jrh * Initial revision * */ #include #include #include #include #include "viewmol.h" #include "dialog.h" /* Prototypes */ double makemo(struct ATOM *, struct ORBITAL *, double, double, double, int, int, int, int); void cnorm(int); size_t norbs(struct MOLECULE *); int numberBasisFunctions(struct BASISSET *); void modcmo(struct MOLECULE *, int); void assignBasisName(int); /* void bfnamn(int, int *, int *); char *bfname(int); */ /* External functions */ extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern void *getmem(size_t, size_t); extern void fremem(void **); extern char *getStringResource(Widget, char *); /* Global variables */ extern struct MOLECULE *molecules; extern Widget topShell; /* Local variables */ /*static int *atombasisnames; static char *basisname;*/ static char basisNames[] = {"s\0p(x)\0p(y)\0p(z)\0d(xx)\0d(yy)\0d(zz)\0d(xy)\0d(xz)\0d(yz)\0f(xxx)\0f(yyy)\0f(zzz)\0f(xxy)\0f(xxz)\0f(yyx)\0f(yyz)\0f(zzx)\0f(zzy)\0f(xyz)\0g(xxxx)\0g(yyyy)\0g(zzzz)\0g(xxxy)\0g(xxxz)\0g(yyyx)\0g(yyyz)\0g(zzzx)\0g(zzzy)\0g(xxyy)\0g(xxzz)\0g(yyzz)\0g(xxyz)\0g(yyxz)\0g(zzxy)"}; double makemo(struct ATOM *atoms, struct ORBITAL *orbital, double xgrid, double ygrid, double zgrid, int na, int morb, int nbasfu, int imo) { struct BASISSET *p; double r, *expnt, *b; double result, x, y, z, f; register int i, j, k; b=(double *)getmem((size_t)morb, sizeof(double)); k=0; for (i=0; ifirst; f=0.0; for (j=0; jnprim; j++) { f+=exp(-expnt[0]*r)*expnt[1]; expnt+=2; } switch (p->ang) { case 0: b[k++]=f; break; case 1: b[k++]=x*f; b[k++]=y*f; b[k++]=z*f; break; case 2: b[k++]=x*x*f; b[k++]=y*y*f; b[k++]=z*z*f; b[k++]=x*y*f; b[k++]=x*z*f; b[k++]=y*z*f; break; case 3: b[k++]=x*x*x*f; b[k++]=y*y*y*f; b[k++]=z*z*z*f; b[k++]=x*x*y*f; b[k++]=x*x*z*f; b[k++]=y*y*x*f; b[k++]=y*y*z*f; b[k++]=z*z*x*f; b[k++]=z*z*y*f; b[k++]=x*y*z*f; break; case 4: b[k++]=x*x*x*x*f; b[k++]=y*y*y*y*f; b[k++]=z*z*z*z*f; b[k++]=x*x*x*y*f; b[k++]=x*x*x*z*f; b[k++]=y*y*y*x*f; b[k++]=y*y*y*z*f; b[k++]=z*z*z*x*f; b[k++]=z*z*z*y*f; b[k++]=x*x*y*y*f; b[k++]=x*x*z*z*f; b[k++]=y*y*z*z*f; b[k++]=x*x*y*z*f; b[k++]=y*y*x*z*f; b[k++]=z*z*x*y*f; default: k+=(p->ang+1)*(p->ang+2)/2; break; } } while ((p=p->next) != NULL); } result=0.0; if (imo == -1) { for (j=0; jfirst; ang=shell->ang+1; if (shell->nprim == 1) { sij=1.0; p[1]=1.0; } else { sij=0.0; for (j=0; jnprim; j++) { sij+=p[2*j+1]*p[2*j+1]; for (k=0; knprim; j++) { nii=fac*pow(2.0, (double)ang)*pow(p[2*j], 0.5*ang+0.25); p[2*j+1]*=nii*sij; } shell=shell->next; } while (shell != NULL); done[i]=TRUE; for (j=0; jna; atom++) nmo+=numberBasisFunctions(mol->atoms[atom].basis); return(nmo); } int numberBasisFunctions(struct BASISSET *basis) { struct BASISSET *shell; int nBasisFunctions; nBasisFunctions=0; shell=basis; if (!shell) return(nBasisFunctions); do { nBasisFunctions+=(shell->ang+1)*(shell->ang+2)/2; shell=shell->next; } while (shell != NULL); return(nBasisFunctions); } void modcmo(struct MOLECULE *mol, int gaussian) { /******************************************************************************* Transform MO coefficients which have been read in with respect to "true" basis functions (if pured, puref, or pureg are true) to MO coefficients with respect to cartesian basis functions used in the calculations (as in moloch). If MO coefficients have been read in with respect to cartesian basis functions some renormalization may be necessary. The coefficients for s and p functions will not be changed. Turbomole uses the following ordering of basis functions in the MO vector: d functions: (-xx-yy+2zz)/sqrt(12), xz, yz, xy, (xx-yy)/2 f functions: (-3xxx-3yyy+2zzz)/sqrt(60), (-xxx-xyy+4xzz)/sqrt(40), (-yyy-xxy+4yzz)/sqrt(40), xyz, (xxz-yyz)/2, (xxx-3xyy)/sqrt(24), (yyy-3xxy)/sqrt(24) g functions: (3xxxx+3yyyy+8zzzz+6xxyy-24xxzz-24yyzz)/sqrt(6720), (-3xxxz+4xzzz-3xyyz)/sqrt(168), (-3yyyz+4yzzz-3xxyz)/sqrt(168), (-xxxy-xyyy+6xyzz)/sqrt(84), (xxxx-yyyy-6xxzz+6yyzz)/sqrt(336), (xxxz-3xyyz)/sqrt(24), (yyyz-3xxyz)/sqrt(24), (xxxy-xyyy)/sqrt(12), (xxxx+yyyy-6xxyy)/sqrt(192) Gaussian uses: d functions: zz, xz, yz, xx-yy, xy f functions: ??? g functions: not available with Gaussian After transformation the MO coefficients are ordered in the following way: d functions: d(xx), d(yy), d(zz), d(xy), d(xz), d(yz) f functions: f(xxx), f(yyy), f(zzz), f(xxy), f(xxz), f(yyx), f(yyz), f(zzx), f(zzy), f(xyz) g functions: g(xxxx), g(yyyy), g(zzzz), g(xxxy), g(xxxz), g(yyyx), g(yyyz), g(zzzx), g(zzzy), g(xxyy), g(xxzz), g(yyzz), g(xxyz), g(yyxz), g(zzxy) *******************************************************************************/ static struct PushButtonRow buttons[] = {{"exit", GetMessageBoxButton, (XtPointer)0, NULL}, {"continue", GetMessageBoxButton, (XtPointer)1, NULL}}; struct ORBITAL *orbital; struct BASISSET *shell; double *newmo, *c, help; int lmax=(-1), fproblem=FALSE, gproblem=FALSE; char line[80], l[4], *p; size_t ntotal; register int mo, atom, i, j; orbital=mol->orbitals; ntotal=norbs(mol); newmo=(double *)getmem(ntotal*mol->nbasfu, sizeof(double)); j=0; for (mo=0; monbasfu; mo++) { i=0; c=&newmo[j]; for (atom=0; atomna; atom++) { shell=mol->atoms[atom].basis; if (shell) { do { if (shell->ang > lmax) lmax=shell->ang; switch (shell->ang) { case 0: newmo[j]=orbital[mo].coeff[i]; i++; j++; break; case 1: newmo[j]=orbital[mo].coeff[i]; newmo[j+1]=orbital[mo].coeff[i+1]; newmo[j+2]=orbital[mo].coeff[i+2]; i+=3; j+=3; break; case 2: if (mol->pured) { if (gaussian) { help=orbital[mo].coeff[i+4]; orbital[mo].coeff[i+4]=orbital[mo].coeff[i+3]; orbital[mo].coeff[i+3]=help; } newmo[j]=-0.5/sqrt(3.)*orbital[mo].coeff[i] +0.5*orbital[mo].coeff[i+4]; newmo[j+1]=-0.5/sqrt(3.)*orbital[mo].coeff[i] -0.5*orbital[mo].coeff[i+4]; newmo[j+2]=1.0/sqrt(3.)*orbital[mo].coeff[i]; newmo[j+3]=orbital[mo].coeff[i+3]; newmo[j+4]=orbital[mo].coeff[i+1]; newmo[j+5]=orbital[mo].coeff[i+2]; i+=5; } else { if (gaussian) { newmo[j] =orbital[mo].coeff[i] /sqrt(3.); newmo[j+1]=orbital[mo].coeff[i+1]/sqrt(3.); newmo[j+2]=orbital[mo].coeff[i+2]/sqrt(3.); newmo[j+3]=orbital[mo].coeff[i+3]/sqrt(3.); newmo[j+4]=orbital[mo].coeff[i+4]/sqrt(3.); newmo[j+5]=orbital[mo].coeff[i+5]/sqrt(3.); } else { newmo[j]=-0.5/sqrt(3.)*orbital[mo].coeff[i] +0.5*orbital[mo].coeff[i+4] +1.0/sqrt(15.0)*orbital[mo].coeff[i+5]; newmo[j+1]=-0.5/sqrt(3.)*orbital[mo].coeff[i] -0.5*orbital[mo].coeff[i+4] +1.0/sqrt(15.0)*orbital[mo].coeff[i+5]; newmo[j+2]=1.0/sqrt(3.)*orbital[mo].coeff[i] +1.0/sqrt(15.0)*orbital[mo].coeff[i+5]; newmo[j+3]=orbital[mo].coeff[i+3]; newmo[j+4]=orbital[mo].coeff[i+1]; newmo[j+5]=orbital[mo].coeff[i+2]; } i+=6; } j+=6; break; case 3: if (mol->puref) { if (gaussian) { help=orbital[mo].coeff[i+4]; orbital[mo].coeff[i+4]=orbital[mo].coeff[i+3]; orbital[mo].coeff[i+3]=help; } newmo[j]=-0.5/sqrt(10.)*orbital[mo].coeff[i+1] +0.5/sqrt(6.)*orbital[mo].coeff[i+5]; newmo[j+1]=-0.5/sqrt(10.)*orbital[mo].coeff[i+2] +0.5/sqrt(6.)*orbital[mo].coeff[i+6]; newmo[j+2]=1.0/sqrt(15.)*orbital[mo].coeff[i]; newmo[j+3]=-0.5/sqrt(10.)*orbital[mo].coeff[i+2] -sqrt(3./8.)*orbital[mo].coeff[i+6]; newmo[j+4]=-0.5*sqrt(3./5.)*orbital[mo].coeff[i] +0.5*orbital[mo].coeff[i+4]; newmo[j+5]=-0.5/sqrt(10.)*orbital[mo].coeff[i+1] -sqrt(3./8.)*orbital[mo].coeff[i+5]; newmo[j+6]=-0.5*sqrt(3./5.)*orbital[mo].coeff[i] -0.5*orbital[mo].coeff[i+4]; newmo[j+7]=sqrt(2./5.)*orbital[mo].coeff[i+1]; newmo[j+8]=sqrt(2./5.)*orbital[mo].coeff[i+2]; newmo[j+9]=orbital[mo].coeff[i+3]; i+=7; } else { if (gaussian) fproblem=TRUE; else { newmo[j]=-0.5/sqrt(10.)*orbital[mo].coeff[i+1] +0.5/sqrt(6.)*orbital[mo].coeff[i+5] +1.0/sqrt(35.)*orbital[mo].coeff[i+8]; newmo[j+1]=-0.5/sqrt(10.)*orbital[mo].coeff[i+2] +0.5/sqrt(6.)*orbital[mo].coeff[i+6] +1.0/sqrt(35.)*orbital[mo].coeff[i+9]; newmo[j+2]=1.0/sqrt(15.)*orbital[mo].coeff[i] +1.0/sqrt(35.)*orbital[mo].coeff[i+7]; newmo[j+3]=-0.5/sqrt(10.)*orbital[mo].coeff[i+2] -sqrt(3./8.)*orbital[mo].coeff[i+6] +1.0/sqrt(35.)*orbital[mo].coeff[i+9]; newmo[j+4]=-0.5*sqrt(3./5.)*orbital[mo].coeff[i] +0.5*orbital[mo].coeff[i+4] +1.0/sqrt(35.)*orbital[mo].coeff[i+7]; newmo[j+5]=-0.5/sqrt(10.)*orbital[mo].coeff[i+1] -sqrt(3./8.)*orbital[mo].coeff[i+5] +1./sqrt(35.)*orbital[mo].coeff[i+8]; newmo[j+6]=-0.5*sqrt(3./5.)*orbital[mo].coeff[i] -0.5*orbital[mo].coeff[i+4] +1./sqrt(35.)*orbital[mo].coeff[i+7]; newmo[j+7]=sqrt(2./5.)*orbital[mo].coeff[i+1] +1./sqrt(35.)*orbital[mo].coeff[i+8]; newmo[j+8]=sqrt(2./5.)*orbital[mo].coeff[i+2] +1./sqrt(35.)*orbital[mo].coeff[i+9]; newmo[j+9]=orbital[mo].coeff[i+3]; } i+=10; } j+=10; break; case 4: if (mol->pureg) { if (gaussian) gproblem=TRUE; else { newmo[j]=0.125*sqrt(3./35.)*orbital[mo].coeff[i] +0.25/sqrt(21.)*orbital[mo].coeff[i+4] +0.125/sqrt(3.)*orbital[mo].coeff[i+8]; newmo[j+1]=0.125*sqrt(3./35.)*orbital[mo].coeff[i] -0.25/sqrt(21.)*orbital[mo].coeff[i+4] +0.125/sqrt(3.)*orbital[mo].coeff[i+8]; newmo[j+2]=1./sqrt(105.)*orbital[mo].coeff[i]; newmo[j+3]=-0.5/sqrt(21.)*orbital[mo].coeff[i+3] +0.5/sqrt(3.)*orbital[mo].coeff[i+7]; newmo[4]=-0.5*sqrt(3./14.)*orbital[mo].coeff[i+1] +0.5/sqrt(6.)*orbital[mo].coeff[i+5]; newmo[j+5]=-0.5/sqrt(21.)*orbital[mo].coeff[i+3] -0.5/sqrt(3.)*orbital[mo].coeff[i+7]; newmo[j+6]=-0.5*sqrt(3./14.)*orbital[mo].coeff[i+2] +0.5/sqrt(6.)*orbital[mo].coeff[i+6]; newmo[j+7]=sqrt(2./21.)*orbital[mo].coeff[i+1]; newmo[j+8]=sqrt(2./21.)*orbital[mo].coeff[i+2]; newmo[j+9]=0.25*sqrt(3./35.)*orbital[mo].coeff[i] -0.25*sqrt(3.)*orbital[mo].coeff[i+8]; newmo[j+10]=(-sqrt(3./35.)*orbital[mo].coeff[i] -0.5*sqrt(3./7.)*orbital[mo].coeff[i+4]); newmo[j+11]=(-sqrt(3./35.)*orbital[mo].coeff[i] +0.5*sqrt(3./7.)*orbital[mo].coeff[i+4]); newmo[j+12]=(-0.5*sqrt(3./14.)*orbital[mo].coeff[i+2] -0.5*sqrt(3./2.)*orbital[mo].coeff[i+6]); newmo[j+13]=(-0.5*sqrt(3./14.)*orbital[mo].coeff[i+1] -0.5*sqrt(3./2.)*orbital[mo].coeff[i+5]); newmo[j+14]=sqrt(3./7.)*orbital[mo].coeff[i+3]; } i+=9; } else { if (gaussian) gproblem=TRUE; else { newmo[j]=0.125*sqrt(3./35.)*orbital[mo].coeff[i] +0.25/sqrt(21.)*orbital[mo].coeff[i+4] +0.125/sqrt(3.)*orbital[mo].coeff[i+8] -1./(6.*sqrt(21.))*orbital[mo].coeff[i+9] +1./(6.*sqrt(7.))*orbital[mo].coeff[i+13] +1./(3.*sqrt(105.))*orbital[mo].coeff[i+14]; newmo[j+1]=0.125*sqrt(3./35.)*orbital[mo].coeff[i] -0.25/sqrt(21.)*orbital[mo].coeff[i+4] +0.125/sqrt(3.)*orbital[mo].coeff[i+8] -1./(6.*sqrt(21.))*orbital[mo].coeff[i+9] -1./(6.*sqrt(7.))*orbital[mo].coeff[i+13] +1./(3.*sqrt(105.))*orbital[mo].coeff[i+14]; newmo[j+2]=1./sqrt(105.)*orbital[mo].coeff[i] +1./(3.*sqrt(21.))*orbital[mo].coeff[i+9] +1./(3.*sqrt(105.))*orbital[mo].coeff[i+14]; newmo[j+3]=-0.5/sqrt(21.)*orbital[mo].coeff[i+3] +0.5/sqrt(3.)*orbital[mo].coeff[i+7] +1./(3.*sqrt(7.))*orbital[mo].coeff[i+12]; newmo[j+4]=-0.5*sqrt(3./14.)*orbital[mo].coeff[i+1] +0.5/sqrt(6.)*orbital[mo].coeff[i+5] +1./(3.*sqrt(7.))*orbital[mo].coeff[i+10]; newmo[j+5]=-0.5/sqrt(21.)*orbital[mo].coeff[i+3] -0.5/sqrt(3.)*orbital[mo].coeff[i+7] +1./(3.*sqrt(7.))*orbital[mo].coeff[i+12]; newmo[j+6]=-0.5*sqrt(3./14.)*orbital[mo].coeff[i+2] +0.5/sqrt(6.)*orbital[mo].coeff[i+6] +1./(3.*sqrt(7.))*orbital[mo].coeff[i+11]; newmo[j+7]=sqrt(2./21.)*orbital[mo].coeff[i+1] +1./(3.*sqrt(7.))*orbital[mo].coeff[i+10]; newmo[j+8]=sqrt(2./21.)*orbital[mo].coeff[i+2] +1./(3.*sqrt(7.))*orbital[mo].coeff[i+11]; newmo[j+9]=0.25*sqrt(3./35.)*orbital[mo].coeff[i] -0.25*sqrt(3.)*orbital[mo].coeff[i+8] -1./(3.*sqrt(21.))*orbital[mo].coeff[i+9] +2./(3.*sqrt(105.))*orbital[mo].coeff[i+14]; newmo[j+10]=(-sqrt(3./35.)*orbital[mo].coeff[i] -0.5*sqrt(3./7.)*orbital[mo].coeff[i+4] +1./(6.*sqrt(21.))*orbital[mo].coeff[i+9] +1./(6.*sqrt(7.))*orbital[mo].coeff[i+13] +2./(3.*sqrt(105.))*orbital[mo].coeff[i+14]); newmo[j+11]=(-sqrt(3./35.)*orbital[mo].coeff[i] +0.5*sqrt(3./7.)*orbital[mo].coeff[i+4] +1./(6.*sqrt(21.))*orbital[mo].coeff[i+9] -1./(6.*sqrt(7.))*orbital[mo].coeff[i+13] +2./(3.*sqrt(105.))*orbital[mo].coeff[i+14]); newmo[j+12]=-0.5*sqrt(3./14.)*orbital[mo].coeff[i+2] -0.5*sqrt(3./2.)*orbital[mo].coeff[i+6] +1./(3.*sqrt(7.))*orbital[mo].coeff[i+11]; newmo[j+13]=-0.5*sqrt(3./14.)*orbital[mo].coeff[i+1] -0.5*sqrt(3./2.)*orbital[mo].coeff[i+5] +1./(3.*sqrt(7.))*orbital[mo].coeff[i+10]; newmo[j+14]=sqrt(3./7.)*orbital[mo].coeff[i+3] +1./(3.*sqrt(7.))*orbital[mo].coeff[i+12]; } i+=15; } j+=15; break; default: break; } shell=shell->next; } while (shell != NULL); } } orbital[mo].coeff=c; } if (fproblem) { p=getStringResource(topShell, "GaussianProblem"); sprintf(line, p, 'f'); if (!messgb(topShell, 3, line, buttons, 2)) exit (-1); } if (gproblem) { p=getStringResource(topShell, "GaussianProblem"); sprintf(line, p, 'g'); if (!messgb(topShell, 3, line, buttons, 2)) exit(-1); } if (fproblem || gproblem) { fremem((void **)&newmo); fremem((void **)&orbital); return; } if (lmax > LMAX) { strcpy(line, "I cannot handle "); for (i=LMAX+1; ibasisFunctionNames == NULL) mol->basisFunctionNames=(char **)getmem((size_t)ntotal, sizeof(char *)); j=0; p=basisname; */ for (atom=0; atomna; atom++) /* assign a name for each basis */ { /* function */ /* atombasisnames[2*atom]=j;*/ j=0; ntotal=numberBasisFunctions(mol->atoms[atom].basis); mol->atoms[atom].basisFunctionNames=(char **)getmem((size_t)ntotal, sizeof(char *)); shell=mol->atoms[atom].basis; if (!shell) return; do { switch (shell->ang) { case 0: /* strcpy(p, "s"); p+=8; */ mol->atoms[atom].basisFunctionNames[j]=&basisNames[0]; j++; break; case 1: /* strcpy(p, "p(x)"); strcpy(p+8, "p(y)"); strcpy(p+16, "p(z)"); p+=24; */ mol->atoms[atom].basisFunctionNames[j]=&basisNames[2]; mol->atoms[atom].basisFunctionNames[j+1]=&basisNames[7]; mol->atoms[atom].basisFunctionNames[j+2]=&basisNames[12]; j+=3; break; case 2: /*strcpy(p, "d(xx)"); strcpy(p+8, "d(yy)"); strcpy(p+16, "d(zz)"); strcpy(p+24, "d(xy)"); strcpy(p+32, "d(xz)"); strcpy(p+40, "d(yz)"); p+=48; */ mol->atoms[atom].basisFunctionNames[j]=&basisNames[17]; mol->atoms[atom].basisFunctionNames[j+1]=&basisNames[23]; mol->atoms[atom].basisFunctionNames[j+2]=&basisNames[29]; mol->atoms[atom].basisFunctionNames[j+3]=&basisNames[35]; mol->atoms[atom].basisFunctionNames[j+4]=&basisNames[41]; mol->atoms[atom].basisFunctionNames[j+5]=&basisNames[47]; j+=6; break; case 3: /*strcpy(p, "f(xxx)"); strcpy(p+8, "f(yyy)"); strcpy(p+16, "f(zzz)"); strcpy(p+24, "f(xxy)"); strcpy(p+32, "f(xxz)"); strcpy(p+40, "f(yyx)"); strcpy(p+48, "f(yyz)"); strcpy(p+56, "f(zzx)"); strcpy(p+64, "f(zzy)"); strcpy(p+72, "f(xyz)"); p+=80;*/ mol->atoms[atom].basisFunctionNames[j]=&basisNames[53]; mol->atoms[atom].basisFunctionNames[j+1]=&basisNames[60]; mol->atoms[atom].basisFunctionNames[j+2]=&basisNames[67]; mol->atoms[atom].basisFunctionNames[j+3]=&basisNames[74]; mol->atoms[atom].basisFunctionNames[j+4]=&basisNames[81]; mol->atoms[atom].basisFunctionNames[j+5]=&basisNames[88]; mol->atoms[atom].basisFunctionNames[j+6]=&basisNames[95]; mol->atoms[atom].basisFunctionNames[j+7]=&basisNames[102]; mol->atoms[atom].basisFunctionNames[j+8]=&basisNames[109]; mol->atoms[atom].basisFunctionNames[j+9]=&basisNames[116]; j+=10; break; case 4: /*strcpy(p, "g(xxxx)"); strcpy(p+8, "g(yyyy)"); strcpy(p+16, "g(zzzz)"); strcpy(p+24, "g(xxxy)"); strcpy(p+32, "g(xxxz)"); strcpy(p+40, "g(yyyx)"); strcpy(p+48, "g(yyyz)"); strcpy(p+56, "g(zzzx)"); strcpy(p+64, "g(zzzy)"); strcpy(p+72, "g(xxyy)"); strcpy(p+80, "g(xxzz)"); strcpy(p+88, "g(yyzz)"); strcpy(p+96, "g(xxyz)"); strcpy(p+104,"g(yyxz)"); strcpy(p+112,"g(zzxy)"); p+=120;*/ mol->atoms[atom].basisFunctionNames[j]=&basisNames[123]; mol->atoms[atom].basisFunctionNames[j+1]=&basisNames[131]; mol->atoms[atom].basisFunctionNames[j+2]=&basisNames[139]; mol->atoms[atom].basisFunctionNames[j+3]=&basisNames[147]; mol->atoms[atom].basisFunctionNames[j+4]=&basisNames[155]; mol->atoms[atom].basisFunctionNames[j+5]=&basisNames[163]; mol->atoms[atom].basisFunctionNames[j+6]=&basisNames[171]; mol->atoms[atom].basisFunctionNames[j+7]=&basisNames[179]; mol->atoms[atom].basisFunctionNames[j+8]=&basisNames[187]; mol->atoms[atom].basisFunctionNames[j+9]=&basisNames[195]; mol->atoms[atom].basisFunctionNames[j+10]=&basisNames[203]; mol->atoms[atom].basisFunctionNames[j+11]=&basisNames[211]; mol->atoms[atom].basisFunctionNames[j+12]=&basisNames[219]; mol->atoms[atom].basisFunctionNames[j+13]=&basisNames[227]; mol->atoms[atom].basisFunctionNames[j+14]=&basisNames[235]; j+=15; break; } shell=shell->next; } while (shell != NULL); mol->atoms[atom].nBasisFunctions=j; /* atombasisnames[2*atom+1]=j-1;*/ } } /* void bfnamn(int atom, int *start, int *end) { *start=atombasisnames[2*atom]; *end=atombasisnames[2*atom+1]; } char *bfname(int ibasfu) { return(basisname+8*ibasfu); }*/ viewmol-2.4.1/source/modifygeo.c0100644000272700027270000003275407752676355015032 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M O D I F Y G E O . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: modifygeo.c,v 1.4 2003/11/07 11:07:25 jrh Exp $ * $Log: modifygeo.c,v $ * Revision 1.4 2003/11/07 11:07:25 jrh * Release 2.4 * * Revision 1.3 2000/12/10 15:12:10 jrh * Release 2.3 * * Revision 1.2 1999/05/24 01:28:58 jrh * Release 2.2.1 * * Revision 1.1 1999/02/07 21:53:09 jrh * Initial revision * * */ #include #include #include #include #include #include "viewmol.h" #include "dialog.h" extern double angle(double, double, double, double, double, double,double,double,double); extern double bondLength(struct ATOM *, int, int); extern double bondAngle(struct ATOM *, int, int, int); extern double torsionAngle(struct ATOM *, int, int, int, int); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern struct SAVE *saveGeometry(struct MOLECULE *); extern void restoreGeometry(struct SAVE *, int); extern int calcInternal(struct MOLECULE *, int); extern void makeConnectivity(struct MOLECULE *, int, int); extern char *getStringResource(Widget, char *); extern void vectorProduct(double *, double *, double *); extern double scalarProduct(double *, double *); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern void redraw(int); extern void setAtom(struct MOLECULE *); extern void deleteMolecule(Widget, caddr_t, XmAnyCallbackStruct *); extern void clearGeometry(Widget, caddr_t, XmAnyCallbackStruct *); extern void setMenuItem(int, int); int findBondPartners(int *, int, int); int findAttachedAtoms(int *, int, int); void changeBondLength(int, int, int *, double); int changeAngle(int, int, int *, double); void makeRotationMatrix(double, double, double, double, double matrix[3][3]); void addUndo(struct MOLECULE *); extern struct MOLECULE *molecules; extern struct WINDOW windows[]; extern struct UNDO *undo; extern Widget topShell, undoButton; extern double bndfac; extern int debug, nUndo; extern int showWarning; void modifyGeometry(int which, char *text) { static struct PushButtonRow buttons[] = {{"ok", GetMessageBoxButton, (XtPointer)0, NULL}}; struct MOLECULE *mol; double factor, value, diff; int *move, *tmove, nmove, m, save; char *word; register int i; if (windows[VIEWER].set >= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; move=(int *)getmem(mol->na, sizeof(int)); move[0]=mol->internals[which].atoms[0]; if (mol->atoms[move[0]].nbonds > 1) nmove=findAttachedAtoms(move, 1, mol->internals[which].atoms[1]); else nmove=1; if (nmove < 0 && (mol->internals[which].type == ANGLE || mol->internals[which].type == TORSION)) { move[0]=mol->internals[which].atoms[1]; nmove=findAttachedAtoms(move, 1, mol->internals[which].atoms[2]); } if (nmove < 0) { if (showWarning) { word=getStringResource(topShell, "notChangeable"); messgb(topShell, 1, word, buttons, 1); } fremem((void *)&move); return; } addUndo(mol); value=atof(text); switch (mol->internals[which].type) { case BONDLENGTH: factor=1.0; if (strstr(text, "pm")) factor=0.01; if (strstr(text, "bohr") || strstr(text, "au")) factor=0.52917706; changeBondLength(which, nmove, move, factor*value); break; case ANGLE: (void)changeAngle(which, nmove, move, value); break; case TORSION: diff=value-torsionAngle(mol->atoms, mol->internals[which].atoms[0], mol->internals[which].atoms[1], mol->internals[which].atoms[2], mol->internals[which].atoms[3]); (void)changeAngle(which, nmove, move, value); move[0]=mol->internals[which].atoms[1]; if ((nmove=findBondPartners(move, 1, mol->internals[which].atoms[0])) > 1) { tmove=(int *)getmem(mol->na, sizeof(int)); save=mol->internals[which].atoms[0]; for (i=1; iinternals[which].atoms[2]) { tmove[0]=move[i]; if ((m=findAttachedAtoms(tmove, 1, move[0])) > 0) { value=torsionAngle(mol->atoms, move[i], move[0], mol->internals[which].atoms[2], mol->internals[which].atoms[3])+diff; mol->internals[which].atoms[0]=move[i]; (void)changeAngle(which, m, tmove, value); } } } mol->internals[which].atoms[0]=save; fremem((void *)&tmove); } break; } fremem((void *)&move); makeConnectivity(mol, FALSE, TRUE); for (i=0; ininternal; i++) (void)calcInternal(mol, i); } int findBondPartners(int *move, int n, int except) { struct MOLECULE *mol; int found; register int i, j, k, l; /* Walk through list of bonds and add all atoms connected to the atoms in move[] to move[], ignore the bond between move[0] and except and all hydrogen bonds */ if (windows[VIEWER].set >= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; l=n; for (i=0; inb; i++) { for (j=0; jbonds[i].order != (-1)) /* ignore hydrogen bonds */ { if ((mol->bonds[i].first == move[0] && mol->bonds[i].second == except) || (mol->bonds[i].first == except && mol->bonds[i].second == move[0])) continue; if (mol->bonds[i].first == move[j]) { found=FALSE; for (k=0; kbonds[i].second == move[k]) found=TRUE; if (!found) move[l++]=mol->bonds[i].second; } if (mol->bonds[i].second == move[j]) { found=FALSE; for (k=0; kbonds[i].first == move[k]) found=TRUE; if (!found) move[l++]=mol->bonds[i].first; } } } } return(l); } int findAttachedAtoms(int *move, int n, int except) { int nmove=1, nmoveold=0, save=except; register int i; while (nmove != nmoveold) { nmoveold=nmove; nmove=findBondPartners(move, nmoveold, except); } for (i=1; i= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; i=mol->internals[which].atoms[0]; j=mol->internals[which].atoms[1]; oldLength=bondLength(mol->atoms, i, j); factor=newLength/oldLength-1.0; vector[0]=factor*(mol->atoms[i].x-mol->atoms[j].x); vector[1]=factor*(mol->atoms[i].y-mol->atoms[j].y); vector[2]=factor*(mol->atoms[i].z-mol->atoms[j].z); mol->internals[which].value=bndfac*newLength; mol->internals[which].x=(mol->atoms[i].x+vector[0]+mol->atoms[j].x)*0.5+0.05; mol->internals[which].y=(mol->atoms[i].y+vector[1]+mol->atoms[j].y)*0.5+0.05; mol->internals[which].z=(mol->atoms[i].z+vector[2]+mol->atoms[j].z)*0.5+0.05; for (i=0; iatoms[move[i]].x+=vector[0]; mol->atoms[move[i]].y+=vector[1]; mol->atoms[move[i]].z+=vector[2]; } } int changeAngle(int which, int nmove, int *move, double newAngle) { struct MOLECULE *mol; double oldAngle, matrix[3][3]; double v1[3], v2[3], v3[3]; register double x, y, z; register int i, j, k; if (windows[VIEWER].set >= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; i=mol->internals[which].atoms[0]; j=mol->internals[which].atoms[1]; k=mol->internals[which].atoms[2]; if (mol->internals[which].type == ANGLE) { oldAngle=bondAngle(mol->atoms, i, j, k); v1[0]=mol->atoms[i].x-mol->atoms[j].x; v1[1]=mol->atoms[i].y-mol->atoms[j].y; v1[2]=mol->atoms[i].z-mol->atoms[j].z; v2[0]=mol->atoms[k].x-mol->atoms[j].x; v2[1]=mol->atoms[k].y-mol->atoms[j].y; v2[2]=mol->atoms[k].z-mol->atoms[j].z; vectorProduct(v1, v2, v3); /* The two bonds are co-linear, find an arbitrary vector perpendicular to the first bond */ if (fabs(v3[0]) < 1.0e-6 && fabs(v3[1]) < 1.0e-6 && fabs(v3[2]) < 1.0e-6) { v3[0]=-v1[1]/v1[0]; v3[1]=1.0; v3[2]=0.0; } } else /* torsion angle */ { oldAngle=torsionAngle(mol->atoms, i, j, k, mol->internals[which].atoms[3]); /* Torsion angle is undefined (one of the bond angles in 180 deg) */ if (oldAngle > 360.) return(FALSE); v3[0]=mol->atoms[k].x-mol->atoms[j].x; v3[1]=mol->atoms[k].y-mol->atoms[j].y; v3[2]=mol->atoms[k].z-mol->atoms[j].z; } makeRotationMatrix(newAngle-oldAngle, v3[0], v3[1], v3[2], matrix); for (i=0; iatoms[move[i]].x-mol->atoms[j].x; y=mol->atoms[move[i]].y-mol->atoms[j].y; z=mol->atoms[move[i]].z-mol->atoms[j].z; mol->atoms[move[i]].x=x*matrix[0][0]+y*matrix[0][1]+z*matrix[0][2]+mol->atoms[j].x; mol->atoms[move[i]].y=x*matrix[1][0]+y*matrix[1][1]+z*matrix[1][2]+mol->atoms[j].y; mol->atoms[move[i]].z=x*matrix[2][0]+y*matrix[2][1]+z*matrix[2][2]+mol->atoms[j].z; } mol->internals[which].value=newAngle; return(TRUE); } void makeRotationMatrix(double angle, double x, double y, double z, double matrix[3][3]) { double r, ca, sa, xx, xy, xz, yy, yz, zz; register double ca1; r=1.0/sqrt(x*x+y*y+z*z); x*=r; y*=r; z*=r; angle*=atan(1.0)/45.0; ca=cos(angle); sa=sin(angle); xx=x*x; xy=x*y; xz=x*z; yy=y*y; yz=y*z; zz=z*z; ca1=1.0-ca; matrix[0][0]=ca1*xx+ca; matrix[1][0]=ca1*xy-sa*z; matrix[2][0]=ca1*xz+sa*y; matrix[0][1]=ca1*xy+sa*z; matrix[1][1]=ca1*yy+ca; matrix[2][1]=ca1*yz-sa*x; matrix[0][2]=ca1*xz-sa*y; matrix[1][2]=ca1*yz+sa*x; matrix[2][2]=ca1*zz+ca; } void addUndo(struct MOLECULE *mol) { if (nUndo++ == 0) undo=(struct UNDO *)getmem((size_t)nUndo, sizeof(struct UNDO)); else undo=(struct UNDO *)expmem((void *)undo, (size_t)nUndo, sizeof(struct UNDO)); undo[nUndo-1].coord=saveGeometry(mol); undo[nUndo-1].mol=windows[VIEWER].set; undo[nUndo-1].na=mol->na; setMenuItem(VIEWER2_UNDO, True); if (undoButton != NULL) XtVaSetValues(undoButton, XmNsensitive, True, NULL); } void undoGeometry(Widget w, caddr_t dummy, XmAnyCallbackStruct *data) { int imolSave; register int i, imol; if (undo != NULL) { imolSave=windows[VIEWER].set; imol=windows[VIEWER].set=undo[--nUndo].mol; if (imol == (-1)) deleteMolecule((Widget)0, (caddr_t)TRUE, (XmAnyCallbackStruct *)0); else { if (undo[nUndo].na >= molecules[imol].na) { molecules[imol].atoms=(struct ATOM *)expmem((void *)molecules[imol].atoms, (size_t)undo[nUndo].na, sizeof(struct ATOM)); } molecules[imol].na=undo[nUndo].na; restoreGeometry(undo[nUndo].coord, imol); for (i=0; i= molecules[imol].na || molecules[imol].internals[i].atoms[1] >= molecules[imol].na || molecules[imol].internals[i].atoms[2] >= molecules[imol].na || molecules[imol].internals[i].atoms[3] >= molecules[imol].na) clearGeometry((Widget)0, (caddr_t)i, (XmAnyCallbackStruct *)0); else { (void)calcInternal(&molecules[imol], i); if (molecules[imol].internals[i].type == TORSION && molecules[imol].internals[i].value > 360.) clearGeometry((Widget)0, (caddr_t)i, (XmAnyCallbackStruct *)0); } } makeConnectivity(&molecules[imol], FALSE, TRUE); setAtom(&molecules[imol]); } if (nUndo) undo=(struct UNDO *)expmem((void *)undo, (size_t)nUndo, sizeof(struct UNDO)); else { fremem((void *)&undo); setMenuItem(VIEWER2_UNDO, False); if (undoButton != NULL) XtVaSetValues(undoButton, XmNsensitive, False, NULL); } windows[VIEWER].set=imolSave; redraw(VIEWER); } } viewmol-2.4.1/source/modules.h0100644000272700027270000000277707752712374014517 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M O D U L E S . H * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: modules.h,v 1.2 2003/11/07 12:50:04 jrh Exp $ * $Log: modules.h,v $ * Revision 1.2 2003/11/07 12:50:04 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:12:27 jrh * Initial revision * */ typedef struct { PyObject_HEAD int moleculeID; } PyMoleculeSpecObject; typedef struct { PyObject_HEAD int moleculeID; int atomID; } PyAtomSpecObject; typedef struct { PyObject_HEAD int elementID; } PyElementSpecObject; typedef struct { PyObject_HEAD int spectrumID; } PySpectrumSpecObject; typedef struct { PyObject_HEAD int historyID; } PyHistorySpecObject; typedef struct { PyObject_HEAD int energyLevelID; } PyEnergyLevelSpecObject; typedef struct { PyObject_HEAD int lightID; } PyLightSpecObject; typedef struct { PyObject_HEAD int labelID; } PyLabelSpecObject; viewmol-2.4.1/source/moform.c0100644000272700027270000001456307752676363014344 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M O F O R M . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: moform.c,v 1.6 2003/11/07 11:07:31 jrh Exp $ * $Log: moform.c,v $ * Revision 1.6 2003/11/07 11:07:31 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:12:37 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:42 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:53:23 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:47 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:42:23 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" static Widget dialog; static double denres_save; static int unit_save; extern struct WINDOW windows[]; extern Widget topShell; extern int unit; extern double denres; void setupEnergyUnits(struct TOGGLE *); void GetUnit(Widget, struct TOGGLE *, XmToggleButtonCallbackStruct *); void GetSlider(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); void MODiagramDialogExit(Widget, caddr_t, XmPushButtonCallbackStruct *); extern void drawMODiagram(Widget, caddr_t, XmAnyCallbackStruct *); extern void MapBox(Widget, caddr_t, XmAnyCallbackStruct *); extern Widget CreateToggleBox(Widget, struct PushButtonRow *, int, int, int, int, int); extern void CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern void setMenuItem(int, int); extern Widget initShell(Widget, char *, Widget *, Widget *); void MODiagramDialog(Widget widget, caddr_t dummy, XmAnyCallbackStruct *data) { Widget form, board, form1, form2, radiobox, label, slider; Widget sep1, sep2; static struct TOGGLE toggle[4]; static struct PushButtonRow buttons[] = { { "ok", MODiagramDialogExit, (XtPointer)TRUE, NULL }, { "cancel", MODiagramDialogExit, (XtPointer)FALSE, NULL } }; static struct PushButtonRow radiobox_buttons[] = { { "hartrees", GetUnit, (XtPointer)&toggle[0], NULL }, { "kj_mol", GetUnit, (XtPointer)&toggle[1], NULL }, { "ev", GetUnit, (XtPointer)&toggle[2], NULL }, { "cm", GetUnit, (XtPointer)&toggle[3], NULL } }; static struct SLIDER resolution; short decimals; /* This function creates the dialog for the MO diagram window */ setMenuItem(MO_SETTINGS, False); unit_save=unit; denres_save=denres; dialog=initShell(windows[MO].widget, "MODiagramForm", &board, &form); form1=XtVaCreateWidget("controlarea", xmFormWidgetClass, form, NULL); sep1=XtVaCreateManagedWidget("sep1", xmSeparatorWidgetClass, form, NULL); form2=XtVaCreateWidget("sliderarea", xmFormWidgetClass, form, NULL); sep2=XtVaCreateManagedWidget("sep2", xmSeparatorWidgetClass, form, NULL); setupEnergyUnits(toggle); radiobox=CreateToggleBox(form1, radiobox_buttons, XtNumber(radiobox_buttons), XmVERTICAL, 1, True, unit-1); XtVaSetValues(radiobox, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, NULL); XtManageChild(form1); label=XtVaCreateManagedWidget("resolutionlabel", xmLabelWidgetClass, form2, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, NULL); slider=XtVaCreateManagedWidget("resolution", xmScaleWidgetClass, form2, XmNorientation, XmHORIZONTAL, XmNshowValue, True, XmNsensitive, True, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, label, XmNbottomAttachment, XmATTACH_FORM, NULL); XtVaGetValues(slider, XmNdecimalPoints, &decimals, NULL); if (denres > 0.0) XtVaSetValues(slider, XmNvalue, (int)(denres*pow((double)10., (double)(decimals))), NULL); resolution.number=&denres; resolution.decimals=(int)decimals; resolution.draw=(void (*)())drawMODiagram; XtAddCallback(slider, XmNvalueChangedCallback, (XtCallbackProc)GetSlider, &resolution); XtManageChild(form2); CreatePushButtonRow(form, buttons, XtNumber(buttons)); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (caddr_t)NULL); XtManageChild(form); XtManageChild(board); } void setupEnergyUnits(struct TOGGLE *toggle) { register int i; for (i=0; i<4; i++) { toggle[i].var=&unit; toggle[i].draw=drawMODiagram; } toggle[0].value=HARTREE; toggle[1].value=KJ_MOL; toggle[2].value=EV; toggle[3].value=CM; } void GetUnit(Widget widget, struct TOGGLE *which, XmToggleButtonCallbackStruct *data) { if (data->set) *(which->var)=which->value; if (*(which->draw) != NULL) (*(which->draw))((Widget)0, (caddr_t)0, (caddr_t)0); } void GetSlider(Widget widget, struct SLIDER *slider, XmScrollBarCallbackStruct *data) { *(slider->number)=(double)(data->value)/pow((double)10.0, (double)slider->decimals); if (*(slider->draw) != NULL) (*(slider->draw))((Widget)0, (caddr_t)0, (caddr_t)0); } void MODiagramDialogExit(Widget widget, caddr_t which, XmPushButtonCallbackStruct *data) { if (!(int)which) { unit=unit_save; denres=denres_save; } XtDestroyWidget(dialog); setMenuItem(MO_SETTINGS, True); drawMODiagram((Widget)0, (caddr_t)0, (XmAnyCallbackStruct *)0); } viewmol-2.4.1/source/moleculemodule.c0100644000272700027270000010044310114367330016022 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M O L E C U L E M O D U L E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: moleculemodule.c,v 1.3 2004/08/29 14:57:28 jrh Exp $ * $Log: moleculemodule.c,v $ * Revision 1.3 2004/08/29 14:57:28 jrh * Release 2.4.1 * * Revision 1.2 2003/11/07 11:07:39 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:12:50 jrh * Initial revision * */ #include #include #include #include "viewmol.h" #define PyMolecule_API_pointers 1 #define PyMoleculeSpec_Type_NUM 0 #define ENTHALPY 1L #define ENTROPY 2L #define GIBBS_ENERGY 3L #define HEAT_CAPACITY 4L PyMoleculeSpecObject *molecule_new(void); static PyObject *molecule_translate(PyObject *, PyObject *); static PyObject *molecule_rotate(PyObject *, PyObject *); static PyObject *molecule_getSpectrum(PyObject *, PyObject *); static PyObject *molecule_getEnergyLevels(PyObject *, PyObject *); static PyObject *molecule_getHistory(PyObject *, PyObject *); static PyObject *molecule_showForces(PyObject *, PyObject *); static PyObject *molecule_getAtoms(PyObject *, PyObject *); static PyObject *molecule_getBonds(PyObject *, PyObject *); static PyObject *molecule_getWavenumbers(PyObject *, PyObject *); static PyObject *molecule_getMOEnergies(PyObject *, PyObject *); static PyObject *molecule_title(PyObject *, PyObject *); static PyObject *molecule_bondAverage(PyObject *, PyObject *); static PyObject *molecule_bondLength(PyObject *, PyObject *); static PyObject *molecule_bondAngle(PyObject *, PyObject *); static PyObject *molecule_torsionAngle(PyObject *, PyObject *); static PyObject *molecule_getThermodynamics(PyObject *, PyObject *); static PyObject *molecule_reaction(PyObject *, PyObject *); static PyObject *molecule_showElectrons(PyObject *, PyObject *); static PyObject *molecule_showGrid(PyObject *, PyObject *); static PyObject *molecule_selectBasisfunction(PyObject *, PyObject *); static PyObject *molecule_unitCell(PyObject *, PyObject *); static PyObject *molecule_millerPlane(PyObject *, PyObject *); static PyObject *molecule_addAtom(PyObject *, PyObject *); static PyObject *molecule_molecule(PyObject *, PyObject *); static void setInternal(struct MOLECULE *, int, int, int, int, int, char *); static PyObject *molecule_getattr(PyMoleculeSpecObject *, char *); static void molecule_dealloc(PyMoleculeSpecObject *); extern PyAtomSpecObject *atom_new(void); extern void getRotation(int, int, int, int); extern void getTranslation(int, int, int); extern void getEnlargement(int, int); extern void setModel(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void setDrawingMode(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void setProjection(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void switchLight(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void initMODiagram(Widget, caddr_t, caddr_t); extern void initHistory(Widget, caddr_t, caddr_t); extern void deleteMolecule(Widget, caddr_t, XmAnyCallbackStruct *); extern PySpectrumSpecObject *spectrum_new(void); extern PyHistorySpecObject *history_new(void); extern PyEnergyLevelSpecObject *energylevels_new(void); extern double bondAverage(struct MOLECULE *, int); extern double bondLength(struct ATOM *, int, int); extern double bondAngle(struct ATOM *, int, int, int); extern double torsionAngle(struct ATOM *, int, int, int, int); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern void modifyGeometry(int, char *); extern void calcmo(void); extern int existsGridObject(void); extern void deleteGridObjects(void); extern void redraw(int); /* extern char *bfname(int);*/ extern void bfnamn(int, int *, int*); extern void annotateWavefunction(void); extern void buildMolecule(struct MOLECULE *, int, int, int); extern void expandCell(int, int); extern void millerPlane(void); extern int checkInterrupt(void); extern void newMolecule(Widget, caddr_t, XmAnyCallbackStruct *); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern struct ELEMENT *elements; extern PyObject *moleculeModule; extern double temp, gridres; extern float *rotObject; extern int nmolecule, ne, moveItem, rotateXY, rotateZ, showForces; extern int iwavef, interp, showUnitCell, element; static char PyMoleculeSpec_Type__doc__[] = "Molecule specification"; statichere PyTypeObject PyMoleculeSpec_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "MoleculeSpec", /*tp_name*/ sizeof(PyMoleculeSpecObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)molecule_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)molecule_getattr, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ /* Space for future expansion */ 0L,0L, /* Documentation string */ PyMoleculeSpec_Type__doc__ }; static PyMethodDef molecule_methods[] = { {"translate", molecule_translate, 1}, {"rotate", molecule_rotate, 1}, {"getSpectrum", molecule_getSpectrum, 1}, {"getEnergyLevels", molecule_getEnergyLevels, 1}, {"getHistory", molecule_getHistory, 1}, {"showForces", molecule_showForces, 1}, {"getAtoms", molecule_getAtoms, 1}, {"getBonds", molecule_getBonds, 1}, {"getWavenumbers", molecule_getWavenumbers, 1}, {"getMOEnergies", molecule_getMOEnergies, 1}, {"title", molecule_title, 1}, {"bondAverage", molecule_bondAverage, 1}, {"bondLength", molecule_bondLength, 1}, {"bondAngle", molecule_bondAngle, 1}, {"torsionAngle", molecule_torsionAngle, 1}, {"getThermodynamics", molecule_getThermodynamics, 1}, {"reaction", molecule_reaction, 1}, {"showElectrons", molecule_showElectrons, 1}, {"showGrid", molecule_showGrid, 1}, {"selectBasisfunction", molecule_selectBasisfunction, 1}, {"unitCell", molecule_unitCell, 1}, {"millerPlane", molecule_millerPlane, 1}, {"addAtom", molecule_addAtom, 1}, {"molecule", molecule_molecule, 1}, {NULL, NULL} }; static PyObject *molecule_rotate(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; int moveItem_save, which, x, y, z; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "iii", &x, &y, &z)) return(NULL); s=(PyMoleculeSpecObject *)self; which=s->moleculeID+MOLECULES; rotObject[4*which]=rotObject[4*which+1]=rotObject[4*which+2]=0.0; rotObject[4*which+3]=1.0; moveItem_save=moveItem; moveItem=which; getRotation(x, y, z, 1); moveItem=moveItem_save; Py_INCREF(Py_None); return(Py_None); } static PyObject *molecule_translate(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; int moveItem_save, rotateXY_save, rotateZ_save, which, x, y, z; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "iii", &x, &y, &z)) return(NULL); s=(PyMoleculeSpecObject *)self; which=s->moleculeID+MOLECULES; moveItem_save=moveItem; moveItem=which; rotateXY_save=rotateXY; rotateZ_save=rotateZ; rotateXY=1; rotateZ=1; getTranslation(x, y, 1); getEnlargement(z, 1); moveItem=moveItem_save; rotateXY=rotateXY_save; rotateZ=rotateZ_save; Py_INCREF(Py_None); return(Py_None); } static PyObject *molecule_getSpectrum(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; PySpectrumSpecObject *spectrum; int which; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if (molecules[which].nmodes == 0) { Py_INCREF(Py_None); return(Py_None); } spectrum=spectrum_new(); if (spectrum == NULL) return(NULL); spectrum->spectrumID=which; return((PyObject *)spectrum); } static PyObject *molecule_getEnergyLevels(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; PyEnergyLevelSpecObject *energylevels; int which; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if (molecules[which].orbitals == NULL) { Py_INCREF(Py_None); return(Py_None); } energylevels=energylevels_new(); if (energylevels == NULL) return(NULL); energylevels->energyLevelID=which; return((PyObject *)energylevels); } static PyObject *molecule_getHistory(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; PyHistorySpecObject *history; int which; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if (molecules[which].nhist < 2) { Py_INCREF(Py_None); return(Py_None); } history=history_new(); if (history == NULL) return(NULL); history->historyID=which; return((PyObject *)history); } static PyObject *molecule_showForces(PyObject *self, PyObject *args) { int show; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "i", &show)) return(NULL); if (show != TRUE && show != FALSE) { PyErr_SetString(PyExc_ValueError, "Mode must be ON or OFF"); return(NULL); } else showForces=show; Py_INCREF(Py_None); return(Py_None); } static PyObject *molecule_getAtoms(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; PyAtomSpecObject *atom; PyObject *list; int which, i; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if ((list=PyList_New(molecules[which].na))) { for (i=0; imoleculeID=which; atom->atomID=i; PyList_SetItem(list, i, (PyObject *)atom); } return((PyObject *)list); } else { Py_INCREF(Py_None); return(Py_None); } } static PyObject *molecule_getBonds(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; PyObject *list, *tuple; int which, i; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if ((list=PyList_New(molecules[which].nb))) { for (i=0; imoleculeID; if ((list=PyList_New(molecules[which].nmodes))) { for (i=0; imoleculeID; if (molecules[which].orbitals == NULL) { Py_INCREF(Py_None); return(Py_None); } if ((list=PyList_New(molecules[which].nbasfu))) { for (i=0; imoleculeID; if (!PyArg_ParseTuple(args, "|s", &title)) return(NULL); if (title == NULL) /* get */ return(PyString_FromString(molecules[which].title)); else { strncpy(molecules[which].title, title, MAXLENLINE-1); Py_INCREF(Py_None); return(Py_None); } } static PyObject *molecule_bondAverage(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; PyAtomSpecObject *atom; double r; int which, i; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } if (!PyArg_ParseTuple(args, "O", &atom)) return(NULL); if (!atom) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if (which != atom->moleculeID) { PyErr_SetString(PyExc_ValueError, "Atom given is not part of the molecule given"); return(NULL); } i=atom->atomID; r=bondAverage(&molecules[which], i); return(PyFloat_FromDouble(r)); } static PyObject *molecule_bondLength(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; PyAtomSpecObject *atom1, *atom2; double r; int which, i, j; char value[MAXLENLINE], *unit=NULL; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if (!PyArg_ParseTuple(args, "OO|ds", &atom1, &atom2, &r, &unit)) return(NULL); if (atom1 && atom2) { if (which != atom1->moleculeID || which != atom2->moleculeID) { PyErr_SetString(PyExc_ValueError, "Atom given is not part of the molecule given"); return(NULL); } i=atom1->atomID; j=atom2->atomID; if (unit == NULL) /* get */ { r=bondLength((&molecules[which])->atoms, i, j); return(PyFloat_FromDouble(r)); } else /* set */ { sprintf(value, "%f %s", r, unit); setInternal(&molecules[which], BONDLENGTH, i, j, 0, 0, value); } } Py_INCREF(Py_None); return(Py_None); } static PyObject *molecule_bondAngle(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; PyAtomSpecObject *atom1, *atom2, *atom3; double r=400.0e0; int which, i, j, k; char value[MAXLENLINE]; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if (!PyArg_ParseTuple(args, "OOO|d", &atom1, &atom2, &atom3, &r)) return(NULL); if (atom1 && atom2 && atom3) { if (which != atom1->moleculeID || which != atom2->moleculeID || which != atom3->moleculeID) { PyErr_SetString(PyExc_ValueError, "Atom given is not part of the molecule given"); return(NULL); } i=atom1->atomID; j=atom2->atomID; k=atom3->atomID; if (r == 400.0e0) /* get */ { r=bondAngle((&molecules[which])->atoms, i, j, k); return(PyFloat_FromDouble(r)); } else /* set */ { sprintf(value, "%f", r); setInternal(&molecules[which], ANGLE, i, j, k, 0, value); } } Py_INCREF(Py_None); return(Py_None); } static PyObject *molecule_torsionAngle(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; PyAtomSpecObject *atom1, *atom2, *atom3, *atom4; double r=400.0e0; int which, i, j, k, l; char value[MAXLENLINE]; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if (!PyArg_ParseTuple(args, "OOOO|d", &atom1, &atom2, &atom3, &atom4, &r)) return(NULL); if (atom1 && atom2 && atom3 && atom4) { if (which != atom1->moleculeID || which != atom2->moleculeID || which != atom3->moleculeID || which != atom4->moleculeID) { PyErr_SetString(PyExc_ValueError, "Atom given is not part of the molecule given"); return(NULL); } i=atom1->atomID; j=atom2->atomID; k=atom3->atomID; l=atom4->atomID; if (r == 400.e0) /* get */ { r=torsionAngle((&molecules[which])->atoms, i, j, k, l); return(PyFloat_FromDouble(r)); } else /* set */ { sprintf(value, "%f", r); setInternal(&molecules[which], TORSION, i, j, k, l, value); } } Py_INCREF(Py_None); return(Py_None); } static PyObject *molecule_getThermodynamics(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; struct MOLECULE *mol; double value=0.0; int which, quantity, type; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if (!PyArg_ParseTuple(args, "ii", &quantity, &type)) return NULL; mol=&molecules[which]; switch (quantity) { case ENTHALPY: switch (type) { case TRANSLATION: value=0.001*mol->htrl; break; case PV: value=0.001*mol->pv; break; case ROTATION: value=0.001*mol->hrot; break; case VIBRATION: value=0.001*mol->hvib; break; case TOTAL: value=0.001*(mol->htrl+mol->pv+mol->hrot+mol->hvib); break; } break; case ENTROPY: switch (type) { case TRANSLATION: value=mol->strl; break; case PV: PyErr_SetString(PyExc_ValueError, "pV is invalid for entropy"); return(NULL); /* NOTREACHED */ break; case ROTATION: value=mol->srot; break; case VIBRATION: value=mol->svib; break; case TOTAL: value=mol->strl+mol->srot+mol->svib; break; } break; case GIBBS_ENERGY: switch (type) { case TRANSLATION: value=0.001*(mol->htrl-temp*mol->strl); break; case PV: value=0.001*mol->pv; break; case ROTATION: value=0.001*(mol->hrot-temp*mol->srot); break; case VIBRATION: value=0.001*(mol->hvib-temp*mol->svib); break; case TOTAL: value=0.001*(mol->htrl+mol->pv+mol->hrot +mol->hvib-temp*(mol->strl+mol->srot+mol->svib)); break; } break; case HEAT_CAPACITY: switch (type) { case TRANSLATION: value=mol->ctrl; break; case PV: PyErr_SetString(PyExc_ValueError, "pV is invalid for heat capacity"); return(NULL); /* NOTREACHED */ break; case ROTATION: value=mol->crot; break; case VIBRATION: value=mol->cvib; break; case TOTAL: value=mol->ctrl+mol->crot+mol->cvib; break; } break; } return(PyFloat_FromDouble(value)); } static PyObject *molecule_reaction(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; struct MOLECULE *mol; int which, side=0; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; side=0; if (!PyArg_ParseTuple(args, "|i", &side)) return NULL; mol=&molecules[which]; if (side == 0) /* get */ return(PyInt_FromLong((long)mol->reaction)); else /* set */ mol->reaction=side; Py_INCREF(Py_None); return(Py_None); } static PyObject *molecule_showElectrons(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; struct MOLECULE *mol; int which; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if (!PyArg_ParseTuple(args, "i|di", &iwavef, &gridres, &interp)) return NULL; mol=&molecules[which]; switch (iwavef) { case FALSE: deleteGridObjects(); break; case BASIS_FUNCTION: case BASIS_IN_MO: case MOLECULAR_ORBITAL: case DENSITY: if (!existsGridObject()) { calcmo(); annotateWavefunction(); } break; default: PyErr_SetString(PyExc_ValueError, "Unknown type of wave function"); return(NULL); /* NOTREACHED */ break; } redraw(VIEWER); Py_INCREF(Py_None); return(Py_None); } static PyObject *molecule_showGrid(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; struct MOLECULE *mol; int which, igrid; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if (!PyArg_ParseTuple(args, "i|i", &igrid, &interp)) return NULL; mol=&molecules[which]; if (mol->gridObjects == (struct GRIDOBJECT *)NULL) { PyErr_SetString(PyExc_ValueError, "No grids have been read for this molecule"); return(NULL); } if (igrid < 1 || igrid > mol->ngridobjects) { PyErr_SetString(PyExc_ValueError, "A grid with this number does not exist"); return(NULL); } iwavef=DENSITY+igrid; redraw(VIEWER); Py_INCREF(Py_None); return(Py_None); } static PyObject *molecule_selectBasisfunction(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; PyAtomSpecObject *atom; struct MOLECULE *mol; int which, count; char *name; register int i, found=FALSE; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } if (!PyArg_ParseTuple(args, "Osi", &atom, &name, &count)) return NULL; if (!atom) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if (which != atom->moleculeID) { PyErr_SetString(PyExc_ValueError, "Atom given is not part of the molecule given"); return(NULL); } mol=&molecules[which]; for (i=0; iatoms[atom->atomID].nBasisFunctions; i++) { if (!strcmp(mol->atoms[atom->atomID].basisFunctionNames[i], name)) { count--; if (count == 0) { mol->ibasfu=i; found=TRUE; break; } } } if (!found) { PyErr_SetString(PyExc_ValueError, "No such basisfunction"); return(NULL); } else { Py_INCREF(Py_None); return(Py_None); } } static PyObject *molecule_unitCell(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; struct MOLECULE *mol; double xfac, yfac, zfac; int visible, which; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; mol=&molecules[which]; if (mol->unitcell == 0) { PyErr_SetString(PyExc_ValueError, "No unit cell defined"); return(NULL); } xfac=mol->unitcell->factor[0]; yfac=mol->unitcell->factor[1]; zfac=mol->unitcell->factor[2]; if (!PyArg_ParseTuple(args, "i|ddd", &visible, &xfac, &yfac, &zfac)) return NULL; if (visible != TRUE && visible != FALSE) { PyErr_SetString(PyExc_ValueError, "Visible must be ON or OFF"); return(NULL); } showUnitCell=visible; if (xfac != mol->unitcell->factor[0] || yfac != mol->unitcell->factor[1] || zfac != mol->unitcell->factor[2]) { mol->unitcell->factor[0]=xfac; mol->unitcell->factor[1]=yfac; mol->unitcell->factor[2]=zfac; expandCell(TRUE, TRUE); } Py_INCREF(Py_None); return(Py_None); } static PyObject *molecule_millerPlane(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; struct MOLECULE *mol; int which, h, k, l, visible; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; mol=&molecules[which]; if (mol->unitcell == 0) { PyErr_SetString(PyExc_ValueError, "No unit cell defined"); return(NULL); } h=mol->unitcell->miller[0]; k=mol->unitcell->miller[1]; l=mol->unitcell->miller[2]; if (!PyArg_ParseTuple(args, "i|iii", &visible, &h, &k, &l)) return NULL; if (visible != TRUE && visible != FALSE) { PyErr_SetString(PyExc_ValueError, "Visible must be ON or OFF"); return(NULL); } mol->unitcell->miller[0]=h; mol->unitcell->miller[1]=k; mol->unitcell->miller[2]=l; mol->unitcell->showMiller=visible; millerPlane(); Py_INCREF(Py_None); return(Py_None); } static PyObject *molecule_addAtom(PyObject *self, PyObject *args) { PyMoleculeSpecObject *s; PyAtomSpecObject *attached=NULL; int which, atomID; char *symbol; register int i, found=FALSE; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PyMoleculeSpecObject *)self; which=s->moleculeID; if (!PyArg_ParseTuple(args, "s|O", &symbol, &attached)) return NULL; if (!attached) atomID=(-1); else atomID=attached->atomID; for (i=0; imoleculeID=0; return(self); } static PyObject *molecule_getattr(PyMoleculeSpecObject *self, char *name) { return(Py_FindMethod(molecule_methods, (PyObject *)self, name)); } static void molecule_dealloc(PyMoleculeSpecObject *self) { /* A dummy function is required here to avoid crashing PyMem_DEL(self); */ } void initMoleculeModule(void) { PyObject *module, *dict; static void *PyMolecule_API[PyMolecule_API_pointers]; PyMoleculeSpec_Type.ob_type=&PyType_Type; PyImport_AddModule("molecule"); module=Py_InitModule("molecule", molecule_methods); dict=PyModule_GetDict(module); PyMolecule_API[PyMoleculeSpec_Type_NUM]=(void *)&PyMoleculeSpec_Type; PyDict_SetItemString(dict, "_C_API", PyCObject_FromVoidPtr((void *)PyMolecule_API, NULL)); PyDict_SetItemString(dict, "SINGLE", PyInt_FromLong(1L)); PyDict_SetItemString(dict, "DOUBLE", PyInt_FromLong(2L)); PyDict_SetItemString(dict, "TRIPLE", PyInt_FromLong(3L)); PyDict_SetItemString(dict, "CONJUGATED", PyInt_FromLong(-2L)); PyDict_SetItemString(dict, "HYDROGENBOND", PyInt_FromLong(-1L)); PyDict_SetItemString(dict, "ENTHALPY", PyInt_FromLong(ENTHALPY)); PyDict_SetItemString(dict, "ENTROPY", PyInt_FromLong(ENTROPY)); PyDict_SetItemString(dict, "GIBBS_ENERGY", PyInt_FromLong(GIBBS_ENERGY)); PyDict_SetItemString(dict, "HEAT_CAPACITY", PyInt_FromLong(HEAT_CAPACITY)); PyDict_SetItemString(dict, "TRANSLATION", PyInt_FromLong((long)TRANSLATION)); PyDict_SetItemString(dict, "PV", PyInt_FromLong((long)PV)); PyDict_SetItemString(dict, "ROTATION", PyInt_FromLong((long)ROTATION)); PyDict_SetItemString(dict, "VIBRATION", PyInt_FromLong((long)VIBRATION)); PyDict_SetItemString(dict, "TOTAL", PyInt_FromLong((long)TOTAL)); PyDict_SetItemString(dict, "BASIS_FUNCTION", PyInt_FromLong((long)BASIS_FUNCTION)); PyDict_SetItemString(dict, "BASIS_IN_MO", PyInt_FromLong((long)BASIS_IN_MO)); PyDict_SetItemString(dict, "MO", PyInt_FromLong((long)MOLECULAR_ORBITAL)); PyDict_SetItemString(dict, "DENSITY", PyInt_FromLong((long)DENSITY)); PyDict_SetItemString(dict, "IP_NONE", PyInt_FromLong((long)IP_NONE)); PyDict_SetItemString(dict, "IP_LINEAR", PyInt_FromLong((long)IP_LINEAR)); PyDict_SetItemString(dict, "IP_LOG", PyInt_FromLong((long)IP_LOG)); PyDict_SetItemString(dict, "REACTANT", PyInt_FromLong((long)REACTANT)); PyDict_SetItemString(dict, "PRODUCT", PyInt_FromLong((long)PRODUCT)); PyDict_SetItemString(dict, "ALLREACTIONS", PyInt_FromLong((long)ALLREACTIONS)); PyDict_SetItemString(dict, "ALPHA+BETA", PyInt_FromLong((long)ALPHAANDBETA)); PyDict_SetItemString(dict, "ALPHA", PyInt_FromLong((long)ALPHA)); PyDict_SetItemString(dict, "BETA", PyInt_FromLong((long)BETA)); } void setInternal(struct MOLECULE *mol, int type, int i, int j, int k, int l, char *value) { if (mol->ninternal == 0) mol->internals=(struct INTERNAL *)getmem((size_t)1, sizeof(struct INTERNAL)); else mol->internals=(struct INTERNAL *)expmem((void *)mol->internals, (size_t)(mol->ninternal+1), sizeof(struct INTERNAL)); mol->internals[mol->ninternal].atoms[0]=i; mol->internals[mol->ninternal].atoms[1]=j; mol->internals[mol->ninternal].atoms[2]=k; mol->internals[mol->ninternal].atoms[3]=l; mol->internals[mol->ninternal].type=type; modifyGeometry(mol->ninternal, value); if (mol->ninternal == 0) fremem((void **)&mol->internals); else mol->internals=(struct INTERNAL *)expmem((void *)mol->internals, (size_t)mol->ninternal, sizeof(struct INTERNAL)); } viewmol-2.4.1/source/mouseaction.c0100644000272700027270000011176210114367371015350 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * M O U S E A C T I O N . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: mouseaction.c,v 1.7 2004/08/29 14:58:01 jrh Exp $ * $Log: mouseaction.c,v $ * Revision 1.7 2004/08/29 14:58:01 jrh * Release 2.4.1 * * Revision 1.6 2003/11/07 11:07:48 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:13:02 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:45 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:53:35 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:50 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:42:28 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" #define BUFFERSIZE 100 void viewerMouseAction(XEvent *, int); void clearGeometry(Widget, caddr_t, XmAnyCallbackStruct *); void spectrumMouseAction(XmDrawingAreaCallbackStruct *, int); void historyMouseAction(unsigned int, int, int, int); void MODiagramMouseAction(XmDrawingAreaCallbackStruct *, int); void setGeometry(int); void restoreGeometry(struct SAVE *, int); void ringBell(void); GLint doPicking(int, int, void draw(), int *); void getBasisfunction(Widget, caddr_t, caddr_t); void setAnimation(int); void selectMolecule(Widget, caddr_t, XmToggleButtonCallbackStruct *); void setWindow(int); void deleteSelection(void); void trim(char *); extern void drawMolecule(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void redraw(int); extern void drawSpectrum(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void drawMODiagram(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void processInput(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern Boolean normalMode(XtPointer); extern Boolean animateHistory(XtPointer); extern Widget makeMenu(Widget, int, char *, struct MenuItem *); extern void makeINSIntensity(void); extern char *getStringResource(Widget, char *); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern void basisDialog(int); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern int calcInternal(struct MOLECULE *, int); extern void redraw(int); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern void initZoom(Widget, XmDrawingAreaCallbackStruct *); extern void endZoom(Widget, int, int); extern void pixelToWorld(int, double *, double *); extern int makeConnectivity(struct MOLECULE *, int, int); extern void setMenuItem(int, int); extern void distortGeometry(double); extern int makeAnnotation(int, int, float, float, float, int, const GLfloat *, int, int, char *); extern void deleteAnnotation(int *); extern void annotateWavefunction(void); extern void modifyAnnotation(int, int, int); extern void setWindowTitle(Widget, char *); extern void buildMolecule(struct MOLECULE *, int, int, int); extern void setupProjection(int); extern void setupModelview(int); extern struct MOLECULE *initMolecule(int); extern Widget makeViewerMenu(Widget); extern int checkZoom(int); extern void setMenu(struct MOLECULE *); extern void updateMOs(int); extern void expandCell(int, int); extern void getScreenCoordinates(double, double, double, double *, double *, double *); extern void getWorldCoordinates(double, double, double, double *, double *, double *); extern void annotateNormalMode(struct MOLECULE *); extern XtAppContext app; extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern struct ANNOTATION *annotation; extern double *grid, forceScale, amplitude; extern double weight, *cnm, wnScale; extern int picking, swapBuffers, setins, projectionMode; extern int bfatom, annotate; extern int rotateXY, rotateZ, moveItem; extern int debug; extern int nmolecule, nAnnotations; extern int historyAnnotation, normalModeAnnotation; extern int modifyMolecule, bondOrderDefault; extern XtAppContext app; extern Widget topShell; extern int showMenu, animate, selectAtom; extern Pixel stdcol[9]; extern char *formBondLength, *formBondAngle, *formTorsionAngle; static int naSaved; static int clicked[4] = {-1, -1, -1, -1}, intcoord; void viewerMouseAction(XEvent *event, int state) { static struct PushButtonRow buttons[] = {{"ok", GetMessageBoxButton, (XtPointer)0, NULL}}; struct MOLECULE *mol; Dimension width, height; GLint picked; double xs, ys, zs, xpix, ypix; float black[4]={0.0, 0.0, 0.0, 0.0}; static int new=TRUE, moveItemSave; static int molclicked[4], ic=(-1); int imol; char line[20], *form=NULL; register int i, j, k, l; if (!(moveItem & 0x80000000)) moveItemSave=moveItem; if (event->xbutton.button == Button1 && state == TRUE) { picking=TRUE; swapBuffers=FALSE; picked=doPicking(event->xbutton.x, event->xbutton.y, drawMolecule, &imol); picking=FALSE; swapBuffers=TRUE; if (picked != -1) { ringBell(); moveItem=imol+MOLECULES; windows[VIEWER].set=imol; setWindow(imol); if (selectAtom) { basisDialog(picked); bfatom=picked; return; } if (setins) { molecules[imol].atoms[picked].neutronScatterfac=weight; makeINSIntensity(); return; } if (modifyMolecule > NOTHING && modifyMolecule < CREATE_BOND) { buildMolecule(&molecules[imol], picked, modifyMolecule, FALSE); return; } if (picked & 0x80000000) { if (!(event->xmotion.state & ShiftMask)) { l=picked & 0x3fffffff; modifyAnnotation(l, event->xbutton.x, event->xbutton.y); } else { moveItem=picked; rotateXY=(-1); } return; } if (picked & 0x40000000 && imol != 0x80000000) { l=picked & 0x3fffffff; switch (molecules[imol].internals[l].type) { case BONDAVERAGE: return; case BONDLENGTH: form=formBondLength; break; case ANGLE: form=formBondAngle; break; case TORSION: form=formTorsionAngle; break; } ic=(-1); for (i=0; ixbutton.x, event->xbutton.y); molecules[imol].internals[l].type=(-molecules[imol].internals[l].type); return; } if (picked & 0x20000000) { l=(picked & 0x1fffffff); molecules[imol].unitcell[0].corners[l].flags^=SELECTED; /* return; */ } if (!(event->xmotion.state & ShiftMask)) { if (new) { new=FALSE; intcoord=0; } if (!(picked & 0x20000000)) molecules[imol].atoms[picked].flags^=SELECTED; /* check whether atom has already been clicked on */ j=FALSE; for (i=0; i REPLACE_ATOM && intcoord == BONDLENGTH) { switch (modifyMolecule) { case CREATE_BOND: if (molecules[imol].addedBonds == NULL) molecules[imol].addedBonds=(int *)getmem((size_t)3, sizeof(int)); else molecules[imol].addedBonds=(int *)expmem((void *)molecules[imol].addedBonds, (size_t)(3*(molecules[imol].nbAdded+1)), sizeof(int)); molecules[imol].addedBonds[3*molecules[imol].nbAdded]=clicked[0]; molecules[imol].addedBonds[3*molecules[imol].nbAdded+1]=clicked[1]; molecules[imol].addedBonds[3*molecules[imol].nbAdded+2]=bondOrderDefault; molecules[imol].nbAdded++; makeConnectivity(&molecules[imol], FALSE, TRUE); break; case REMOVE_BOND: k=FALSE; for (i=0; ixmotion.state & ShiftMask) && (modifyMolecule == ADD_ATOM))) { modifyMolecule=ADD_ATOM; /* mol=&molecules[nmolecule]; if (mol == NULL)*/ mol=initMolecule(20); ringBell(); if (nmolecule == 0) buildMolecule(mol, picked, modifyMolecule, TRUE); else buildMolecule(mol, picked, modifyMolecule, FALSE); nmolecule++; windows[VIEWER].menu=makeViewerMenu(windows[VIEWER].widget); setWindowTitle(windows[VIEWER].widget, mol->title); setMenuItem(VIEWER1_SAVE, True); setMenuItem(VIEWER1_DELETE, True); setMenuItem(VIEWER1_BUILD, True); } } } switch (event->xbutton.button) { case Button1: if (state == TRUE) { if (annotate) modifyAnnotation((-1), event->xbutton.x, event->xbutton.y); rotateXY=(-1); } else { rotateXY=0; moveItem=moveItemSave; } break; case Button2: if (state == TRUE) rotateZ=(-1); else rotateZ=0; break; case Button3: if (state == TRUE) { if (!(event->xmotion.state & ShiftMask)) { new=TRUE; if (windows[VIEWER].set >= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; /* Is the internal coordinate in clicked[] already defined ? If yes, delete it. */ for (i=0; ininternal; i++) { if (mol->internals[i].type == intcoord) { k=l=0; for (j=0; jinternals[i].atoms[j] == clicked[j]) k++; if (mol->internals[i].atoms[j] == clicked[intcoord-j-1]) l++; } if (k == intcoord || l == intcoord) { if (i == mol->ninternal-1) clearGeometry((Widget)0, (caddr_t)LAST, (XmAnyCallbackStruct *)0); else clearGeometry((Widget)0, (caddr_t)i, (XmAnyCallbackStruct *)0); clicked[0]=(-1); break; } } } /* end of i-loop */ if (clicked[0] >= 0) { j=FALSE; switch (intcoord) { case 2: if (molclicked[0] != molclicked[1]) j=TRUE; break; case 3: if (molclicked[0] != molclicked[1] || molclicked[0] != molclicked[2] || molclicked[1] != molclicked[2]) j=TRUE; break; case 4: if (molclicked[0] != molclicked[1] || molclicked[0] != molclicked[2] || molclicked[0] != molclicked[3] || molclicked[1] != molclicked[2] || molclicked[1] != molclicked[3] || molclicked[2] != molclicked[3]) j=TRUE; break; } if (j) { form=getStringResource(topShell, "differentMolecules"); messgb(topShell, 1, form, buttons, 1); break; } if (mol->internals == NULL) mol->internals=(struct INTERNAL *)getmem(mol->ninternal+1, sizeof(struct INTERNAL)); else mol->internals=(struct INTERNAL *)expmem((void *)mol->internals, mol->ninternal+1, sizeof(struct INTERNAL)); mol->internals[mol->ninternal].atoms[0]=clicked[0]; mol->internals[mol->ninternal].atoms[1]=clicked[1]; mol->internals[mol->ninternal].atoms[2]=clicked[2]; mol->internals[mol->ninternal].atoms[3]=clicked[3]; mol->internals[mol->ninternal].type=intcoord; intcoord=0; if (calcInternal(mol, mol->ninternal)) { mol->ninternal++; setMenuItem(VIEWER2_ALL, True); setMenuItem(VIEWER2_LAST, True); } else { form=getStringResource(topShell, "notDefined"); messgb(topShell, 1, form, buttons, 1); if (mol->ninternal) mol->internals=(struct INTERNAL *)expmem((void *)mol->internals, mol->ninternal, sizeof(struct INTERNAL)); else fremem((void *)&(mol->internals)); } } } deleteSelection(); } break; } } void clearGeometry(Widget widget, caddr_t which, XmAnyCallbackStruct *data) { struct MOLECULE *mol; register int i; if (windows[VIEWER].set >= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; if ((int)which == ALL) { fremem((void **)&(mol->internals)); mol->ninternal=0; } else if ((int)which == LAST) { mol->ninternal--; if (mol->ninternal > 0) mol->internals=(struct INTERNAL *)expmem(mol->internals, mol->ninternal, sizeof(struct INTERNAL)); else { fremem((void **)&(mol->internals)); mol->ninternal=0; } } else { for (i=(int)which; ininternal-1; i++) { mol->internals[i].value=mol->internals[i+1].value; mol->internals[i].x=mol->internals[i+1].x; mol->internals[i].y=mol->internals[i+1].y; mol->internals[i].z=mol->internals[i+1].z; mol->internals[i].atoms[0]=mol->internals[i+1].atoms[0]; mol->internals[i].atoms[1]=mol->internals[i+1].atoms[1]; mol->internals[i].atoms[2]=mol->internals[i+1].atoms[2]; mol->internals[i].atoms[3]=mol->internals[i+1].atoms[3]; mol->internals[i].type=mol->internals[i+1].type; } mol->ninternal--; if (mol->ninternal > 0) mol->internals=(struct INTERNAL *)expmem(mol->internals, mol->ninternal, sizeof(struct INTERNAL)); else { fremem((void **)&(mol->internals)); mol->ninternal=0; } } if (mol->ninternal == 0) { setMenuItem(VIEWER2_ALL, False); setMenuItem(VIEWER2_LAST, False); } redraw(VIEWER); } void spectrumMouseAction(XmDrawingAreaCallbackStruct *data, int state) { /*const GLfloat black[4] = {0.0, 0.0, 0.0, 0.0};*/ struct MOLECULE *mol; static struct PushButtonRow button[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; int mode, imol; char /*line[MAXLENLINE],*/ *word; register int i; mol=&molecules[windows[SPECTRUM].set]; if (data->event->xbutton.button == Button1 && state == TRUE) { picking=TRUE; swapBuffers=FALSE; mode=doPicking(data->event->xbutton.x, data->event->xbutton.y, drawSpectrum, &imol); mol->mode=mode; picking=FALSE; swapBuffers=TRUE; if (mol->cnm == NULL) { word=getStringResource(topShell, "noNormalModes"); messgb(topShell, 3, word, button, 1); } else { if (mode != -1) { ringBell(); if (animate == ANIMATE) setAnimation(animate); else { restoreGeometry(mol->coord, windows[SPECTRUM].set); if (animate == DISTORT) distortGeometry(amplitude); } annotateNormalMode(mol); } else { if (animate == ANIMATE) setAnimation(animate); else { for (i=0; ievent->xbutton.button == Button2) { if (state == TRUE) initZoom(windows[SPECTRUM].widget, data); else endZoom(windows[SPECTRUM].widget, data->event->xbutton.x, data->event->xbutton.y); } } void getImaginaryMode(Widget widget, caddr_t which, caddr_t data) { struct MOLECULE *mol; mol=&molecules[windows[SPECTRUM].set]; mol->mode=(int)which; if (animate == ANIMATE) setAnimation(animate); else { restoreGeometry(mol->coord, windows[SPECTRUM].set); redraw(VIEWER); } } void selectMolecule(Widget widget, caddr_t which, XmToggleButtonCallbackStruct *data) { struct MENUDATA {struct MenuItem *submenu; int window; int which;} *menudata; char t[7], *string, line[MAXLENLINE]; int offset=0; register int i; if (data->set) { menudata=(struct MENUDATA *)which; windows[menudata->window].set=menudata->which; if (menudata->window == VIEWER) { XtVaSetValues(menudata->submenu[0].widget, XmNset, False, NULL); offset=2; } for (i=0; iwhich) XtVaSetValues(menudata->submenu[i+offset].widget, XmNset, False, NULL); } if (menudata->which >= 0) XtVaSetValues(menudata->submenu[menudata->which+offset].widget, XmNset, True, NULL); else XtVaSetValues(menudata->submenu[0].widget, XmNset, True, NULL); switch (menudata->window) { case VIEWER: if (menudata->which >= 0) { moveItem=menudata->which+MOLECULES; setWindowTitle(windows[VIEWER].widget, molecules[menudata->which].title); setMenu(&molecules[menudata->which]); annotateWavefunction(); } else { moveItem=WORLD; string=getStringResource(menudata->submenu[0].widget, "labelString"); setWindowTitle(windows[VIEWER].widget, string); setMenu(&molecules[0]); } break; case SPECTRUM: sprintf(t, "title%.1d", windows[SPECTRUM].mode); string=getStringResource(XtParent(windows[SPECTRUM].widget), t); sprintf(line, string, molecules[windows[SPECTRUM].set].title); setWindowTitle(windows[SPECTRUM].widget, line); redraw(SPECTRUM); break; case MO: if (!checkZoom(MO)) { if ((string=getStringResource(topShell, "MO-energy")) == NULL) { windows[MO].bottom=1.05*molecules[menudata->which].orbitals[0].energy; windows[MO].top=1.05*molecules[menudata->which].orbitals[molecules[menudata->which].nbasfu-1].energy; } else { windows[MO].bottom=atof(strtok(string, ":")); windows[MO].top=atof(strtok(NULL, ":")); } } string=getStringResource(XtParent(windows[MO].widget), "title"); sprintf(line, string, molecules[windows[MO].set].title); setWindowTitle(windows[MO].widget, line); redraw(MO); break; case HISTORY: string=getStringResource(XtParent(windows[HISTORY].widget), "title"); sprintf(line, string, molecules[windows[HISTORY].set].title); setWindowTitle(windows[HISTORY].widget, line); redraw(HISTORY); break; } } } void historyMouseAction(unsigned int button, int state, int x, int y) { struct MOLECULE *mol; double xw, yw, zw; int i; mol=&molecules[windows[HISTORY].set]; windows[HISTORY].mouseX=x; windows[HISTORY].mouseY=y; if (button == Button1 && state == TRUE) { getWorldCoordinates(x, y, 0.0, &xw, &yw, &zw); i=(int)floor(xw); mol->cycle=xw-(double)i < (double)(i+1)-xw ? i : i+1; if (xw < 1.0) { mol->cycle=1; getScreenCoordinates(1.0, 0.0, 0.0, &xw, &yw, &zw); windows[HISTORY].mouseX=(int)xw; } else if (xw > (double)(mol->nhist)) { mol->cycle=mol->nhist; getScreenCoordinates((double)(mol->nhist), 0.0, 0.0, &xw, &yw, &zw); windows[HISTORY].mouseX=(int)xw; } } if (button == Button1 && state == FALSE) { getScreenCoordinates((double)(mol->cycle), 0.0, 0.0, &xw, &yw, &zw); windows[HISTORY].mouseX=(int)xw; } setGeometry(TRUE); } void MODiagramMouseAction(XmDrawingAreaCallbackStruct *data, int state) { struct MOLECULE *mol; int imoSave, imol; mol=&molecules[windows[MO].set]; imoSave=mol->imo; if (data->event->xbutton.button == Button1 && state == TRUE) { picking=TRUE; swapBuffers=FALSE; mol->imo=doPicking(data->event->xbutton.x, data->event->xbutton.y, drawMODiagram, &imol); picking=FALSE; swapBuffers=TRUE; if (mol->imo != -1) { windows[MO].set=imol; ringBell(); updateMOs(imoSave); setMenuItem(MO_TRANSITION, True); } else setMenuItem(MO_TRANSITION, False); annotateWavefunction(); } else if (data->event->xbutton.button == Button2) { if (state == TRUE) initZoom(windows[MO].widget, data); else endZoom(windows[MO].widget, data->event->xbutton.x, data->event->xbutton.y); } } GLint doPicking(int x, int y, void draw(), int *molecule) { GLfloat picksize=3.0; GLuint buffer[BUFFERSIZE], n, *p, z, zmax; GLint viewport[4], picked=(-1); GLint hits; register int i; *molecule=(-1); glGetIntegerv(GL_VIEWPORT, viewport); glSelectBuffer(BUFFERSIZE, buffer); glRenderMode(GL_SELECT); glInitNames(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPickMatrix((GLdouble)x, (GLdouble)(viewport[3]-y), picksize, picksize, viewport); (*draw)((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); hits=glRenderMode(GL_RENDER); p=buffer; zmax=0; if (debug) printf("%d hits\n", hits); /* Buffer overrun, but the data in the buffer is still good */ if (hits == -1) hits=1; for (i=0; i= zmax) { picked=(GLint)(*p)-1; zmax=z; } p++; } if (debug) printf("\n"); } if (debug) printf("picked: molecule: %d, item: %d\n", *molecule, picked); return(picked); } void setGeometry(int doConnectivity) { struct MOLECULE *mol; const GLfloat black[4] = {0.0, 0.0, 0.0, 0.0}; double top, bottom, right, left, force; char line[MAXLENLINE], *word; int cycle; register int i, j; mol=&molecules[windows[HISTORY].set]; naSaved=mol->na; /*cycle=((int)ceil(mol->cycle-0.5)-1); if (cycle < 0) cycle=0; */ cycle=mol->cycle-1; /*if (cycle > 0) mol->na=mol->optimization[j].natoms; */ i=mol->optimization[cycle].coords; for (j=0; jna; j++) { if (mol->atoms[j].flags & ORIGINAL) { mol->atoms[j].x=mol->history[i].x; mol->atoms[j].y=mol->history[i].y; mol->atoms[j].z=mol->history[i].z; } i++; } if (mol->unitcell) { i=(int)ceil(mol->cycle-0.5); for (j=0; junitcell->nc; j++) { mol->unitcell[0].corners[j].x=mol->unitcell[i].corners[j].x; mol->unitcell[0].corners[j].y=mol->unitcell[i].corners[j].y; mol->unitcell[0].corners[j].z=mol->unitcell[i].corners[j].z; } expandCell(TRUE, FALSE); } word=getStringResource(topShell, "historyTitle"); /*sprintf(line, word, (int)mol->cycle, mol->optimization[(int)mol->cycle-1].energy, mol->optimization[(int)mol->cycle-1].gnorm);*/ sprintf(line, word, mol->cycle, mol->optimization[cycle].energy, mol->optimization[cycle].gnorm); historyAnnotation=makeAnnotation(historyAnnotation, CENTERED, 0.0, 1.0, 0.0, stdcol[BLACK], black, 0, 0, line); if (!doConnectivity) return; top=windows[VIEWER].top; bottom=windows[VIEWER].bottom; right=windows[VIEWER].right; left=windows[VIEWER].left; force=forceScale; makeConnectivity(mol, FALSE, FALSE); windows[VIEWER].top=top; windows[VIEWER].bottom=bottom; windows[VIEWER].right=right; windows[VIEWER].left=left; forceScale=force; for (i=0; ininternal; i++) (void)calcInternal(mol, i); } void restoreGeometry(struct SAVE *c, int imol) { register int i, j; /*molecules[imol].na=naSaved;*/ j=0; for (i=0; i 1) { data.set=TRUE; (void)selectMolecule((Widget)0, (XtPointer)&windows[VIEWER].selectMenu[imol+2], &data); } } void deleteSelection() { register int i, j; if (windows[VIEWER].set < 0) { for (i=0; i #include #include #include #include #include #include "viewmol.h" void processInput(Widget, caddr_t, XmDrawingAreaCallbackStruct *); void processSpaceballEvent(XEvent *); void doMenu(Widget, Widget, XmDrawingAreaCallbackStruct *); extern void setMenuItem(int, int); extern Widget makeMenu(Widget, int, char *, struct MenuItem *); extern void redraw(int); extern void drawSpectrum(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void drawHistory(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void drawMODiagram(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void viewerMouseAction(XEvent *, int); extern void spectrumMouseAction(XmDrawingAreaCallbackStruct *, int); extern void historyMouseAction(unsigned int, int, int, int); extern void MODiagramMouseAction(XmDrawingAreaCallbackStruct *, int); extern void viewerKeyAction(KeySym); extern void spectrumKeyAction(KeySym); extern void historyKeyAction(KeySym); extern void MODiagramKeyAction(KeySym); extern void getTranslation(int, int, int); extern void getRotation(int, int, int, int); extern void getEnlargement(int, int); extern void zoomIn(Widget, XmDrawingAreaCallbackStruct *); extern void redraw(int); extern void switchPointerDevice(void); extern struct WINDOW windows[]; extern float *transObject, *rotObject; extern int lines, label, showForces; extern int rotateXY, rotateZ; extern int showMenu, primitive, selectAtom, iwavef; extern int picking, swapBuffers, moveItem, simplify; extern int spaceballButtonPress, spaceballMotionNotify; extern int sensitivity, pythonInterrupt; extern Widget bfMenu; void processInput(Widget w, caddr_t client_data, XmDrawingAreaCallbackStruct *data) { KeySym keysym; XComposeStatus status; static int primitiveSave; char buffer[2]; if (data->reason == XmCR_INPUT) { switch (data->event->type) { case ButtonPress: if (w == windows[VIEWER].widget) { if (data->event->xbutton.button != Button3 && simplify && (moveItem & 0x7fffffff) > WORLD) { primitiveSave=primitive; primitive=GLU_LINE; } if (data->event->xbutton.button == Button3) { if (showMenu) doMenu(w, windows[VIEWER].menu, data); else viewerMouseAction(data->event, TRUE); } else { getRotation(data->event->xmotion.x, data->event->xmotion.y, data->event->xmotion.x, 2); viewerMouseAction(data->event, TRUE); } } else if (w == windows[SPECTRUM].widget) { if (data->event->xbutton.button == Button3) doMenu(w, windows[SPECTRUM].menu, data); else spectrumMouseAction(data, TRUE); } else if (w == windows[HISTORY].widget) { if (data->event->xbutton.button == Button3) doMenu(w, windows[HISTORY].menu, data); else historyMouseAction(data->event->xbutton.button, TRUE, data->event->xbutton.x, data->event->xbutton.y); } else if (w == windows[MO].widget) { if (data->event->xbutton.button == Button3) doMenu(w, windows[MO].menu, data); else MODiagramMouseAction(data, TRUE); } break; case ButtonRelease: if (w == windows[VIEWER].widget) { if (data->event->xbutton.button != Button3 && simplify && moveItem > WORLD) primitive=primitiveSave; viewerMouseAction(data->event, FALSE); rotateXY=rotateZ=0; /* return; */ } else if (w == windows[SPECTRUM].widget) spectrumMouseAction(data, FALSE); else if (w == windows[HISTORY].widget) historyMouseAction(data->event->xbutton.button, FALSE, data->event->xbutton.x, data->event->xbutton.y); else if (w == windows[MO].widget) MODiagramMouseAction(data, FALSE); break; case KeyPress: buffer[0]=buffer[1]='\0'; XLookupString((XKeyEvent *)data->event, buffer, 2, &keysym, &status); if ((int)(buffer[0]) == 3) pythonInterrupt=TRUE; if (w == windows[VIEWER].widget) viewerKeyAction(keysym); if (w == windows[SPECTRUM].widget) spectrumKeyAction(keysym); else if (w == windows[HISTORY].widget) historyKeyAction(keysym); else if (w == windows[MO].widget) MODiagramKeyAction(keysym); break; case MotionNotify: if (data->event->xmotion.state & Button1Mask) { if (w == windows[VIEWER].widget) { if (data->event->xmotion.state & ShiftMask) getTranslation(data->event->xmotion.x, data->event->xmotion.y, 2); else getRotation(data->event->xmotion.x, data->event->xmotion.y, -1, 0); } else if (w == windows[HISTORY].widget) { historyMouseAction(Button1, TRUE, data->event->xmotion.x, data->event->xmotion.y); } } else if (data->event->xmotion.state & Button2Mask) { if (w == windows[VIEWER].widget) if (data->event->xmotion.state & ShiftMask) getEnlargement(data->event->xmotion.x, 2); else getRotation(-1, -1, data->event->xmotion.x, 0); else { zoomIn(w, data); return; } } else return; break; default: break; } if (w == windows[VIEWER].widget) { windows[VIEWER].mouseX=data->event->xmotion.x; windows[VIEWER].mouseY=data->event->xmotion.y; } redraw(VIEWER); if (w == windows[SPECTRUM].widget) { windows[SPECTRUM].mouseX=data->event->xmotion.x; windows[SPECTRUM].mouseY=data->event->xmotion.y; drawSpectrum(w, client_data, data); } else if (w == windows[HISTORY].widget) { /* windows[HISTORY].mouseX=data->event->xmotion.x; windows[HISTORY].mouseY=data->event->xmotion.y; */ drawHistory(w, client_data, data); } else if (w == windows[MO].widget) { windows[MO].mouseX=data->event->xmotion.x; windows[MO].mouseY=data->event->xmotion.y; drawMODiagram(w, client_data, data); } } } void processSpaceballEvent(XEvent *event) { XDeviceMotionEvent *motionEvent; XDeviceButtonEvent *buttonEvent; static int sensitivity=4, i; if (event->type == spaceballMotionNotify) { motionEvent=(XDeviceMotionEvent *)event; getRotation(motionEvent->axis_data[3]/sensitivity, motionEvent->axis_data[4]/sensitivity, motionEvent->axis_data[5]/sensitivity, 1); rotateXY=rotateZ=1; getTranslation(motionEvent->axis_data[0]/(10*sensitivity), -motionEvent->axis_data[2]/(10*sensitivity), 1); getEnlargement(-motionEvent->axis_data[1]/(10*sensitivity), 1); rotateXY=rotateZ=0; } else if (event->type == spaceballButtonPress) { buttonEvent=(XDeviceButtonEvent *)event; if (buttonEvent->button == Button1) { i=3*(windows[VIEWER].set+3); transObject[i]=transObject[i+1]=transObject[i+2]=0.0; redraw(VIEWER); } if (buttonEvent->button == Button2) { i=4*(windows[VIEWER].set+3); rotObject[i]=rotObject[i+1]=rotObject[i+2]=0.0; rotObject[i+3]=1.0; redraw(VIEWER); } /* if (buttonEvent->button == Button3) { switchPointerDevice(); XmMenuPosition(windows[VIEWER].menu, (XButtonPressedEvent *)(event)); XtManageChild(windows[VIEWER].menu); switchPointerDevice(); } */ if (buttonEvent->button == Button4) sensitivity+=2; if (buttonEvent->button == Button5) sensitivity-=2; } } void doMenu(Widget widget, Widget menu, XmDrawingAreaCallbackStruct *data) { XmMenuPosition(menu, (XButtonPressedEvent *)(data->event)); XtManageChild(menu); } void changeBoolean(Widget w, int *bool, XmDrawingAreaCallbackStruct *data) { *bool=!(*bool); redraw(VIEWER); } void setModel(Widget w, caddr_t model, XmDrawingAreaCallbackStruct *data) { setMenuItem((VIEWER_WIRE)+windows[VIEWER].mode-WIREMODEL, True); windows[VIEWER].mode=(int)model; setMenuItem((VIEWER_WIRE)+(int)model-WIREMODEL, False); if ((int)model != WIREMODEL) setMenuItem(VIEWER_RAYTRACING, True); else setMenuItem(VIEWER_RAYTRACING, False); redraw(VIEWER); } void setDiagram(Widget w, caddr_t diagram, XmDrawingAreaCallbackStruct *data) { if (windows[MO].mode == DENSITY_OF_STATES) windows[MO].mode=ENERGY_LEVELS; else windows[MO].mode=DENSITY_OF_STATES; drawMODiagram((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); } viewmol-2.4.1/source/normod.c0100644000272700027270000000504610114367425014315 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * N O R M O D . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: normod.c,v 1.7 2004/08/29 14:58:29 jrh Exp $ * $Log: normod.c,v $ * Revision 1.7 2004/08/29 14:58:29 jrh * Release 2.4.1 * * Revision 1.6 2003/11/07 11:08:01 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:13:19 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:49 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:53:50 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:48:55 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:42:41 jrh * Initial revision * */ #include #include #include "viewmol.h" extern void redraw(int); extern int calcInternal(struct MOLECULE *, int); extern int getIntResource(Widget, char *); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern double amplitude; extern int nmolecule; Boolean normalMode(XtPointer data) { static int j=1, k=0; double fac; int imol, mode; register int i, l, n; /*if ((int)data == 1) { j=1; k=0; }*/ fac=(double)k*amplitude*0.05; for (imol=0; imol #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" void GetDiagram(Widget, caddr_t, XmToggleButtonCallbackStruct *); Widget CreateToggleBox(Widget, struct PushButtonRow *, int, int, int, int, int); void optimizationExit(Widget, caddr_t, XmPushButtonCallbackStruct *); extern void MapBox(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern Widget CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern void redraw(int); extern void setMenuItem(int, int); extern Widget initShell(Widget, char *, Widget *, Widget *); extern struct WINDOW windows[]; extern Widget topShell; static Widget dialog; static int optset_save; void optimizationDialog(Widget widget, caddr_t dummy, XmAnyCallbackStruct *data) { Widget form, board, form1, checkbox, sep, button; static struct PushButtonRow buttons[] = { { "ok", optimizationExit, (XtPointer)TRUE, NULL }, { "cancel", optimizationExit, (XtPointer)FALSE, NULL }, }; static struct PushButtonRow checkbox_buttons[] = { { "energies", GetDiagram, (XtPointer)ENERGY, NULL }, { "norms", GetDiagram, (XtPointer)GNORM, NULL }, }; /* This function creates the dialog for the optimization history window */ setMenuItem(HISTORY_SETTINGS, False); optset_save=windows[HISTORY].mode; dialog=initShell(windows[HISTORY].widget, "optimizationForm", &board, &form); form1=XtVaCreateWidget("controlarea", xmFormWidgetClass, form, NULL); sep=XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, form, NULL); checkbox=CreateToggleBox(form1, checkbox_buttons, XtNumber(checkbox_buttons), XmVERTICAL, 1, False, (windows[HISTORY].mode & 0x3)); XtVaSetValues(checkbox, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, NULL); sep=XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, form1, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, checkbox, NULL); button=XtVaCreateManagedWidget("scales", xmToggleButtonWidgetClass, form1, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, sep, XmNbottomAttachment, XmATTACH_FORM, NULL); if (windows[HISTORY].mode & SCALES) XtVaSetValues(button, XmNset, True, NULL); XtAddCallback(button, XmNvalueChangedCallback, (XtCallbackProc)GetDiagram, (XtPointer)SCALES); XtManageChild(form1); CreatePushButtonRow(form, buttons, XtNumber(buttons)); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XmAnyCallbackStruct *)NULL); XtManageChild(form); XtManageChild(board); } Widget CreateToggleBox(Widget parent, struct PushButtonRow *buttons, int num_buttons, int orientation, int columns, int radio, int deflt) { Widget rc; register int i; rc=XtVaCreateWidget("rowcolumn", xmRowColumnWidgetClass, parent, XmNorientation, orientation, XmNradioBehavior, radio, XmNnumColumns, (short)columns, NULL); for (i=0; i> i) & 0x1) XtVaSetValues(buttons[i].widget, XmNset, True, NULL); } if (buttons[i].callback) XtAddCallback(buttons[i].widget, XmNvalueChangedCallback, (XtCallbackProc)buttons[i].callback, buttons[i].client_data); } XtManageChild(rc); return(rc); } void GetDiagram(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { if (data->set) { windows[HISTORY].mode |= (int)which; if (button) XtVaSetValues(button, XmNset, True, NULL); } else { windows[HISTORY].mode &= ~((int)which); if (button) XtVaSetValues(button, XmNset, False, NULL); } redraw(HISTORY); } void optimizationExit(Widget button, caddr_t which, XmPushButtonCallbackStruct *data) { if (!(int)which) windows[HISTORY].mode=optset_save; XtDestroyWidget(dialog); setMenuItem(HISTORY_SETTINGS, True); redraw(HISTORY); } viewmol-2.4.1/source/osname.c0100644000272700027270000000341207752676443014315 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * O S N A M E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: osname.c,v 1.6 2003/11/07 11:08:19 jrh Exp $ * $Log: osname.c,v $ * Revision 1.6 2003/11/07 11:08:19 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:13:38 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:53 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:54:13 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:00 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:42:54 jrh * Initial revision * */ #include #include #include void osname(char *os) { struct utsname sysname; FILE *pipe; uname(&sysname); strcpy(os, sysname.sysname); if (!strncmp(sysname.sysname, "AIX", 3)) { strcat(os, "_"); if (sysname.machine[8] == '7' && sysname.machine[9] == '0') strcat(os, "POWER2"); else strcat(os, "POWER"); } else if (strstr(sysname.sysname, "IRIX")) { strcat(os, "_"); if ((pipe=popen("hinv | awk '/^CPU/ {print $3}' | cut -d/ -f2", "r")) != NULL) { fscanf(pipe, "%s", os+strlen(os)); pclose(pipe); } else strcat(os, "R3000"); } } viewmol-2.4.1/source/postscript.c0100644000272700027270000004433307752676454015256 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * P O S T S C R I P T . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: postscript.c,v 1.6 2003/11/07 11:08:28 jrh Exp $ * $Log: postscript.c,v $ * Revision 1.6 2003/11/07 11:08:28 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:13:44 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:56 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:54:40 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:03 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:43:12 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" #define TOPSUNIT 72./25.4 #define EPS_GOURAUD_THRESHOLD 0.1 /* smaller values result in smoother shading */ extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern int rgbMode; extern char *textPointer; extern Widget topShell; extern int primitive, iwavef; extern void getRGBColor(Widget, Pixel, float *, float *, float *); extern char *getStringResource(Widget, char *); static GLfloat pointSize; static GLfloat lastred=(-1.), lastgreen=(-1.), lastblue=(-1.); static int cyrillic=FALSE, bitmap=FALSE; FILE *PostscriptInit(char *, double, double, double, int, int); void writeVectorHeader(FILE *, int, int, GLfloat, GLfloat, double, double, GLfloat *, GLfloat *); void writeBitmapHeader(FILE *, int, int, double, double, double); void PostscriptClose(FILE *); void PostscriptSetRGBColor(FILE *, GLfloat, GLfloat, GLfloat); void PostscriptMoveto(FILE *, int, GLfloat, GLfloat); void PostscriptLineto(FILE *, int, GLfloat, GLfloat); void PostscriptTriangle(FILE *, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); void PostscriptTriangleColor(FILE *, GLfloat, GLfloat, GLfloat); void PostscriptPoint(FILE *, int, GLfloat, GLfloat); void PostscriptLineStipple(FILE *, GLushort); void PostscriptShowString(FILE *, int, GLfloat, GLfloat); FILE *PostscriptInit(char *filename, double paperWidth, double paperHeight, double fontHeight, int window, int smooth) { FILE *file; time_t now; struct passwd *entry; GLfloat clearColor[4], viewport[4], clearIndex, xtrans, ytrans; double ratio, scale; int portrait, leftX, leftY; if ((file=fopen(filename, "w")) == NULL) return(NULL); portrait=paperWidth < paperHeight ? TRUE : FALSE; glGetFloatv(GL_VIEWPORT, viewport); ratio=(viewport[2]-viewport[0])/(viewport[3]-viewport[1]); if (paperHeight*ratio > paperWidth) scale=(paperWidth-20.)*TOPSUNIT/(viewport[2]-viewport[0]); else scale=(paperHeight-20.)*TOPSUNIT/(viewport[3]-viewport[1]); if (portrait) { xtrans=(paperWidth*TOPSUNIT-scale*(viewport[2]+viewport[0]))*0.5; ytrans=(paperHeight*TOPSUNIT-scale*(viewport[3]+viewport[1]))*0.5; } else { xtrans=(paperHeight*TOPSUNIT/scale+viewport[3]-viewport[1])*0.5; ytrans=(paperWidth*TOPSUNIT-scale*(viewport[2]+viewport[0]))*0.5; } if (rgbMode) glGetFloatv(GL_COLOR_CLEAR_VALUE, clearColor); else { glGetFloatv(GL_INDEX_CLEAR_VALUE, &clearIndex); getRGBColor(windows[VIEWER].widget, (Pixel)clearIndex, &clearColor[0], &clearColor[1], &clearColor[2]); } fprintf(file, "%%!PS-Adobe-3.0 EPSF-3.0\n"); if (portrait) { leftX=(int)(scale*(viewport[0]+xtrans)+0.5); leftY=(int)(scale*(viewport[1]+ytrans)+0.5); fprintf(file, "%%%%BoundingBox: %d %d %d %d\n", leftX, leftY, (int)(scale*(viewport[2]-viewport[0]+xtrans)+0.5), (int)(scale*(viewport[3]-viewport[1]+ytrans)+0.5)); } else { leftX=(int)(paperHeight*TOPSUNIT-xtrans*scale+0.5); leftY=(int)(scale*ytrans+0.5); fprintf(file, "%%%%BoundingBox: %d %d %d %d\n", leftX, leftY, (int)(scale*xtrans+0.5), (int)(scale*(viewport[2]-viewport[0]+ytrans)+0.5)); } fprintf(file, "%%%%Creator: %s %s\n", PROGRAM, VERSION); now=time((time_t *)NULL); fprintf(file, "%%%%CreationDate: %s", ctime(&now)); entry=getpwuid(getuid()); fprintf(file, "%%%%For: %s\n", entry->pw_gecos); if (portrait) fprintf(file, "%%%%Orientation: Portrait\n"); else fprintf(file, "%%%%Orientation: Landscape\n"); fprintf(file, "%%%%Pages: 1\n"); fprintf(file, "%%%%Title: %s\n", molecules[windows[window].set].title); fprintf(file, "%%%%EndComments\n"); fprintf(file, "%%%%Page: 0 1\n\n"); fprintf(file,"%% remember original state\n"); fprintf(file,"/origstate save def\n\n"); if (window == VIEWER && primitive == GLU_FILL && (windows[VIEWER].mode != WIREMODEL || iwavef != ALL_OFF)) writeBitmapHeader(file, window, portrait, (int)(scale*xtrans+0.5), leftY, scale); else writeVectorHeader(file, smooth, portrait, xtrans, ytrans, scale, fontHeight, clearColor, viewport); return(file); } void writeVectorHeader(FILE *file, int smooth, int portrait, GLfloat xtrans, GLfloat ytrans, double scale, double fontHeight, GLfloat *clearColor, GLfloat *viewport) { GLfloat lineWidth; char *word; word=getStringResource(topShell, "fontList"); if (word && strstr(word, "koi8")) cyrillic=TRUE; if (cyrillic) { fprintf(file, "/Cyrillic findfont dup length dict begin\n"); fprintf(file, "{1 index /FID ne {def} {pop pop} ifelse} forall\n"); fprintf(file, "/Encoding[/NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL\n"); fprintf(file, "/NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL\n"); fprintf(file, "/NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /space\n"); fprintf(file, "/exclam /quotedbl /numbersign /NUL /percent /NUL /quoteright\n"); fprintf(file, "/parenleft /parenright /asterisk /plus /comma /endash /period\n"); fprintf(file, "/slash /zero /one /two /three /four /five /six /seven /eight\n"); fprintf(file, "/nine /colon /semicolon /less /equal /greater /question /NUL\n"); fprintf(file, "/NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL\n"); fprintf(file, "/NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL\n"); fprintf(file, "/NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL\n"); fprintf(file, "/NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL\n"); fprintf(file, "/NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL\n"); fprintf(file, "/NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL\n"); fprintf(file, "/NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL\n"); fprintf(file, "/NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL\n"); fprintf(file, "/Oslash /NUL /NUL /NUL /NUL /NUL /NUL /NUL /oslash /NUL /NUL\n"); fprintf(file, "/NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL\n"); fprintf(file, "/NUL /NUL /NUL /NUL /NUL /NUL /NUL /NUL /bracketright /a /b\n"); fprintf(file, "/c /d /e /f /g /h /i /y /k /l /m /n /o /p /aring /r /s /t /u\n"); fprintf(file, "/j /v /exclamdown /bracketleft /z /w /hyphen /x /q /trademark\n"); fprintf(file, "/braceright /A /B /C /D /E /F /G /H /I /Y /K /L /M /N /O /P\n"); fprintf(file, "/Aring /R /S /T /U /J /V /fraction /braceleft /Z /W /Z /X /Q\n"); fprintf(file, "/currency] def currentdict end\n"); fprintf(file, "/Cyrillic-koi8 exch definefont pop\n"); fprintf(file, "/Cyrillic-koi8 findfont %f scalefont setfont\n", fontHeight); } else { fprintf(file, "/Times-Roman findfont dup length dict begin\n"); fprintf(file, "{1 index /FID ne {def} {pop pop} ifelse} forall\n"); fprintf(file, "/Encoding ISOLatin1Encoding def currentdict end\n"); fprintf(file, "/Times-Roman-ISOLatin1 exch definefont pop\n"); fprintf(file, "/Times-Roman-ISOLatin1 findfont %f scalefont setfont\n", fontHeight); } if (smooth) { fprintf(file, "/threshold %f def\n", EPS_GOURAUD_THRESHOLD); fprintf(file, "/bd{bind def}bind def /triangle { aload pop setrgbcolor aload pop 5 3\n"); fprintf(file, "roll 4 2 roll 3 2 roll exch moveto lineto lineto closepath fill } bd\n"); fprintf(file, "/computediff1 { 2 copy sub abs threshold ge {pop pop pop true} { exch 2\n"); fprintf(file, "index sub abs threshold ge { pop pop true} { sub abs threshold ge } ifelse\n"); fprintf(file, "} ifelse } bd /computediff3 { 3 copy 0 get 3 1 roll 0 get 3 1 roll 0 get\n"); fprintf(file, "computediff1 {true} { 3 copy 1 get 3 1 roll 1 get 3 1 roll 1 get\n"); fprintf(file, "computediff1 {true} { 3 copy 2 get 3 1 roll 2 get 3 1 roll 2 get\n"); fprintf(file, "computediff1 } ifelse } ifelse } bd /middlecolor { aload pop 4 -1 roll\n"); fprintf(file, "aload pop 4 -1 roll add 2 div 5 1 roll 3 -1 roll add 2 div 3 1 roll add 2\n"); fprintf(file, "div 3 1 roll exch 3 array astore } bd /G { computediff3 { 4\n"); fprintf(file, "-1 roll aload 7 1 roll 6 -1 roll pop 3 -1 roll pop add 2 div 3 1 roll add\n"); fprintf(file, "2 div exch 3 -1 roll aload 7 1 roll exch pop 4 -1 roll pop add 2 div 3 1\n"); fprintf(file, "roll add 2 div exch 3 -1 roll aload 7 1 roll pop 3 -1 roll pop add 2 div 3\n"); fprintf(file, "1 roll add 2 div exch 7 3 roll 10 -3 roll dup 3 index middlecolor 4 1 roll\n"); fprintf(file, "2 copy middlecolor 4 1 roll 3 copy pop middlecolor 4 1 roll 13 -1 roll\n"); fprintf(file, "aload pop 17 index 6 index 15 index 19 index 6 index 17 index 6 array\n"); fprintf(file, "astore 10 index 10 index 14 index G 17 index 5 index 17\n"); fprintf(file, "index 19 index 5 index 19 index 6 array astore 10 index 9 index 13 index\n"); fprintf(file, "G 13 index 16 index 5 index 15 index 18 index 5 index 6\n"); fprintf(file, "array astore 12 index 12 index 9 index G 17 index 16 index\n"); fprintf(file, "15 index 19 index 18 index 17 index 6 array astore 10 index 12 index 14\n"); fprintf(file, "index G 18 {pop} repeat } { aload pop 5 3 roll aload pop 7 3\n"); fprintf(file, "roll aload pop 9 3 roll 4 index 6 index 4 index add add 3 div 10 1 roll 7\n"); fprintf(file, "index 5 index 3 index add add 3 div 10 1 roll 6 index 4 index 2 index add\n"); fprintf(file, "add 3 div 10 1 roll 9 {pop} repeat 3 array astore triangle } ifelse } bd\n"); } fprintf(file, "/l {lineto} bind def /m {moveto} bind def /c {setrgbcolor} bind def\n"); fprintf(file, "/sl {3 2 roll 3 2 roll moveto show} bind def\n"); fprintf(file, "/sr {dup stringwidth pop -1 mul 4 3 roll add 3 2 roll moveto show} bind def\n"); fprintf(file, "/sc {dup stringwidth pop -2 div 4 3 roll add 3 2 roll moveto show} bind def\n"); fprintf(file, "%.2f %.2f scale\n", scale, scale); if (portrait) fprintf(file, "%.2f %.2f translate\n", xtrans, ytrans); else fprintf(file, "90 rotate %.2f %.2f translate\n", ytrans, -xtrans); glGetFloatv(GL_LINE_WIDTH, &lineWidth); fprintf(file, "%.2f setlinewidth\n", lineWidth); fprintf(file, "%f %f %f setrgbcolor\n", clearColor[0], clearColor[1], clearColor[2]); fprintf(file, "%.2f %.2f %.2f %.2f rectfill\n", viewport[0], viewport[1], viewport[2], viewport[3]); glGetFloatv(GL_POINT_SIZE, &pointSize); lastred=lastgreen=lastblue=(-1.); bitmap=FALSE; } void writeBitmapHeader(FILE *file, int window, int portrait, double xtrans, double ytrans, double scale) { Dimension width, height; int bits=8; XtVaGetValues(windows[window].widget, XmNwidth, &width, XmNheight, &height, NULL); /* Make sure the image width is divisable by 4 */ if (width % 4 != 0) width-=(width % 4); fprintf(file, "%% build a temporary dictionary\n"); fprintf(file, "20 dict begin\n\n"); /*fprintf(file, "/readstring {\n"); fprintf(file, " currentfile exch readhexstring pop /RunLengthDecode filter\n"); fprintf(file, "} bind def\n"); */ fprintf(file, "%% define strings to hold a scanline's worth of data\n"); fprintf(file, "/pix 2100 string def\n\n"); /*fprintf(file, "/rpicstr %d string def\n", width); fprintf(file, "/gpicstr %d string def\n", width); fprintf(file, "/bpicstr %d string def\n\n", width); */ fprintf(file, "%% define space for color conversions\n"); fprintf(file, "/grays 700 string def %% space for gray scale line\n"); fprintf(file, "/npixls 0 def\n"); fprintf(file, "/rgbindx 0 def\n\n"); fprintf(file, "%% lower left corner\n"); if (portrait) fprintf(file, "%.2f %.2f translate\n", xtrans, ytrans); else fprintf(file, "90 rotate %.2f %.2f translate\n", ytrans, -xtrans); fprintf(file, "%% size of image (on paper, in Postscript coordinates, 1/72 inch)\n"); fprintf(file, "%f %f scale\n", scale*width, scale*height); /* This code checks if the PostScript device in question knows about the 'colorimage' operator. If it doesn't, it defines 'colorimage' in terms of image (ie, generates a greyscale image from RGB data) */ fprintf(file, "%% define 'colorimage' if it isn't defined\n"); fprintf(file, "%% ('colortogray' and 'mergeprocs' come from xwd2ps\n"); fprintf(file, "%% via xgrab)\n"); fprintf(file, "/colorimage where %% do we know about 'colorimage'?\n"); fprintf(file, " { pop } %% yes: pop off the 'dict' returned\n"); fprintf(file, " { %% no: define one\n"); fprintf(file, " /colortogray { %% define an RGB->I function\n"); fprintf(file, " /rgbdata exch store %% call input 'rgbdata'\n"); fprintf(file, " rgbdata length 3 idiv\n"); fprintf(file, " /npixls exch store\n"); fprintf(file, " /rgbindx 0 store\n"); fprintf(file, " 0 1 npixls 1 sub {\n"); fprintf(file, " grays exch\n"); fprintf(file, " rgbdata rgbindx get 20 mul %% Red\n"); fprintf(file, " rgbdata rgbindx 1 add get 32 mul %% Green\n"); fprintf(file, " rgbdata rgbindx 2 add get 12 mul %% Blue\n"); fprintf(file, " add add 64 idiv %% I = .5G + .31R + .18B\n"); fprintf(file, " put\n"); fprintf(file, " /rgbindx rgbindx 3 add store\n"); fprintf(file, " } for\n"); fprintf(file, " grays 0 npixls getinterval\n"); fprintf(file, " } bind def\n\n"); fprintf(file, " %% Utility procedure for colorimage operator.\n"); fprintf(file, " %% This procedure takes two procedures off the\n"); fprintf(file, " %% stack and merges them into a single procedure.\n\n"); fprintf(file, " /mergeprocs { %% def\n"); fprintf(file, " dup length\n"); fprintf(file, " 3 -1 roll\n"); fprintf(file, " dup\n"); fprintf(file, " length\n"); fprintf(file, " dup\n"); fprintf(file, " 5 1 roll\n"); fprintf(file, " 3 -1 roll\n"); fprintf(file, " add\n"); fprintf(file, " array cvx\n"); fprintf(file, " dup\n"); fprintf(file, " 3 -1 roll\n"); fprintf(file, " 0 exch\n"); fprintf(file, " putinterval\n"); fprintf(file, " dup\n"); fprintf(file, " 4 2 roll\n"); fprintf(file, " putinterval\n"); fprintf(file, " } bind def\n\n"); fprintf(file, " /colorimage { %% def\n"); fprintf(file, " pop pop %% remove 'false 3' operands\n"); fprintf(file, " {colortogray} mergeprocs\n"); fprintf(file, " image\n"); fprintf(file, " } bind def\n"); fprintf(file, " } ifelse %% end of 'false' case\n"); fprintf(file, "\n\n"); fprintf(file, "%d %d %d\t\t\t%% dimensions of data\n", width, height, bits); fprintf(file, "[%d 0 0 %d 0 0]\t\t%% mapping matrix\n", width, height); fprintf(file, "{currentfile pix readhexstring pop}\n"); fprintf(file, "false 3 colorimage\n"); /*fprintf(file, "{rpicstr readstring}\n"); fprintf(file, "{gpicstr readstring}\n"); fprintf(file, "{bpicstr readstring}\n"); fprintf(file, "true 3 colorimage\n"); */ bitmap=TRUE; } void PostscriptClose(FILE *file) { fprintf(file, "showpage\n%%%%EOF\n"); if (bitmap) fprintf(file, "end\n"); fprintf(file, "origstate restore\n%%%%EOF\n"); fclose(file); } void PostscriptSetRGBColor(FILE *file, GLfloat red, GLfloat green, GLfloat blue) { if (red == lastred && green == lastgreen && blue == lastblue) return; lastred=red; lastgreen=green; lastblue=blue; fprintf(file, "%f %f %f c\n", red, green, blue); } void PostscriptMoveto(FILE *file, int portrait, GLfloat x, GLfloat y) { fprintf(file, "%.2f %.2f m\n", x, y); } void PostscriptLineto(FILE *file, int portrait, GLfloat x, GLfloat y) { fprintf(file, "%.2f %.2f l\n", x, y); } void PostscriptTriangle(FILE *file, GLfloat x1, GLfloat x2, GLfloat x3, GLfloat y1, GLfloat y2, GLfloat y3) { fprintf(file, "[%.2f %.2f %.2f %.2f %.2f %.2f] ", x1, x2, x3, y1, y2, y3); } void PostscriptTriangleColor(FILE *file, GLfloat red, GLfloat green, GLfloat blue) { static int count=0; fprintf(file, "[%f %f %f] ", red, green, blue); count++; if (count == 1) fprintf(file, "\n"); if (count == 3) { fprintf(file, "G\n"); count=0; } } void PostscriptPoint(FILE *file, int portrait, GLfloat x, GLfloat y) { fprintf(file, "%.2f %.2f %.2f 0 360 arc fill\n", x, y, pointSize*0.5); } void PostscriptLineStipple(FILE *file, GLushort style) { int count; register int i, j, k; if (style == 0xffff) fprintf(file, "[] 0 setdash\n"); else { fprintf(file, "["); j=style & 1; count=1; for (i=1; i> i; if (k != j) { fprintf(file, "%d ", count); j=k; count=1; } else count++; } fprintf(file, "] 0 setdash\n"); } } void PostscriptShowString(FILE *file, int dummy, GLfloat x, GLfloat y) { register unsigned char *p; fprintf(file, "%.2f %.2f (", x, y); for (p=(unsigned char *)textPointer+1; *p; p++) { switch (*p) { case '(': fprintf(file, "\\("); break; case ')': fprintf(file, "\\)"); break; default: fprintf(file, "%c", *p); break; } } fprintf(file, ") s%c\n", textPointer[0]); textPointer+=strlen(textPointer)+1; } viewmol-2.4.1/source/printform.c0100644000272700027270000006421510140725624015040 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * P R I N T F O R M . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: printform.c,v 1.6 2003/11/07 11:08:33 jrh Exp $ * $Log: printform.c,v $ * Revision 1.6 2003/11/07 11:08:33 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:13:52 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:26:58 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:54:50 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:05 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:43:19 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "tiffio.h" #include "viewmol.h" #include "dialog.h" void printDialog(Widget, caddr_t, XmAnyCallbackStruct *); void printDialogExit(Widget, caddr_t, XmPushButtonCallbackStruct *); char *saveFile(struct MOLECULE *, int, char *, char *); void GetFormat(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetOrientation(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetPapersize(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetCompression(Widget, caddr_t, XmToggleButtonCallbackStruct *); void SetPapersize(int); void Fileselect(Widget, caddr_t, XmAnyCallbackStruct *); char *saveMultipleFiles(struct MOLECULE *, char *, char *, int, int); extern void GetDouble(Widget, caddr_t, XmAnyCallbackStruct *); extern Widget makeMenu(Widget, int, char *, struct MenuItem *); extern void MapBox(Widget, caddr_t, XmAnyCallbackStruct *); extern Widget CreateToggleBox(Widget, struct PushButtonRow *, int, int, int, int, int); extern char *selectFile(char *, char *, int); extern char *getStringResource(Widget, char *); extern char *saveVectorFile(int, char *, int); extern char *saveTiff(int, char *, int); extern char *savePng(int, char *, int); extern char *savePostScriptBitmap(int, char *); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern void setAnimation(int); extern Boolean normalMode(XtPointer); extern Boolean animateHistory(XtPointer); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern void CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern void setMenuItem(int, int); extern Widget initShell(Widget, char *, Widget *, Widget *); extern void GetTransperancy(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern Widget topShell, fileBox; extern double paperWidth, paperHeight; extern int format, landscape, animate, primitive, iwavef; static Widget filename, dialog, pWidth, pHeight, comp, transparent, paperformat; static int window, format_save, landscape_save, compression=COMPRESSION_NONE; static int transparentBackground=FALSE, paper=A4; static char name[MAXLENLINE]; static struct PushButtonRow radiobox2_buttons[] = { { "landscape", GetOrientation, (XtPointer)TRUE, NULL }, { "portrait", GetOrientation, (XtPointer)FALSE, NULL } }; void printDialog(Widget widget, caddr_t which, XmAnyCallbackStruct *data) { Widget board, form, form1, form2, form3, form4, form5, form6, sep1, sep2; Widget sep3, sep4, radiobox1, radiobox2, file, select, papersize; Widget clabel, wlabel, hlabel; static struct PushButtonRow buttons[] = { { "ok", printDialogExit, (XtPointer)TRUE, NULL }, { "cancel", printDialogExit, (XtPointer)FALSE, NULL } }; static struct PushButtonRow radiobox1_buttons[] = { { "tiff", GetFormat, (XtPointer)TIFFFILE, NULL }, { "png", GetFormat, (XtPointer)PNGFILE, NULL }, { "hpgl", GetFormat, (XtPointer)HPGL, NULL }, { "postscript", GetFormat, (XtPointer)POSTSCRIPT, NULL }, { "raytracer", GetFormat, (XtPointer)RAYTRACER, NULL } }; static struct MenuItem paperMenu[] = { { "a5", &xmPushButtonGadgetClass, GetPapersize, (XtPointer)A5, NULL, NULL }, { "a4", &xmPushButtonGadgetClass, GetPapersize, (XtPointer)A4, NULL, NULL }, { "a3", &xmPushButtonGadgetClass, GetPapersize, (XtPointer)A3, NULL, NULL }, { "letter", &xmPushButtonGadgetClass, GetPapersize, (XtPointer)LETTER, NULL, NULL }, { "legal", &xmPushButtonGadgetClass, GetPapersize, (XtPointer)LEGAL, NULL, NULL }, { "userdefined", &xmPushButtonGadgetClass, GetPapersize, (XtPointer)USER, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL } }; static struct MenuItem compressionMenu[] = { { "none", &xmPushButtonGadgetClass, GetCompression, (XtPointer)COMPRESSION_NONE, NULL, NULL }, { "mac", &xmPushButtonGadgetClass, GetCompression, (XtPointer)COMPRESSION_PACKBITS, NULL, NULL }, { "lzw", &xmPushButtonGadgetClass, GetCompression, (XtPointer)COMPRESSION_LZW, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL } }; char line[MAXLENLINE], *word; int imol; register int i; /* This function creates the dialog for file output */ format_save=format; landscape_save=landscape; window=(int)which; if (windows[window].set >= 0) imol=windows[window].set; else imol=0; setMenuItem(VIEWER_HARDCOPY, False); if (windows[SPECTRUM].widget) setMenuItem(SPECTRUM_HARDCOPY, False); if (windows[HISTORY].widget) setMenuItem(HISTORY_HARDCOPY, False); if (windows[MO].widget) setMenuItem(MO_HARDCOPY, False); dialog=initShell(windows[window].widget, "printForm", &board, &form); form1=XtVaCreateWidget("controlarea1", xmRowColumnWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); radiobox1=CreateToggleBox(form1, radiobox1_buttons, XtNumber(radiobox1_buttons), XmVERTICAL, 1, True, format-2); if (window != VIEWER || (windows[VIEWER].mode == WIREMODEL && iwavef == ALL_OFF)) XtVaSetValues(radiobox1_buttons[RAYTRACER-2].widget, XmNsensitive, False, NULL); if ((((animate == ANIMATE && molecules[imol].mode != (-1)) || animate == TRAJECTORY) && window == VIEWER)) { XtVaSetValues(radiobox1_buttons[HPGL-2].widget, XmNsensitive, False, NULL); XtVaSetValues(radiobox1_buttons[POSTSCRIPT-2].widget, XmNsensitive, False, NULL); } if (window == VIEWER && primitive == GLU_FILL && (iwavef != ALL_OFF || windows[window].mode != WIREMODEL)) { XtVaSetValues(radiobox1_buttons[HPGL-2].widget, XmNsensitive, False, NULL); /* XtVaSetValues(radiobox1_buttons[POSTSCRIPT-2].widget, XmNsensitive, False, NULL);*/ } XtVaSetValues(radiobox1, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); sep1=XtVaCreateManagedWidget("sep1", xmSeparatorWidgetClass, form1, XmNorientation, XmVERTICAL, XmNtraversalOn, False, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, radiobox1, NULL); form2=XtVaCreateWidget("controlarea2", xmRowColumnWidgetClass, form1, XmNorientation, XmVERTICAL, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); radiobox2=CreateToggleBox(form2, radiobox2_buttons, XtNumber(radiobox2_buttons), XmVERTICAL, 1, True, landscape ? 0 : 1); XtVaSetValues(radiobox2,XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, NULL); if (format == TIFFFILE || format == RAYTRACER) { XtVaSetValues(radiobox2_buttons[0].widget, XmNsensitive, False, NULL); XtVaSetValues(radiobox2_buttons[1].widget, XmNsensitive, False, NULL); } sep2=XtVaCreateManagedWidget("sep2", xmSeparatorWidgetClass, form2, XmNorientation, XmHORIZONTAL, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, radiobox2, NULL); clabel=XtVaCreateManagedWidget("compressionlabel", xmLabelWidgetClass, form2, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, sep2, NULL); word=getStringResource(topShell, "hasLZW"); if (word && strcmp(word, "True")) compressionMenu[2].label=NULL; comp=makeMenu(form2, XmMENU_OPTION, "compression", compressionMenu); if (format == TIFFFILE) { for (i=0; compressionMenu[i].label != NULL; i++) { if ((int)(compressionMenu[i].callback_data) == compression) XtVaSetValues(comp, XmNmenuHistory, compressionMenu[i].widget, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, clabel, NULL); } } else XtVaSetValues(comp, XmNsensitive, False, NULL); XtManageChild(comp); transparent=XtVaCreateManagedWidget("transparent", xmToggleButtonWidgetClass, form2, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, comp, XmNrightAttachment, XmATTACH_FORM, NULL); if (transparentBackground) XtVaSetValues(transparent, XmNset, True, NULL); XtAddCallback(transparent, XmNvalueChangedCallback, (XtCallbackProc)GetTransperancy, &transparentBackground); if (format != PNGFILE) XtVaSetValues(transparent, XmNsensitive, False, NULL); sep3=XtVaCreateManagedWidget("sep3", xmSeparatorWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNleftWidget, form1, NULL); form3=XtVaCreateWidget("controlarea3", xmFormWidgetClass, form, NULL); file=XtVaCreateManagedWidget("file", xmLabelWidgetClass, form3, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); switch (format) { case TIFFFILE: strcpy(name, "vm_image.tiff"); break; case PNGFILE: strcpy(name, "vm_image.png"); break; case HPGL: strcpy(name, "vm_plot.hpgl"); break; case POSTSCRIPT: strcpy(name, "vm_plot.eps"); break; case RAYTRACER: strcpy(name, "vm_image.ray"); break; } filename=XtVaCreateManagedWidget("filename", xmTextWidgetClass, form3, XmNvalue, name, XmNcolumns, 12, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, file, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); select=XtVaCreateManagedWidget("select", xmPushButtonGadgetClass, form3, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, filename, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNdefaultButtonShadowThickness, 1, NULL); XtAddCallback(select, XmNactivateCallback, (XtCallbackProc)Fileselect, NULL); form4=XtVaCreateWidget("controlarea4", xmFormWidgetClass, form, NULL); papersize=XtVaCreateManagedWidget("papersize", xmLabelWidgetClass, form4, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); paperformat=makeMenu(form4, XmMENU_OPTION, "paperformat", paperMenu); for (i=0; paperMenu[i].label != NULL; i++) { if ((int)paperMenu[i].callback_data == paper) XtVaSetValues(paperformat, XmNmenuHistory, paperMenu[i].widget, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); } if (format == TIFFFILE || format == PNGFILE || format == RAYTRACER) XtVaSetValues(paperformat, XmNsensitive, False, NULL); XtManageChild(paperformat); form5=XtVaCreateWidget("controlarea5", xmFormWidgetClass, form, NULL); form6=XtVaCreateWidget("controlarea5", xmFormWidgetClass, form, NULL); wlabel=XtVaCreateManagedWidget("widthlabel", xmLabelWidgetClass, form5, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); hlabel=XtVaCreateManagedWidget("heightlabel", xmLabelWidgetClass, form6, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); sprintf(line, "%7.2f", paperWidth); pWidth=XtVaCreateManagedWidget("width", xmTextWidgetClass, form5, XmNvalue, line, XmNcolumns, 7, XmNtopAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); XtAddCallback(pWidth, XmNvalueChangedCallback, (XtCallbackProc)GetDouble, &paperWidth); sprintf(line, "%7.2f", paperHeight); pHeight=XtVaCreateManagedWidget("height", xmTextWidgetClass, form6, XmNvalue, line, XmNcolumns, 7, XmNtopAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); XtAddCallback(pHeight, XmNvalueChangedCallback, (XtCallbackProc)GetDouble, &paperHeight); if (paper != USER) { XtVaSetValues(pWidth, XmNsensitive, False, NULL); XtVaSetValues(pHeight, XmNsensitive, False, NULL); } sep4=XtVaCreateManagedWidget("sep4", xmSeparatorWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNleftWidget, form5, NULL); XtManageChild(form1); XtManageChild(form2); XtManageChild(form3); XtManageChild(form4); XtManageChild(form5); XtManageChild(form6); CreatePushButtonRow(form, buttons, 2); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XmAnyCallbackStruct *)NULL); XtManageChild(form); XtManageChild(board); } void GetFormat(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { if (data->set) format=(int)which; switch (format) { case TIFFFILE: strcpy(name, "vm_image.tiff"); XtVaSetValues(radiobox2_buttons[0].widget, XmNsensitive, False, NULL); XtVaSetValues(radiobox2_buttons[1].widget, XmNsensitive, False, NULL); XtVaSetValues(comp, XmNsensitive, True, NULL); XtVaSetValues(paperformat, XmNsensitive, False, NULL); XtVaSetValues(transparent, XmNsensitive, False, NULL); break; case PNGFILE: strcpy(name, "vm_image.png"); XtVaSetValues(radiobox2_buttons[0].widget, XmNsensitive, False, NULL); XtVaSetValues(radiobox2_buttons[1].widget, XmNsensitive, False, NULL); XtVaSetValues(comp, XmNsensitive, True, NULL); XtVaSetValues(paperformat, XmNsensitive, False, NULL); XtVaSetValues(transparent, XmNsensitive, True, NULL); break; case HPGL: strcpy(name, "vm_plot.hpgl"); XtVaSetValues(radiobox2_buttons[0].widget, XmNsensitive, True, NULL); XtVaSetValues(radiobox2_buttons[1].widget, XmNsensitive, True, NULL); XtVaSetValues(comp, XmNsensitive, False, NULL); XtVaSetValues(paperformat, XmNsensitive, True, NULL); XtVaSetValues(transparent, XmNsensitive, False, NULL); break; case POSTSCRIPT: strcpy(name, "vm_plot.eps"); XtVaSetValues(radiobox2_buttons[0].widget, XmNsensitive, True, NULL); XtVaSetValues(radiobox2_buttons[1].widget, XmNsensitive, True, NULL); XtVaSetValues(comp, XmNsensitive, False, NULL); XtVaSetValues(paperformat, XmNsensitive, True, NULL); XtVaSetValues(transparent, XmNsensitive, False, NULL); break; case RAYTRACER: strcpy(name, "vm_image.ray"); XtVaSetValues(radiobox2_buttons[0].widget, XmNsensitive, False, NULL); XtVaSetValues(radiobox2_buttons[1].widget, XmNsensitive, False, NULL); XtVaSetValues(comp, XmNsensitive, False, NULL); XtVaSetValues(paperformat, XmNsensitive, False, NULL); XtVaSetValues(transparent, XmNsensitive, False, NULL); break; } XtVaSetValues(filename, XmNvalue, name, NULL); } void GetOrientation(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { if (data->set) { SetPapersize(TRUE); if ((int)which) landscape=TRUE; else landscape=FALSE; } } void GetTransperancy(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { if (data->set) *(int *)which=TRUE; else *(int *)which=FALSE; } void GetPapersize(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { paper=(int)which; switch (paper) { case A5: paperWidth=210.2; paperHeight=148.6; break; case A4: paperWidth=297.3; paperHeight=210.2; break; case A3: paperWidth=420.4; paperHeight=297.3; break; case LETTER: paperWidth=278.0; paperHeight=216.0; break; case LEGAL: paperWidth=356.0; paperHeight=216.0; break; } if (button == 0) return; SetPapersize(!landscape); if (paper == USER) { XtVaSetValues(pWidth, XmNsensitive, True, NULL); XtVaSetValues(pHeight, XmNsensitive, True, NULL); } else { XtVaSetValues(pWidth, XmNsensitive, False, NULL); XtVaSetValues(pHeight, XmNsensitive, False, NULL); } } void GetCompression(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { compression=(int)which; } void printDialogExit(Widget button, caddr_t which, XmPushButtonCallbackStruct *data) { static struct PushButtonRow buttons1[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}, {"cancel", GetMessageBoxButton, (XtPointer)1, NULL}}; static struct PushButtonRow buttons2[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; char *file, *dot, *word=NULL; char f[MAXLENLINE], str[MAXLENLINE]; int imol; if (!(int)which) { format=format_save; landscape=landscape_save; } else { if (windows[window].set >= 0) imol=windows[window].set; else imol=0; file=XmTextGetString(filename); if (!access(file, F_OK)) { dot=getStringResource(topShell, "FileExists"); sprintf(str, dot, file); if (messgb(topShell, 1, str, buttons1, 2) == 1) return; } strcpy(f, file); word=saveFile(&molecules[imol], format, file, f); if (word) { sprintf(str, word, f); messgb(topShell, 0, str, buttons2, 1); } XtFree(file); } XtDestroyWidget(dialog); XtUnmanageChild(fileBox); setMenuItem(VIEWER_HARDCOPY, True); if (windows[SPECTRUM].widget) setMenuItem(SPECTRUM_HARDCOPY, True); if (windows[HISTORY].widget) setMenuItem(HISTORY_HARDCOPY, True); if (windows[MO].widget) setMenuItem(MO_HARDCOPY, True); } void saveDrawing(int which, int format, char *filename) { int i; char f[MAXLENLINE]; window=which; if (windows[which].set >= 0) i=windows[which].set; else i=0; (void)saveFile(&molecules[i], format, filename, f); } char *saveFile(struct MOLECULE *mol, int format, char *file, char *f) { char *word=NULL; switch (format) { case TIFFFILE: if (((animate == ANIMATE && mol->mode != (-1)) || animate == TRAJECTORY) && window == VIEWER) word=saveMultipleFiles(mol, file, f, animate, format); else word=saveTiff(window, file, compression); break; case PNGFILE: if (((animate == ANIMATE && mol->mode != (-1)) || animate == TRAJECTORY) && window == VIEWER) word=saveMultipleFiles(mol, file, f, animate, format); else word=savePng(window, file, transparentBackground); break; case HPGL: word=saveVectorFile(window, file, format); break; case POSTSCRIPT: if (window == VIEWER && primitive == GLU_FILL && (windows[VIEWER].mode != WIREMODEL || iwavef != ALL_OFF)) word=savePostScriptBitmap(window, file); else word=saveVectorFile(window, file, format); break; case RAYTRACER: if (((animate == ANIMATE && mol->mode != (-1)) || animate == TRAJECTORY) && window == VIEWER) word=saveMultipleFiles(mol, file, f, animate, format); else word=saveVectorFile(window, file, format); break; } return(word); } void SetPapersize(int swap) { double help; char line[MAXLENLINE]; if (swap) { help=paperWidth; paperWidth=paperHeight; paperHeight=help; } sprintf(line, "%f", paperWidth); XtVaSetValues(pWidth, XmNvalue, line, NULL); sprintf(line, "%f", paperHeight); XtVaSetValues(pHeight, XmNvalue, line, NULL); } void Fileselect(Widget button, caddr_t dummy, XmAnyCallbackStruct *call_data) { char *str, filter[MAXLENLINE]; XtVaGetValues(filename, XmNvalue, &str, NULL); strcpy(filter, "*"); strcat(filter, strrchr(str, '.')); str=selectFile(filter, str, TRUE); XtVaSetValues(filename, XmNvalue, str, NULL); } char *saveMultipleFiles(struct MOLECULE *mol, char *file, char *f, int animate, int format) { char *dot, *word=NULL, num[10], fmt[6]; register int i, j, k=20, n; dot=strrchr(file, '.'); n=dot-file; switch (animate) { case ANIMATE: k=20; strcpy(fmt, "%2.2d"); break; case TRAJECTORY: k=mol->nhist; sprintf(fmt, "%%%.1d.%.1dd", (int)floor(log10((double)k))+1, (int)floor(log10((double)k))+1); break; } setAnimation(FALSE); j=1; for (i=0; i #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" extern void drawMolecule(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void MapBox(Widget, caddr_t, XmAnyCallbackStruct *); extern void CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern Widget CreateToggleBox(Widget, struct PushButtonRow *, int, int, int, int, int); extern void setMenuItem(int, int); extern void undoGeometry(Widget, caddr_t, XmAnyCallbackStruct *); extern Widget makeMenu(Widget, int, char *, struct MenuItem *); extern int makeConnectivity(struct MOLECULE *, int, int); extern struct MOLECULE *initMolecule(int); extern void *getmem(size_t number, size_t size); extern void fremem(void **pointer); extern Widget initShell(Widget, char *, Widget *, Widget *); void pseDialog(Widget, caddr_t, XmAnyCallbackStruct *); void pseDialogExit(Widget, caddr_t, XmPushButtonCallbackStruct *); void newMolecule(Widget, caddr_t, XmAnyCallbackStruct *); void GetElement(Widget, XtPointer, XmPushButtonCallbackStruct *); void GetEditMode(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetTorsionDefault(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetBondOrderDefault(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetToggle(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern Widget topShell, undoButton; extern struct ELEMENT *elements; extern Pixel stdcol[9]; extern double torsionDefault; extern int ne, element, nmolecule, nUndo; extern int modifyMolecule, bondOrderDefault, localGeometry; static Widget dialog, oldButton; static Pixel oldBackground; static struct MOLECULE *mol; static int nUndoSave, nbAddedSave, nbDeletedSave, *addedSave, *deletedSave; void pseDialog(Widget w, caddr_t dummy, XmAnyCallbackStruct *data) { Widget widget, board, form, form1, form2, sep; Widget radiobox, tors, label1, label2, bo, local; static struct PushButtonRow buttons1[] = { { "change", GetEditMode, (XtPointer)NOTHING, NULL}, { "add", GetEditMode, (XtPointer)ADD_ATOM, NULL }, { "delete", GetEditMode, (XtPointer)DELETE_ATOM, NULL }, { "replace", GetEditMode, (XtPointer)REPLACE_ATOM, NULL }, { "create", GetEditMode, (XtPointer)CREATE_BOND, NULL }, { "remove", GetEditMode, (XtPointer)REMOVE_BOND, NULL }, { "order", GetEditMode, (XtPointer)BOND_ORDER, NULL }, }; static struct PushButtonRow buttons2[] = { { "ok", pseDialogExit, (XtPointer)TRUE, NULL }, { "undo", undoGeometry, NULL, NULL }, { "cancel", pseDialogExit, (XtPointer)FALSE, NULL }, }; static struct MenuItem torsionDefaultsMenu[] = { { "trans", &xmPushButtonGadgetClass, GetTorsionDefault, (XtPointer)180, NULL, NULL }, { "cis", &xmPushButtonGadgetClass, GetTorsionDefault, (XtPointer)0, NULL, NULL }, { "gauche", &xmPushButtonGadgetClass, GetTorsionDefault, (XtPointer)60, NULL, NULL }, { "-gauche", &xmPushButtonGadgetClass, GetTorsionDefault, (XtPointer)(-60), NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL } }; static struct MenuItem bondOrderMenu[] = { { "fractional", &xmPushButtonGadgetClass, GetBondOrderDefault, (XtPointer)(-1), NULL, NULL }, { "single", &xmPushButtonGadgetClass, GetBondOrderDefault, (XtPointer)1, NULL, NULL }, { "double", &xmPushButtonGadgetClass, GetBondOrderDefault, (XtPointer)2, NULL, NULL }, { "triple", &xmPushButtonGadgetClass, GetBondOrderDefault, (XtPointer)3, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL } }; int left, top; register int i; /* This function creates the PSE dialog */ setMenuItem(VIEWER1_NEW, False); setMenuItem(VIEWER1_BUILD, False); nUndoSave=nUndo; if (windows[VIEWER].set >= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; nbAddedSave=mol->nbAdded; nbDeletedSave=mol->nbDeleted; if (nbAddedSave != 0) { addedSave=(int *)getmem((size_t)nbAddedSave, sizeof(int)); (void)memcpy(addedSave, mol->addedBonds, nbAddedSave*sizeof(int)); } if (nbDeletedSave != 0) { deletedSave=(int *)getmem((size_t)nbDeletedSave, sizeof(int)); (void)memcpy(deletedSave, mol->deletedBonds, nbDeletedSave*sizeof(int)); } dialog=initShell(windows[VIEWER].widget, "pseForm", &board, &form); /* Form1 is the form widget which organizes the PSE */ form1=XtVaCreateWidget("pse", xmFormWidgetClass, form, XmNfractionBase, 359, NULL); left=0; top=0; for (i=0; i 17) { left=0; top++; } } } sep=XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNtraversalOn, False, NULL); /* Form 2 is the Form widget which organizes the operations area */ form2=XtVaCreateWidget("operations", xmFormWidgetClass, form, XmNfractionBase, 100, NULL); if (modifyMolecule == NEW_MOLECULE) i=ADD_ATOM; else i=modifyMolecule; radiobox=CreateToggleBox(form2, buttons1, XtNumber(buttons1), XmHORIZONTAL, 3, True, i); XtVaSetValues(radiobox, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, NULL); label1=XtVaCreateManagedWidget("torsionDefault", xmLabelWidgetClass, form2, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 10, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, radiobox, NULL); tors=makeMenu(form2, XmMENU_OPTION, "torsion", torsionDefaultsMenu); XtVaSetValues(tors, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 0, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 85, XmNrightAttachment, XmATTACH_FORM, NULL); label2=XtVaCreateManagedWidget("bondOrderLabel", xmLabelWidgetClass, form2, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 43, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, radiobox, NULL); bo=makeMenu(form2, XmMENU_OPTION, "bondOrder", bondOrderMenu); XtVaSetValues(bo, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 33, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 85, XmNrightAttachment, XmATTACH_FORM, XmNmenuHistory, bondOrderMenu[bondOrderDefault > 0 ? bondOrderDefault : 0].widget, NULL); local=XtVaCreateManagedWidget("localGeometry", xmToggleButtonWidgetClass, form2, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, radiobox, XmNbottomAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); XtAddCallback(local, XmNvalueChangedCallback, (XtCallbackProc)GetToggle, &localGeometry); if (localGeometry) XtVaSetValues(local, XmNset, True, NULL); sep=XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNtraversalOn, False, NULL); CreatePushButtonRow(form, buttons2, XtNumber(buttons2)); undoButton=buttons2[1].widget; if (nUndo == 0) XtVaSetValues(undoButton, XmNsensitive, False, NULL); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XmAnyCallbackStruct *)NULL); XtManageChild(form1); XtManageChild(tors); XtManageChild(bo); XtManageChild(form2); XtManageChild(form); XtManageChild(board); } void pseDialogExit(Widget button, caddr_t which, XmPushButtonCallbackStruct *data) { modifyMolecule=NOTHING; undoButton=NULL; XtDestroyWidget(dialog); setMenuItem(VIEWER1_NEW, True); if (nmolecule > 0) setMenuItem(VIEWER1_BUILD, True); if (!(int)which) { if (nmolecule > 0) { if (nUndoSave != 0 && nUndo > nUndoSave) { nUndo=nUndoSave+1; undoGeometry((Widget)0, (caddr_t)0, (XmAnyCallbackStruct *)0); } if (nbAddedSave != mol->nbAdded) { mol->nbAdded=nbAddedSave; if (nbAddedSave != 0) { (void)memcpy(mol->addedBonds, addedSave, nbAddedSave*sizeof(int)); fremem((void **)&addedSave); } else fremem((void **)&mol->addedBonds); } if (nbDeletedSave != mol->nbDeleted) { mol->nbDeleted=nbDeletedSave; if (nbDeletedSave != 0) { (void)memcpy(mol->deletedBonds, deletedSave, nbDeletedSave*sizeof(int)); fremem((void **)&deletedSave); } else fremem((void **)&mol->deletedBonds); } makeConnectivity(mol, FALSE, TRUE); } } } void newMolecule(Widget w, caddr_t dummy, XmAnyCallbackStruct *data) { if (molecules == NULL) { XtRemoveAllCallbacks(windows[VIEWER].widget, XmNexposeCallback); XtAddCallback(windows[VIEWER].widget, XmNexposeCallback, (XtCallbackProc)drawMolecule, NULL); (void)initMolecule(20); } if (w != NULL) { modifyMolecule=NEW_MOLECULE; pseDialog(w, dummy, data); } } void GetElement(Widget button, XtPointer which, XmPushButtonCallbackStruct *data) { element=(int)which; if (button != oldButton) { XtVaSetValues(oldButton, XmNbackground, oldBackground, NULL); XtVaGetValues(button, XmNbackground, &oldBackground, NULL); XtVaSetValues(button, XmNbackground, stdcol[YELLOW], NULL); oldButton=button; } } void GetEditMode(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { if (data->set) modifyMolecule=(int)which; } void GetTorsionDefault(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { int t; t=(int)which; torsionDefault=(double)t; } void GetBondOrderDefault(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { bondOrderDefault=(int)which; } void GetToggle(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { int *w; w=(int *)which; *w=!(*w); } viewmol-2.4.1/source/quaternion.c0100644000272700027270000000510610042742353015176 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * Q U A T E R N I O N . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: quaternion.c,v 1.2 2003/11/07 11:09:31 jrh Exp $ * $Log: quaternion.c,v $ * Revision 1.2 2003/11/07 11:09:31 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:14:24 jrh * Initial revision * */ #include #include #include void quaternionToMatrix(GLenum, float *); void incrementQuaternion(double, double, double, float *); void multQuaternions(float *, float *, float *); void quaternionToMatrix(GLenum matrixMode, float q[4]) { double xx, xy, xz, xw, yy, yz, yw, zz, zw, x2, y2, z2; double mat[4][4]; x2=q[0]+q[0]; y2=q[1]+q[1]; z2=q[2]+q[2]; xx=q[0]*x2; xy=q[0]*y2; xz=q[0]*z2; yy=q[1]*y2; yz=q[1]*z2; zz=q[2]*z2; xw=q[3]*x2; yw=q[3]*y2; zw=q[3]*z2; mat[0][0]=1.0-yy-zz; mat[0][1]= xy-zw; mat[0][2]= xz+yw; mat[0][3]=0.0; mat[1][0]= xy+zw; mat[1][1]=1.0-xx-zz; mat[1][2]= yz-xw; mat[1][3]=0.0; mat[2][0]= xz-yw; mat[2][1]= yz+xw; mat[2][2]=1.0-xx-yy; mat[2][3]=0.0; mat[3][0]=mat[3][1]=mat[3][2]=0.0; mat[3][3]=1.0; glMatrixMode(matrixMode); glMultMatrixd((const double *)mat); } void incrementQuaternion(double x, double y, double z, float *q) { double torad=atan(1.0)/90.0; double cx, cy, cz, sx, sy, sz, cycz, sysz; float q1[4], q2[4]; x*=torad; y*=torad; z*=torad; cx=cos(x); cy=cos(y); cz=cos(z); sx=sin(x); sy=sin(y); sz=sin(z); cycz=cy*cz; sysz=sy*sz; q1[0]=sx*cycz-cx*sysz; q1[1]=cx*sy*cz+sx*cy*sz; q1[2]=cx*cy*sz-sx*sy*cz; q1[3]=cx*cycz+sx*sysz; multQuaternions(q, q1, q2); q[0]=q2[0]; q[1]=q2[1]; q[2]=q2[2]; q[3]=q2[3]; } void multQuaternions(float *q1, float *q2, float *q3) { q3[0]=q1[3]*q2[0]+q1[0]*q2[3]+q1[1]*q2[2]-q1[2]*q2[1]; q3[1]=q1[3]*q2[1]+q1[1]*q2[3]+q1[2]*q2[0]-q1[0]*q2[2]; q3[2]=q1[3]*q2[2]+q1[2]*q2[3]+q1[0]*q2[1]-q1[1]*q2[0]; q3[3]=q1[3]*q2[3]-q1[0]*q2[0]-q1[1]*q2[1]-q1[2]*q2[2]; } viewmol-2.4.1/source/ray.c0100644000272700027270000002616710114367560013621 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * R A Y . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: ray.c,v 1.7 2004/08/29 15:00:00 jrh Exp $ * $Log: ray.c,v $ * Revision 1.7 2004/08/29 15:00:00 jrh * Release 2.4.1 * * Revision 1.6 2003/11/07 11:09:36 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:14:33 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:27:03 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:55:11 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:07 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:43:24 jrh * Initial revision * */ #include #include #include #include #include #include "viewmol.h" #include "dialog.h" extern void transformCoordinates(int, float input[4], float output[4]); extern void *getmem(size_t, size_t); extern void fremem(void **); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern struct ELEMENT *elements; extern double tmat[4][4]; extern GLfloat light0p[], light1p[]; extern float *transObject, *rotObject; extern int ne, iwavef, lights, projectionMode; static struct ELEMENT *material; static double n[3], nSave[3][3], vSave[3][3]; static int printNormal=FALSE, nCorners; static FILE *f; FILE *raytraceInit(char *filename, Dimension width, Dimension height) { struct MOLECULE *mol; struct ELEMENT *element=(struct ELEMENT *)NULL; FILE *file; double box, todeg=45.0/atan(1.0);; GLfloat zview, light[4]; GLfloat lookat[4]={0.0, 0.0, 1.0, 1.0}; GLfloat up[4]={0.0, 1.0, 0.0, 1.0}; GLfloat right[4]={-1.0, 0.0, 0.0, 1.0}; int *done, hbond; register int i, j; if ((file=fopen(filename, "w")) == NULL) return(NULL); if (projectionMode == ORTHO) fprintf(file, "camera {\n orthographic\n"); else fprintf(file, "camera {\n perspective\n"); /* Position camera */ if (2.0*windows[VIEWER].far > transObject[3*VIEWPOINT+2]) zview=2.0*windows[VIEWER].far-transObject[3*VIEWPOINT+2]; else zview=0.1; fprintf(file, " location <%.7f, %.7f, %.7f>\n", (-transObject[3*VIEWPOINT]), (-transObject[3*VIEWPOINT+1]), zview+windows[VIEWER].far); /* Define up and right directions for camera */ if (projectionMode == ORTHO) { fprintf(file, " up <0.0, %.7f, 0.0>\n", 2.0*windows[VIEWER].top); fprintf(file, " right <%.7f, 0.0, 0.0>\n", -2.0*windows[VIEWER].right); } else { transformCoordinates(VIEWPOINT, up, light); fprintf(file, " up <%.7f, %.7f, %.7f>\n", -light[0], light[1], light[2]); fprintf(file, " sky <%.7f, %.7f, %.7f>\n", -light[0], light[1], light[2]); right[0]=-(double)width/(double)height; transformCoordinates(VIEWPOINT, right, light); fprintf(file, " right <%.7f, %.7f, %.7f>\n", light[0], light[1], light[2]); } /* Point camera into right direction and set its viewing angle */ fprintf(file, " angle %.7f\n", 2.0*todeg*atan(windows[VIEWER].right/zview)); lookat[0]=-transObject[3*VIEWPOINT]; lookat[1]=-transObject[3*VIEWPOINT+1]; lookat[2]=zview; transformCoordinates(VIEWPOINT, lookat, light); fprintf(file, " look_at <%.7f, %.7f, %.7f>}\n", light[0], light[1], light[2]); /* Set background color */ fprintf(file, "background { color rgb <%.3f, %.3f, %.3f>}\n", windows[VIEWER].background_rgb[0], windows[VIEWER].background_rgb[1], windows[VIEWER].background_rgb[2]); /* Position lights */ box=2.0*windows[VIEWER].far; if (lights & 0x1) { transformCoordinates(LIGHTNO0, light0p, light); fprintf(file, "light_source { <%.7f, %.7f, %.7f>\n color <1.0, 1.0, 1.0>\n shadowless\n}\n", box*light[0], box*light[1], box*light[2]); } if (lights & 0x2) { transformCoordinates(LIGHTNO1, light1p, light); fprintf(file, "light_source { <%.7f, %.7f, %.7f>\n color <1.0, 1.0, 1.0>\n}\n", box*light[0], box*light[1], box*light[2]); } /* Draw the molecule */ if (windows[VIEWER].set >= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; hbond=FALSE; for (i=0; inb; i++) { if (mol->bonds[i].order == (-1)) { hbond=TRUE; break; } } done=(int *)getmem(mol->na, sizeof(int)); for (i=0; ina; i++) { if (!done[i]) { element=mol->atoms[i].element; fprintf(file, "#declare %s = texture {\n", element->symbol); fprintf(file, " pigment {color rgbf <%.3f, %.3f, %.3f, %.3f>}\n", (element->dark[0]+element->light[0])*0.5, (element->dark[1]+element->light[1])*0.5, (element->dark[2]+element->light[2])*0.5, 1.0-element->alpha); fprintf(file, " finish {ambient rgb <%.3f, %.3f, %.3f>\n phong 0.9\n", element->ambient[0], element->ambient[1], element->ambient[2]); fprintf(file, " specular %.3f}}\n", element->shininess/128.0); for (j=i; jna; j++) { if (mol->atoms[j].element == element) done[j]=TRUE; } } } if (hbond) { element=mol->bondStyle; fprintf(file, "#declare %s = texture {\n", element->symbol); fprintf(file, " pigment {color rgbf <%.3f, %.3f, %.3f, %.3f>}\n", (element->dark[0]+element->light[0])*0.5, (element->dark[1]+element->light[1])*0.5, (element->dark[2]+element->light[2])*0.5, 1.0-element->alpha); fprintf(file, " finish {ambient rgb <%.3f, %.3f, %.3f>\n phong 0.9\n", element->ambient[0], element->ambient[1], element->ambient[2]); fprintf(file, " specular %.3f}}\n", element->shininess/128.0); } if (mol->unitcell) { element=mol->unitcell->corners[0].element; fprintf(file, "#declare %s = texture {\n", element->symbol); fprintf(file, " pigment {color rgbf <%.3f, %.3f, %.3f, %.3f>}\n", (element->dark[0]+element->light[0])*0.5, (element->dark[1]+element->light[1])*0.5, (element->dark[2]+element->light[2])*0.5, 1.0-element->alpha); fprintf(file, " finish {ambient rgb <%.3f, %.3f, %.3f>\n phong 0.9\n", element->ambient[0], element->ambient[1], element->ambient[2]); fprintf(file, " specular %.3f}}\n", element->shininess/128.0); } if (iwavef != ALL_OFF) { for (i=0; i}\n", (elements[i].dark[0]+elements[i].light[0])*0.5, (elements[i].dark[1]+elements[i].light[1])*0.5, (elements[i].dark[2]+elements[i].light[2])*0.5, 1.0-elements[i].alpha); fprintf(file, " finish {ambient rgb <%.3f, %.3f, %.3f>\n phong 0.9\n", element->ambient[0], element->ambient[1], element->ambient[2]); fprintf(file, " specular %.3f}}\n", element->shininess/128.0); } } } fremem((void **)&done); if (projectionMode == PERSPECTIVE) { fprintf(file, "#declare ground = texture {\n"); fprintf(file, " pigment {color rgb <%.3f, %.3f, %.3f>}}\n", windows[VIEWER].foreground_rgb[0], windows[VIEWER].foreground_rgb[1], windows[VIEWER].foreground_rgb[2]); fprintf(file, "plane { <0.0, 1.0, 0.0>, %10.5f\n texture {ground}}\n", windows[VIEWER].bottom); } f=file; return(file); } void raytraceClose(FILE *file) { fclose(file); } void raytracerBegin(GLenum what) { fprintf(f, "smooth_triangle {\n"); glGetDoublev(GL_MODELVIEW_MATRIX, &tmat[0][0]); nCorners=0; } void raytracerEnd() { } void raytracerVertex3d(double vx, double vy, double vz) { double t[3]; register int i; if (nCorners > 2) { fprintf(f, "smooth_triangle {\n <%.6f, %.6f, %.6f>, ", vSave[0][1], vSave[1][1], vSave[2][1]); if (printNormal) fprintf(f, "<%.6f, %.6f, %.6f>,\n", nSave[0][1], nSave[1][1], nSave[2][1]); fprintf(f, "<%.6f, %.6f, %.6f>, ", vSave[0][2], vSave[1][2], vSave[2][2]); if (printNormal) fprintf(f, "<%.6f, %.6f, %.6f>,\n", nSave[0][2], nSave[1][2], nSave[2][2]); } t[0]=vx*tmat[0][0]+vy*tmat[1][0]+vz*tmat[2][0]+tmat[3][0]; t[1]=vx*tmat[0][1]+vy*tmat[1][1]+vz*tmat[2][1]+tmat[3][1]; t[2]=vx*tmat[0][2]+vy*tmat[1][2]+vz*tmat[2][2]+tmat[3][2]; fprintf(f, "<%.6f, %.6f, %.6f>, ", t[0], t[1], t[2]); nCorners++; for (i=0; i<3; i++) { vSave[i][0]=vSave[i][1]; vSave[i][1]=vSave[i][2]; vSave[i][2]=t[i]; } if (printNormal) { t[0]=n[0]*tmat[0][0]+n[1]*tmat[1][0]+n[2]*tmat[2][0]+tmat[3][0]; t[1]=n[0]*tmat[0][1]+n[1]*tmat[1][1]+n[2]*tmat[2][1]+tmat[3][1]; t[2]=n[0]*tmat[0][2]+n[1]*tmat[1][2]+n[2]*tmat[2][2]+tmat[3][2]; fprintf(f, "<%.6f, %.6f, %.6f>\n", t[0], t[1], t[2]); printNormal=FALSE; for (i=0; i<3; i++) { nSave[i][0]=nSave[i][1]; nSave[i][1]=nSave[i][2]; nSave[i][2]=t[i]; } if (nCorners > 2) fprintf(f, " texture {%s}}\n", material->symbol); } } void raytracerNormal3d(double vx, double vy, double vz) { n[0]=vx; n[1]=vy; n[2]=vz; printNormal=TRUE; } void raytracerSphere(GLUquadricObj *object, GLdouble radius, GLint dummy1, GLint dummy2) { double matrix[4][4]; glGetDoublev(GL_MODELVIEW_MATRIX, &matrix[0][0]); fprintf(f, "sphere { <%10.6f, %10.6f, %10.6f>, %f\n texture {%s}}\n", matrix[3][0], matrix[3][1], matrix[3][2], radius, material->symbol); } void raytracerCylinder(GLUquadricObj *object, GLdouble top, GLdouble bottom, GLdouble height, GLint dummy1, GLint dummy2) { double matrix[4][4]; glGetDoublev(GL_MODELVIEW_MATRIX, &matrix[0][0]); fprintf(f, "cylinder {<%10.6f, %10.6f, %10.6f>,\n <%10.6f, %10.6f, %10.6f>,\n %f open\n texture {%s}}\n", matrix[3][0], matrix[3][1], matrix[3][2], height*matrix[2][0]+matrix[3][0], height*matrix[2][1]+matrix[3][1], height*matrix[2][2]+matrix[3][2], bottom, material->symbol); } void raytracerCone(GLUquadricObj *object, GLdouble top, GLdouble bottom, GLdouble height, GLint dummy1, GLint dummy2) { double matrix[4][4]; glGetDoublev(GL_MODELVIEW_MATRIX, &matrix[0][0]); fprintf(f, "cone {<%.6f, %.6f, %.6f>, %.6f\n <%.6f, %.6f, %.6f>, %.6f\n open\n texture {%s}}\n", matrix[3][0], matrix[3][1], matrix[3][2], top, height*matrix[2][0]+matrix[3][0], height*matrix[2][1]+matrix[3][1], height*matrix[2][2]+matrix[3][2], bottom, material->symbol); } void raytracerColor4fv(const GLfloat *color) { } void raytracerClearColor(GLclampf red, GLclampf green , GLclampf blue, GLclampf alpha) { } void raytracerMaterial(struct ELEMENT *e) { material=e; } viewmol-2.4.1/source/raytrace.c0100644000272700027270000000723707752677103014650 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * R A Y T R A C E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: raytrace.c,v 1.6 2003/11/07 11:13:07 jrh Exp $ * $Log: raytrace.c,v $ * Revision 1.6 2003/11/07 11:13:07 jrh * Release 2.4 * * * Revision 1.5 2000/12/10 15:14:42 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:27:05 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:55:23 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:09 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:43:29 jrh * Initial revision * */ #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" extern char *getStringResource(Widget, char *); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern char *selectFile(char *, char *, int); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern char *saveVectorFile(int, char *, int); extern int runProg(char *, int, char *, char *, char *, pid_t *); extern int checkFile(char **); extern Widget topShell; extern struct WINDOW windows[]; extern pid_t raypid; extern char raytracer[], displayImage[]; void raytrace(Widget widget, caddr_t data1, caddr_t data2) { static struct PushButtonRow buttons1[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}, {"cancel", GetMessageBoxButton, (XtPointer)1, NULL}}; static struct PushButtonRow buttons2[] = {{"doRaytracing", GetMessageBoxButton, (XtPointer)0, NULL}, {"stopRaytracing", GetMessageBoxButton, (XtPointer)1, NULL}}; static struct PushButtonRow buttons3[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; static char *rayfile="vm_image.ray"; Dimension width, height; pid_t pid; char line[MAXLENLINE]; char pngfile[MAXLENLINE], *dot; if ((rayfile=selectFile("*", rayfile, TRUE)) == NULL) return; saveVectorFile(VIEWER, rayfile, RAYTRACER); strcpy(pngfile, rayfile); if ((dot=strrchr(pngfile,'.')) != NULL) strcpy(dot, ".png"); else strcat(pngfile, ".png"); if (!access(pngfile, F_OK)) { dot=getStringResource(topShell, "FileExists"); sprintf(line, dot, pngfile); if (messgb(topShell, 1, line, buttons1, 2) == 1) return; } if (*raytracer != '\0') { if (*displayImage == '\0') { dot=getStringResource(topShell, "noDisplay"); if (messgb(topShell, 3, dot, buttons2, 2) == 1) return; } if ((raypid=fork()) == (pid_t)0) { XtVaGetValues(windows[VIEWER].widget, XmNwidth, &width, XmNheight, &height, NULL); sprintf(line, raytracer, rayfile, pngfile, width, height); runProg(line, TRUE, NULL, NULL, "/dev/null", &pid); /* runProg(raytracer, TRUE, rayfile, pngfile, "/dev/null", &pid);*/ if (*displayImage != '\0') { sprintf(line, displayImage, pngfile); runProg(line, FALSE, NULL, NULL, "/dev/null", &pid); } exit(0); } } else { dot=getStringResource(topShell, "noRayshade"); messgb(topShell, 3, dot, buttons3, 1); } } viewmol-2.4.1/source/readframe.c0100644000272700027270000000775610114367621014755 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * R E A D F R A M E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: readframe.c,v 1.6 2004/08/29 15:00:33 jrh Exp $ * $Log: readframe.c,v $ * Revision 1.6 2004/08/29 15:00:33 jrh * Release 2.4.1 * * Revision 1.5 2003/11/07 11:13:18 jrh * Release 2.4 * * Revision 1.4 2000/12/10 15:15:02 jrh * Release 2.3 * * Revision 1.3 1999/05/24 01:27:10 jrh * Release 2.2.1 * * Revision 1.2 1999/02/07 21:55:39 jrh * Release 2.2 * * Revision 1.1 1998/01/26 00:35:17 jrh * Initial revision * */ #include #include #include #include #define MAXLENLINE 84 #define FALSE 0 #define TRUE 1 int readFrame(FILE *mainfile, int pbc, int first, double conv, int version, long *offset) { double energy; long start; static int cycle=0; int realEnd=FALSE, na=0, iend; char line[MAXLENLINE], *word, *w; *offset=ftell(mainfile); fgets(line, MAXLENLINE, mainfile); if (first) { printf("$title\n"); /* Cutoff spaces */ iend=strlen(line) > 65 ? 64 : strlen(line)-1; word=&line[iend]; while (*word == ' ' || *word == '\n') word--; word++; *word='\0'; word=&line[0]; while (*word == ' ') word++; printf("%s\n", word); fgets(line, MAXLENLINE, mainfile); } else { word=line+64; /* Energies in car/arc files are supposed to be in thermochemical kcal/mol */ energy=atof(word)/627.50959; cycle++; printf(" cycle = %d SCF energy = %17.10f |dE/dxyz| = 0.000000\n", cycle, energy); } /*if (first) { printf("$coord %12.8f\n", conv); conv=(double)1.0/conv; }*/ while (fgets(line, MAXLENLINE, mainfile) != NULL) { if (strstr(line, "end") == NULL && line[0] != '!') { if (strstr(line, "PBC") == &line[0]) { if (first) { printf("$unitcell %s\n", strtok(line, "(")+3); printf("$symmetry %s\n", strtok(NULL, ")")); } else printf(" unitcell %s\n", strtok(line, "(")+3); } else { if (first && na == 0) { printf("$coord %12.8f\n", conv); conv=(double)1.0/conv; } word=strtok(line+6, " \t"); printf("%22.14f ", conv*atof(word)); if (strlen(word) > 15) { if ((w=strchr(word, '.')) != NULL) word=w+10; else word+=16; } else word=strtok(NULL, " \t"); printf("%22.14f ", conv*atof(word)); if (strlen(word) > 15) { if ((w=strchr(word, '.')) != NULL) word=w+10; else word+=16; } else word=strtok(NULL, " \t"); printf("%22.14f ", conv*atof(word)); word=strtok(NULL, " \t"); word=strtok(NULL, " \t"); word=strtok(NULL, " \t"); if (version < 2) printf("%s\n", word); else { word=strtok(NULL, " \t"); printf("%s\n", word); } if (realEnd) realEnd=FALSE; na++; } } else { if (realEnd) { if (!first) { while (na--) printf("%22.14e%22.14e%22.14e\n", 0.0, 0.0, 0.0); } start=ftell(mainfile); if (fgets(line, MAXLENLINE, mainfile) != NULL) { (void)fseek(mainfile, start, SEEK_SET); return(TRUE); } else return(FALSE); } else realEnd=TRUE; } } return(TRUE); } viewmol-2.4.1/source/readgamess.c0100644000272700027270000005411407752677126015152 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * R E A D G A M E S S . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: readgamess.c,v 1.2 2003/11/07 11:13:26 jrh Exp $ * $Log: readgamess.c,v $ * Revision 1.2 2003/11/07 11:13:26 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:15:13 jrh * Initial revision * * */ #include #include #include #include #include #include "isotopes.h" #define RHF 1 #define UHF 2 #define ROHF 3 #define MCSCF 4 #define GVB 5 #define TRUE 1 #define FALSE 0 #define MAXLENLINE 134 int main(int, char **); void readBasis(FILE *, char *, char *, int *, int); void readMOs(int, int, FILE *, int); void readFrq(FILE *, int); int readOpg(FILE *, int); void printCoord(double **, char **, int, int); void makeLower(char *); void changeDs(char *); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern void eof(char *, char *, int); int main(int argc, char **argv) { FILE *file; double atomicCharge; int found, na, mna=50, mnn=80, cycle=0, atomNumber; int freq=FALSE, opt=FALSE, scftype=RHF, *done; char line[MAXLENLINE], pgroup[8], *atomNames, *currentName, *word=NULL, *p, *symbol; register int i, k; if ((file=fopen(argv[1], "r")) == NULL) eof("noFile", argv[1], 1); /* Check whether it really is a GAMESS output file */ do { if (fgets(line, MAXLENLINE, file) == NULL) eof("wrongFiletype", argv[1], 1); makeLower(line); } while (!strstr(line, "gamess")); /* Load Title */ found=TRUE; do { if (fgets(line, MAXLENLINE, file) == NULL) { found=FALSE; rewind(file); break; } } while (!strstr(line, "RUN TITLE")); if (found) { fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); word=line; while (*word == ' ') word++; printf("$title\n%s", word); } /* Load symmetry */ found=TRUE; do { if (fgets(line, MAXLENLINE, file) == NULL) { found=FALSE; rewind(file); break; } } while (!strstr(line, "THE POINT GROUP OF THE MOLECULE IS")); if (found) { word=strtok(line, " "); for (i=0; i<7; i++) word=strtok(NULL, " "); strcpy(pgroup, word); fgets(line, MAXLENLINE, file); if (strstr(line, "THE ORDER OF THE PRINCIPAL AXIS IS")) { word=strtok(line, " "); for (i=0; i<7; i++) word=strtok(NULL, " \n"); if (*word != '0' && (p=strchr(pgroup, 'N')) != NULL) *p=*word; } printf("$symmetry %s\n", pgroup); if (strcmp(pgroup, "C1")) printf("$error onlySymmetricBasis 0\n"); } /* Check SCF and run type */ do { if (fgets(line, MAXLENLINE, file) == NULL) break; } while (!(word=strstr(line, "RUNTYP="))); if (!strncmp(word+7, "OPTIMIZE", 8)) opt=TRUE; if (!strncmp(word+7, "HESSIAN", 7)) freq=TRUE; word=strstr(line, "SCFTYP="); if (word) { if (!strncmp(word+7, "RHF", 3)) scftype=RHF; if (!strncmp(word+7, "UHF", 3)) scftype=UHF; if (!strncmp(word+7, "ROHF", 4)) scftype=ROHF; if (!strncmp(word+7, "MCSCF", 5)) scftype=MCSCF; if (!strncmp(word+7, "GVB", 3)) scftype=GVB; } /* Load coordinates */ rewind(file); do { if (fgets(line, MAXLENLINE, file) == NULL) eof("noCoordinates", argv[1], 1); } while (!strstr(line, "ATOM ATOMIC COORDINATES (BOHR)")); fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); na=0; symbol=(char *)getmem((size_t)mna, (size_t)(3*sizeof(char))); atomNames=(char *)getmem((size_t)mnn, sizeof(char)); currentName=atomNames; if (!opt) printf("$coord 0.52917706\n"); while (line[0] != '\n' && !strstr(line, "INTERNUCLEAR DISTANCES")) { word=strtok(line, " \t"); if (strlen(word)+(int)(currentName-atomNames) > mnn-1) { mnn+=80; p=atomNames; atomNames=(char *)expmem((void *)atomNames, mnn, sizeof(char)); if (p != atomNames) currentName+=atomNames-p; } strcpy(currentName, word); currentName+=strlen(word)+1; atomicCharge=atof(strtok(NULL, " \t")); atomNumber=(int)floor(atomicCharge); if (fabs((double)atomNumber-atomicCharge) < 1.0e-6) { atomNumber--; symbol[3*na]=pse[atomNumber][0]; symbol[3*na+1]=pse[atomNumber][1]; symbol[3*na+2]='\0'; if (!opt) { p=strtok(NULL, " \t"); printf("%s ", p); p=strtok(NULL, " \t"); printf("%s ", p); p=strtok(NULL, " \t\n"); printf("%s %s\n", p, &symbol[3*na]); } na++; if (na >= mna) { mna+=50; symbol=(char *)expmem((void *)symbol, (size_t)mna, (size_t)(3*sizeof(char))); } } if (fgets(line, MAXLENLINE, file) == NULL) break; } /* Load optimization history */ if (opt) cycle=readOpg(file, na); /* Load basis functions */ rewind(file); found=TRUE; do { if (fgets(line, MAXLENLINE, file) == NULL) { found=FALSE; break; } } while (!strstr(line, "ATOMIC BASIS SET")); if (found) { do { if (fgets(line, MAXLENLINE, file) == NULL) break; } while (!strstr(line, "SHELL TYPE PRIM")); printf("$atoms\n"); done=(int *)getmem((size_t)na, sizeof(int)); for (i=0; i maxpri) { maxpri+=20; ex=(double *)expmem((void *)ex, maxpri, sizeof(double)); scoeff=(double *)expmem((void *)scoeff, maxpri, sizeof(double)); pcoeff=(double *)expmem((void *)pcoeff, maxpri, sizeof(double)); dcoeff=(double *)expmem((void *)dcoeff, maxpri, sizeof(double)); fcoeff=(double *)expmem((void *)fcoeff, maxpri, sizeof(double)); } fgets(line, MAXLENLINE, file); if (line[0] == '\n') fgets(line, MAXLENLINE, file); if (strstr(line, "TOTAL NUMBER OF")) break; word=strtok(line, " \t"); if (isalpha(*word)) break; } /* end of while (ishell == atoi(word)) */ for (p=&shell[0]; *p; p++) { printf("%4d %c\n", i, tolower(*p)); for (j=0; j= mno) { mno+=20; eorb=(double *)expmem((void *)eorb, (size_t)mno, sizeof(double)); symorb=(char *)expmem((void *)symorb, (size_t)mno, 4*sizeof(char)); } word=strtok(NULL, " \t\n"); } found=FALSE; fgets(line, MAXLENLINE, file); word=strtok(line, " \t\n"); while (word) { strncpy(&symorb[j], word, 4); j+=4*sizeof(char); word=strtok(NULL, " \t\n"); } fgets(line, MAXLENLINE, file); while (line[0] != '\n' && (line[14] != ' ' || line[15] != ' ')) { (void)strtok(line, " \t\n"); (void)strtok(NULL, " \t\n"); word=strtok(NULL, " \t\n"); if (word[0] >= '0' && word[0] <= '9') (void)strtok(NULL, " \t\n"); while ((word=strtok(NULL, " \t"))) { cmo[k]=atof(word); if (++k >= mnc) { mnc+=200; cmo=(double *)expmem((void *)cmo, (size_t)mnc, sizeof(double)); } } fgets(line, MAXLENLINE, file); if (strstr(line, "...... END OF") || strstr(line, "- BETA SET -")) break; } if (strstr(line, "...... END OF") || strstr(line, "- BETA SET -")) break; } norbital=i; nbasfu=k/i; if (scftype == RHF) printf("$scfmo gaussian\n"); else { if (spin == 0) printf("$uhfmo_alpha gaussian\n"); else printf("$uhfmo_beta gaussian\n"); } k=0; for (i=0; i nend) { freq[nfrq++]=atof(word); accepted++; } all++; } } nfrq-=accepted; /* Read IR intensities */ fgets(line, MAXLENLINE, file); (void)strtok(line, " \t\n"); (void)strtok(NULL, " \t\n"); accepted=all=0; while ((word=strtok(NULL, " \t\n"))) { if (i+all < nstart || i+all > nend) { ir[nfrq++]=atof(word); accepted++; } all++; } nfrq-=accepted; fgets(line, MAXLENLINE, file); /* Read normal modes */ for (j=0; j<3*na; j++) { accepted=all=0; fgets(line, MAXLENLINE, file); word=strtok(line, " \t\n"); if (isdigit(*word)) { (void)strtok(NULL, " \t\n"); (void)strtok(NULL, " \t\n"); } while ((word=strtok(NULL, " \t\n"))) { if (i+all < nstart || i+all > nend) { nmo[j*ncart+nfrq]=atof(word); accepted++; nfrq++; } all++; } if (j != 3*na-1) nfrq-=accepted; } i+=all; } printf("$vibrational spectrum\n"); for (i=0; i #include #include #include #include #include "isotopes.h" #define TRUE 1 #define FALSE 0 #define MAXLENLINE 134 #define TABMAR "---" #define EHF "rhf) =" #define EMP2 "eump2" #define EMP4 "sdtq)=" #define EDFT ") =" #define EUHF "uhf) =" #define EMPTWO "ump2 =" #define FRAME "framework group" #define STAOR "standard orientation:" #define INPOR "input orientation:" #define GAUSS1 "entering gaussian system" #define GAUSS2 "entering link 1 =" #define GAUSSIAN03 "This is the Gaussian(R) 03 program." #define XCOORD "x-coord" #define OSYM "orbital symmetries" #define AMOS "alpha mos:" #define BMOS "beta mos:" #define MOCOEFFICIENTS "molecular orbital coefficients" #define AXES "***** axes restored to original set *****" #define SYMMETRIES 1 #define ALPHAMOS 2 #define COEFFICIENTS 3 int main(int, char **); void readBasis(FILE *, int); void readMOs(int, FILE *); void readFrq(FILE *, int, int, int); int readOpg(FILE *, int, int, char *, char *); void printCoord(double **, char **, int); double reade(char *, char *, int *); int msub(char *, int, char *); void makeLower(char *); void changeDs(char *); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern void eof(char *, char *, int); int main(int argc, char **argv) { FILE *file; double etotal, *xcoord, *ycoord, *zcoord; char emark[2][7] = {"0@ ~0", "0@ ~0"}, line[MAXLENLINE], *word; char *symbol, orientation[24]; int freq=FALSE, gfprn=FALSE, opt=FALSE; int nemark=0, nout, na, ncent, nuc; int mna=50, cycle=0; int etex; int version = 98; register double x, y, z; register int i, mak; if ((file=fopen(argv[1], "r")) == NULL) eof("noFile", argv[1], 1); /* Check type of calculation */ do { if (fgets(line, MAXLENLINE, file) == NULL) eof("wrongFiletype", argv[1], 1); makeLower(line); } while (!(strstr(line, GAUSS1) || strstr(line, GAUSS2))); for (i=0; i<10; i++) /* test for Gaussian03 */ { if (fgets(line, MAXLENLINE, file) == NULL) eof("wrongFiletype", argv[1], 1); if (strstr(line, GAUSSIAN03)) version=3; } do { if (fgets(line, MAXLENLINE, file) == NULL) eof("noCoordinates", argv[1], 1); /*} while (!strstr(line, TABMAR)); fgets(line, MAXLENLINE, file);*/ } while (strncmp(line, " #", 2)); do { makeLower(line); if (strstr(line, "gfprint")) gfprn=TRUE; if (strstr(line, "nosymm")) strcpy(orientation, INPOR); else strcpy(orientation, STAOR); if (strstr(line, "opt")) opt=TRUE; if (strstr(line, "freq")) freq=TRUE; if (strstr(line, "hf")) { strcpy(emark[0], EHF); strcpy(emark[1], EUHF); nemark=2; } if (strstr(line, "scf")) { strcpy(emark[0], EHF); nemark=2; } if (strstr(line, "mp2")) { strcpy(emark[0], EMP2); strcpy(emark[1], EMPTWO); nemark=2; } if (strstr(line, "mp4")) { strcpy(emark[0], EMP4); nemark=1; } if (!strncmp(line, " #", 2)) { printf("$pople "); if (!strstr(line, "5d")) printf("6d "); else printf("5d "); if (!strstr(line, "7f")) printf("10f "); else printf("7f"); printf("\n"); } /* AdM added IF block for DFT overruling all previous stuff */ if (strstr(line, "lyp") || strstr(line, "pl") || strstr(line, "andh") || strstr(line, "hfb") || strstr(line, "xalpha") || strstr(line, "hfs") || strstr(line, "p86") || strstr(line, "vwn") || strstr(line, "pw91")) { strcpy(emark[0], EDFT); nemark=1; } if (fgets(line, MAXLENLINE, file) == NULL) eof("noCoordinates", argv[1], 1); makeLower(line); } while (!strstr(line, TABMAR)); /* Load Title */ /*rewind(file); int ntmar=0; while (ntmar != 3) { */ do { if (fgets(line, MAXLENLINE, file) == NULL) eof("noCoordinates", argv[1], 1); } while (!strstr(line, TABMAR)); /* ntmar++; } */ fgets(line, MAXLENLINE, file); printf("$title\n%s", line); /* Look whether molecule is linear or not */ do { if (fgets(line, MAXLENLINE, file) == NULL) eof("noCoordinates", argv[1], 1); makeLower(line); } while (!strstr(line, FRAME)); if (strstr(line, "C*V") || strstr(line, "D*H")) nout=5; else nout=6; strtok(line, " \t"); strtok(NULL, " \t"); word=strtok(NULL, " ["); printf("$symmetry %s\n", word); /* Load coordinates */ do { if (fgets(line, MAXLENLINE, file) == NULL) eof("noCoordinates", argv[1], 1); makeLower(line); } while (!strstr(line, orientation)); fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); na=0; ncent=0; if (!opt) printf("$coord 1.0\n"); xcoord=(double *)getmem(mna, sizeof(double)); ycoord=(double *)getmem(mna, sizeof(double)); zcoord=(double *)getmem(mna, sizeof(double)); symbol=(char *)getmem(mna, 3*sizeof(char)); while (fgets(line, MAXLENLINE, file) != NULL) { if (strstr(line, TABMAR)) break; ncent++; strtok(line, " \t"); nuc=atoi(strtok(NULL, " \t"))-1; word=strtok(NULL, " \t"); if (strchr(word, '.')) x=atof(word); else x=atof(strtok(NULL, " \t\n")); y=atof(strtok(NULL, " \t\n")); z=atof(strtok(NULL, " \t\n")); if (nuc >= 0) /* only for Z-ori ! */ { symbol[3*na]=pse[nuc][0]; symbol[3*na+1]=pse[nuc][1]; symbol[3*na+2]='\0'; xcoord[na]=x; ycoord[na]=y; zcoord[na]=z; if (!opt) printf("%22.14f%22.14f%22.14f %s\n", x, y, z, &symbol[3*na]); if (++na >= mna) { mna+=50; xcoord=(double *)expmem((void *)xcoord, mna, sizeof(double)); ycoord=(double *)expmem((void *)ycoord, mna, sizeof(double)); zcoord=(double *)expmem((void *)zcoord, mna, sizeof(double)); symbol=(char *)expmem((void *)symbol, mna, 3*sizeof(char)); } } } /* Load optimization history */ if (opt) cycle=readOpg(file, na, nemark, &emark[0][0], orientation); /* Load basis functions */ if (gfprn) { printf("$atoms\n"); for (i=0; i= maxpri) { maxpri+=20; ex=(double *)expmem((void *)ex, maxpri, sizeof(double)); scoeff=(double *)expmem((void *)scoeff, maxpri, sizeof(double)); pcoeff=(double *)expmem((void *)pcoeff, maxpri, sizeof(double)); dcoeff=(double *)expmem((void *)dcoeff, maxpri, sizeof(double)); fcoeff=(double *)expmem((void *)fcoeff, maxpri, sizeof(double)); } } if (shell[0] == '?') { if (scoeff[0] != 0.0) strcpy(shell, "S"); if (pcoeff[0] != 0.0) strcpy(shell, "P"); if (scoeff[0] != 0.0 && pcoeff[0] != 0.0) strcpy(shell, "SP"); if (dcoeff[0] != 0.0) strcpy(shell, "D"); if (fcoeff[0] != 0.0) strcpy(shell, "F"); } for (word=&shell[0]; *word; word++) { if (isalpha(*word)) { printf("%4d %c\n", i, tolower(*word)); for (j=0; j= mno) { mno+=20; symorb=(char *)expmem((void *)symorb, mno, 4*sizeof(char)); } } } norbital=i; } else { rewind(file); do { if (fgets(line, MAXLENLINE, file) == NULL) return; makeLower(line); } while (!strstr(line, "symmetry adapted basis")); while (strstr(line, "symmetry adapted basis")) { strtok(line, " \t"); strtok(NULL, " \t"); norbital+=atof(strtok(NULL, " \t")); fgets(line, MAXLENLINE, file); makeLower(line); } symorb=(char *)expmem((void *)symorb, norbital, 4*sizeof(char)); strcpy(closed, "A1 1-"); } rewind(file); do { if (fgets(line, MAXLENLINE, file) == NULL) return; makeLower(line); word=strstr(line, AMOS); if (word) cycle--; if (!word) { word=strstr(line, MOCOEFFICIENTS); if (word) info=COEFFICIENTS; } } while (!word || cycle > 0); printf("$scfmo gaussian\n"); eorb=(double *)getmem(norbital, sizeof(double)); cmo=(double *)getmem(mnc, sizeof(double)); fgets(line, MAXLENLINE, file); do { ie=0; strtok(line, " \t"); while (strtok(NULL, " \t") != NULL) ie++; ie++; fgets(line, MAXLENLINE, file); if (info == COEFFICIENTS) fgets(line, MAXLENLINE, file); strtok(line, " \t"); strtok(NULL, " \t"); for (i=ia; i 0.0 && nocc == 0) { sprintf(number, "%d", i+1); strcat(closed, number); nocc++; } } } k=0; for (j=0; j= mnc) { mnc+=200; cmo=(double *)expmem((void *)cmo, mnc, sizeof(double)); } word=strtok(NULL, " \t"); } } for (i=ia; i #include #include #include #include "viewmol.h" #include "dialog.h" extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern char *getStringResource(Widget, char *); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern void *getmem(size_t, size_t); extern Widget topShell; void readGrid(struct GRIDOBJECT *grid, FILE *file, char *line) { int data=FALSE, len=0, i=0; char *word, format[6]; strncpy(grid->symmetry, "A", 1); while ((fgets(line, MAXLENLINE, file)) != NULL) { if (strchr(line, '$')) return; if (strstr(line, "origin")) { (void)strtok(line, " \t"); grid->origin[0]=atof(strtok(NULL, " \t")); grid->origin[1]=atof(strtok(NULL, " \t")); grid->origin[2]=atof(strtok(NULL, " \t")); } if (strstr(line, "vector1")) { (void)strtok(line, " \t"); grid->vector1[0]=atof(strtok(NULL, " \t")); grid->vector1[1]=atof(strtok(NULL, " \t")); grid->vector1[2]=atof(strtok(NULL, " \t")); } if (strstr(line, "vector2")) { (void)strtok(line, " \t"); grid->vector2[0]=atof(strtok(NULL, " \t")); grid->vector2[1]=atof(strtok(NULL, " \t")); grid->vector2[2]=atof(strtok(NULL, " \t")); } if (strstr(line, "vector3")) { (void)strtok(line, " \t"); grid->vector3[0]=atof(strtok(NULL, " \t")); grid->vector3[1]=atof(strtok(NULL, " \t")); grid->vector3[2]=atof(strtok(NULL, " \t")); } if (strstr(line, "grid1")) { (void)strtok(line, " \t"); (void)strtok(NULL, " \t"); grid->start[0]=0.52917706*atof(strtok(NULL, " \t")); (void)strtok(NULL, " \t"); grid->step[0]=0.52917706*atof(strtok(NULL, " \t")); (void)strtok(NULL, " \t"); grid->ngridpoints[0]=(int)(atof(strtok(NULL, " \t")))-1; grid->npoints[0]=grid->ngridpoints[0]; } if (strstr(line, "grid2")) { (void)strtok(line, " \t"); (void)strtok(NULL, " \t"); grid->start[1]=0.52917706*atof(strtok(NULL, " \t")); (void)strtok(NULL, " \t"); grid->step[1]=0.52917706*atof(strtok(NULL, " \t")); (void)strtok(NULL, " \t"); grid->ngridpoints[1]=(int)(atof(strtok(NULL, " \t")))-1; grid->npoints[1]=grid->ngridpoints[1]; } if (strstr(line, "grid3")) { (void)strtok(line, " \t"); (void)strtok(NULL, " \t"); grid->start[2]=0.52917706*atof(strtok(NULL, " \t")); (void)strtok(NULL, " \t"); grid->step[2]=0.52917706*atof(strtok(NULL, " \t")); (void)strtok(NULL, " \t"); grid->ngridpoints[2]=(int)(atof(strtok(NULL, " \t")))-1; grid->npoints[2]=grid->ngridpoints[2]; } if (strstr(line, "title")) { word=fgets(line, MAXLENLINE, file); strncpy(grid->text, word, MAXLENLINE); } if (strstr(line, "type")) { (void)strtok(line, " \t"); word=strtok(NULL, " \t"); if (!strcmp(word, "mo")) { grid->type=GRIDREAD | MOLECULAR_ORBITAL; word=strtok(NULL, " \t"); sscanf(word, "%d%s", &(grid->mo), grid->symmetry); } else if (!strcmp(word, "density")) grid->type=GRIDREAD | DENSITY; } if (data) { while ((word=strchr(line, 'D')) != NULL) *word='E'; if ((word=strrchr(line, '\n')) != NULL) *word='\0'; word=line; if (len == 0) { len=strlen(line) > 76 ? 16 : 15; sprintf(format, "%%%.2dle", len); } while (sscanf(word, format, &grid->grid[i++]) != EOF) word+=len; i--; } if (strstr(line, "plotdata")) { data=TRUE; grid->grid=(double *)getmem((size_t)((grid->ngridpoints[0]+1)*(grid->ngridpoints[1]+1) *(grid->ngridpoints[2]+1)), sizeof(double)); grid->resolution=(double)grid->ngridpoints[0]; i=0; } } } void adjustMONumbers(struct MOLECULE *mol) { register int i, j; for (i=0; ingridobjects; i++) { for (j=0; jnbasfu; j++) { if (!strcmp(mol->gridObjects[i].symmetry, mol->orbitals[j].symmetry)) { if (--mol->gridObjects[i].mo == 0) { mol->gridObjects[i].mo=j; break; } } } } } viewmol-2.4.1/source/readmopac.c0100644000272700027270000003235010114367707014753 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * R E A D M O P A C . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: readmopac.c,v 1.5 2004/08/29 15:01:27 jrh Exp $ * $Log: readmopac.c,v $ * Revision 1.5 2004/08/29 15:01:27 jrh * Release 2.4.1 * * Revision 1.4 2003/11/07 11:14:38 jrh * Release 2.4 * * Revision 1.3 2000/12/10 15:15:38 jrh * Release 2.3 * * Revision 1.2 1999/05/24 01:27:21 jrh * Release 2.2.1 * * Revision 1.1 1999/02/07 21:56:01 jrh * Initial revision * */ #include #include #include #include #include #include #include "isotopes.h" #define MAXLENLINE 132 #define TRUE 1 #define FALSE 0 int main(int, char **); int fileLength(char *); int swapInt(int *); double swapDouble(double *); int passInt(int *); double passDouble(double *); void makeLower(char *line); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern void eof(char *, char *, int); int main(int argc, char **argv) { FILE *file; double (*getDouble)(double *); double x, y, z, *dp, *coord=NULL, *wn=NULL, *cnm=NULL; double *s, *p, *d, *mos=NULL, *e=NULL; int (*getInt)(int *); int *ip, dof=0, last, count=0, hasSymLabels=FALSE; int numat=0, norbs=0, nelecs=0, *nfirst=NULL, *nlast, *nat; int isVamp=FALSE; char line[MAXLENLINE], f[MAXLENLINE], *word, *buffer, *sym=NULL; register int i=0, j, k; if (argc != 2) eof("noFile", "", 1); strcpy(f, argv[1]); if ((word=strrchr(f, '.')) != NULL) { strcpy(word, ".gpt"); if ((k=fileLength(f)) > 0) { file=fopen(f, "r"); buffer=(char *)getmem((size_t)k, sizeof(char)); read(fileno(file), (void *)buffer, (size_t)k); fclose(file); ip=(int *)buffer; if (*ip > 1000000) { getInt=swapInt; getDouble=swapDouble; } else { getInt=passInt; getDouble=passDouble; } ip++; numat=(*getInt)(ip++); coord=(double *)getmem((size_t)(6*numat), sizeof(double)); s=coord+3*numat; p=s+numat; d=p+numat; nfirst=(int *)getmem((size_t)(3*numat), sizeof(int)); nlast=nfirst+numat; nat=nlast+numat; norbs=(*getInt)(ip++); nelecs=(*getInt)(ip++); dp=(double *)ip; for (i=0; i<3; i++) { for (j=0; j= 0) { strncpy(line, pse[nat[i]], 2); line[2]='\0'; printf("%s min\n*\n", line); printf(" 1 s\n%15.6f 1.0\n", s[i]); if (p[i] != 0.0) printf(" 1 p\n%15.6f 1.0\n", p[i]); if (d[i] != 0.0) printf(" 1 d\n%15.6f 1.0\n", d[i]); printf("*\n"); for (j=i+1; j")) fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); makeLower(line); if (strstr(line, "no. atom x y z")) { printf("$coord 1.0\n"); numat=0; fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); while (line[0] != '\n') { (void)strtok(line, " \t"); word=strtok(NULL, " \t"); x=atof(strtok(NULL, " \t")); y=atof(strtok(NULL, " \t")); z=atof(strtok(NULL, " \t")); printf("%22.14f%22.14f%22.14f %s\n", x, y, z, word); numat++; fgets(line, MAXLENLINE, file); } } else if (strstr(line, "no. atom x y z no. atom x y z") && numat == 0) { isVamp=TRUE; printf("$coord 1.0\n"); numat=0; fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); while (line[0] != '\n') { (void)strtok(line, " \t"); j=atoi(strtok(NULL, " \t"))-1; x=atof(strtok(NULL, " \t")); y=atof(strtok(NULL, " \t")); z=atof(strtok(NULL, " \t")); printf("%22.14f%22.14f%22.14f %s\n", x, y, z, pse[j]); numat++; if (strtok(NULL, " \t") != NULL) { j=atoi(strtok(NULL, " \t"))-1; x=atof(strtok(NULL, " \t")); y=atof(strtok(NULL, " \t")); z=atof(strtok(NULL, " \t")); printf("%22.14f%22.14f%22.14f %s\n", x, y, z, pse[j]); numat++; fgets(line, MAXLENLINE, file); } } } } /* if (strstr(line, "NO. OF DOUBLY OCCUPIED LEVELS") && norbs == 0) { norbs=2*atoi(&line[58]); } */ if (strstr(line, "********")) { count++; if (count == 4) { fgets(line, MAXLENLINE, file); do { fgets(line, MAXLENLINE, file); } while (strrchr(line, '+')); printf("$title\n%s", line); } } else if (strstr(line, "vibrations are the translation")) { line[14]='\0'; dof=3*numat-atoi(&line[13]); } else if (strstr(line, "translations and rotations (cm-1)")) { isVamp=TRUE; fgets(line, MAXLENLINE, file); while (!strstr(line, "Vibration Frequency Reduced I.R. Raman")) fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); printf("$vibrational spectrum\n"); dof=0; while (line[0] != '\n') { dof++; (void)strtok(line, " \t"); printf("%s ", strtok(NULL, " \t\n")); printf("%s ", strtok(NULL, " \t\n")); (void)strtok(NULL, " \t\n"); printf("%s ", strtok(NULL, " \t\n")); printf("%s\n", strtok(NULL, " \t\n")); fgets(line, MAXLENLINE, file); } } else if (strstr(line, "normal coordinate analysis")) { wn=(double *)getmem((size_t)dof, sizeof(double)); sym=(char *)getmem((size_t)dof, 8*sizeof(char)); cnm=(double *)getmem((size_t)(3*numat*dof), sizeof(double)); k=0; while (k < dof) { for (i=0; i<4; i++) { fgets(line, MAXLENLINE, file); if (line[0] == '1') fgets(line, MAXLENLINE, file); } fgets(line, MAXLENLINE, file); makeLower(line); if (strstr(line, "root no.")) hasSymLabels=FALSE; else hasSymLabels=TRUE; if (hasSymLabels) { j=k; word=&line[0]; while (strtok(word, " \t\n") != NULL) { if (j > dof) break; word=NULL; strncpy(&sym[8*j++], strtok(word, " \t\n"), 7); } } fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); word=&line[0]; last=k; while ((buffer=strtok(word, " \t")) != NULL) { if (k > dof) { k--; break; } if (!hasSymLabels) strcpy(&sym[8*k], "A1"); wn[k++]=atof(buffer); word=NULL; } last=k-last; fgets(line, MAXLENLINE, file); for (i=0; i<3*numat; i++) { fgets(line, MAXLENLINE, file); if (line[0] == '1' || line[0] == '\n') fgets(line, MAXLENLINE, file); word=strtok(line, " \t"); if (!isdigit(word[0])) { (void)strtok(NULL, " \t"); (void)strtok(NULL, " \t"); } for (j=0; j")) { if (norbs == 0) norbs=50; e=(double *)getmem((size_t)norbs, sizeof(double)); fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); i=0; while (line[0] != '\n') { word=strtok(line, " \t\n"); while (word != NULL) { e[i++]=atof(word); if (i >= norbs) { norbs+=50; e=(double *)expmem((void *)e, (size_t)norbs, sizeof(double)); } word=strtok(NULL, " \t\n"); } fgets(line, MAXLENLINE, file); } norbs=i; } else if (strstr(line, " eigenvectors")) { i=0; if (norbs == 0) norbs=50; e=(double *)getmem((size_t)norbs, sizeof(double)); fgets(line, MAXLENLINE, file); makeLower(line); buffer=NULL; while (!buffer) { while (strstr(line, "root no.") == NULL && (buffer=strstr(line, "net atomic charges")) == NULL) fgets(line, MAXLENLINE, file); if (!buffer) { fgets(line, MAXLENLINE, file); fgets(line, MAXLENLINE, file); word=strtok(line, " \t\n"); while (word != NULL) { e[i++]=atof(word); if (i >= norbs) { norbs+=50; e=(double *)expmem((void *)e, (size_t)norbs, sizeof(double)); } word=strtok(NULL, " \t\n"); } } } norbs=i; } } if (mos == NULL) k=0; else k=norbs; if (e != NULL) { printf("$scfmo\n"); for (i=0; i> 8) & (0x0000FF00)) | ((n >> 24) & (0x000000FF)) ); } */ /* find endianness int i = 1 ; little_endian = *((char *) &i ) ; */ } double swapDouble(double *dp) { char x, *cp; cp=(char *)dp; x=*(cp+7); *(cp+7)=*cp; *cp=x; x=*(cp+6); *(cp+6)=*(cp+1); *(cp+1)=x; x=*(cp+5); *(cp+5)=*(cp+2); *(cp+2)=x; x=*(cp+4); *(cp+4)=*(cp+3); *(cp+3)=x; return(*dp); } int passInt(int *ip) { return(*ip); } double passDouble(double *dp) { return(*dp); } void makeLower(char *line) { char *p=line; while (*p) { *p=tolower(*p); p++; } } viewmol-2.4.1/source/readpdb.c0100644000272700027270000001246707752677245014447 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * R E A D P D B . C * * * * Copyright (c) Joerg-R. Hill, Andrew Dalke, October 2003 * * * ******************************************************************************** * * $Id: readpdb.c,v 1.3 2003/11/07 11:14:45 jrh Exp $ * $Log: readpdb.c,v $ * Revision 1.3 2003/11/07 11:14:45 jrh * Release 2.4 * * Revision 1.2 2000/12/10 15:37:08 jrh * Release 2.3 * * Revision 1.1 1999/05/24 01:29:21 jrh * Initial revision * */ #include #include #include #include #define TRUE 1 #define FALSE 0 #define MAXLENLINE 132 int main(int, char **); int get_pdb_fields(char *, char *, char *, char *, char *, char *, char *, double *, double *, double *, double *, double *); void get_pdb_coordinates(char *, double *, double *, double *, double *, double *); extern void eof(char *, char *, int); int main(int argc, char **argv) { FILE *file; double x, y, z, occup, beta; int first=TRUE; char line[MAXLENLINE], *word; char name[5], resname[5], chain[2], segname[5], resid[5], insertion[2]; register int i; register char *p; if ((file=fopen(argv[1], "r")) == NULL) eof("noFile", argv[1], 1); while (fgets(line, MAXLENLINE, file) != NULL) { word=strtok(line, " \t"); if (!strcmp(word, "COMPND")) { if ((word=strstr(&line[7], "MOLECULE")) != NULL) { printf("$title\n"); word=strchr(word, ' ')+1; if ((p=strchr(word, ';')) != NULL) *p='\0'; printf("%s\n", word); } } else if (!strcmp(word, "ATOM") || !strcmp(word, "HETATM")) { (void)get_pdb_fields(line, name, resname, chain, segname, resid, insertion, &x, &y, &z, &occup, &beta); if (first) { printf("$coord 1.0\n"); first=FALSE; } printf("%22.14f %22.14f %22.14f %s\n", x, y, z, name); } else if (!strcmp(word, "CRYST1")) { printf("$unitcell "); i=0; while ((word=strtok(NULL, " \t")) != NULL && i < 6) { printf("%s ", word); i++; } printf("\n"); } } printf("$end\n"); fclose(file); exit(0); } int get_pdb_fields(char *record, char *name, char *resname, char *chain, char *segname, char *resid, char *insertion, double *x, double *y, double *z, double *occup, double *beta) { /* Break a pdb ATOM record into its fields. The user must provide the necessary space to store the atom name, residue name, and segment name. Character strings will be null-terminated. Returns the atom serial number. */ int i,len, num; /* get serial number */ if (record[6] >= 'A' && record[6] <= 'Z') { /* If there are too many atoms, XPLOR uses 99998, 99999, A0000, A0001, ... */ int base = ((int)(record[6] - 'A') + 10) * 100000; sscanf(record + 6, "%d", &num); num += base; } else { sscanf(record + 6,"%d",&num); } /* get atom name */ strncpy(name,record + 12, 2); name[2]='\0'; if (name[0] == ' ' || isdigit(name[0])) { name[0]=name[1]; name[1]='\0'; } name[1]=tolower(name[1]); /* get residue name */ strncpy(resname,record + 17, 4); resname[4] = '\0'; while((len = strlen(resname)) > 0 && resname[len-1] == ' ') resname[len-1] = '\0'; while(len > 0 && resname[0] == ' ') { for(i=0; i < len; i++) resname[i] = resname[i+1]; len--; } chain[0] = record[21]; chain[1] = 0; /* get residue id number */ strncpy(resid,record + 22, 4); resid[4] = '\0'; while((len = strlen(resid)) > 0 && resid[len-1] == ' ') resid[len-1] = '\0'; while(len > 0 && resid[0] == ' ') { for(i=0; i < len; i++) resid[i] = resid[i+1]; len--; } insertion[0] = record[26]; insertion[1] = 0; /* get x, y, and z coordinates */ get_pdb_coordinates(record, x, y, z, occup, beta); /* get segment name */ if(strlen(record) >= 73) { strncpy(segname, record + 72, 4); segname[4] = '\0'; while((len = strlen(segname)) > 0 && segname[len-1] == ' ') segname[len-1] = '\0'; while(len > 0 && segname[0] == ' ') { for(i=0; i < len; i++) segname[i] = segname[i+1]; len--; } } else { strcpy(segname,""); } return num; } void get_pdb_coordinates(char *record, double *x, double *y, double *z, double *occup, double *beta) { /* Extract the x,y, and z coordinates from the given ATOM record. */ char numstr[9]; /* get X, Y, and Z */ memset(numstr, 0, 9 * sizeof(char)); strncpy(numstr, record + 30, 8); *x = atof(numstr); memset(numstr, 0, 9 * sizeof(char)); strncpy(numstr, record + 38, 8); *y = atof(numstr); memset(numstr, 0, 9 * sizeof(char)); strncpy(numstr, record + 46, 8); *z = atof(numstr); memset(numstr, 0, 9 * sizeof(char)); strncpy(numstr, record + 54, 6); *occup = atof(numstr); memset(numstr, 0, 9 * sizeof(char)); strncpy(numstr, record + 60, 6); *beta = atof(numstr); } viewmol-2.4.1/source/redraw.c0100644000272700027270000000437007752677255014325 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * R E D R A W . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: redraw.c,v 1.6 2003/11/07 11:14:53 jrh Exp $ * $Log: redraw.c,v $ * Revision 1.6 2003/11/07 11:14:53 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:15:58 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:27:26 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:56:17 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:22 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:43:41 jrh * Initial revision * */ #include #include #include "viewmol.h" extern void showTitle(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void drawMolecule(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void drawSpectrum(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void drawMODiagram(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void drawHistory(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern struct MOLECULE *molecules; void redraw(int window) { switch (window) { case VIEWER: if (molecules == NULL) showTitle((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); else drawMolecule((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); break; case SPECTRUM: drawSpectrum((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); break; case MO: drawMODiagram((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); break; case HISTORY: drawHistory((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); break; } } viewmol-2.4.1/source/resource.c0100644000272700027270000000453607752677271014672 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * R E S O U R C E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: resource.c,v 1.6 2003/11/07 11:15:05 jrh Exp $ * $Log: resource.c,v $ * Revision 1.6 2003/11/07 11:15:05 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:16:06 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:27:30 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:56:26 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:25 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:43:46 jrh * Initial revision * */ #include #include #include int getIntResource(Widget widget, char *resource) /* get an integer from the resources */ { int ret; XtResource resource_description[1]; resource_description[0].resource_name=resource; resource_description[0].resource_class=XmCWidth; resource_description[0].resource_type=XmRInt; resource_description[0].resource_size=sizeof(int); resource_description[0].resource_offset=0; resource_description[0].default_type=XmRInt; resource_description[0].default_addr=NULL; XtGetApplicationResources(widget, &ret, resource_description, 1, NULL, 0); return(ret); } char *getStringResource(Widget widget, char *resource) /* get a string from the resources */ { char *ret; XtResource resource_description[1]; resource_description[0].resource_name=resource; resource_description[0].resource_class=XmCString; resource_description[0].resource_type=XmRString; resource_description[0].resource_size=sizeof(char *); resource_description[0].resource_offset=0; resource_description[0].default_type=XmRString; resource_description[0].default_addr=NULL; XtGetApplicationResources(widget, &ret, resource_description, 1, NULL, 0); return(ret); } viewmol-2.4.1/source/runprog.c0100644000272700027270000001020107752677276014526 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * R U N P R O G . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: runprog.c,v 1.6 2003/11/07 11:15:10 jrh Exp $ * $Log: runprog.c,v $ * Revision 1.6 2003/11/07 11:15:10 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:16:14 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:27:33 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:56:33 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:27 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:43:53 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #ifdef _HPUX_SOURCE #define PATH_MAX MAXPATHLEN #endif #define TRUE 1 #define FALSE 0 /* Prototypes */ int runProg(char *, int, char *, char *, char *, pid_t *); extern void *getmem(size_t, size_t); extern void fremem(void **); int runProg(char *command, int wait_for_child, char *input, char *output, char *error, pid_t *pid) { int status; char *argv[10]; register int i=0; if ((*pid=fork()) < 0) { fprintf(stderr, "ERROR: Unable to fork: "); perror(NULL); return(-1); } else if (*pid == 0) { if (input != NULL) freopen(input, "r", stdin); if (output != NULL) freopen(output, "w", stdout); if (error != NULL) freopen(error, "w", stderr); argv[i++]=strtok(command, " \t"); while ((argv[i++]=strtok(NULL, " \t")) != NULL); argv[i]=NULL; if (*command == '\0') exit(-1); if (execvp(command, argv)) { fprintf(stderr, "ERROR: Unable to execute %s:", argv[0]); perror(NULL); exit(-1); } } else { if (wait_for_child) { while((wait(&status)) != *pid); if (WIFEXITED(status) != 0) return(WEXITSTATUS(status)); } else return(0); } return(-1); } int checkFile(char **filename) { static char name1[PATH_MAX], name2[PATH_MAX]; char *c, *d, *env, *path, *opt; strcpy(name1, *filename); while ((c=strchr(name1, '$')) != NULL) { if (*(c+1) == '{') { d=strchr(c+1, '}'); *d='\0'; env=getenv(c+2); } else { d=strchr(c+1, '/'); *d='\0'; env=getenv(c+1); } *c='\0'; strcpy(name2, name1); if (env != NULL) strcat(name2, env); if (*(c+1) != '{') strcat(name2, "/"); strcat(name2, d+1); strcpy(name1, name2); } if ((opt=strchr(name1, ' ')) != NULL) *opt='\0'; if (access(name1, F_OK)) { env=getenv("PATH"); if (env == NULL) { *filename=NULL; return(FALSE); } path=(char *)getmem((size_t)strlen(env)+1, sizeof(char)); strcpy(path, env); c=strtok(path, ":"); strcpy(name2, c); strcat(name2, "/"); strcat(name2, name1); if (!access(name2, F_OK)) { *filename=name2; if (opt != NULL) { *opt=' '; strcat(name2, opt); } fremem((void **)&path); return(TRUE); } while ((c=strtok(NULL, ":")) != NULL) { strcpy(name2, c); strcat(name2, "/"); strcat(name2, name1); if (!access(name2, F_OK)) { *filename=name2; if (opt != NULL) { *opt=' '; strcat(name2, opt); } fremem((void **)&path); return(TRUE); } } *filename=NULL; fremem((void **)&path); return(FALSE); } else { *filename=name1; if (opt != NULL) *opt=' '; return(TRUE); } } viewmol-2.4.1/source/runscript.c0100644000272700027270000000457207752677321015070 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * R U N S C R I P T . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: runscript.c,v 1.2 2003/11/07 11:15:29 jrh Exp $ * $Log: runscript.c,v $ * Revision 1.2 2003/11/07 11:15:29 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:16:22 jrh * Initial revision * */ #include #include #include "viewmol.h" #include "dialog.h" extern char *selectFile(char *, char *, int); extern char *getStringResource(Widget, char *); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern Widget topShell; extern int pythonInterrupt; void runScript(Widget, caddr_t, XmAnyCallbackStruct *); void startModule(Widget, caddr_t, XmAnyCallbackStruct *); void runScript(Widget w, caddr_t data, XmAnyCallbackStruct *dummy) { FILE *file; static struct PushButtonRow buttons[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; static char *filename=""; char line[MAXLENLINE], *word; if ((char *)data == NULL) filename=selectFile("*.py", filename, TRUE); else filename=(char *)data; if (filename != NULL) { if ((file=fopen(filename, "r")) == NULL) { word=getStringResource(topShell, "noFile"); sprintf(line, word, filename); (void)messgb(topShell, 1, line, buttons, 1); } else { pythonInterrupt=FALSE; PyRun_SimpleFile(file, filename); fclose(file); } } } void startModule(Widget w, caddr_t data, XmAnyCallbackStruct *dummy) { char cmd[MAXLENLINE], number[4]; sprintf(number, "%2.2d", (int)data); strncpy(cmd, "module", MAXLENLINE-1); strncat(cmd, number, MAXLENLINE-strlen(cmd)); strncat(cmd, ".run()", MAXLENLINE-strlen(cmd)-strlen(number)); PyRun_SimpleString(cmd); } viewmol-2.4.1/source/save.c0100644000272700027270000005357207752677327014007 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * S A V E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: save.c,v 1.6 2003/11/07 11:15:35 jrh Exp $ * $Log: save.c,v $ * Revision 1.6 2003/11/07 11:15:35 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:16:29 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:27:35 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:56:49 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:30 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:43:57 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern char *selectFile(char *, char *, int); extern char *getStringResource(Widget, char *); extern int getIntResource(Widget, char *); extern void getRGBColor(Widget, Pixel, float *, float *, float *); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern int checkFile(char **); extern double bondLength(struct ATOM *, int, int); extern double bondAngle(struct ATOM *, int, int, int); extern double dist(double, double, double, double, double, double); extern double angle(double, double, double, double, double, double, double, double, double); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); void checkStringResource(char *, const char **, int, int, char **, int *); void checkIntResource(char *, int, char **, int *); void checkDoubleResource(char *, double, char **, int *); void checkWindowResource(struct WINDOW *, char *, char **, int *); void copyLanguageResources(char **, int *); extern struct MOLECULE *molecules; extern struct OPTION *output; extern struct WINDOW windows[]; extern double paperWidth, paperHeight; extern double sphereres, lineWidth, level, denres, hbondThreshold; extern int outputType, saveLanguage, automaticRecalculate, saveAll; extern int primitive, bondType, interp, simplify, nmolecule, thermoUnits; extern Widget topShell; extern char language[], webbrowser[], moloch[], raytracer[], displayImage[]; void saveMolecule(char *name) { static struct PushButtonRow buttons1[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}, {"cancel", GetMessageBoxButton, (XtPointer)1, NULL}}; static struct PushButtonRow buttons2[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; static char *filename="vm_coord"; struct MOLECULE *mol; FILE *file; double a2bohr=1.0/0.52917706; double a, b, c, alpha, beta, gamma; char *word, line[MAXLENLINE], command[MAXLENLINE]; const char *locale; int cell; register int i, j, k; if (name == NULL) filename=selectFile("*", filename, TRUE); else filename=name; if (filename != NULL) { if (!access(filename, F_OK)) { word=getStringResource(topShell, "FileExists"); sprintf(line, word, filename); if (messgb(topShell, 1, line, buttons1, 2) == 1) return; } strcpy(command, output[outputType].command); word=command; if (!(checkFile(&word))) { word=getStringResource(topShell, "noFile"); strtok(command, " \t"); sprintf(line, word, command); messgb(topShell, 3, line, buttons2, 1); return; } sprintf(line, word, filename); if ((file=popen(line, "w")) == NULL) { word=getStringResource(topShell, "cannotExecute"); sprintf(line, word, command); messgb(topShell, 3, line, buttons2, 1); return; } locale=setlocale(LC_ALL, "C"); if (windows[VIEWER].set >= 0) { mol=&molecules[windows[VIEWER].set]; if (mol->unitcell) { a=bondLength(mol->unitcell->corners, 0, 1); b=bondLength(mol->unitcell->corners, 0, 2); c=bondLength(mol->unitcell->corners, 0, 3); alpha=bondAngle(mol->unitcell->corners, 2, 0, 3); beta=bondAngle(mol->unitcell->corners, 1, 0, 3); gamma=bondAngle(mol->unitcell->corners, 1, 0, 2); fprintf(file, "$unitcell %10.6f %10.6f %10.6f %10.3f %10.3f %10.3f\n", a*a2bohr, b*a2bohr, c*a2bohr, alpha, beta, gamma); } fprintf(file, "$coord\n"); for (i=0; ina; i++) { if (!(mol->atoms[i].flags & DISPLAY_ONLY)) { if (saveAll || (mol->atoms[i].flags & SELECTED)) { fprintf(file, "%22.14f%22.14f%22.14f %s\n", (mol->atoms[i].x-mol->transx)*a2bohr, (mol->atoms[i].y-mol->transy)*a2bohr, (mol->atoms[i].z-mol->transz)*a2bohr, mol->atoms[i].name); } } } fprintf(file, "$bonds\n"); for (i=0; inb; i++) { if (!(mol->atoms[mol->bonds[i].first].flags & DISPLAY_ONLY) && !(mol->atoms[mol->bonds[i].second].flags & DISPLAY_ONLY)) { fprintf(file, "%d %d %d\n", mol->bonds[i].first+1, mol->bonds[i].second+1, mol->bonds[i].order); } } if (mol->nhist > 0) { fprintf(file, "$grad cartesian gradients\n"); for (i=0; inhist; i++) { fprintf(file, " cycle = %d SCF energy = %17.10f |dE/dxyz| = %9.6f\n", i+1, mol->optimization[i].energy, mol->optimization[i].gnorm); j=mol->optimization[i].coords; if (mol->unitcell) { /* a=dist(mol->history[j+n].x, mol->history[j+n].y, mol->history[j+n].z, mol->history[j+n+1].x, mol->history[j+n+1].y, mol->history[j+n+1].z); b=dist(mol->history[j+n].x, mol->history[j+n].y, mol->history[j+n].z, mol->history[j+n+2].x, mol->history[j+n+2].y, mol->history[j+n+2].z); c=dist(mol->history[j+n].x, mol->history[j+n].y, mol->history[j+n].z, mol->history[j+n+3].x, mol->history[j+n+3].y, mol->history[j+n+3].z); alpha=angle(mol->history[j+n+2].x, mol->history[j+n+2].y, mol->history[j+n+2].z, mol->history[j+n].x, mol->history[j+n].y, mol->history[j+n].z, mol->history[j+n+3].x, mol->history[j+n+3].y, mol->history[j+n+3].z); beta=angle(mol->history[j+n+1].x, mol->history[j+n+1].y, mol->history[j+n+1].z, mol->history[j+n].x, mol->history[j+n].y, mol->history[j+n].z, mol->history[j+n+3].x, mol->history[j+n+3].y, mol->history[j+n+3].z); gamma=angle(mol->history[j+n+1].x, mol->history[j+n+1].y, mol->history[j+n+1].z, mol->history[j+n].x, mol->history[j+n].y, mol->history[j+n].z, mol->history[j+n+2].x, mol->history[j+n+2].y, mol->history[j+n+2].z); */ fprintf(file, " unitcell %10.6f %10.6f %10.6f %10.3f %10.3f %10.3f\n", mol->unitcell[i+1].a*a2bohr, mol->unitcell[i+1].b*a2bohr, mol->unitcell[i+1].c*a2bohr, mol->unitcell[i+1].alpha, mol->unitcell[i+1].beta, mol->unitcell[i+1].gamma); } for (k=j; kna; k++) { if (!(mol->atoms[k-j].flags & DISPLAY_ONLY)) { if (saveAll || (mol->atoms[k-j].flags & SELECTED)) { fprintf(file, "%22.14f%22.14f%22.14f %s\n", mol->history[k].x*a2bohr, mol->history[k].y*a2bohr, mol->history[k].z*a2bohr, mol->atoms[k-j].name); } } } for (k=j; kna; k++) { if (!(mol->atoms[k-j].flags & DISPLAY_ONLY)) { if (saveAll || (mol->atoms[k-j].flags & SELECTED)) { fprintf(file, "%22.14f%22.14f%22.14f\n", mol->history[k].gx/a2bohr, mol->history[k].gy/a2bohr, mol->history[k].gz/a2bohr); } } } } } } else { cell=FALSE; for (i=0; iunitcell && !cell) { /* a=bondLength(mol->unitcell->corners, 0, 1); b=bondLength(mol->unitcell->corners, 0, 2); c=bondLength(mol->unitcell->corners, 0, 3); alpha=bondAngle(mol->unitcell->corners, 2, 0, 3); beta=bondAngle(mol->unitcell->corners, 1, 0, 3); gamma=bondAngle(mol->unitcell->corners, 1, 0, 2); */ fprintf(file, "$unitcell %10.6f %10.6f %10.6f %10.3f %10.3f %10.3f\n", mol->unitcell->a*a2bohr, mol->unitcell->b*a2bohr, mol->unitcell->c*a2bohr, mol->unitcell->alpha, mol->unitcell->beta, mol->unitcell->gamma); cell=TRUE; } if (i == 0) fprintf(file, "$coord\n"); for (j=0; jna; j++) fprintf(file, "%22.14f%22.14f%22.14f %s\n", (mol->atoms[j].x-mol->transx)*a2bohr, (mol->atoms[j].y-mol->transy)*a2bohr, (mol->atoms[j].z-mol->transz)*a2bohr, mol->atoms[j].name); } fprintf(file, "$bonds\n"); for (i=0; inb; j++) fprintf(file, "%d %d %d\n", mol->bonds[j].first+1, mol->bonds[j].second+1, mol->bonds[j].order); } } fprintf(file, "$end\n"); pclose(file); (void)setlocale(LC_ALL, locale); if (name == NULL) { word=getStringResource(topShell, "MoleculeSaved"); sprintf(line, word, filename); messgb(topShell, 0, line, buttons2, 1); } } } void saveConfiguration(void) { static struct PushButtonRow buttons[] = {{"continue", GetMessageBoxButton, (XtPointer)0, NULL}}; FILE *file, *tmp; const char *models[]={"wire", "stick", "ball", "cpk"}; const char *primitives[]={"dot", "line", "surface"}; const char *bondtypes[]={"single", "multiple", "conjugated"}; const char *simplifyrotation[]={"False", "True"}; const char *interpolation[]={"none", "linear", "logarithmic"}; const char *recalculate[]={"False", "True"}; const char *units[]={"joules", "calories", "thermochemical calories"}; const char *locale; char *paper[]={"A5", "A4", "A3", "Letter", "Legal", "100.0x100.0"}; int nconfig=0, paperSize; char *word, *config=NULL, *p; char *home, f[MAXLENLINE], line[MAXLENLINE]; char **str=(char **)&f; register int i, found; checkStringResource("model", models, 4, windows[VIEWER].mode, &config, &nconfig); checkStringResource("drawingMode", primitives, 3, primitive-GLU_POINT+1, &config, &nconfig); checkStringResource("bondType", bondtypes, 3, bondType, &config, &nconfig); checkStringResource("simplifyWhileRotating", simplifyrotation, 2, simplify+1, &config, &nconfig); checkStringResource("interpolation", interpolation, 3, interp, &config, &nconfig); checkStringResource("automaticRecalculation", recalculate, 2, automaticRecalculate+1, &config, &nconfig); if ((paperWidth == 210.2 && paperHeight == 148.6) || (paperWidth == 148.6 && paperHeight == 210.2)) paperSize=A5; else if ((paperWidth == 297.3 && paperHeight == 210.2) || (paperWidth == 210.2 && paperHeight == 297.3)) paperSize=A4; else if ((paperWidth == 420.4 && paperHeight == 297.3) || (paperWidth == 297.3 && paperHeight == 420.4)) paperSize=A3; else if ((paperWidth == 278.0 && paperHeight == 216.0) || (paperWidth == 216.0 && paperHeight == 278.0)) paperSize=LETTER; else if ((paperWidth == 356.0 && paperHeight == 216.0) || (paperWidth == 216.0 && paperHeight == 356.0)) paperSize=LEGAL; else { paperSize=USER; sprintf(paper[5], "%5.1fx%5.1f", paperWidth, paperHeight); } checkStringResource("paperSize", (const char **)paper, 6, paperSize, &config, &nconfig); *str=(char *)&webbrowser; checkStringResource("webBrowser", (const char **)str, 1, 1, &config, &nconfig); *str=(char *)&moloch; checkStringResource("Moloch", (const char **)str, 1, 1, &config, &nconfig); *str=(char *)&raytracer; checkStringResource("Raytracer", (const char **)str, 1, 1, &config, &nconfig); *str=(char *)&displayImage; checkStringResource("DisplayImage", (const char **)str, 1, 1, &config, &nconfig); checkIntResource("sphereResolution", (int)sphereres, &config, &nconfig); checkIntResource("lineWidth", (int)lineWidth, &config, &nconfig); checkDoubleResource("isosurface", level, &config, &nconfig); checkDoubleResource("densityResolution", denres, &config, &nconfig); checkDoubleResource("hydrogenBondThreshold", hbondThreshold, &config, &nconfig); checkStringResource("thermoUnits", units, 3, thermoUnits+1, &config, &nconfig); checkWindowResource(&windows[VIEWER], "viewer", &config, &nconfig); checkWindowResource(&windows[SPECTRUM], "spectrum", &config, &nconfig); checkWindowResource(&windows[HISTORY], "history", &config, &nconfig); checkWindowResource(&windows[MO], "MODiagram", &config, &nconfig); if (saveLanguage) copyLanguageResources(&config, &nconfig); locale=setlocale(LC_ALL, "C"); if ((home=getenv("HOME")) != NULL) { strcpy(f, home); strcat(f, "/.Xdefaults"); tmp=tmpfile(); if (!access(f, W_OK)) { file=fopen(f, "r"); while (fgets(line, MAXLENLINE, file) != NULL) { if (!strstr(line, "Viewmol")) fprintf(tmp, "%s", line); else { found=FALSE; p=config; for (i=0; iwidget != 0) { XtVaGetValues(window->widget, XmNbackground, &pixel, NULL); getRGBColor(window->widget, pixel, &r, &g, &b); if (r != window->background_rgb[0] || g != window->background_rgb[1] || b != window->background_rgb[2]) { (*nconfig)++; if (*config == NULL) { *config=(char *)getmem(*nconfig, MAXLENLINE*sizeof(char)); p=*config; } else { *config=(char *)expmem((void *)*config, *nconfig, MAXLENLINE*sizeof(char)); p=*config+((*nconfig)-1)*MAXLENLINE; } strcpy(p, "Viewmol."); strcat(p, resource); strcat(p, ".canvas.background: rgb:"); sprintf(line, "%4x/%4x/%4x\n", (int)(65535.*window->background_rgb[0]), (int)(65535.*window->background_rgb[1]), (int)(65535.*window->background_rgb[2])); strcat(p, line); } XtVaGetValues(window->widget, XmNforeground, &pixel, NULL); getRGBColor(window->widget, pixel, &r, &g, &b); if (r != window->foreground_rgb[0] || g != window->foreground_rgb[1] || b != window->foreground_rgb[2]) { (*nconfig)++; if (*config == NULL) { *config=(char *)getmem(*nconfig, MAXLENLINE*sizeof(char)); p=*config; } else { *config=(char *)expmem((void *)*config, *nconfig, MAXLENLINE*sizeof(char)); p=*config+((*nconfig)-1)*MAXLENLINE; } strcpy(p, "Viewmol."); strcat(p, resource); strcat(p, ".foreground: rgb:"); sprintf(line, "%4x/%4x/%4x\n", (int)(65535.*window->foreground_rgb[0]), (int)(65535.*window->foreground_rgb[1]), (int)(65535.*window->foreground_rgb[2])); strcat(p, line); } XGetWindowAttributes(XtDisplay(window->widget), XtWindow(window->widget), &attributes); XTranslateCoordinates(XtDisplay(window->widget), XtWindow(window->widget), attributes.root, -attributes.border_width, -attributes.border_width, &xw, &yw, &dummy); screen=XtScreen(window->widget); p=getStringResource(window->widget, "geometry"); which=XParseGeometry(p, &x, &y, &w, &h); if (which & XValue) { if (which & XNegative) x=WidthOfScreen(screen)-w+x; if (x != xw) update=TRUE; } if (which & YValue) { if (which & YNegative) y=HeightOfScreen(screen)-h+y; if (y != yw) update=TRUE; } if (which & WidthValue) if (w != attributes.width) update=TRUE; if (which & HeightValue) if (h != attributes.height) update=TRUE; if (update) { (*nconfig)++; if (*config == NULL) { *config=(char *)getmem(*nconfig, MAXLENLINE*sizeof(char)); p=*config; } else { *config=(char *)expmem((void *)*config, *nconfig, MAXLENLINE*sizeof(char)); p=*config+((*nconfig)-1)*MAXLENLINE; } strcpy(p, "Viewmol."); if (strcmp(resource, "viewer")) { strcat(p, resource); strcat(p, "."); } strcat(p, "geometry: "); sprintf(line, "%dx%d+%d+%d\n", attributes.width, attributes.height, xw, yw); strcat(p, line); } } } void copyLanguageResources(char **config, int *nconfig) { FILE *file; int copy=FALSE, mc, i; char filename[FILENAME_MAX], line[MAXLENLINE], *p; strcpy(filename, getenv("VIEWMOLPATH")); strcat(filename, "/locale/"); strcat(filename, language); strcat(filename, "/Viewmol"); if ((file=fopen(filename, "r")) != NULL) { mc=*nconfig; mc+=350; if (*config == NULL) { *config=(char *)getmem(mc, MAXLENLINE*sizeof(char)); p=*config; } else { *config=(char *)expmem((void *)*config, mc, MAXLENLINE*sizeof(char)); p=*config+(*nconfig)*MAXLENLINE; } i=*nconfig; while (fgets(line, MAXLENLINE, file) != NULL) { if (!strncmp(line, "Viewmol.language", 16)) copy=TRUE; if (copy) { strncpy(p, line, MAXLENLINE); if (++i >= mc) { mc+=50; *config=(char *)expmem((void *)*config, mc, MAXLENLINE*sizeof(char)); p=*config+i*MAXLENLINE; } else p+=MAXLENLINE; } } *nconfig+=i; fclose(file); } } viewmol-2.4.1/source/saveform.c0100644000272700027270000001131407752677336014657 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * S A V E F O R M . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: saveform.c,v 1.5 2003/11/07 11:15:42 jrh Exp $ * $Log: saveform.c,v $ * Revision 1.5 2003/11/07 11:15:42 jrh * Release 2.4 * * Revision 1.4 2000/12/10 15:16:38 jrh * Release 2.3 * * Revision 1.3 1999/05/24 01:27:37 jrh * Release 2.2.1 * * Revision 1.2 1999/02/07 21:56:55 jrh * Release 2.2 * * Revision 1.1 1998/01/26 00:35:25 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" void saveMoleculeExit(Widget, caddr_t, XmPushButtonCallbackStruct *); void GetOutputType(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void MapBox(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern Widget CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern Widget CreateToggleBox(Widget, struct PushButtonRow *, int, int, int, int, int); extern void saveMolecule(char *); extern void setMenuItem(int, int); extern void *getmem(size_t, size_t); extern void fremem(void **); extern Widget initShell(Widget, char *, Widget *, Widget *); extern struct WINDOW windows[]; extern struct OPTION *output; extern Widget topShell; extern int outputType, noutput, saveAll; static Widget dialog; static int outputType_save; void saveMoleculeDialog(Widget widget, caddr_t all, XmAnyCallbackStruct *data) { Widget form, board, form1, togglebox, sep; static struct PushButtonRow buttons[] = { { "ok", saveMoleculeExit, (XtPointer)TRUE, NULL }, { "cancel", saveMoleculeExit, (XtPointer)FALSE, NULL }, }; struct PushButtonRow *togglebox_buttons; register int i; /* This function creates the dialog for the "Save molecule" option */ if (all) saveAll=TRUE; else saveAll=FALSE; switch (noutput) { case 0: return; case 1: saveMolecule(NULL); break; default: setMenuItem(VIEWER1_SAVE, False); outputType_save=outputType; togglebox_buttons=(struct PushButtonRow *)getmem((size_t)noutput, sizeof(struct PushButtonRow)); for (i=0; iset) outputType=(int)which; } viewmol-2.4.1/source/scandir.c0100644000272700027270000000437407752677351014465 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * S C A N D I R . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: scandir.c,v 1.3 2003/11/07 11:15:53 jrh Exp $ * $Log: scandir.c,v $ * Revision 1.3 2003/11/07 11:15:53 jrh * Release 2.4 * * Revision 1.2 2000/12/10 15:37:02 jrh * Release 2.3 * * Revision 1.1 1999/05/24 01:29:43 jrh * Initial revision * */ #include #include #include #include /* This function is only required for SunOS, all other supported OS have this function in their system library */ int scandir(const char *dir, struct dirent ***namelist, int (*select)(const struct dirent *), int (*compar)(const struct dirent **, const struct dirent **)) { DIR *d; struct dirent *entry; register int i=0; size_t entrysize; if ((d=opendir(dir)) == NULL) return(-1); *namelist=NULL; while ((entry=readdir(d)) != NULL) { if (select == NULL || (select != NULL && (*select)(entry))) { *namelist=(struct dirent **)realloc((void *)(*namelist), (size_t)((i+1)*sizeof(struct dirent *))); if (*namelist == NULL) return(-1); entrysize=sizeof(struct dirent)-sizeof(entry->d_name)+strlen(entry->d_name)+1; (*namelist)[i]=(struct dirent *)malloc(entrysize); if ((*namelist)[i] == NULL) return(-1); memcpy((*namelist)[i], entry, entrysize); i++; } } if (closedir(d)) return(-1); if (i == 0) return(-1); if (compar != NULL) qsort((void *)(*namelist), (size_t)i, sizeof(struct dirent *), compar); return(i); } int alphasort(const struct dirent **a, const struct dirent **b) { return(strcmp((*a)->d_name, (*b)->d_name)); } viewmol-2.4.1/source/shadow.c0100644000272700027270000000257507752677370014331 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * S H A D O W . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: shadow.c,v 1.1 2003/11/07 11:16:08 jrh Exp $ * $Log: shadow.c,v $ * Revision 1.1 2003/11/07 11:16:08 jrh * Initial revision * */ #include #include "viewmol.h" int findShadowMapSupport(void) { const GLubyte *extensions=NULL; int hasTextureEnvCombine=FALSE, hasNVRegisterCombiners=FALSE; extensions=glGetString(GL_EXTENSIONS); if (strstr((char *)extensions, "GL_EXT_texture_env_combine")) hasTextureEnvCombine=TRUE; if (strstr((char *)extensions, "GL_NV_register_combiners")) hasNVRegisterCombiners=TRUE; if (hasTextureEnvCombine || hasNVRegisterCombiners) return(TRUE); else return(FALSE); } viewmol-2.4.1/source/specform.c0100644000272700027270000005377507752677402014666 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * S P E C F O R M . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: specform.c,v 1.6 2003/11/07 11:16:18 jrh Exp $ * $Log: specform.c,v $ * Revision 1.6 2003/11/07 11:16:18 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:16:52 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:27:39 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:57:03 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:33 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:44:01 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" void GetMode(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetAnimate(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetType(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetSlider(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); void GetAmplitude(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); void GetScale(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); void spectrumDialogExit(Widget, caddr_t, XmPushButtonCallbackStruct *); void GetIns(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetInsWeight(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetDouble(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetOption(Widget, caddr_t, XmToggleButtonCallbackStruct *); void GetLineWidth(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void MapBox(Widget, caddr_t, XmAnyCallbackStruct *); extern Widget CreateToggleBox(Widget, struct PushButtonRow *, int, int, int, int, int); extern char *getStringResource(Widget, char *); extern void CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern void setWindowTitle(Widget, char *); extern void redraw(int); extern void drawSpectrum(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void setAnimation(int); extern void restoreGeometry(struct SAVE *, int); extern void distortGeometry(double); extern void setMenuItem(int, int); extern int makeAnnotation(int, int, float, float, float, int, const GLfloat *, int, int, char *); extern void deleteAnnotation(int *); extern Widget initShell(Widget, char *, Widget *, Widget *); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern int animate, lines, setins, xIsTop, showGrid; extern int setinsAnnotation; extern double weight, temp, amplitude, wnScale, spectrumLineWidth; extern Widget topShell; extern Pixel stdcol[9]; static Widget dialog, insweight; static int mode_save, animate_save, lines_save, setins_save, xIsTop_save, showGrid_save; static double weight_save, temp_save, amplitude_save, wnScale_save, lineWidth_save; void spectrumDialog(Widget widget, caddr_t dummy, XmAnyCallbackStruct *data) { Widget board, form, form1, form2, form3, form4, form5; Widget radiobox1, radiobox2, radiobox3; Widget ins, slider1, slider2, slider3, temperature, ampl, scale; Widget axisTop, lineWidthLabel, lineWidthWidget, showGridWidget; Widget sep1, sep2, sep3, sep4, sep5, sep6; static struct SLIDER tempSlider, amplitudeSlider, scaleSlider; short decimals; char str[20]; static struct PushButtonRow buttons[] = { { "ok", spectrumDialogExit, (XtPointer)TRUE, NULL }, { "cancel", spectrumDialogExit, (XtPointer)FALSE, NULL } }; static struct PushButtonRow radiobox1_buttons[] = { { "all_modes", GetMode, (XtPointer)SPECTRUM_ALL, NULL }, { "ir_modes", GetMode, (XtPointer)SPECTRUM_IR, NULL }, { "raman_modes", GetMode, (XtPointer)SPECTRUM_RAMAN, NULL }, { "ins_modes", GetMode, (XtPointer)SPECTRUM_INS, NULL } }; static struct PushButtonRow radiobox2_buttons[] = { { "animate", GetAnimate, (XtPointer)ANIMATE, NULL }, { "draw_arrows", GetAnimate, (XtPointer)ARROWS, NULL }, { "distort", GetAnimate, (XtPointer)DISTORT, NULL } }; static struct PushButtonRow radiobox3_buttons[] = { { "line_spectrum", GetType, (XtPointer)TRUE, NULL }, { "gaussian_spectrum", GetType, (XtPointer)FALSE, NULL } }; /* This function creates the dialog for the spectrum window */ setMenuItem(SPECTRUM_SETTINGS, False); mode_save=windows[SPECTRUM].mode; animate_save=animate; lines_save=lines; setins_save=setins; weight_save=weight; temp_save=temp; amplitude_save=amplitude; wnScale_save=wnScale; xIsTop_save=xIsTop; showGrid_save=showGrid; lineWidth_save=spectrumLineWidth; dialog=initShell(windows[SPECTRUM].widget, "spectrumForm", &board, &form); /* Form1 is the row/column widget which organizes the toggle button boxes at the left and the sliders at the right */ form1=XtVaCreateWidget("controlarea1", xmRowColumnWidgetClass, form, XmNorientation, XmHORIZONTAL, NULL); /* Form2 is the container for the toggle button boxes */ form2=XtVaCreateWidget("controlarea2", xmFormWidgetClass, form1, NULL); sep1=XtVaCreateManagedWidget("sep1", xmSeparatorWidgetClass, form1, XmNorientation, XmVERTICAL, XmNtraversalOn, False, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, form2, NULL); /* Form3 is the container for the sliders */ form3=XtVaCreateWidget("controlarea3", xmFormWidgetClass, form1, NULL); radiobox1=CreateToggleBox(form2, radiobox1_buttons, XtNumber(radiobox1_buttons), XmVERTICAL, 1, True, windows[SPECTRUM].mode-1); XtVaSetValues(radiobox1, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); sep2=XtVaCreateManagedWidget("sep2", xmSeparatorWidgetClass, form2, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, radiobox1, XmNrightAttachment, XmATTACH_FORM, NULL); radiobox2=CreateToggleBox(form2, radiobox2_buttons, XtNumber(radiobox2_buttons), XmVERTICAL, 1, True, animate-1); XtVaSetValues(radiobox2, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, sep2, XmNrightAttachment, XmATTACH_FORM, NULL); sep3=XtVaCreateManagedWidget("sep3", xmSeparatorWidgetClass, form2, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, radiobox2, XmNrightAttachment, XmATTACH_FORM, NULL); radiobox3=CreateToggleBox(form2, radiobox3_buttons, XtNumber(radiobox3_buttons), XmVERTICAL, 1, True, lines ? 0 : 1); XtVaSetValues(radiobox3, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, sep3, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); temperature=XtVaCreateManagedWidget("temperature", xmLabelWidgetClass, form3, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, NULL); slider1=XtVaCreateManagedWidget("temperatureSlider", xmScaleWidgetClass, form3, XmNorientation, XmVERTICAL, XmNprocessingDirection, XmMAX_ON_BOTTOM, XmNvalue, (int)(temp), XmNminimum, 0, XmNmaximum, 1000, XmNshowValue, True, XmNsensitive, True, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, temperature, XmNbottomAttachment, XmATTACH_FORM, NULL); tempSlider.number=&temp; tempSlider.decimals=0; tempSlider.draw=(void (*)())drawSpectrum; XtAddCallback(slider1, XmNvalueChangedCallback, (XtCallbackProc)GetSlider, &tempSlider); XtAddCallback(slider1, XmNdragCallback, (XtCallbackProc)GetSlider, &tempSlider); ampl=XtVaCreateManagedWidget("amplitude", xmLabelWidgetClass, form3, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, temperature, XmNtopAttachment, XmATTACH_FORM, NULL); slider2=XtVaCreateManagedWidget("amplitudeSlider", xmScaleWidgetClass, form3, XmNorientation, XmVERTICAL, XmNprocessingDirection, XmMAX_ON_BOTTOM, XmNshowValue, True, XmNsensitive, True, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, temperature, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, ampl, XmNbottomAttachment, XmATTACH_FORM, NULL); XtVaGetValues(slider2, XmNdecimalPoints, &decimals, NULL); XtVaSetValues(slider2, XmNvalue, (int)(amplitude*pow((double)10.0, (double)decimals)/windows[VIEWER].top), NULL); amplitudeSlider.number=&litude; amplitudeSlider.decimals=decimals; amplitudeSlider.draw=NULL; XtAddCallback(slider2, XmNvalueChangedCallback, (XtCallbackProc)GetAmplitude, &litudeSlider); XtAddCallback(slider2, XmNdragCallback, (XtCallbackProc)GetAmplitude, &litudeSlider); scale=XtVaCreateManagedWidget("scale", xmLabelWidgetClass, form3, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, ampl, XmNtopAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); slider3=XtVaCreateManagedWidget("scaleSlider", xmScaleWidgetClass, form3, XmNorientation, XmVERTICAL, XmNprocessingDirection, XmMAX_ON_BOTTOM, XmNshowValue, True, XmNsensitive, True, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, ampl, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, scale, XmNbottomAttachment, XmATTACH_FORM, NULL); XtVaGetValues(slider3, XmNdecimalPoints, &decimals, NULL); XtVaSetValues(slider3, XmNvalue, (int)(wnScale*pow((double)10.0, (double)decimals)), NULL); scaleSlider.number=&wnScale; scaleSlider.decimals=decimals; scaleSlider.draw=NULL; XtAddCallback(slider3, XmNvalueChangedCallback, (XtCallbackProc)GetScale, &scaleSlider); XtAddCallback(slider3, XmNdragCallback, (XtCallbackProc)GetScale, &scaleSlider); sep4=XtVaCreateManagedWidget("sep4", xmSeparatorWidgetClass, form, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, form1, XmNrightAttachment, XmATTACH_FORM, NULL); form4=XtVaCreateWidget("controlarea4", xmFormWidgetClass, form, NULL); ins=XtVaCreateManagedWidget("setins", xmToggleButtonWidgetClass, form4, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); if (setins) XtVaSetValues(ins, XmNset, True, NULL); XtAddCallback(ins, XmNvalueChangedCallback, (XtCallbackProc)GetIns, &setins); sprintf(str, "%f", weight); insweight=XtVaCreateManagedWidget("insweight", xmTextWidgetClass, form4, XmNvalue, str, XmNcolumns, 8, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, ins, XmNtopAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); XtAddCallback(insweight, XmNvalueChangedCallback, (XtCallbackProc)GetInsWeight, NULL); if (!setins) XtVaSetValues(insweight, XmNsensitive, False, NULL); sep5=XtVaCreateManagedWidget("sep5", xmSeparatorWidgetClass, form, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, insweight, XmNrightAttachment, XmATTACH_FORM, NULL); form5=XtVaCreateWidget("controlarea5", xmFormWidgetClass, form, NULL); axisTop=XtVaCreateManagedWidget("axisTop", xmToggleButtonWidgetClass, form5, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); if (xIsTop) XtVaSetValues(axisTop, XmNset, True, NULL); XtAddCallback(axisTop, XmNvalueChangedCallback, (XtCallbackProc)GetOption, &xIsTop); showGridWidget=XtVaCreateManagedWidget("showGrid", xmToggleButtonWidgetClass, form5, XmNleftAttachment, XmATTACH_WIDGET, XmNleftWidget, axisTop, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); if (showGrid) XtVaSetValues(showGridWidget, XmNset, True, NULL); XtAddCallback(showGridWidget, XmNvalueChangedCallback, (XtCallbackProc)GetOption, &showGrid); sprintf(str, "%f", spectrumLineWidth); lineWidthWidget=XtVaCreateManagedWidget("lineWidth", xmTextWidgetClass, form5, XmNvalue, str, XmNcolumns, 4, XmNtopAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); XtAddCallback(lineWidthWidget, XmNvalueChangedCallback, (XtCallbackProc)GetLineWidth, NULL); lineWidthLabel=XtVaCreateManagedWidget("lineWidthLabel", xmLabelWidgetClass, form5, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, lineWidthWidget, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM, NULL); sep6=XtVaCreateManagedWidget("sep6", xmSeparatorWidgetClass, form, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, axisTop, XmNrightAttachment, XmATTACH_FORM, NULL); XtManageChild(form1); XtManageChild(form2); XtManageChild(form3); XtManageChild(form4); XtManageChild(form5); CreatePushButtonRow(form, buttons, 2); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XmAnyCallbackStruct *)NULL); XtManageChild(form); XtManageChild(board); } void GetMode(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { struct MOLECULE *mol; char t[7], *string, line[MAXLENLINE]; if (data->set) { windows[SPECTRUM].mode=(int)which; mol=&molecules[windows[SPECTRUM].set]; sprintf(t, "title%.1d", windows[SPECTRUM].mode); string=getStringResource(XtParent(windows[SPECTRUM].widget), t); sprintf(line, string, mol->title); setWindowTitle(windows[SPECTRUM].widget, line); if (mol->mode != -1) { if ((windows[SPECTRUM].mode == SPECTRUM_IR && mol->normal_modes[mol->mode].ir_intensity == 0.0) || (windows[SPECTRUM].mode == SPECTRUM_RAMAN && mol->normal_modes[mol->mode].raman_intensity == 0.0)) { mol->mode=(-1); if (animate == ANIMATE) setAnimation(FALSE); else restoreGeometry(mol->coord, windows[SPECTRUM].set); redraw(VIEWER); } } drawSpectrum((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); } } void GetAnimate(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { if (data->set) { animate=(int)which; if (animate == ANIMATE) setAnimation(animate); else { setAnimation(FALSE); if (animate == DISTORT) distortGeometry(amplitude); } redraw(VIEWER); } } void GetType(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { if (data->set) { if ((int)which) lines=TRUE; else lines=FALSE; drawSpectrum((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); } } void GetAmplitude(Widget button, struct SLIDER *slider, XmScrollBarCallbackStruct *data) { *(slider->number)=(double)(data->value)*windows[VIEWER].top/pow((double)10.0, (double)slider->decimals); restoreGeometry(molecules[windows[SPECTRUM].set].coord, windows[SPECTRUM].set); if (animate == DISTORT) distortGeometry(amplitude); redraw(VIEWER); } void GetScale(Widget button, struct SLIDER *slider, XmScrollBarCallbackStruct *data) { *(slider->number)=(double)(data->value)/pow((double)10.0, (double)slider->decimals); redraw(SPECTRUM); redraw(VIEWER); } void GetIns(Widget button, caddr_t dest, XmToggleButtonCallbackStruct *data) { const GLfloat black[4] = {0.0, 0.0, 0.0, 0.0}; char line[MAXLENLINE], *word; if (data->set) { *(int *)dest=TRUE; XtVaSetValues(insweight, XmNsensitive, True, NULL); word=getStringResource(topShell, "selectINSTitle"); sprintf(line, word, weight); setinsAnnotation=makeAnnotation(setinsAnnotation, CENTERED, 0.0, 1.0, 0.0, stdcol[BLACK], black, 0, 0, line); } else { *(int *)dest=FALSE; XtVaSetValues(insweight, XmNsensitive, False, NULL); deleteAnnotation(&setinsAnnotation); } redraw(VIEWER); } void GetInsWeight(Widget button, caddr_t dummy, XmToggleButtonCallbackStruct *data) { const GLfloat black[4] = {0.0, 0.0, 0.0, 0.0}; char line[MAXLENLINE], *word; GetDouble(button, (caddr_t)&weight, data); word=getStringResource(topShell, "selectINSTitle"); sprintf(line, word, weight); setinsAnnotation=makeAnnotation(setinsAnnotation, CENTERED, 0.0, 1.0, 0.0, stdcol[BLACK], black, 0, 0, line); redraw(VIEWER); } void GetOption(Widget button, caddr_t dest, XmToggleButtonCallbackStruct *data) { if (data->set) *(int *)dest=TRUE; else *(int *)dest=FALSE; redraw(SPECTRUM); } void GetLineWidth(Widget field, caddr_t dummy, XmToggleButtonCallbackStruct *data) { GetDouble(field, (caddr_t)&spectrumLineWidth, data); redraw(SPECTRUM); } void GetDouble(Widget button, caddr_t dest, XmToggleButtonCallbackStruct *data) { char *str; str=XmTextGetString(button); *(double *)dest=atof(str); } void spectrumDialogExit(Widget button, caddr_t which, XmPushButtonCallbackStruct *data) { char t[7], *string, line[MAXLENLINE]; if (!(int)which) { windows[SPECTRUM].mode=mode_save; animate=animate_save; lines=lines_save; setins=setins_save; weight=weight_save; temp=temp_save; amplitude=amplitude_save; wnScale=wnScale_save; xIsTop=xIsTop_save; showGrid=showGrid_save; spectrumLineWidth=lineWidth_save; deleteAnnotation(&setinsAnnotation); restoreGeometry(molecules[windows[SPECTRUM].set].coord, windows[SPECTRUM].set); sprintf(t, "title%.1d", windows[SPECTRUM].mode); string=getStringResource(XtParent(windows[SPECTRUM].widget), t); sprintf(line, string, molecules[windows[SPECTRUM].set].title); setWindowTitle(windows[SPECTRUM].widget, line); } XtDestroyWidget(dialog); setMenuItem(SPECTRUM_SETTINGS, True); redraw(SPECTRUM); redraw(VIEWER); } viewmol-2.4.1/source/spectrummodule.c0100644000272700027270000003030607752677413016103 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * S P E C T R U M M O D U L E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: spectrummodule.c,v 1.2 2003/11/07 11:16:27 jrh Exp $ * $Log: spectrummodule.c,v $ * Revision 1.2 2003/11/07 11:16:27 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:17:03 jrh * Initial revision * */ #include #include #include #include #include "viewmol.h" #define PySpectrum_API_pointers 1 #define PySpectrumSpec_Type_NUM 0 extern void initSpectrum(Widget, caddr_t, caddr_t); extern void setAnimation(int); extern void GetMode(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void GetAnimate(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void GetType(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void saveZoom(int); extern void setMenuItem(int, int); extern void selectMolecule(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void redraw(int); extern void saveDrawing(int, int, char *); extern void drawSpectrum(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void quitSpectrum(Widget, caddr_t, XmAnyCallbackStruct *); extern void annotateNormalMode(struct MOLECULE *); extern int checkInterrupt(void); PySpectrumSpecObject *spectrum_new(void); static PyObject *spectrum_show(PyObject *, PyObject *); /*static PyObject *spectrum_hide(PyObject *, PyObject *);*/ static PyObject *spectrum_mode(PyObject *, PyObject *); static PyObject *spectrum_deselect(PyObject *, PyObject *); static PyObject *spectrum_type(PyObject *, PyObject *); static PyObject *spectrum_display(PyObject *, PyObject *); static PyObject *spectrum_style(PyObject *, PyObject *); static PyObject *spectrum_amplitude(PyObject *, PyObject *); static PyObject *spectrum_scaleFactor(PyObject *, PyObject *); static PyObject *spectrum_zoom(PyObject *, PyObject *); static PyObject *spectrum_saveDrawing(PyObject *, PyObject *); static PyObject *spectrum_getattr(PySpectrumSpecObject *, char *); static void spectrum_dealloc(PySpectrumSpecObject *); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern double amplitude, wnScale; extern int nmolecule, animate, lines; static char PySpectrumSpec_Type__doc__[] = "Spectrum specification"; statichere PyTypeObject PySpectrumSpec_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "SpectrumSpec", /*tp_name*/ sizeof(PySpectrumSpecObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)spectrum_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)spectrum_getattr, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ /* Space for future expansion */ 0L,0L, /* Documentation string */ PySpectrumSpec_Type__doc__ }; static PyMethodDef spectrum_methods[] = { {"show", spectrum_show, 1}, /*{"hide", spectrum_hide, 1},*/ {"mode", spectrum_mode, 1}, {"deselect", spectrum_deselect, 1}, {"type", spectrum_type, 1}, {"display", spectrum_display, 1}, {"style", spectrum_style, 1}, {"amplitude", spectrum_amplitude, 1}, {"scaleFactor", spectrum_scaleFactor, 1}, {"zoom", spectrum_zoom, 1}, {"saveDrawing", spectrum_saveDrawing, 1}, {NULL, NULL} }; PySpectrumSpecObject *spectrum_new(void) { PySpectrumSpecObject *self; self=PyObject_NEW(PySpectrumSpecObject, &PySpectrumSpec_Type); if (self == NULL) { PyErr_NoMemory(); return(NULL); } self->spectrumID=0; return(self); } static PyObject *spectrum_show(PyObject *self, PyObject *args) { PySpectrumSpecObject *s; XmToggleButtonCallbackStruct data; int which, set_save; if (checkInterrupt()) return(NULL); if (!self) { Py_INCREF(Py_None); return(Py_None); } s=(PySpectrumSpecObject *)self; which=s->spectrumID; if (windows[SPECTRUM].widget == NULL) { set_save=windows[VIEWER].set; windows[VIEWER].set=which; initSpectrum((Widget)0, (caddr_t)0, (caddr_t)0); drawSpectrum((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); windows[VIEWER].set=set_save; } else { windows[SPECTRUM].set=which; if (nmolecule > 1) { data.set=TRUE; (void)selectMolecule((Widget)0, (XtPointer)&(windows[SPECTRUM].selectMenu[which]), &data); } redraw(SPECTRUM); } Py_INCREF(Py_None); return(Py_None); } /* static PyObject *spectrum_hide(PyObject *self, PyObject *args) { quitSpectrum((Widget)0, (caddr_t)0, (XmAnyCallbackStruct *)0); Py_INCREF(Py_None); return(Py_None); } */ static PyObject *spectrum_mode(PyObject *self, PyObject *args) { PySpectrumSpecObject *s; int which, mode=(-1); if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|i", &mode)) return(NULL); s=(PySpectrumSpecObject *)self; which=s->spectrumID; if (mode == -1) /* get */ return(PyInt_FromLong((long)molecules[which].mode+1)); else /* set */ { if (mode > 0 && mode <= molecules[which].nmodes) { molecules[which].mode=mode; annotateNormalMode(&molecules[which]); redraw(SPECTRUM); if (animate == ANIMATE) setAnimation(animate); } else { PyErr_SetString(PyExc_ValueError, "Mode out of range"); return(NULL); } Py_INCREF(Py_None); return(Py_None); } } static PyObject *spectrum_deselect(PyObject *self, PyObject *args) { PySpectrumSpecObject *s; int which; if (checkInterrupt()) return(NULL); s=(PySpectrumSpecObject *)self; which=s->spectrumID; molecules[which].mode=(-1); annotateNormalMode(&molecules[which]); redraw(SPECTRUM); Py_INCREF(Py_None); return(Py_None); } static PyObject *spectrum_type(PyObject *self, PyObject *args) { XmToggleButtonCallbackStruct data; PySpectrumSpecObject *s; int which, set_save, type=(-1); if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|i", &type)) return(NULL); s=(PySpectrumSpecObject *)self; which=s->spectrumID; if (type == -1) return(PyInt_FromLong((long)windows[SPECTRUM].mode)); else { if (type != SPECTRUM_ALL && type != SPECTRUM_IR && type != SPECTRUM_RAMAN && type != SPECTRUM_INS) { PyErr_SetString(PyExc_ValueError, "Type is unknown"); return(NULL); } data.set=TRUE; set_save=windows[SPECTRUM].set; windows[SPECTRUM].set=which; GetMode((Widget)0, (caddr_t)type, &data); windows[SPECTRUM].set=set_save; redraw(SPECTRUM); Py_INCREF(Py_None); return(Py_None); } } static PyObject *spectrum_display(PyObject *self, PyObject *args) { XmToggleButtonCallbackStruct data; PySpectrumSpecObject *s; int which, display=(-1); if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|i", &display)) return(NULL); s=(PySpectrumSpecObject *)self; which=s->spectrumID; if (display == -1) return(PyInt_FromLong((long)animate)); else { if (display != ANIMATE && display != ARROWS && display != DISTORT) { PyErr_SetString(PyExc_ValueError, "Type is unknown"); return(NULL); } data.set=TRUE; GetAnimate((Widget)0, (caddr_t)display, &data); redraw(SPECTRUM); Py_INCREF(Py_None); return(Py_None); } } static PyObject *spectrum_style(PyObject *self, PyObject *args) { XmToggleButtonCallbackStruct data; PySpectrumSpecObject *s; int which, style=(-1); if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|i", &style)) return(NULL); s=(PySpectrumSpecObject *)self; which=s->spectrumID; if (style == (-1)) return(PyInt_FromLong((long)lines)); else { if (style != TRUE && style != FALSE) { PyErr_SetString(PyExc_ValueError, "Style is unknown"); return(NULL); } data.set=TRUE; GetType((Widget)0, (caddr_t)style, &data); redraw(SPECTRUM); Py_INCREF(Py_None); return(Py_None); } } static PyObject *spectrum_amplitude(PyObject *self, PyObject *args) { double a=400.0e0; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|d", &a)) return(NULL); if (a == 400.0e0) return(PyFloat_FromDouble(amplitude/windows[VIEWER].top)); else { amplitude=a*windows[VIEWER].top; redraw(SPECTRUM); Py_INCREF(Py_None); return(Py_None); } } static PyObject *spectrum_scaleFactor(PyObject *self, PyObject *args) { double sf=(-1.0e0); if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|d", &sf)) return(NULL); if (sf == -1.0e0) return(PyFloat_FromDouble(wnScale)); else { wnScale=sf; redraw(SPECTRUM); Py_INCREF(Py_None); return(Py_None); } } static PyObject *spectrum_zoom(PyObject *self, PyObject *args) { double x1, x2, y1, y2; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "dddd", &x1, &y1, &x2, &y2)) return(NULL); if (x1 == x2 || y1 == y2) { PyErr_SetString(PyExc_ValueError, "x1 and x2 as well as y1 and y2 have to be different"); return(NULL); } saveZoom(SPECTRUM); windows[SPECTRUM].left=x1; windows[SPECTRUM].right=x2; windows[SPECTRUM].top=y1; windows[SPECTRUM].bottom=y2; setMenuItem(SPECTRUM_ZOOMOUT, True); redraw(SPECTRUM); Py_INCREF(Py_None); return(Py_None); } static PyObject *spectrum_saveDrawing(PyObject *self, PyObject *args) { int format; char *filename; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "is", &format, &filename)) return NULL; if (!access(filename, F_OK)) { PyErr_SetString(PyExc_IOError, "File already exists."); return(NULL); } if (format != TIFFFILE && format != PNGFILE && format != HPGL && format != POSTSCRIPT) { PyErr_SetString(PyExc_ValueError, "Format not recognised."); return(NULL); } saveDrawing(SPECTRUM, format, filename); Py_INCREF(Py_None); return(Py_None); } static void spectrum_dealloc(PySpectrumSpecObject *self) { if (!self) return; PyMem_DEL(self); quitSpectrum((Widget)0, (caddr_t)0, (XmAnyCallbackStruct *)0); (void)checkInterrupt(); } static PyObject *spectrum_getattr(PySpectrumSpecObject *self, char *name) { return(Py_FindMethod(spectrum_methods, (PyObject *)self, name)); } void initSpectrumModule(void) { PyObject *module, *dict; static void *PySpectrum_API[PySpectrum_API_pointers]; PySpectrumSpec_Type.ob_type=&PyType_Type; module=Py_InitModule("spectrum", spectrum_methods); dict=PyModule_GetDict(module); PySpectrum_API[PySpectrumSpec_Type_NUM]=(void *)&PySpectrumSpec_Type; PyDict_SetItemString(dict, "_C_API", PyCObject_FromVoidPtr((void *)PySpectrum_API, NULL)); PyDict_SetItemString(dict, "ALLMODES", PyInt_FromLong(SPECTRUM_ALL)); PyDict_SetItemString(dict, "IRMODES", PyInt_FromLong(SPECTRUM_IR)); PyDict_SetItemString(dict, "RAMANMODES", PyInt_FromLong(SPECTRUM_RAMAN)); PyDict_SetItemString(dict, "INSMODES", PyInt_FromLong(SPECTRUM_INS)); PyDict_SetItemString(dict, "ANIMATE", PyInt_FromLong(ANIMATE)); PyDict_SetItemString(dict, "ARROWS", PyInt_FromLong(ARROWS)); PyDict_SetItemString(dict, "DISTORT", PyInt_FromLong(DISTORT)); PyDict_SetItemString(dict, "LINES", PyInt_FromLong(TRUE)); PyDict_SetItemString(dict, "GAUSSIANS", PyInt_FromLong(FALSE)); } viewmol-2.4.1/source/texture.h0100644000272700027270000001017507752712430014527 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * T E X T U R E . H * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: texture.h,v 1.2 2003/11/07 12:50:32 jrh Exp $ * $Log: texture.h,v $ * Revision 1.2 2003/11/07 12:50:32 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:17:28 jrh * Initial revision * */ #define texture_width 64 #define texture_height 64 static unsigned char texture_bits[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; viewmol-2.4.1/source/thermo.c0100644000272700027270000004157707752677434014350 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * T H E R M O . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: thermo.c,v 1.3 2003/11/07 11:16:44 jrh Exp $ * $Log: thermo.c,v $ * Revision 1.3 2003/11/07 11:16:44 jrh * Release 2.4 * * Revision 1.2 2000/12/10 15:37:13 jrh * Release 2.3 * * Revision 1.1 1999/05/24 01:29:53 jrh * Initial revision * */ #include #include #include #include #include #include "viewmol.h" #define AVOGADRO 6.022045e23 extern void balanceDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern int checkReaction(void); extern char *getStringResource(Widget, char *); extern void *getmem(size_t, size_t); extern void fremem(void **); void thermo(struct MOLECULE *); int reaction(int, int *); double getMass(struct MOLECULE *); double getVolume(struct MOLECULE *); double getDensity(struct MOLECULE *mol); int isLinear(struct MOLECULE *); double getSymmetryNumber(struct MOLECULE *); void getSumFormula(struct MOLECULE *, char *, int); void printCoefficients(char *, double *, char *, int, int); extern Widget topShell; extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern double temp, pressure; extern int nmolecule, ne, debug; void thermo(struct MOLECULE *mol) { const double N=6.022169e23, k=1.380622e-23; const double h=6.626196e-34, c=2.997925e10; double R=k*N, pi=4.0*atan(1.0), RT=R*temp; double sigma, hc, u=0.0, r, s; register int i; /* Translation */ mol->htrl=1.5*RT; if (mol->unitcell) mol->pv=AVOGADRO*pressure*1e-30*getVolume(mol)*101325.0; else mol->pv=RT; mol->ctrl=2.5*R; if (temp > 0.0) /* mol->strl=R*(2.5+1.5*log(2.0*pi*k/(h*h))+log(k)+1.5*log(getMass(mol))+2.5*log(temp)-log(pressure)); mol->strl=R*(2.5+1.5*log(2.0*pi*k*1.0e7/N)+log(k/(1.0e20*h*h*h))+1.5*log(getMass(mol))+2.5*log(temp)-log(pressure)); */ mol->strl=R*(2.5*log(temp)+1.5*log(getMass(mol))-log(pressure))-2.31482*4.184; else mol->strl=0.0; /* Rotation */ mol->hrot=0.0; mol->srot=0.0; mol->crot=0.0; mol->cvib=0.0; mol->hvib=0.0; mol->svib=0.0; if (mol->na > 1) { sigma=getSymmetryNumber(mol); if (isLinear(mol)) { mol->hrot=RT; mol->crot=R; for (i=0; i<3; i++) { if (mol->rotConstants[i] != 0.0) { if (temp > 0.0) mol->srot=R*log(k*temp/(sigma*h*mol->rotConstants[i]))+R; else mol->srot=R; break; } } } else { mol->hrot=1.5*RT; mol->crot=1.5*R; if (temp > 0.0) mol->srot=0.5*R*log(pi*k*k*k*temp*temp*temp/(sigma*sigma*h*h*h *c*c*c*mol->rotConstants[0]*mol->rotConstants[1] *mol->rotConstants[2]))+1.5*R; else mol->srot=1.5*R; } /* Vibration */ hc=h*c; for (i=0; inmodes; i++) { if (mol->normal_modes[i].wavenumber < 10.0) continue; if (temp > 0.0) { u=hc*mol->normal_modes[i].wavenumber/(k*temp); r=exp(-u); } else r=0.0; s=1.0/(1.0-r); mol->cvib+=u*u*r*s*s; mol->hvib+=hc*mol->normal_modes[i].wavenumber*(r*s+0.5); mol->svib+=u*r*s-log(1.0/s); } mol->cvib*=R; mol->hvib*=N; mol->svib*=R; } if (debug) { printf(" C/[J/mol] H/[J/mol] S[J/(mol K)]\n"); printf("Translation %12.6f %12.6f %12.6f\n", mol->ctrl, mol->htrl, mol->strl); printf("Rotation %12.6f %12.6f %12.6f\n", mol->crot, mol->hrot, mol->srot); printf("Vibration %12.6f %12.6f %12.6f\n", mol->cvib, mol->hvib, mol->svib); } } int reaction(int which, int *nreactions) { struct MOLECULE *mol; double *matrix, *c, *denom, x; int nelem, nmol, found=FALSE, notInt, ret, type=0, *molIndex; char *elements; register int i, j, k; for (i=0; istoichioNumber=(-1); for (j=0; jna; j++) { found=FALSE; for (k=0; katoms[j].element->symbol)) { found=TRUE; matrix[nmol*ne+k]+=(double)(mol->reaction); } } if (!found) { strcpy(&elements[4*nelem], mol->atoms[j].element->symbol); matrix[nmol*ne+nelem]=(double)(mol->reaction); nelem++; } } nmol++; } else mol->stoichioNumber=0; } for (i=0; istoichioNumber=1; for (j=0; jna; j++) { found=FALSE; for (k=0; katoms[j].element->symbol)) { found=TRUE; if (mol->reaction == PRODUCT) matrix[nmol*ne+k]+=(double)(mol->reaction); else matrix[nmol*ne+k]+=1.0; } } if (!found) { strcpy(&elements[4*nelem], mol->atoms[j].element->symbol); if (mol->reaction == PRODUCT) matrix[nmol*ne+nelem]=(double)(mol->reaction); else matrix[nmol*ne+nelem]=1.0; nelem++; } } nmol++; } } if (type != ALLREACTIONS) { for (i=0; i 0) k=TRUE; } if (!found || !k) { fremem((void *)&elements); fremem((void *)&matrix); return(MISSING_ATOMS); } } } if (debug) printCoefficients("Start coefficients", matrix, elements, nelem, FALSE); ret=REACTION_OK; for (i=0; i i) { /* diagonal element is zero, try to find another row */ /* where this is not the case, then swap the two rows */ found=FALSE; for (j=i+1; j=i; k--) matrix[k*ne+j]-=matrix[k*ne+i]*matrix[i*ne+j]; } /* if (debug) printCoefficients("Iteration", matrix, elements, nelem, FALSE); */ } c=(double *)getmem((size_t)nmol, sizeof(double)); if (type == ALLREACTIONS) { *nreactions=nmol-nelem; *nreactions=*nreactions > 0 ? *nreactions : 1; for (j=0; j 1.0e-6) { notInt=TRUE; break; } } if (notInt) { denom=(double *)getmem((size_t)nmol, sizeof(double)); for (i=0; i 1.0) break; } for (j=0; j 0) || (molecules[i].reaction == PRODUCT && molecules[i].stoichioNumber < 0)) { ret=CANT_BALANCE; break; } } } if (debug) printCoefficients("Resulting coefficients", matrix, elements, nelem, TRUE); fremem((void **)&c); fremem((void **)&molIndex); fremem((void *)&elements); fremem((void *)&matrix); /*if (ret == CANT_BALANCE && type != ALLREACTIONS) */ if (type != ALLREACTIONS && !checkReaction()) { balanceDialog((Widget)0, (caddr_t)0, (XmAnyCallbackStruct *)0); ret=REACTION_OK; } return(ret); } int isLinear(struct MOLECULE *mol) { if (mol->rotConstants[0] == 0.0 || mol->rotConstants[1] == 0.0 || mol->rotConstants[2] == 0.0) return(TRUE); else return(FALSE); } double getSymmetryNumber(struct MOLECULE *mol) { if (!strcmp(mol->pgroup, "c1") || !strcmp(mol->pgroup, "cs") || !strcmp(mol->pgroup, "ci") || !strcmp(mol->pgroup, "c*v")) return(1.0); if (!strcmp(mol->pgroup, "d*h")) return(2.0); if (!strcmp(mol->pgroup, "td")) return(12.0); if (!strcmp(mol->pgroup, "oh")) return(24.0); if (!strcmp(mol->pgroup, "ih")) return(60.0); if (mol->pgroup[0] == 'c') return(atof(&mol->pgroup[1])); if (mol->pgroup[0] == 'd') return(2*atof(&mol->pgroup[1])); if (mol->pgroup[0] == 's') return(atof(&mol->pgroup[1])/2.0); return(1); } double getMass(struct MOLECULE *mol) { double mass=0.0; register int i; for (i=0; ina; i++) { if (mol->atoms[i].flags & ORIGINAL) mass+=mol->atoms[i].mass; } return(mass); } double getVolume(struct MOLECULE *mol) { double volume=0.0, x, y, z; int n=1; if (mol->unitcell) { x=mol->unitcell->corners[n-1].x; y=mol->unitcell->corners[n-1].y; z=mol->unitcell->corners[n-1].z; volume=(mol->unitcell->corners[n].x-x)*(mol->unitcell->corners[n+1].y-y)*(mol->unitcell->corners[n+2].z-z) +(mol->unitcell->corners[n].y-y)*(mol->unitcell->corners[n+1].z-z)*(mol->unitcell->corners[n+2].x-x) +(mol->unitcell->corners[n].z-z)*(mol->unitcell->corners[n+1].x-x)*(mol->unitcell->corners[n+2].y-y) -(mol->unitcell->corners[n].z-z)*(mol->unitcell->corners[n+1].y-y)*(mol->unitcell->corners[n+2].x-x) -(mol->unitcell->corners[n].x-x)*(mol->unitcell->corners[n+1].z-z)*(mol->unitcell->corners[n+2].y-y) -(mol->unitcell->corners[n].y-y)*(mol->unitcell->corners[n+1].x-x)*(mol->unitcell->corners[n+2].z-z); } return(volume); } double getDensity(struct MOLECULE *mol) { double volume, mass, density=0.0; if ((volume=getVolume(mol)) != 0.0) { mass=getMass(mol); density=mass/(AVOGADRO*volume*1e-24); } return(density); } void getSumFormula(struct MOLECULE *mol, char *formula, int sub) { struct ELEMENT **found; int *count, nfound, new; char num[10], order[MAXLENLINE], *word; register int i, j; found=(struct ELEMENT **)getmem((size_t)mol->na, sizeof(struct ELEMENT *)); count=(int *)getmem((size_t)mol->na, sizeof(int)); nfound=0; for (i=0; ina; i++) { new=TRUE; for (j=0; jatoms[i].element == found[j]) { count[j]++; new=FALSE; break; } } if (new && strncmp(mol->atoms[i].element->symbol, "Uc", 2) && strncmp(mol->atoms[i].element->symbol, "Mp", 2)) { found[nfound]=mol->atoms[i].element; count[nfound]++; nfound++; } } strncpy(order, getStringResource(topShell, "elementSortOrder"), MAXLENLINE-1); word=strtok(order, ","); *formula='\0'; while (word != NULL) { for (i=0; isymbol, word)) { strcat(formula, found[i]->symbol); if (count[i] > 1) { if (sub) { if (count[i] > 9) sprintf(num, "_{%d}", count[i]); else sprintf(num, "_%d", count[i]); } else sprintf(num, "%d", count[i]); strcat(formula, num); } count[i]=0; } } word=strtok(NULL, ","); } for (i=0; i 0) { strcat(formula, found[i]->symbol); if (count[i] > 1) { if (sub) { if (count[i] > 9) sprintf(num, "_{%d}", count[i]); else sprintf(num, "_%d", count[i]); } else sprintf(num, "%d", count[i]); strcat(formula, num); } } } fremem((void **)&found); fremem((void **)&count); } void printCoefficients(char *label, double *matrix, char *elements, int nelem, int final) { char formula[MAXLENLINE]; register int i, j, k; printf("%s\n\t", label); for (i=0; i #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "TabBook.h" #include "viewmol.h" #include "dialog.h" void thermoDialog(Widget, caddr_t, XmAnyCallbackStruct *); void thermoExit(Widget, caddr_t, XmPushButtonCallbackStruct *); void GetThermo(Widget, caddr_t, XmToggleButtonCallbackStruct *); void calculateThermodynamics(int); void GetUnits(Widget, caddr_t, XmToggleButtonCallbackStruct *); void environmentChanged(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); void GetReaction(Widget, caddr_t, XmToggleButtonCallbackStruct *); void findReaction(Widget, caddr_t, XmPushButtonCallbackStruct *); void makeReaction(char *, double *); void setUnits(int, double *); double getEnergyConversionFactor(int); XmString makeIndexedString(char *); void setReaction(Widget, caddr_t, XmPushButtonCallbackStruct *); void selectScreen(int); extern double getSymmetryNumber(struct MOLECULE *); extern void MapBox(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern Widget CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern void redraw(int); extern void setMenuItem(int, int); extern Widget initShell(Widget, char *, Widget *, Widget *); extern void GetSlider(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); extern Widget makeMenu(Widget, int, char *, struct MenuItem *); extern char *getStringResource(Widget, char *); extern double getMass(struct MOLECULE *); extern double getDensity(struct MOLECULE *); extern void getSumFormula(struct MOLECULE *, char *, int); extern void selectMolecule(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern Widget CreateToggleBox(Widget, struct PushButtonRow *, int, int, int, int, int); extern int reaction(int, int *); extern void thermo(struct MOLECULE *); extern void *getmem(size_t, size_t); extern void fremem(void **); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern Widget topShell; extern double temp, pressure; extern int nmolecule, ireaction; extern int thermoUnits; static Widget dialog, tabs, board, *header, *table, equation, eWidget[7]; static double temp_save, reactionData[7]; static int thermoSettings_save, thermoUnits_save, nreactions; static struct { char *label; double value; } thermodata[] = { { "Htrans", 0.0}, { "Strans", 0.0}, { "Gtrans", 0.0}, { "Ctrans", 0.0}, { "Hpv", 0.0}, { "", 0.0}, { "Gpv", 0.0}, { "", 0.0}, { "Hrot", 0.0}, { "Srot", 0.0}, { "Grot", 0.0}, { "Crot", 0.0}, { "Hvib", 0.0}, { "Svib", 0.0}, { "Gvib", 0.0}, { "Cvib", 0.0}, { "Htotal", 0.0}, { "Stotal", 0.0}, { "Gtotal", 0.0}, { "Ctotal", 0.0} }; static struct PushButtonRow reactionButtons[] = { { "previous", setReaction, (XtPointer)(-1), NULL }, { "next", setReaction, (XtPointer)1, NULL }, }; void thermoDialog(Widget widget, caddr_t dummy, XmAnyCallbackStruct *data) { Widget form, form1, form2, form3, form4, form5, form6; Widget title, massLabel, symmLabel, reactant, rb, reactionTab; Widget menu, slider1, slider2, sep; struct MOLECULE *mol; XmString str; static struct PushButtonRow buttons[] = { { "ok", thermoExit, (XtPointer)TRUE, NULL }, { "cancel", thermoExit, (XtPointer)FALSE, NULL }, }; static struct PushButtonRow checkbox_buttons[] = { { "translation", GetThermo, (XtPointer)TRANSLATION, NULL }, { "pv", GetThermo, (XtPointer)PV, NULL }, { "rotation", GetThermo, (XtPointer)ROTATION, NULL }, { "vibration", GetThermo, (XtPointer)VIBRATION, NULL }, { "total", NULL, (XtPointer)0, NULL }, }; static struct MenuItem unitsMenu[] = { { "joules", &xmPushButtonGadgetClass, GetUnits, (XtPointer)JOULES, NULL, NULL }, { "calories", &xmPushButtonGadgetClass, GetUnits, (XtPointer)CALORIES, NULL, NULL }, { "thermocalories", &xmPushButtonGadgetClass, GetUnits, (XtPointer)THERMOCALORIES, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL } }; static struct MenuItem reactantMenu[] = { { "reactant", &xmPushButtonGadgetClass, GetReaction, (XtPointer)REACTANT, NULL, NULL }, { "notInvolved", &xmPushButtonGadgetClass, GetReaction, (XtPointer)0, NULL, NULL }, { "product", &xmPushButtonGadgetClass, GetReaction, (XtPointer)PRODUCT, NULL, NULL }, { "allReactions", &xmPushButtonGadgetClass, GetReaction, (XtPointer)ALLREACTIONS, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL } }; static struct SLIDER tempSlider, pressureSlider; short decimals; char line[MAXLENLINE+40], formula[40], eq[2*MAXLENLINE]; char *format; register int i, j, k, l; /* This function creates the dialog for thermodynamics */ setMenuItem(VIEWER_THERMODYNAMICS, False); thermoSettings_save=molecules[0].thermoSettings; thermoUnits_save=thermoUnits; temp_save=temp; dialog=initShell(windows[VIEWER].widget, "thermoForm", &board, &form); tabs=XtVaCreateManagedWidget("tabs", xcgTabBookWidgetClass, form, NULL); header=(Widget *)getmem((size_t)(24*nmolecule), sizeof(Widget)); table=header+4*nmolecule; l=0; for (i=0; ititle, "DEFAULT"); title=XtVaCreateManagedWidget("moleculeTitleValue", xmLabelWidgetClass, form2, XmNlabelString, str, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); XmStringFree(str); reactant=makeMenu(form2, XmMENU_OPTION, "reactantMenu", reactantMenu); if (mol->reaction < 0) j=0; else if (mol->reaction == 0) j=1; else j=2; XtVaSetValues(reactant, XmNmenuHistory, reactantMenu[j].widget, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, title, XmNrightAttachment, XmATTACH_FORM, NULL); XtManageChild(reactant); format=getStringResource(board, "moleculeMass"); sprintf(line, format, getMass(mol)); str=XmStringCreate(line, "DEFAULT"); massLabel=XtVaCreateManagedWidget("moleculeMass", xmLabelWidgetClass, form2, XmNlabelString, str, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, title, XmNleftAttachment, XmATTACH_FORM, NULL); XmStringFree(str); format=getStringResource(board, "symmetryNumber"); sprintf(line, format, (int)(getSymmetryNumber(mol))); str=XmStringCreate(line, "DEFAULT"); symmLabel=XtVaCreateManagedWidget("symmetryNumber", xmLabelWidgetClass, form2, XmNlabelString, str, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, massLabel, XmNleftAttachment, XmATTACH_FORM, NULL); XmStringFree(str); if (mol->unitcell) { format=getStringResource(board, "solidDensity"); sprintf(line, format, getDensity(mol)); str=XmStringCreate(line, "DEFAULT"); (void)XtVaCreateManagedWidget("density", xmLabelWidgetClass, form2, XmNlabelString, str, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, symmLabel, XmNleftAttachment, XmATTACH_FORM, NULL); XmStringFree(str); } else { format=getStringResource(board, "rotationalConstants"); sprintf(line, format, mol->rotConstants[0], mol->rotConstants[1], mol->rotConstants[2]); str=XmStringCreate(line, "DEFAULT"); (void)XtVaCreateManagedWidget("rotConstants", xmLabelWidgetClass, form2, XmNlabelString, str, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, symmLabel, XmNleftAttachment, XmATTACH_FORM, NULL); XmStringFree(str); } form3=XtVaCreateWidget("rowcolumn", xmRowColumnWidgetClass, form1, XmNorientation, XmHORIZONTAL, XmNpacking, XmPACK_COLUMN, XmNnumColumns, (short)6, NULL); (void)XtVaCreateManagedWidget("", xmLabelWidgetClass, form3, NULL); header[l++]=XtVaCreateManagedWidget("enthalphy", xmLabelWidgetClass, form3, NULL); header[l++]=XtVaCreateManagedWidget("entropy", xmLabelWidgetClass, form3, NULL); header[l++]=XtVaCreateManagedWidget("gibbsEnergy", xmLabelWidgetClass, form3, NULL); header[l++]=XtVaCreateManagedWidget("heatCapacity", xmLabelWidgetClass, form3, NULL); for (j=0; jthermoSettings & (int)checkbox_buttons[j].client_data) XtVaSetValues(checkbox_buttons[j].widget, XmNset, True, NULL); for (k=0; k<4; k++) { table[20*i+4*j+k]=XtVaCreateManagedWidget(thermodata[4*j+k].label, xmLabelWidgetClass, form3, NULL); } if (!(mol->thermoSettings & (int)checkbox_buttons[j].client_data)) { for (k=0; k<4; k++) XtVaSetValues(table[20*i+4*j+k], XmNsensitive, False, NULL); } } checkbox_buttons[4].widget=XtVaCreateManagedWidget(checkbox_buttons[4].label, xmLabelWidgetClass, form3, NULL); for (k=0; k<4; k++) { table[20*i+16+k]=XtVaCreateManagedWidget(thermodata[16+k].label, xmLabelWidgetClass, form3, NULL); } calculateThermodynamics(i); XtManageChild(form3); XtManageChild(form2); XtManageChild(form1); } /* Build reaction page */ reactionTab=XtVaCreateManagedWidget("reactions", xmPushButtonWidgetClass, tabs, NULL); XtAddCallback(reactionTab, XmNactivateCallback, (XtCallbackProc)findReaction, NULL); form4=XtVaCreateWidget("reactionpage", xmFormWidgetClass, tabs, XmNfractionBase, 6, NULL); equation=XtVaCreateManagedWidget("equation", xmLabelWidgetClass, form4, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, NULL); form5=XtVaCreateWidget("rowcolumn", xmRowColumnWidgetClass, form4, XmNorientation, XmVERTICAL, XmNpacking, XmPACK_COLUMN, XmNnumColumns, (short)2, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, equation, NULL); (void)XtVaCreateManagedWidget("electronicEnergy", xmLabelWidgetClass, form5, NULL); (void)XtVaCreateManagedWidget("statisticalEnergy", xmLabelWidgetClass, form5, NULL); (void)XtVaCreateManagedWidget("reactionEnergy", xmLabelWidgetClass, form5, NULL); (void)XtVaCreateManagedWidget("reactionEntropy", xmLabelWidgetClass, form5, NULL); (void)XtVaCreateManagedWidget("reactionGibbsEnergy", xmLabelWidgetClass, form5, NULL); (void)XtVaCreateManagedWidget("reactionHeatCapacity", xmLabelWidgetClass, form5, NULL); (void)XtVaCreateManagedWidget("equilibriumConstant", xmLabelWidgetClass, form5, NULL); for (i=0; i<7; i++) { sprintf(line, "E%d", i); eWidget[i]=XtVaCreateManagedWidget(line, xmLabelWidgetClass, form5, NULL); } XtManageChild(form5); rb=CreatePushButtonRow(form4, reactionButtons, XtNumber(reactionButtons)); XtVaSetValues(rb, XmNtopAttachment, XmATTACH_POSITION, XmNtopPosition, 5, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); makeReaction(eq, reactionData); str=makeIndexedString(eq); XtVaSetValues(equation, XmNlabelString, str, NULL); XmStringFree(str); setUnits(thermoUnits, reactionData); XtManageChild(form4); /* Fixed part of form with unit selector and temperature and pressure sliders */ form6=XtVaCreateWidget("controlarea", xmFormWidgetClass, form, XmNorientation, XmHORIZONTAL, NULL); (void)XtVaCreateManagedWidget("temperature", xmLabelWidgetClass, form6, XmNtopAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM, NULL); menu=makeMenu(form6, XmMENU_OPTION, "units", unitsMenu); XtVaSetValues(menu, XmNmenuHistory, unitsMenu[thermoUnits].widget, XmNtopAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, NULL); XtManageChild(menu); (void)XtVaCreateManagedWidget("unitlabel", xmLabelWidgetClass, form6, XmNtopAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_WIDGET, XmNrightWidget, menu, NULL); XtManageChild(form6); slider1=XtVaCreateManagedWidget("temperatureSlider", xmScaleWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNvalue, (int)(temp), XmNminimum, 0, XmNmaximum, 1000, XmNshowValue, True, XmNsensitive, True, NULL); tempSlider.number=&temp; tempSlider.decimals=0; tempSlider.draw=NULL; XtAddCallback(slider1, XmNvalueChangedCallback, (XtCallbackProc)environmentChanged, &tempSlider); (void)XtVaCreateManagedWidget("pressure", xmLabelWidgetClass, form, NULL); slider2=XtVaCreateManagedWidget("pressureSlider", xmScaleWidgetClass, form, XmNorientation, XmHORIZONTAL, XmNshowValue, True, XmNsensitive, True, NULL); XtVaGetValues(slider2, XmNdecimalPoints, &decimals, NULL); XtVaSetValues(slider2, XmNvalue, (int)(pressure*pow((double)10.0, (double)decimals)), NULL); pressureSlider.number=&pressure; pressureSlider.decimals=decimals; pressureSlider.draw=NULL; XtAddCallback(slider2, XmNvalueChangedCallback, (XtCallbackProc)environmentChanged, &pressureSlider); sep=XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, form, XmNtraversalOn, False, NULL); CreatePushButtonRow(form, buttons, XtNumber(buttons)); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XmAnyCallbackStruct *)NULL); XtManageChild(form); XtManageChild(board); } void thermoExit(Widget button, caddr_t which, XmPushButtonCallbackStruct *data) { if (!(int)which) { molecules[XcgTabBookGetActivePage(tabs)-1].thermoSettings=thermoSettings_save; thermoUnits=thermoUnits_save; temp=temp_save; } XtDestroyWidget(dialog); fremem((void **)&header); setMenuItem(VIEWER_THERMODYNAMICS, True); } void GetThermo(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { double q; int w=(int)which; register int i, j, k; q=log((double)w)/log((double)2.0); i=(int)rint(q); j=XcgTabBookGetActivePage(tabs)-1; if (data->set) { molecules[j].thermoSettings |= w; for (k=0; k<4; k++) XtVaSetValues(table[20*j+4*i+k], XmNsensitive, True, NULL); } else { molecules[j].thermoSettings &= ~w; for (k=0; k<4; k++) XtVaSetValues(table[20*j+4*i+k], XmNsensitive, False, NULL); } calculateThermodynamics(XcgTabBookGetActivePage(tabs)-1); } void calculateThermodynamics(int which) { struct MOLECULE *mol; XmString str; double convFactor; char value[MAXLENLINE], *format; register int i; convFactor=getEnergyConversionFactor(thermoUnits); mol=&molecules[which]; thermo(mol); thermodata[0].value=0.001*convFactor*mol->htrl; thermodata[1].value=convFactor*mol->strl; thermodata[2].value=0.001*convFactor*(mol->htrl-temp*mol->strl); thermodata[3].value=convFactor*mol->ctrl; thermodata[4].value=0.001*convFactor*mol->pv; thermodata[5].value=0.0; thermodata[6].value=0.001*convFactor*mol->pv; thermodata[7].value=0.0; thermodata[8].value=0.001*convFactor*mol->hrot; thermodata[9].value=convFactor*mol->srot; thermodata[10].value=0.001*convFactor*(mol->hrot-temp*mol->srot); thermodata[11].value=convFactor*mol->crot; thermodata[12].value=0.001*convFactor*mol->hvib; thermodata[13].value=convFactor*mol->svib; thermodata[14].value=0.001*convFactor*(mol->hvib-temp*mol->svib); thermodata[15].value=convFactor*mol->cvib; format=getStringResource(dialog, "format"); for (i=0; i<16; i++) { if (i != 5 && i != 7) sprintf(value, format, thermodata[i].value); else sprintf(value, " "); str=XmStringCreate(value, "DEFAULT"); XtVaSetValues(table[20*which+i], XmNlabelString, str, NULL); XmStringFree(str); } thermodata[16].value=0.0; if (mol->thermoSettings & TRANSLATION) thermodata[16].value+=mol->htrl; if (mol->thermoSettings & PV) thermodata[16].value+=mol->pv; if (mol->thermoSettings & ROTATION) thermodata[16].value+=mol->hrot; if (mol->thermoSettings & VIBRATION) thermodata[16].value+=mol->hvib; thermodata[16].value*=0.001*convFactor; thermodata[17].value=0.0; if (mol->thermoSettings & TRANSLATION) thermodata[17].value+=mol->strl; if (mol->thermoSettings & ROTATION) thermodata[17].value+=mol->srot; if (mol->thermoSettings & VIBRATION) thermodata[17].value+=mol->svib; thermodata[17].value*=convFactor; thermodata[18].value=0.0; if (mol->thermoSettings & TRANSLATION) thermodata[18].value+=thermodata[2].value; if (mol->thermoSettings & PV) thermodata[18].value+=thermodata[6].value; if (mol->thermoSettings & ROTATION) thermodata[18].value+=thermodata[10].value; if (mol->thermoSettings & VIBRATION) thermodata[18].value+=thermodata[14].value; thermodata[19].value=0.0; if (mol->thermoSettings & TRANSLATION) thermodata[19].value+=mol->ctrl; if (mol->thermoSettings & ROTATION) thermodata[19].value+=mol->crot; if (mol->thermoSettings & VIBRATION) thermodata[19].value+=mol->cvib; thermodata[19].value*=convFactor; for (i=0; i<4; i++) { sprintf(value, format, thermodata[16+i].value); str=XmStringCreate(value, "DEFAULT"); XtVaSetValues(table[20*which+16+i], XmNlabelString, str, NULL); XmStringFree(str); } } void GetUnits(Widget button, caddr_t which, XmToggleButtonCallbackStruct *data) { register int i; thermoUnits=(int)which; for (i=0; i 0) { getSumFormula(&molecules[i], formula, TRUE); if (*rightSide) strcat(rightSide, " + "); if (molecules[i].stoichioNumber == 1) strcat(rightSide, formula); else { sprintf(line, "%d %s", molecules[i].stoichioNumber, formula); strcat(rightSide, line); } if (ret == REACTION_OK) { if (molecules[i].optimization) reactionData[0]+=molecules[i].stoichioNumber *molecules[i].optimization[molecules[i].nhist-1].energy *2625.5001; reactionData[1]+=0.001*molecules[i].stoichioNumber*(molecules[i].htrl +molecules[i].pv+molecules[i].hrot+molecules[i].hvib); reactionData[3]+=molecules[i].stoichioNumber*(molecules[i].strl +molecules[i].srot+molecules[i].svib); reactionData[5]+=molecules[i].stoichioNumber*(molecules[i].ctrl +molecules[i].crot+molecules[i].cvib); } } } if (!(*leftSide && *rightSide)) strcpy(eq, getStringResource(board, "noReaction")); else if (ret == INCONSISTENT_TYPE) strcpy(eq, getStringResource(board, "inconsistentType")); else { strcpy(eq, leftSide); strcat(eq, " \\rightarrow "); strcat(eq, rightSide); reactionData[2]=reactionData[0]+reactionData[1]; reactionData[4]=reactionData[2]-temp*0.001*reactionData[3]; reactionData[6]=(-1000.0*reactionData[4])/(R*temp*log(10.0)); switch (ret) { case MISSING_ATOMS: strcat(eq, " "); strcat(eq, getStringResource(board, "missingAtoms")); break; case CANT_BALANCE: strcat(eq, " "); strcat(eq, getStringResource(board, "cantBalance")); break; default: break; } } if (nreactions <= 1) { XtUnmanageChild(reactionButtons[0].widget); XtUnmanageChild(reactionButtons[1].widget); } else { XtManageChild(reactionButtons[0].widget); XtManageChild(reactionButtons[1].widget); if (ireaction == 0) XtVaSetValues(reactionButtons[0].widget,XmNsensitive, False, NULL); else XtVaSetValues(reactionButtons[0].widget,XmNsensitive, True, NULL); if (ireaction == nreactions-1) XtVaSetValues(reactionButtons[1].widget,XmNsensitive, False, NULL); else XtVaSetValues(reactionButtons[1].widget,XmNsensitive, True, NULL); } } void setUnits(int thermoUnits, double reactionData[]) { XmString h, s, g, cv; double convFactor; char *unit, *word, line[MAXLENLINE]; register int i, j; convFactor=getEnergyConversionFactor(thermoUnits); switch (thermoUnits) { case JOULES: unit=getStringResource(dialog, "joules"); break; case CALORIES: case THERMOCALORIES: unit=getStringResource(dialog, "calories"); break; default: return; } word=getStringResource(header[0], "labelString"); sprintf(line, word, unit); h=XmStringCreate(line, "DEFAULT"); word=getStringResource(header[1], "labelString"); sprintf(line, word, unit); s=XmStringCreate(line, "DEFAULT"); word=getStringResource(header[2], "labelString"); sprintf(line, word, unit); g=XmStringCreate(line, "DEFAULT"); word=getStringResource(header[3], "labelString"); sprintf(line, word, unit); cv=makeIndexedString(line); j=0; for (i=0; i= nreactions) ireaction=nreactions-1; if (ireaction == 0) XtVaSetValues(reactionButtons[0].widget, XmNsensitive, False, NULL); else XtVaSetValues(reactionButtons[0].widget, XmNsensitive, True, NULL); if (ireaction == nreactions-1) XtVaSetValues(reactionButtons[1].widget, XmNsensitive, False, NULL); else XtVaSetValues(reactionButtons[1].widget, XmNsensitive, True, NULL); makeReaction(eq, reactionData); str=makeIndexedString(eq); XtVaSetValues(equation, XmNlabelString, str, NULL); XmStringFree(str); setUnits(thermoUnits, reactionData); } void selectScreen(int which) { if (which > 0) XcgTabBookSetActivePage(tabs, which, XcgTabBook_OPT_NO_CB); else thermoExit((Widget)0, (caddr_t)FALSE, (XmPushButtonCallbackStruct *)0); } viewmol-2.4.1/source/tm.c0100644000272700027270000003526410114367754013451 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * T M . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: tm.c,v 1.7 2004/08/29 15:02:04 jrh Exp $ * $Log: tm.c,v $ * Revision 1.7 2004/08/29 15:02:04 jrh * Release 2.4.1 * * Revision 1.6 2003/11/07 11:17:02 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:17:50 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:27:41 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:57:41 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:38 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:44:15 jrh * Initial revision * */ #include #include #include #include #include #include #define MAXLENLINE 82 #define FALSE 0 #define TRUE 1 /* Prototypes */ int main(int, char **); void copyDataGroup(FILE *, FILE *, char *, char *, char *, int); void readDataGroup(FILE *, FILE *, char *, char *, char *, int); FILE *checkfile(FILE *, char *, char *); void changeDs(char *); void eof(int); extern int readFrame(FILE *, int, int, double, int, long *); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); static char *buffer=NULL; int main(int argc, char **argv) { FILE *mainfile, *file=NULL; double *mode; long offset; char line[MAXLENLINE], copy[MAXLENLINE], fullpath[MAXLENLINE], *word; char *column[6], form[8], pointGroup[4]; int n=0, version, atomsDone=FALSE, titleDone=FALSE, MOsDone=FALSE, msi=FALSE; size_t nmodes=100; register int i, j; if (!strcmp(argv[1], "-msi")) { msi=TRUE; i=2; } else i=1; if ((mainfile=fopen(argv[i], "r")) == NULL) { printf("$error noFile 1 %s\n", argv[i]); printf("$end\n"); exit(-1); } if ((word=strrchr(argv[i], '/')) != NULL) { strncpy(fullpath, argv[i], (int)(word-argv[i])); fullpath[(int)(word-argv[i])]='\0'; } else strcpy(fullpath, "."); while (fgets(line, MAXLENLINE, mainfile) != NULL) { if (line[0] == '#') continue; else if (strstr(line, "$coord") && !strstr(line, "update")) { if (strstr(line, "type=car") != NULL) { if ((file=checkfile(mainfile, line, fullpath)) != NULL) { if (strstr(line, "!BIOSYM archive") == NULL) { printf("$error wrongReference 1 %s\n", argv[i]); printf("$end\n"); exit(-1); } sscanf(line+15, "%d", &version); if (version != 3) { printf("$error unsupportedVersion 1 %d\n", version); printf("$end\n"); exit(-1); } fgets(line, MAXLENLINE, file); readFrame(file, FALSE, TRUE, 0.52917706, version, &offset); titleDone=TRUE; } else { printf("$end\n"); exit(-1); } } else copyDataGroup(mainfile, file, line, "$coord 0.52917706", fullpath, MOsDone); } else if (strstr(line, "$title") && !titleDone) copyDataGroup(mainfile, file, line, "$title", fullpath, MOsDone); else if (strstr(line, "$symmetry")) { printf("%s", line); word=strtok(line, " \t"); word=strtok(NULL, " \t"); strcpy(pointGroup, word); if ((word=strrchr(pointGroup, '\n')) != NULL) *word='\0'; } else if (strstr(line, "$vibrational spectrum")) { if ((file=checkfile(mainfile, line, fullpath)) != NULL) { if (file != mainfile) { while (fgets(line, MAXLENLINE, file) != NULL) if (strstr(line, "$vibrational spectrum")) break; } printf("$vibrational spectrum\n"); if (fgets(line, MAXLENLINE, file) != NULL) { while (line[0] != '$') { if (line[0] != '#') { column[0]=strtok(line, " \t\n"); column[1]=strtok(NULL, " \t\n"); column[2]=strtok(NULL, " \t\n"); column[3]=strtok(NULL, " \t\n"); if (column[3] == NULL) { column[1][0]=(char)toupper(column[1][0]); printf("%s %s 1.0000000 1.0000000\n", column[1], column[2]); } else { column[4]=strtok(NULL, " \t\n"); column[5]=strtok(NULL, " \t\n"); if (*column[4] != '-') { column[1][0]=(char)toupper(column[1][0]); printf("%s %s %s ", column[1], column[2], column[3]); if (strstr(column[5], "NO")) printf("0.0000000\n"); else printf("1.0000000\n"); } else printf("- %s %s 0.0000000\n", column[1], column[2]); } } if (fgets(line, MAXLENLINE, file) == NULL) break; } } if (file != mainfile) fclose(file); fseek(file, -strlen(line), SEEK_CUR); } } else if (strstr(line, "$vibrational normal modes")) { if (msi) /* in MSI's version the normal modes are transposed */ { if ((file=checkfile(mainfile, line, fullpath)) != NULL) { if (file != mainfile) { while (fgets(line, MAXLENLINE, file) != NULL) if (strstr(line, "$vibrational normal modes")) break; } printf("$vibrational normal modes\n"); mode=(double *)getmem(nmodes, sizeof(double)); i=0; if (fgets(line, MAXLENLINE, file) != NULL) { while (line[0] != '$') { if (line[0] != '#') { strtok(line, " \t"); strtok(NULL, " \t"); while ((word=strtok(NULL, " \t")) != NULL) { mode[i++]=atof(word); if (i >= nmodes) { nmodes+=100; mode=(double *)expmem((void *)mode, nmodes, sizeof(double)); } } } if (fgets(line, MAXLENLINE, file) == NULL) break; } } nmodes=(int)(sqrt((double)i)); for (i=0; i #include #include #include #include #include #ifdef _SGI_EXTRA_PREDEFINES #include #else #define XSGIFastInternAtom(dpy,string,fast_name,how) XInternAtom(dpy,string,how) #endif #include #include #include #include #include #include #include "dialog.h" #include "viewmol.h" #include "fallbacks.h" /* #include "xdnd.h" */ void reshape(Widget, caddr_t, XmDrawingAreaCallbackStruct *); void setShape(int, Dimension, Dimension); void getRotation(int, int, int, int); void setDrawingDevice(int); void ende(Widget, caddr_t, XmAnyCallbackStruct *); void setIcon(Widget, XtPointer, XEvent *); void signalHandler(int); void installColormap(void); extern void drawMolecule(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void processInput(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void printString(char *, double, double, double, double, GLuint, char); extern void feedbackString(char *, double, double, double, double, GLuint, char); extern void feedbackLineStipple(GLint, GLushort); extern void feedbackLineWidth(GLfloat); extern void feedbackDisable(GLenum); extern void raytracerBegin(GLenum), raytracerEnd(void), raytracerVertex3d(double, double, double); extern void raytracerNormal3d(double, double, double); extern void raytracerColor4fv(const GLfloat *); extern void raytracerClearColor(GLclampf, GLclampf, GLclampf, GLclampf); extern void raytracerSphere(GLUquadricObj *, GLdouble, GLint, GLint); extern void raytracerCylinder(GLUquadricObj *qobj, GLdouble, GLdouble, GLdouble, GLint, GLint); extern void raytracerCone(GLUquadricObj *qobj, GLdouble, GLdouble, GLdouble, GLint, GLint); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern char *getStringResource(Widget, char *); extern void pixelToWorld(int, double *, double *); extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern void loadColorMap(void); extern void findInputDevices(Widget); extern int getrc(void); extern void showTitle(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern int initViewer(int, char **, Widget); extern void redraw(int); extern void fremem(void **); extern void scaleAnnotation(float); extern void processSpaceballEvent(XEvent *); extern int load(Widget, caddr_t, XmAnyCallbackStruct *); extern void allocWindowColors(void); extern XVisualInfo *getVisualInfo(Display *, Visual *); extern Colormap getRGBcolormap(Display *, int, XVisualInfo *); extern void incrementQuaternion(double, double, double, float *); extern void initPython(int, char **); extern void loadAtomColors(XVisualInfo *, Colormap); extern int findShadowMapSupport(void); extern void testBegin(GLenum), testEnd(void), testVertex(double, double, double), testNorm(double, double, double); void (*drawBegin)(GLenum), (*drawEnd)(void), (*drawVertex3d)(double, double, double); void (*drawVertex2d)(double, double), (*drawNormal3d)(double, double, double); void (*drawColor4fv)(const GLfloat *); void (*drawClearColor)(GLclampf, GLclampf, GLclampf, GLclampf); void (*drawSphere)(GLUquadricObj *, GLdouble, GLint, GLint); void (*drawCylinder)(GLUquadricObj *qobj, GLdouble, GLdouble, GLdouble, GLint, GLint); void (*drawCone)(GLUquadricObj *qobj, GLdouble, GLdouble, GLdouble, GLint, GLint); void (*drawString)(char *, double, double, double, double, GLuint, char); void (*drawLineStipple)(GLint, GLushort); void (*drawLineWidth)(GLfloat); void (*drawDisable)(GLenum); struct MOLECULE *molecules=NULL; struct ELEMENT *elements; struct WINDOW windows[4]; struct OPTION *options=NULL; struct OPTION *output=NULL; struct ANNOTATION *annotation=NULL; struct UNDO *undo=NULL; Pixel stdcol[9], historyColor; XtAppContext app; Widget topShell, fileBox, bfMenu, undoButton=NULL; PyObject *viewmolModule, *moleculeModule; double *grid=NULL; double bndfac=1.0, amplitude, forceScale, wnScale=1.0, hbondThreshold=2.0, scaleRadius=1.0; double tmat[4][4]; double paperWidth=0.0, paperHeight=0.0, sphereres=10., lineWidth=0.0, spectrumLineWidth=1.0; double temp, pressure=1.0, weight=0.0; double e1, e2, denres=(1.); double level=0.05, gridres=(-1.), torsionDefault=180.0, drawingSpeed=0.0; float *transObject=NULL, *rotObject=NULL; float historyColor_rgb[4] = {0.0, 0.0, 1.0, 0.0}; GLfloat light0p[4] = {0.0, 0.0, 1.0, 0.0}; GLfloat light1p[4] = {0.0, 1.0, 0.0, 0.0}; int ne, nopt=0, noutput=0, nUndo=0; int nmolecule=0, imol, ireaction=0; int rotateXY=FALSE, rotateZ=FALSE; int primitive, animate=ANIMATE, lights=3, moveItem=MOLECULES, projectionMode=ORTHO; int lines=TRUE, showForces=FALSE, setins=FALSE, xIsTop=TRUE, showGrid=TRUE; int showUnitCell=TRUE, bondOrderDefault=1; int showInertia=FALSE, selectAtom=FALSE, simplify=TRUE; int rgbMode, picking=FALSE, swapBuffers=TRUE, shadows=FALSE, ground=TRUE, drawIcon=FALSE; int drawingDevice, bondType=CONJUGATION, showHBond=TRUE, localGeometry=TRUE; int label, outputType=0, automaticRecalculate=FALSE; int showWarning=TRUE, debug, annotate=FALSE, saveAll=TRUE; int nAnnotations=0, normalModeAnnotation=(-1), selectAtomAnnotation=(-1); int historyAnnotation=(-1), setinsAnnotation=(-1); int unit, bfatom, element=0, modifyMolecule=NOTHING; int thermoUnits=JOULES, pythonInterrupt=FALSE; int spaceballButtonPress, spaceballMotionNotify; int showMenu=TRUE, saveLanguage=FALSE; int iwavef=ALL_OFF, interp=IP_LINEAR; int format=TIFFFILE, landscape=TRUE; int shadowMap=FALSE; char *formBondLength, *formBondAngle, *formTorsionAngle; char *text, *textPointer, *moduleName; char language[20]; char webbrowser[MAXLENLINE]={""}, moloch[MAXLENLINE]={""}; char raytracer[MAXLENLINE]={""}, displayImage[MAXLENLINE]={""}; pid_t manual_pid=0, raypid=0; int main(int argc, char** argv) { Display *display; XVisualInfo *vi; Colormap colormap; XEvent event; /*DndClass dnd;*/ String translations=": DrawingAreaInput()\n\ : DrawingAreaInput()\n\ : DrawingAreaInput()\n\ : DrawingAreaInput()\n\ : DrawingAreaInput()"; int attrib[] = {GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, GLX_DEPTH_SIZE, 1, GLX_DOUBLEBUFFER, GLX_RGBA, GLX_STENCIL_SIZE, 2, None}; static struct PushButtonRow buttons[] = {{"exit", GetMessageBoxButton, (XtPointer)0, NULL}}; /*Atom dropType; int dropBufferSize, dropX, dropY; unsigned char *dropBuffer; */ char *line, *locale; locale=setlocale(LC_ALL, ""); signal(SIGBUS, signalHandler); signal(SIGFPE, signalHandler); signal(SIGSEGV, signalHandler); XtSetLanguageProc(NULL, NULL, NULL); topShell=XtVaAppInitialize(&app, "Viewmol", NULL, 0, &argc, argv, fallbacks, NULL); if (topShell == NULL) { fprintf(stderr, "%s: ERROR: Cannot connect to X server.\n", PROGRAM); exit(-1); } display=XtDisplay(topShell); rgbMode=TRUE; if ((vi=glXChooseVisual(display, XScreenNumberOfScreen(XtScreen(topShell)), attrib)) == NULL || vi->class == DirectColor) { /* Could not find a double buffered RGB visual with stencil buffer, try to find one without stencil buffer */ attrib[10]=None; if ((vi=glXChooseVisual(display, XScreenNumberOfScreen(XtScreen(topShell)), attrib)) == NULL) { /* Could not find a double buffered RGB visual, try to find a color mapped one */ attrib[9]=None; rgbMode=FALSE; if ((vi=glXChooseVisual(display, XScreenNumberOfScreen(XtScreen(topShell)), attrib)) == NULL) { /* Still no success, give up */ line=getStringResource(topShell, "noVisual"); messgb(topShell, 3, line, buttons, 1); exit(-1); } } } colormap=getRGBcolormap(display, vi->screen, vi); /* AIX doesn't return anything meanigful here, but also requires that the color map is not set */ /*if (strlen(glXQueryServerString(display, vi->screen, GLX_VERSION)) > 0) */ XtVaSetValues(topShell, XtNvisual, vi->visual, XtNdepth, vi->depth, XtNcolormap, colormap, NULL); /*else XtVaSetValues(topShell, XtNvisual, vi->visual, XtNdepth, vi->depth, NULL);*/ XtRealizeWidget(topShell); windows[VIEWER].left=-1.0; windows[VIEWER].right=1.0; windows[VIEWER].bottom=-1.0; windows[VIEWER].top=1.0; windows[VIEWER].near=-1.0; windows[VIEWER].far=1.0; windows[VIEWER].widget=XtVaCreateManagedWidget("viewer", xmDrawingAreaWidgetClass, topShell, XtNvisual, vi->visual, XmNtranslations, XtParseTranslationTable(translations), XmNmarginHeight, 0, XmNmarginWidth, 0, NULL); windows[VIEWER].context=glXCreateContext(XtDisplay(windows[VIEWER].widget), vi, None, GL_TRUE); glXMakeCurrent(XtDisplay(windows[VIEWER].widget), XtWindow(windows[VIEWER].widget), windows[VIEWER].context); loadColorMap(); findInputDevices(windows[VIEWER].widget); /*XtAddEventHandler(topShell, PropertyChangeMask, False, (XtEventHandler)setIcon, (XtPointer)NULL); */ shadowMap=findShadowMapSupport(); if (getrc()) { setDrawingDevice(SCREEN); XtAddCallback(windows[VIEWER].widget, XmNexposeCallback, (XtCallbackProc)showTitle, NULL); XtAddCallback(windows[VIEWER].widget, XmNinputCallback, (XtCallbackProc)processInput, NULL); XtAddCallback(windows[VIEWER].widget, XmNresizeCallback, (XtCallbackProc)reshape, (XtPointer)VIEWER); showTitle((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); allocWindowColors(); initPython(argc, argv); windows[VIEWER].menu=NULL; if (!initViewer(argc, argv, windows[VIEWER].widget)) (void)load((Widget)0, (caddr_t)0, (XmAnyCallbackStruct *)0); if (molecules) { XtRemoveAllCallbacks(windows[VIEWER].widget, XmNexposeCallback); XtAddCallback(windows[VIEWER].widget, XmNexposeCallback, (XtCallbackProc)drawMolecule, NULL); } } /*xdnd_init(&dnd, display); xdnd_set_dnd_aware(&dnd, XtWindow(topShell), NULL); */ while (TRUE) { XtAppNextEvent(app, &event); /* xdnd_get_drop(display, &event, NULL, NULL, &dropBuffer, &dropBufferSize, &dropType, &dropX, &dropY); */ if (event.type == spaceballMotionNotify || event.type == spaceballButtonPress) processSpaceballEvent(&event); else XtDispatchEvent(&event); } } void reshape(Widget widget, caddr_t window, XmDrawingAreaCallbackStruct *data) { Dimension width, height; int w=(int)window; XtVaGetValues(widget, XmNwidth, &width, XmNheight, &height, NULL); glXMakeCurrent(XtDisplay(windows[w].widget), XtWindow(windows[w].widget), windows[w].context); setShape((int)window, width, height); redraw(w); } void setShape(int window, Dimension width, Dimension height) { double rel; XtVaSetValues(windows[window].widget, XmNwidth, width, XmNheight, height, NULL); glViewport(0, 0, width, height); if (window == VIEWER) { if (width > height) { rel=((double)width/(double)height-1.0)*windows[VIEWER].near; windows[VIEWER].left=windows[VIEWER].near+rel; windows[VIEWER].right=windows[VIEWER].far-rel; windows[VIEWER].bottom=windows[VIEWER].near; windows[VIEWER].top=windows[VIEWER].far; } else { rel=((double)height/(double)width-1.0)*windows[VIEWER].near; windows[VIEWER].left=windows[VIEWER].near; windows[VIEWER].right=windows[VIEWER].far; windows[VIEWER].bottom=windows[VIEWER].near+rel; windows[VIEWER].top=windows[VIEWER].far-rel; } } } void getRotation(int x, int y, int z, int mode) { static int xold, yold, zold; double factor=1.0; if (mode == 2) { xold=x; yold=y; zold=z; return; } if (x < 0) x=xold; if (y < 0) y=yold; if (z < 0) z=zold; if (moveItem == VIEWPOINT) factor=0.25; if (mode == 1) { incrementQuaternion(factor*(double)y, factor*(double)x, factor*(double)z, &rotObject[4*moveItem]); } else { incrementQuaternion(factor*(double)(yold-y), factor*(double)(xold-x), factor*(double)(z-zold), &rotObject[4*moveItem]); } if (mode == 0) { xold=x; yold=y; zold=z; } } void getTranslation(int x, int y, int mode) { static int xold, yold; Dimension width, height; double xpix, ypix; if (rotateXY == 1) { pixelToWorld(VIEWER, &xpix, &ypix); if (moveItem & 0x80000000) { XtVaGetValues(windows[VIEWER].widget, XmNwidth, &width, XmNheight, &height, NULL); if (mode == 1) { annotation[moveItem & 0x7fffffff].x+=2.0*(double)x/(double)width; annotation[moveItem & 0x7fffffff].y+=2.0*(double)y/(double)height; } else { annotation[moveItem & 0x7fffffff].x+=2.0*(double)(x-xold)/(double)width; annotation[moveItem & 0x7fffffff].y+=2.0*(double)(yold-y)/(double)height; } } else { if (mode == 1) { transObject[3*moveItem]+=(float)x*xpix; transObject[3*moveItem+1]+=(float)y*ypix; } else { transObject[3*moveItem]+=(float)(x-xold)*xpix; transObject[3*moveItem+1]+=(float)(yold-y)*ypix; } } } if (rotateXY == -1) rotateXY=1; xold=x; yold=y; } void getEnlargement(int x, int mode) { static int xold=(-1); float scale; if (rotateZ == 1) { if (projectionMode == ORTHO) { if (mode == 1) scale=1.+(float)x*0.025; else scale=1.+(float)(x-xold)*0.025; windows[VIEWER].top*=scale; windows[VIEWER].bottom*=scale; windows[VIEWER].right*=scale; windows[VIEWER].left*=scale; if (nAnnotations) scaleAnnotation(scale); } else { if (mode == 1) transObject[3*moveItem+2]+=(float)x; else transObject[3*moveItem+2]+=(float)(x-xold); } } if (rotateZ == -1) rotateZ=1; xold=x; redraw(VIEWER); } void setDrawingDevice(int device) { drawingDevice=device; switch (device) { case SCREEN: drawBegin=glBegin; drawEnd=glEnd; drawVertex3d=glVertex3d; drawVertex2d=glVertex2d; drawNormal3d=glNormal3d; drawColor4fv=glColor4fv; drawClearColor=glClearColor; drawSphere=gluSphere; drawCylinder=gluCylinder; drawCone=gluCylinder; drawString=printString; drawLineStipple=glLineStipple; drawLineWidth=glLineWidth; drawDisable=glDisable; break; case HPGL: case POSTSCRIPT: drawBegin=glBegin; drawEnd=glEnd; drawVertex3d=glVertex3d; drawVertex2d=glVertex2d; drawNormal3d=glNormal3d; drawColor4fv=glColor4fv; drawClearColor=glClearColor; drawLineStipple=glLineStipple; drawLineWidth=glLineWidth; drawDisable=glDisable; drawSphere=gluSphere; drawCylinder=gluCylinder; drawCone=gluCylinder; drawString=feedbackString; drawLineStipple=feedbackLineStipple; drawLineWidth=feedbackLineWidth; drawDisable=feedbackDisable; break; case RAYTRACER: drawBegin=raytracerBegin; drawEnd=raytracerEnd; drawVertex3d=raytracerVertex3d; drawVertex2d=glVertex2d; drawNormal3d=raytracerNormal3d; drawColor4fv=raytracerColor4fv; drawClearColor=raytracerClearColor; drawSphere=raytracerSphere; drawCylinder=raytracerCylinder; drawCone=raytracerCone; drawString=printString; drawLineStipple=glLineStipple; drawLineWidth=glLineWidth; drawDisable=glDisable; break; } } void ende(Widget widget, caddr_t client_data, XmAnyCallbackStruct *call_data) { struct MOLECULE *mol; register int i; fremem((void **)&windows[VIEWER].font); if (windows[SPECTRUM].font != NULL) fremem((void **)&windows[SPECTRUM].font); if (windows[HISTORY].font != NULL) fremem((void **)&windows[HISTORY].font); if (windows[MO].font != NULL) fremem((void **)&windows[MO].font); for (i=0; iatoms)); fremem((void **)&(mol->bonds)); if (mol->cnm != NULL) fremem((void **)&(mol->cnm)); if (mol->normal_modes != NULL) fremem((void **)&(mol->normal_modes)); if (mol->history != NULL) fremem((void **)&(mol->history)); if (mol->optimization != NULL) fremem((void **)&(mol->optimization)); if (mol->orbitals != NULL) fremem((void **)&(mol->orbitals)); if (mol->basisset != NULL) fremem((void **)&(mol->basisset)); if (mol->exponents != NULL) fremem((void **)&(mol->exponents)); } if (options != NULL) fremem((void **)&options); fremem((void **)&molecules); nmolecule=0; if (manual_pid && kill(manual_pid, 0) != -1) kill(manual_pid, SIGTERM); if (raypid && kill(raypid, 0) != -1) kill(raypid, SIGTERM); Py_Exit(0); exit(0); } void setIcon(Widget widget, XtPointer dummy, XEvent *e) { static int iconic=FALSE; static Dimension width, height; Display *display; Screen *screen; XVisualInfo *visualInfo; XPropertyEvent *event=(XPropertyEvent *)e; Atom wmStateAtom=(Atom)0; XIconSize *sizes; Pixmap pixmap; GLXPixmap glxPixmap; GLXContext context; int count, restore=FALSE; unsigned int w, h; #if defined LINUX || defined DARWIN || defined FREEBSD wmStateAtom=XInternAtom(XtDisplay(topShell), "XmSWM_STATE", False); #else wmStateAtom=XSGIFastInternAtom(XtDisplay(topShell), "XmSWM_STATE", SGI_XA_WM_STATE, False); #endif if (event->atom == wmStateAtom) { if (!iconic) { display=XtDisplay(topShell); screen=XtScreen(topShell); if (XGetIconSizes(display, RootWindowOfScreen(screen), &sizes, &count)) { w=sizes[0].max_width; h=sizes[0].max_height; XFree(sizes); } else { w=32; h=32; } visualInfo=getVisualInfo(display, DefaultVisualOfScreen(screen)); pixmap=XCreatePixmap(display, XtWindow(topShell), w, h, (unsigned int)(visualInfo->depth)); glxPixmap=glXCreateGLXPixmap(display, visualInfo, pixmap); context=glXCreateContext(display, visualInfo, NULL, FALSE); glXMakeCurrent(display, glxPixmap, context); drawIcon=TRUE; if (rgbMode && visualInfo->class == PseudoColor) { restore=TRUE; rgbMode=FALSE; loadAtomColors(visualInfo, DefaultColormapOfScreen(screen)); } XtVaGetValues(windows[VIEWER].widget, XmNwidth, &width, XmNheight, &height, NULL); setShape(VIEWER, (Dimension)w, (Dimension)h); drawMolecule((Widget)0, (caddr_t)0, (XmDrawingAreaCallbackStruct *)0); if (restore) rgbMode=TRUE; drawIcon=FALSE; XtVaSetValues(topShell, XtNiconPixmap, pixmap, NULL); } else setShape(VIEWER, width, height); iconic=!iconic; } } void signalHandler(int signalNumber) { struct PushButtonRow buttons[] = {{"exit", GetMessageBoxButton, (XtPointer)0, NULL}}; char *word=NULL; switch (signalNumber) { case SIGBUS: word=getStringResource(topShell, "BusError"); break; case SIGFPE: word=getStringResource(topShell, "FloatingPointException"); break; case SIGSEGV: word=getStringResource(topShell, "SegmentationViolation"); break; } messgb(topShell, 3, word, buttons, 1); exit(-1); } void installColormap(void) { int status; Window windows[1], *windowsReturn, *windowList; int countReturn, i; status=XGetWMColormapWindows(XtDisplay(topShell), XtWindow(topShell), &windowsReturn, &countReturn); if(!status) { windows[0]=XtWindow(topShell); XSetWMColormapWindows(XtDisplay(topShell),XtWindow(topShell),windows,1); } /* there was a property, add myself to the beginning */ else { windowList=(Window *)XtMalloc((sizeof(Window))*(countReturn+1)); windowList[0]=XtWindow(topShell); for(i=0; i #include #include #include #include "menu.h" #include "modules.h" #define PROGRAM "Viewmol" #define VERSION "2.4.1" #define MAXLENLINE 256 #define MAXLENBASISNAME 32 #define TRUE 1 #define FALSE 0 #define BLACK 0 #define WHITE 1 #define RED 2 #define GREEN 3 #define BLUE 4 #define YELLOW 5 #define CYAN 6 #define MAGENTA 7 #define SKYBLUE 8 #define VIEWER 0 #define SPECTRUM 1 #define HISTORY 2 #define MO 3 #define VIEWER1 4 #define VIEWER2 5 #define VIEWER_MOLECULE ((VIEWER << 8) | 0) #define VIEWER_SELECT ((VIEWER << 8) | 1) #define VIEWER_SEP1 ((VIEWER << 8) | 2) #define VIEWER_WIRE ((VIEWER << 8) | 3) #define VIEWER_STICK ((VIEWER << 8) | 4) #define VIEWER_BALL ((VIEWER << 8) | 5) #define VIEWER_CPK ((VIEWER << 8) | 6) #define VIEWER_SEP2 ((VIEWER << 8) | 7) #define VIEWER_GEOMETRY ((VIEWER << 8) | 8) #define VIEWER_BONDTYPE ((VIEWER << 8) | 9) #define VIEWER_WAVEFUNCTION ((VIEWER << 8) | 10) #define VIEWER_ENERGYLEVEL ((VIEWER << 8) | 11) #define VIEWER_OPTIMIZATION ((VIEWER << 8) | 12) #define VIEWER_FORCES ((VIEWER << 8) | 13) #define VIEWER_SPECTRUM ((VIEWER << 8) | 14) #define VIEWER_THERMODYNAMICS ((VIEWER << 8) | 15) #define VIEWER_UNITCELL ((VIEWER << 8) | 16) #define VIEWER_INERTIA ((VIEWER << 8) | 17) #define VIEWER_SEP3 ((VIEWER << 8) | 18) #define VIEWER_DRAWING ((VIEWER << 8) | 19) #define VIEWER_FOREGROUND ((VIEWER << 8) | 20) #define VIEWER_BACKGROUND ((VIEWER << 8) | 21) #define VIEWER_LABEL ((VIEWER << 8) | 22) #define VIEWER_ANNOTATE ((VIEWER << 8) | 23) #define VIEWER_RUNSCRIPT ((VIEWER << 8) | 24) #define VIEWER_SEP4 ((VIEWER << 8) | 25) #define VIEWER_HARDCOPY ((VIEWER << 8) | 26) #define VIEWER_RAYTRACING ((VIEWER << 8) | 27) #define VIEWER_MANUAL ((VIEWER << 8) | 28) #define VIEWER_SEP5 ((VIEWER << 8) | 29) #define VIEWER_CONFIGURATION ((VIEWER << 8) | 30) #define VIEWER_QUIT ((VIEWER << 8) | 31) #define VIEWER1_LOAD ((VIEWER1 << 8) | 0) #define VIEWER1_SAVE ((VIEWER1 << 8) | 1) #define VIEWER1_DELETE ((VIEWER1 << 8) | 2) #define VIEWER1_NEW ((VIEWER1 << 8) | 3) #define VIEWER1_BUILD ((VIEWER1 << 8) | 4) #define VIEWER2_ALL ((VIEWER2 << 8) | 0) #define VIEWER2_LAST ((VIEWER2 << 8) | 1) #define VIEWER2_SEP ((VIEWER2 << 8) | 2) #define VIEWER2_UNDO ((VIEWER2 << 8) | 3) #define SPECTRUM_SETTINGS ((SPECTRUM << 8) | 0) #define SPECTRUM_SELECT ((SPECTRUM << 8) | 1) #define SPECTRUM_IMAGINARY ((SPECTRUM << 8) | 2) #define SPECTRUM_OBSERVED ((SPECTRUM << 8) | 3) #define SPECTRUM_DELETE ((SPECTRUM << 8) | 4) #define SPECTRUM_ZOOMOUT ((SPECTRUM << 8) | 5) #define SPECTRUM_HARDCOPY ((SPECTRUM << 8) | 6) #define SPECTRUM_SEP1 ((SPECTRUM << 8) | 7) #define SPECTRUM_FOREGROUND ((SPECTRUM << 8) | 8) #define SPECTRUM_BACKGROUND ((SPECTRUM << 8) | 9) #define SPECTRUM_SEP2 ((SPECTRUM << 8) | 10) #define SPECTRUM_QUIT ((SPECTRUM << 8) | 11) #define HISTORY_SETTINGS ((HISTORY << 8) | 0) #define HISTORY_SELECT ((HISTORY << 8) | 1) #define HISTORY_ANIMATE ((HISTORY << 8) | 2) #define HISTORY_HARDCOPY ((HISTORY << 8) | 3) #define HISTORY_SEP1 ((HISTORY << 8) | 4) #define HISTORY_ENERGY ((HISTORY << 8) | 5) #define HISTORY_GRADIENT ((HISTORY << 8) | 6) #define HISTORY_BACKGROUND ((HISTORY << 8) | 7) #define HISTORY_SEP2 ((HISTORY << 8) | 8) #define HISTORY_QUIT ((HISTORY << 8) | 9) #define MO_SETTINGS ((MO << 8) | 0) #define MO_SELECT ((MO << 8) | 1) #define MO_TRANSITION ((MO << 8) | 2) #define MO_ZOOMOUT ((MO << 8) | 3) #define MO_HARDCOPY ((MO << 8) | 4) #define MO_ENERGYLEVELS ((MO << 8) | 5) #define MO_SEP1 ((MO << 8) | 6) #define MO_FOREGROUND ((MO << 8) | 7) #define MO_BACKGROUND ((MO << 8) | 8) #define MO_SEP2 ((MO << 8) | 9) #define MO_QUIT ((MO << 8) | 10) #define BACKGROUND 1 #define FOREGROUND 2 #define WIREMODEL 1 #define STICKMODEL 2 #define BALLMODEL 3 #define CUPMODEL 4 #define SPECTRUM_ALL 1 #define SPECTRUM_IR 2 #define SPECTRUM_RAMAN 3 #define SPECTRUM_INS 4 #define ANIMATE 1 #define ARROWS 2 #define DISTORT 3 #define TRAJECTORY 4 #define SCALES 0x1 #define ENERGY 0x2 #define GNORM 0x4 #define HARTREE 1 #define KJ_MOL 2 #define EV 3 #define CM 4 #define DENSITY_OF_STATES 1 #define ENERGY_LEVELS 2 #define BONDAVERAGE 1 #define BONDLENGTH 2 #define ANGLE 3 #define TORSION 4 #define ALL_OFF 1 #define BASIS_FUNCTION 2 #define BASIS_IN_MO 3 #define MOLECULAR_ORBITAL 4 #define DENSITY 5 #define GRIDREAD 0x100 #define IP_NONE 1 #define IP_LINEAR 2 #define IP_LOG 3 #define LABEL 1 #define INS 2 #define SCREEN 1 #define TIFFFILE 2 #define PNGFILE 3 #define HPGL 4 #define POSTSCRIPT 5 #define RAYTRACER 6 #define A5 1 #define A4 2 #define A3 3 #define LETTER 4 #define LEGAL 5 #define USER 6 #define ORTHO 0 #define PERSPECTIVE 1 #define LINE_STIPPLE 0x10000 #define LINE_WIDTH 0x20000 #define ADD_DEPTH 0x30000 #define VISIBILITY 0x40000 #define VIEWPOINT 0 #define LIGHTNO0 1 #define LIGHTNO1 2 #define WORLD 3 #define MOLECULES 4 #define CENTERED 1 #define COORDINATES 2 #define SINGLE_BONDS 1 #define MULTIPLE_BONDS 2 #define CONJUGATION 3 #define NOTHING 0 #define TEXT 1 #define DELETE 2 #define DRAWANN 0x1 #define EDITABLE 0x2 #define MOVEABLE 0x4 #define GEOMETRY 0x8 #define ORIGINAL 0x1 #define DISPLAY_ONLY 0x2 #define X_FIXED 0x4 #define Y_FIXED 0x8 #define Z_FIXED 0x10 #define SELECTED 0x20 #define ADD_ATOM 1 #define DELETE_ATOM 2 #define REPLACE_ATOM 3 #define CREATE_BOND 4 #define REMOVE_BOND 5 #define NEW_MOLECULE 6 #define BOND_ORDER 7 #define TRANSLATION 0x1 #define PV 0x2 #define ROTATION 0x4 #define VIBRATION 0x8 #define TOTAL 0x10 #define JOULES 0 #define CALORIES 1 #define THERMOCALORIES 2 #define REACTANT -1 #define PRODUCT 1 #define ALLREACTIONS 2 #define REACTION_OK 0 #define MISSING_ATOMS 1 #define CANT_BALANCE 2 #define INCONSISTENT_TYPE 3 #define ALPHAANDBETA 0 #define ALPHA 1 #define BETA 2 #define ALL -1 #define LAST -2 #define LMAX 4 /* maximum l quantum number supported */ struct BASISSET { double *first; /* points to the first exponent of a shell */ int nprim; /* the number of primitives in a shell */ int ang; /* the angular quantum number of the shell */ struct BASISSET *next; /* points to the BASISSET structure for the */ }; /* next shell of this atom or NULL */ struct MOLECULE { struct ATOM *atoms; struct BOND *bonds; struct UNITCELL *unitcell; struct NORMAL_MODE *normal_modes; struct COORDS *history; struct INTERNAL *internals; struct OPTIMIZATION *optimization; struct ORBITAL *orbitals; struct GRIDOBJECT *gridObjects; struct BASISSET *basisset; struct ELEMENT *bondStyle; struct SAVE *coord; PyMoleculeSpecObject *pyObject; double bondRadius, bondShift; double *cnm, *exponents; double transx, transy, transz; double rotConstants[3], tinert[3][3]; double htrl, strl, ctrl, hrot, srot, crot, hvib, svib, cvib, pv; double emax, emin, gmax; int *addedBonds, *deletedBonds; int cycle; int na, nb, nbAdded, nbDeleted, nmodes, nhist, ninternal, nbasfu, ngridobjects; int pured, puref, pureg, reaction, stoichioNumber; int mode, imo, imosave, ibasfu, imag, needMoloch, gaussian, thermoSettings; char title[MAXLENLINE], pgroup[6]; }; struct ATOM { double x; double y; double z; double rad; double radScale; double mass; double neutronScatterfac; int nbonds; int hbonds; int nelectrons; int ref; int nBasisFunctions; int flags; struct ELEMENT *element; struct BASISSET *basis; char name[8]; char **basisFunctionNames; char basisname[MAXLENBASISNAME]; }; struct BOND { int first; int second; int order; double frac; double x; double y; double z; }; struct UNITCELL { struct ATOM *corners; struct ATOM *millerPlanes; struct EDGE *edges; double a, b, c; double alpha, beta, gamma; double factor[3]; int nc, ne, np; int miller[3], nmiller; int showUnitCell, showMiller; }; struct EDGE { int first; int second; }; struct ELEMENT { double rad; double radScale; double mass; GLfloat dark[4]; GLfloat light[4]; GLfloat emission[4]; GLfloat ambient[4]; GLfloat specular[4]; GLfloat shininess; GLfloat alpha; GLint colormap[3]; char symbol[2]; }; struct NORMAL_MODE { double wavenumber; double ir_intensity; double raman_intensity; double ins_intensity; double rel_ir_intensity; double rel_raman_intensity; double rel_ins_intensity; char sym[8]; }; struct WINDOW { Widget widget; GLXContext context; int foreground; int background; int smooth; int mode; int set; Widget menu; struct MENUDATA *selectMenu; double left; double right; double bottom; double top; double near; double far; int horizontalMargin; int verticalMargin; int mouseX; int mouseY; float foreground_rgb[4]; float background_rgb[4]; XFontStruct *font; XFontStruct *greekFont; GLuint GLfontId; GLuint GLgreekFontId; }; struct OPTION { char flag[8]; char *identifier; char command[MAXLENLINE]; }; struct COORDS { GLdouble x; GLdouble y; GLdouble z; GLdouble gx; GLdouble gy; GLdouble gz; }; struct SAVE { double x, y, z; char name[8]; }; struct UNDO { struct SAVE *coord; int mol; int na; }; struct INTERNAL { double value; double x; double y; double z; int atoms[4]; int type; }; struct OPTIMIZATION { GLdouble energy; GLdouble gnorm; int coords; int natoms; }; struct ORBITAL { GLdouble energy; GLdouble occupation; double *coeff; int spin; char symmetry[8]; }; struct GRIDOBJECT { double origin[3]; double vector1[3], vector2[3], vector3[3]; double start[3], step[3]; double resolution; double *grid; int npoints[3]; int ngridpoints[3]; int type; int mo; int basisfunction; char symmetry[8]; char text[MAXLENLINE]; }; struct ZOOM { int window; double left; double right; double bottom; double top; }; struct TOGGLE { int *var; int value; void (*draw)(); }; struct SLIDER { double *number; int decimals; void (*draw)(); }; struct ANNOTATION { PyLabelSpecObject *pyObject; Widget widget; double x; double y; double z; float color_rgb[4]; int color; int flags; int userdata; char text[MAXLENLINE]; }; viewmol-2.4.1/source/viewmolmodule.c0100644000272700027270000004363107752677475015740 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * V I E W M O L M O D U L E . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: viewmolmodule.c,v 1.2 2003/11/07 11:17:17 jrh Exp $ * $Log: viewmolmodule.c,v $ * Revision 1.2 2003/11/07 11:17:17 jrh * Release 2.4 * * Revision 1.1 2000/12/10 15:18:35 jrh * Initial revision * */ #include #include #include #include #include #include "viewmol.h" static PyObject *viewmol_load(PyObject *, PyObject *); static PyObject *viewmol_save(PyObject *, PyObject *); static PyObject *viewmol_delete(PyObject *, PyObject *); static PyObject *viewmol_getMolecules(PyObject *, PyObject *); static PyObject *viewmol_getLights(PyObject *, PyObject *); static PyObject *viewmol_getLabels(PyObject *, PyObject *); static PyObject *viewmol_model(PyObject *, PyObject *); static PyObject *viewmol_drawingMode(PyObject *, PyObject *); static PyObject *viewmol_projection(PyObject *, PyObject *); static PyObject *viewmol_sphereResolution(PyObject *, PyObject *); static PyObject *viewmol_lineWidth(PyObject *, PyObject *); static PyObject *viewmol_groundColor(PyObject *, PyObject *); static PyObject *viewmol_backgroundColor(PyObject *, PyObject *); static PyObject *viewmol_labelAtoms(PyObject *, PyObject *); static PyObject *viewmol_saveDrawing(PyObject *, PyObject *); static PyObject *viewmol_isosurface(PyObject *, PyObject *); static PyObject *viewmol_showThermodynamics(PyObject *, PyObject *); static PyObject *viewmol_redraw(PyObject *, PyObject *); static PyObject *viewmol_getFramesPerSecond(PyObject *, PyObject *); static PyObject *viewmol_write(PyObject *, PyObject *); static PyObject *viewmol_registerMenuItem(PyObject *, PyObject *); static PyObject *viewmol_showWarnings(PyObject *, PyObject *); static PyObject *viewmol_getWindowSize(PyObject *, PyObject *); static PyObject *viewmol_quit(PyObject *, PyObject *); int checkInterrupt(void); extern XtAppContext app; extern PyMoleculeSpecObject *molecule_new(void); extern int load(Widget, caddr_t, XmAnyCallbackStruct *); extern void saveMolecule(char *); extern void setModel(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void setDrawingMode(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void setProjection(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void switchLight(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern void thermoDialog(Widget, caddr_t, XmAnyCallbackStruct *); extern void annotateWavefunction(void); extern void redraw(int); extern void ende(Widget, caddr_t, XmAnyCallbackStruct *); extern void saveDrawing(int, int, char *); extern void selectScreen(int); extern Boolean normalMode(XtPointer); extern int findMolecule(PyMoleculeSpecObject *); extern void deleteMolecule(Widget, caddr_t, XmAnyCallbackStruct *); extern void infoSetText(char *); extern void setShape(int, Dimension, Dimension); extern PyLightSpecObject *light_new(void); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern struct OPTION *output; extern struct ANNOTATION *annotation; extern double lineWidth, sphereres, level, drawingSpeed; extern int primitive, projectionMode, nAnnotations; extern int nmolecule, imol, label, outputType, noutput, animate, pythonInterrupt; extern int showWarning; extern char *moduleName; static PyMethodDef viewmol_methods[] = { {"load", viewmol_load, 1}, {"save", viewmol_save, 1}, {"delete", viewmol_delete, 1}, {"getMolecules", viewmol_getMolecules, 1}, {"getLights", viewmol_getLights, 1}, {"getLabels", viewmol_getLabels, 1}, {"model", viewmol_model, 1}, {"drawingMode", viewmol_drawingMode, 1}, {"projection", viewmol_projection, 1}, {"sphereResolution", viewmol_sphereResolution, 1}, {"lineWidth", viewmol_lineWidth, 1}, {"groundColor", viewmol_groundColor, 1}, {"backgroundColor", viewmol_backgroundColor, 1}, {"labelAtoms", viewmol_labelAtoms, 1}, {"saveDrawing", viewmol_saveDrawing, 1}, {"isosurface", viewmol_isosurface, 1}, {"showThermodynamics", viewmol_showThermodynamics, 1}, {"redraw", viewmol_redraw, 1}, {"getFramesPerSecond", viewmol_getFramesPerSecond, 1}, {"write", viewmol_write, 1}, {"registerMenuItem", viewmol_registerMenuItem, 1}, {"showWarnings", viewmol_showWarnings, 1}, {"getWindowSize", viewmol_getWindowSize, 1}, {"quit", viewmol_quit, 1}, {NULL, NULL} }; static PyObject *viewmol_load(PyObject *self, PyObject *args) { PyObject *new; char *filename; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "s", &filename)) return NULL; if (load((Widget)0, filename, (XmAnyCallbackStruct *)0)) { new=(PyObject *)(molecules[imol].pyObject); return(new); } else { PyErr_SetString(PyExc_ValueError, "File does not exist"); return(NULL); } } static PyObject *viewmol_save(PyObject *self, PyObject *args) { PyMoleculeSpecObject *molecule; int which, found; char *filename, *type; register int i; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "Oss", &molecule, &filename, &type)) return NULL; if (!molecule) { PyErr_SetString(PyExc_ValueError, "Molecule does not exist"); return(NULL); } found=FALSE; for (i=0; imoleculeID; i=windows[VIEWER].set; windows[VIEWER].set=which; saveMolecule(filename); windows[VIEWER].set=i; Py_INCREF(Py_None); return(Py_None); } static PyObject *viewmol_delete(PyObject *self, PyObject *args) { PyMoleculeSpecObject *molecule; int which, set_save; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "O", &molecule)) return NULL; if (!molecule) { PyErr_SetString(PyExc_ValueError, "Molecule does not exist"); return(NULL); } which=molecule->moleculeID; set_save=windows[VIEWER].set; windows[VIEWER].set=which; deleteMolecule((Widget)0, (caddr_t)FALSE, (XmAnyCallbackStruct *)0); if (set_save != which) windows[VIEWER].set=set_save; Py_INCREF(Py_None); return(Py_None); } static PyObject *viewmol_getMolecules(PyObject *self, PyObject *args) { PyObject *list; int i; if (checkInterrupt()) return(NULL); if ((list=PyList_New(nmolecule))) { for (i=0; ilightID=0; PyList_SetItem(list, 0, (PyObject *)new); new=light_new(); new->lightID=1; PyList_SetItem(list, 1, (PyObject *)new); return((PyObject *)list); } Py_INCREF(Py_None); return(Py_None); } static PyObject *viewmol_getLabels(PyObject *self, PyObject *args) { PyObject *list; int i; if (checkInterrupt()) return(NULL); if ((list=PyList_New(nAnnotations))) { for (i=0; i= 0.0 && r <= 1.0 && g >= 0.0 && g <= 1.0 && b >= 0.0 && b <= 1.0) { windows[VIEWER].foreground_rgb[0]=r; windows[VIEWER].foreground_rgb[1]=g; windows[VIEWER].foreground_rgb[2]=b; } else { PyErr_SetString(PyExc_ValueError, "Color specifications have to be between 0.0 and 1.0."); return(NULL); } } Py_INCREF(Py_None); return(Py_None); } static PyObject *viewmol_backgroundColor(PyObject *self, PyObject *args) { PyObject *tuple; float r=-1.0, g=-1.0, b=-1.0; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|fff", &r, &g, &b)) return(NULL); if (r == -1.0 && g == -1.0 && b == -1.0) /* get */ { if ((tuple=PyTuple_New(3))) { PyTuple_SetItem(tuple, 0, PyFloat_FromDouble((double)windows[VIEWER].background_rgb[0])); PyTuple_SetItem(tuple, 1, PyFloat_FromDouble((double)windows[VIEWER].background_rgb[1])); PyTuple_SetItem(tuple, 2, PyFloat_FromDouble((double)windows[VIEWER].background_rgb[2])); return(tuple); } } else /* set */ { if (r >= 0.0 && r <= 1.0 && g >= 0.0 && g <= 1.0 && b >= 0.0 && b <= 1.0) { windows[VIEWER].background_rgb[0]=r; windows[VIEWER].background_rgb[1]=g; windows[VIEWER].background_rgb[2]=b; } else { PyErr_SetString(PyExc_ValueError, "Color specifications have to be between 0.0 and 1.0."); return(NULL); } } Py_INCREF(Py_None); return(Py_None); } static PyObject *viewmol_labelAtoms(PyObject *self, PyObject *args) { int l; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "i", &l)) return(NULL); if (l != TRUE && l != FALSE) { PyErr_SetString(PyExc_ValueError, "Label must be ON or OFF"); return(NULL); } label=l; redraw(VIEWER); Py_INCREF(Py_None); return(Py_None); } static PyObject *viewmol_saveDrawing(PyObject *self, PyObject *args) { int format; char *filename; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "is", &format, &filename)) return NULL; if (!access(filename, F_OK)) { PyErr_SetString(PyExc_IOError, "File already exists."); return(NULL); } if (format != TIFFFILE && format != PNGFILE && format != HPGL && format != POSTSCRIPT && format != RAYTRACER) { PyErr_SetString(PyExc_ValueError, "Format not recognised."); return(NULL); } saveDrawing(VIEWER, format, filename); Py_INCREF(Py_None); return(Py_None); } static PyObject *viewmol_isosurface(PyObject *self, PyObject *args) { double l=(-1.0e0); if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|d", &l)) return(NULL); if (l == -1.0e0) return(PyFloat_FromDouble(level)); else { level=l; annotateWavefunction(); Py_INCREF(Py_None); return(Py_None); } } static PyObject *viewmol_showThermodynamics(PyObject *self, PyObject *args) { int selected=0; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "|i", &selected)) return(NULL); thermoDialog((Widget)0, (caddr_t)0, (XmAnyCallbackStruct *)0); if (selected >= 0 && selected <= nmolecule) selectScreen(selected); else { if (selected == (-1)) selectScreen(nmolecule+1); else { PyErr_SetString(PyExc_ValueError, "No such molecule."); return(NULL); } } Py_INCREF(Py_None); return(Py_None); } static PyObject *viewmol_redraw(PyObject *self, PyObject *args) { if (checkInterrupt()) return(NULL); Py_INCREF(Py_None); return(Py_None); } static PyObject *viewmol_getFramesPerSecond(PyObject *self, PyObject *args) { if (checkInterrupt()) return(NULL); return(PyFloat_FromDouble(drawingSpeed)); } static PyObject *viewmol_write(PyObject *self, PyObject *args) { char *string; if (!PyArg_ParseTuple(args, "s", &string)) return(NULL); infoSetText(string); Py_INCREF(Py_None); return(Py_None); } static PyObject *viewmol_registerMenuItem(PyObject *self, PyObject *args) { if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "s", &moduleName)) return(NULL); Py_INCREF(Py_None); return(Py_None); } static PyObject *viewmol_showWarnings(PyObject *self, PyObject *args) { int warning; if (checkInterrupt()) return(NULL); if (!PyArg_ParseTuple(args, "i", &warning)) return(NULL); if (warning != TRUE && warning != FALSE) { PyErr_SetString(PyExc_ValueError, "Argument must be ON or OFF"); return(NULL); } showWarning=warning; redraw(VIEWER); Py_INCREF(Py_None); return(Py_None); } static PyObject *viewmol_getWindowSize(PyObject *self, PyObject *args) { PyObject *tuple; Dimension width, height; if (checkInterrupt()) return(NULL); if ((tuple=PyTuple_New(2))) { XtVaGetValues(windows[VIEWER].widget, XtNwidth, &width, XtNheight, &height, NULL); PyTuple_SetItem(tuple, 0, PyInt_FromLong((long)width)); PyTuple_SetItem(tuple, 1, PyInt_FromLong((long)height)); return(tuple); } Py_INCREF(Py_None); return(Py_None); } static PyObject *viewmol_quit(PyObject *self, PyObject *args) { if (checkInterrupt()) return(NULL); ende((Widget)0, (caddr_t)0, (XmAnyCallbackStruct *)0); Py_INCREF(Py_None); return(Py_None); } int checkInterrupt() { XEvent event; if (pythonInterrupt) { PyErr_SetString(PyExc_KeyboardInterrupt, ""); pythonInterrupt=FALSE; return(TRUE); } else { if (animate == ANIMATE) (void)normalMode(0); else redraw(VIEWER); while (XtAppPending(app)) { XtAppNextEvent(app, &event); XtDispatchEvent(&event); } return(FALSE); } } void initViewmolModule(void) { PyObject *viewmol, *m, *d, *v; viewmol=PyImport_AddModule("viewmol"); m=Py_InitModule("viewmol", viewmol_methods); d=PyModule_GetDict(m); v=PyString_FromString(VERSION); PyDict_SetItemString(d, "version", v); PyDict_SetItemString(d, "__version__", v); PyDict_SetItemString(d, "ON", PyInt_FromLong((long)TRUE)); PyDict_SetItemString(d, "OFF", PyInt_FromLong((long)FALSE)); PyDict_SetItemString(d, "WIREMODEL", PyInt_FromLong((long)WIREMODEL)); PyDict_SetItemString(d, "STICKMODEL", PyInt_FromLong((long)STICKMODEL)); PyDict_SetItemString(d, "BALLMODEL", PyInt_FromLong((long)BALLMODEL)); PyDict_SetItemString(d, "CPKMODEL", PyInt_FromLong((long)CUPMODEL)); PyDict_SetItemString(d, "ORTHO", PyInt_FromLong((long)ORTHO)); PyDict_SetItemString(d, "PERSPECTIVE", PyInt_FromLong((long)PERSPECTIVE)); PyDict_SetItemString(d, "DOT", PyInt_FromLong((long)GLU_POINT)); PyDict_SetItemString(d, "LINE", PyInt_FromLong((long)GLU_LINE)); PyDict_SetItemString(d, "SURFACE", PyInt_FromLong((long)GLU_FILL)); PyDict_SetItemString(d, "TIFF", PyInt_FromLong((long)TIFFFILE)); PyDict_SetItemString(d, "PNG", PyInt_FromLong((long)PNGFILE)); PyDict_SetItemString(d, "HPGL", PyInt_FromLong((long)HPGL)); PyDict_SetItemString(d, "POSTSCRIPT", PyInt_FromLong((long)POSTSCRIPT)); PyDict_SetItemString(d, "RAYTRACER", PyInt_FromLong((long)RAYTRACER)); PyDict_SetItemString(d, "REACTION", PyInt_FromLong((long)(-1))); Py_DECREF(v); m=PyImport_Import(PyString_FromString("sys")); d=PyModule_GetDict(m); PyDict_SetItemString(d, "stdout", viewmol); PyDict_SetItemString(d, "stderr", viewmol); } viewmol-2.4.1/source/waveform.c0100644000272700027270000005315007752677504014664 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * W A V E F O R M . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: waveform.c,v 1.6 2003/11/07 11:17:24 jrh Exp $ * $Log: waveform.c,v $ * Revision 1.6 2003/11/07 11:17:24 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:18:53 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:27:56 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:59:44 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:47 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:44:23 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "viewmol.h" #include "dialog.h" extern void MapBox(Widget, caddr_t, caddr_t); extern void GetUnit(Widget, struct TOGGLE *, XmPushButtonCallbackStruct *); extern void GetSlider(Widget, struct SLIDER *, XmScrollBarCallbackStruct *); extern Widget CreateToggleBox(Widget, struct PushButtonRow *, int, int, int, int, int); extern char *getStringResource(Widget, char *); extern void CreatePushButtonRow(Widget, struct PushButtonRow *, int); extern int checkFile(char **); extern void calcmo(void); extern void redraw(int); extern void drawMolecule(Widget, caddr_t, XmDrawingAreaCallbackStruct *); extern void *getmem(size_t, size_t); extern void fremem(void **); extern void setMenuItem(int, int); extern int makeAnnotation(int, int, float, float, float, int, const GLfloat *, int, int, char *); extern void deleteAnnotation(int *); extern void pixelToWorld(int, double *, double *); extern int StringWidth(XFontStruct *, char *); extern int StringHeight(XFontStruct *); /* extern char *bfname(int);*/ extern int messgb(Widget, int, char *, struct PushButtonRow *, int); extern void GetMessageBoxButton(Widget, XtPointer, caddr_t); extern void setCursor(Widget, int); extern Widget initShell(Widget, char *, Widget *, Widget *); void wavefunctionDialogExit(Widget, caddr_t, XmPushButtonCallbackStruct *); int existsGridObject(void); void annotateWavefunction(void); void deleteGridObjects(void); void GetWave(Widget, struct TOGGLE *, XmToggleButtonCallbackStruct *); void GetAutomatic(Widget, caddr_t, XmToggleButtonCallbackStruct *); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern struct ELEMENT *elements; extern int iwavef, interp; extern int selectAtom, primitive, swapBuffers, selectAtomAnnotation; extern int *wavefunctionAnnotation, bfatom, ne, rgbMode; extern int nmolecule, automaticRecalculate; extern double level, gridres; extern Widget topShell; extern char moloch[]; extern Pixel stdcol[9]; static Widget dialog, slider2; static int iwavef_save, interp_save; static double level_save, gridres_save; void wavefunctionDialog(Widget widget, caddr_t dummy, XmAnyCallbackStruct *data) { Widget form, board, form1, checkbox1, checkbox2, sep1, sep2, sep3, sep4; Widget slider1, label, button; register int i, j; struct TOGGLE *toggle1; static struct TOGGLE toggle2[3]; struct PushButtonRow buttons[] = { { "ok", wavefunctionDialogExit, (XtPointer)TRUE, NULL }, { "cancel", wavefunctionDialogExit, (XtPointer)FALSE, NULL }, }; struct PushButtonRow *checkbox1_buttons; struct PushButtonRow checkbox2_buttons[] = { { "none", GetUnit, (XtPointer)&toggle2[0], NULL }, { "linear", GetUnit, (XtPointer)&toggle2[1], NULL }, { "logarithmic", GetUnit, (XtPointer)&toggle2[2], NULL }, }; static struct SLIDER surface, gridsize; struct MOLECULE *mol; int nDrawable, start, levelInt, minimum, maximum; short decimals; if (windows[VIEWER].set >= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; setMenuItem(VIEWER_WAVEFUNCTION, False); iwavef_save=iwavef; interp_save=interp; level_save=level; gridres_save=gridres; gridsize.number=&gridres; gridsize.decimals=0; gridsize.draw=NULL; dialog=initShell(windows[VIEWER].widget, "wavefunctionForm", &board, &form); form1=XtVaCreateWidget("controlarea", xmFormWidgetClass, form, NULL); if (mol->basisset) { start=ALL_OFF; nDrawable=DENSITY; } else { start=DENSITY; nDrawable=ALL_OFF; } for (i=0; ingridobjects; i++) if (mol->gridObjects[i].type & GRIDREAD) nDrawable++; toggle1=(struct TOGGLE *)getmem((size_t)nDrawable, sizeof(struct TOGGLE)); checkbox1_buttons=(struct PushButtonRow *)getmem((size_t)nDrawable, sizeof(struct PushButtonRow)); toggle1[0].var=&iwavef; toggle1[0].draw=NULL; toggle1[0].value=ALL_OFF; checkbox1_buttons[0].callback=GetWave; checkbox1_buttons[0].client_data=(XtPointer)&toggle1[0]; checkbox1_buttons[0].widget=(Widget)NULL; checkbox1_buttons[0].label="all_off"; j=0; for (i=1; i DENSITY) checkbox1_buttons[i].label=mol->gridObjects[j++].text; } if (mol->basisset) { checkbox1_buttons[1].label="basis_function"; checkbox1_buttons[2].label="basis_in_mo"; checkbox1_buttons[3].label="molecular_orbital"; checkbox1_buttons[4].label="electron_density"; } checkbox1=CreateToggleBox(form1, checkbox1_buttons, nDrawable, XmVERTICAL, 1, True, iwavef-start); if (mol->orbitals != NULL) { if (mol->needMoloch && *moloch == '\0') { XtVaSetValues(checkbox1_buttons[BASIS_IN_MO-1].widget, XmNsensitive, False, NULL); XtVaSetValues(checkbox1_buttons[MOLECULAR_ORBITAL-1].widget, XmNsensitive, False, NULL); XtVaSetValues(checkbox1_buttons[DENSITY-1].widget, XmNsensitive, False, NULL); } } else { XtVaSetValues(checkbox1_buttons[BASIS_IN_MO-1].widget, XmNsensitive, False, NULL); XtVaSetValues(checkbox1_buttons[MOLECULAR_ORBITAL-1].widget, XmNsensitive, False, NULL); XtVaSetValues(checkbox1_buttons[DENSITY-1].widget, XmNsensitive, False, NULL); } XtVaSetValues(checkbox1, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, NULL); sep1=XtVaCreateManagedWidget("sep1", xmSeparatorWidgetClass, form1, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, checkbox1, NULL); label=XtVaCreateManagedWidget("levelLabel", xmLabelWidgetClass, form1, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, sep1, NULL); slider1=XtVaCreateManagedWidget("level", xmScaleWidgetClass, form1, XmNorientation, XmHORIZONTAL, XmNshowValue, True, XmNsensitive, True, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, label, NULL); XtVaGetValues(slider1, XmNdecimalPoints, &decimals, NULL); levelInt=(int)(level*pow((double)10.0, (double)decimals)); XtVaGetValues(slider1, XmNminimum, &minimum, XmNmaximum, &maximum, NULL); if (minimum > levelInt) XtVaSetValues(slider1, XmNminimum, levelInt, NULL); if (maximum < levelInt) XtVaSetValues(slider1, XmNmaximum, levelInt, NULL); XtVaSetValues(slider1, XmNvalue, levelInt, NULL); surface.number=&level; surface.decimals=decimals; surface.draw=(void (*)())drawMolecule; XtAddCallback(slider1, XmNvalueChangedCallback, (XtCallbackProc)GetSlider, &surface); XtAddCallback(slider1, XmNdragCallback, (XtCallbackProc)GetSlider, &surface); sep2=XtVaCreateManagedWidget("sep2", xmSeparatorWidgetClass, form1, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, slider1, NULL); label=XtVaCreateManagedWidget("interpolationLabel", xmLabelWidgetClass, form1, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, sep2, NULL); for (i=0; i<3; i++) { toggle2[i].var=&interp; toggle2[i].draw=NULL; } toggle2[0].value=IP_NONE; toggle2[1].value=IP_LINEAR; toggle2[2].value=IP_LOG; checkbox2=CreateToggleBox(form1, checkbox2_buttons, XtNumber(checkbox2_buttons), XmVERTICAL, 1, True, interp-1); XtVaSetValues(checkbox2, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, label, NULL); sep3=XtVaCreateManagedWidget("sep3", xmSeparatorWidgetClass, form1, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, checkbox2, NULL); label=XtVaCreateManagedWidget("gridLabel", xmLabelWidgetClass, form1, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, sep3, NULL); slider2=XtVaCreateManagedWidget("grid", xmScaleWidgetClass, form1, XmNorientation, XmHORIZONTAL, XmNdecimalPoints, 0, XmNshowValue, True, XmNsensitive, True, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, label, NULL); if (iwavef > DENSITY) gridres=(double)(mol->gridObjects[iwavef-DENSITY-1].ngridpoints[0]); if (gridres > 0.0) XtVaSetValues(slider2, XmNvalue, (int)gridres, NULL); else { XtVaGetValues(slider2, XmNvalue, &levelInt, NULL); gridres=(double)levelInt; } XtAddCallback(slider2, XmNvalueChangedCallback, (XtCallbackProc)GetSlider, &gridsize); if (iwavef > DENSITY) XtVaSetValues(slider2, XmNsensitive, False, NULL); button=XtVaCreateManagedWidget("automatic", xmToggleButtonWidgetClass, form1, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, slider2, NULL); if (automaticRecalculate) XtVaSetValues(button, XmNset, True, NULL); XtAddCallback(button, XmNvalueChangedCallback, (XtCallbackProc)GetAutomatic, (XtPointer)&automaticRecalculate); sep4=XtVaCreateManagedWidget("sep5", xmSeparatorWidgetClass, form1, XmNtraversalOn, False, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, button, NULL); XtManageChild(form1); CreatePushButtonRow(form, buttons, XtNumber(buttons)); XtAddCallback(dialog, XmNpopupCallback, (XtCallbackProc)MapBox, (XtPointer)NULL); XtManageChild(form); XtManageChild(board); } void wavefunctionDialogExit(Widget widget, caddr_t which, XmPushButtonCallbackStruct *data) { const GLfloat black[4] = {0.0, 0.0, 0.0, 0.0}; char *word; if (!(int)which) { iwavef=iwavef_save; interp=interp_save; level=level_save; gridres=gridres_save; } else { switch (iwavef) { case ALL_OFF: deleteGridObjects(); break; case BASIS_FUNCTION: case BASIS_IN_MO: word=getStringResource(topShell, "selectAtomTitle"); selectAtomAnnotation=makeAnnotation(selectAtomAnnotation, CENTERED, 0.0, 1.0, 0.0, stdcol[BLACK], black, 0, 0, word); selectAtom=TRUE; break; case MOLECULAR_ORBITAL: case DENSITY: selectAtom=FALSE; if (!existsGridObject()) { setCursor(dialog, XC_watch); calcmo(); } break; /* Grid read from input */ default: selectAtom=FALSE; break; } } XtDestroyWidget(dialog); annotateWavefunction(); setMenuItem(VIEWER_WAVEFUNCTION, True); redraw(VIEWER); } void annotateWavefunction(void) { static int wavefunctionAnnotation[4]={-1, -1, -1, -1}; struct MOLECULE *mol; Pixel pixel=0; double xpix, ypix; float x, y, z; GLfloat color[4] = {0.0, 0.0, 0.0, 1.0}; const GLfloat black[4] = {0.0, 0.0, 0.0, 1.0}; char line1[MAXLENLINE], line2[MAXLENLINE], *c, *d; int annotateSurface=0; register int i; if (windows[VIEWER].set >= 0) mol=&molecules[windows[VIEWER].set]; else mol=&molecules[0]; deleteAnnotation(&wavefunctionAnnotation[0]); if (wavefunctionAnnotation[1] != (-1)) wavefunctionAnnotation[1]--; deleteAnnotation(&wavefunctionAnnotation[1]); if (wavefunctionAnnotation[2] != (-1)) wavefunctionAnnotation[2]-=2; deleteAnnotation(&wavefunctionAnnotation[2]); if (wavefunctionAnnotation[3] != (-1)) wavefunctionAnnotation[3]-=3; deleteAnnotation(&wavefunctionAnnotation[3]); if (!existsGridObject()) return; if (iwavef == BASIS_FUNCTION && mol->ibasfu != -1) { c=getStringResource(topShell, "basisfunctionTitle"); sprintf(line1, c, mol->ibasfu+1, mol->atoms[bfatom].name, bfatom+1, /* bfname(mol->ibasfu));*/ mol->atoms[bfatom].basisFunctionNames[mol->ibasfu]); wavefunctionAnnotation[0]=makeAnnotation(wavefunctionAnnotation[0], CENTERED, 0.0, 1.0, 0.0, stdcol[BLACK], black, 0, 0, line1); annotateSurface=2; } else if (iwavef == BASIS_IN_MO && mol->ibasfu != -1) { c=getStringResource(topShell, "basisfunctionInMOTitle"); sprintf(line1, c, mol->ibasfu+1, mol->imo+1, mol->atoms[bfatom].name, bfatom+1, /* mol->orbitals[mol->imo].coeff[mol->ibasfu], bfname(mol->ibasfu));*/ mol->orbitals[mol->imo].coeff[mol->ibasfu], mol->atoms[bfatom].basisFunctionNames[mol->ibasfu]); wavefunctionAnnotation[0]=makeAnnotation(wavefunctionAnnotation[0], CENTERED, 0.0, 1.0, 0.0, stdcol[BLACK], black, 0, 0, line1); annotateSurface=2; } else if (iwavef == MOLECULAR_ORBITAL && mol->imo != -1) { c=getStringResource(topShell, "molecularOrbitalTitle"); sprintf(line1, c, mol->imo+1, mol->orbitals[mol->imo].symmetry, mol->orbitals[mol->imo].energy); wavefunctionAnnotation[0]=makeAnnotation(wavefunctionAnnotation[0], CENTERED, 0.0, 1.0, 0.0, stdcol[BLACK], black, 0, 0, line1); annotateSurface=2; } else if (iwavef == DENSITY) { c=getStringResource(topShell, "electronDensityTitle"); sprintf(line1, c); wavefunctionAnnotation[0]=makeAnnotation(wavefunctionAnnotation[0], CENTERED, 0.0, 1.0, 0.0, stdcol[BLACK], black, 0, 0, line1); annotateSurface=1; } if (annotateSurface) { pixelToWorld(VIEWER, &xpix, &ypix); c=getStringResource(topShell, "isosurfaceLabel"); d=getStringResource(topShell, "isosurfaceLevel"); if (annotateSurface == 1) { sprintf(line1, "%s%s", c, d); sprintf(line2, line1, level); } else { sprintf(line1, "%s%s%s", c, d, d); sprintf(line2, line1, level, (-level)); } x=(windows[VIEWER].left+windows[VIEWER].right -xpix*(double)StringWidth(windows[VIEWER].font, line2))*0.5; y=windows[VIEWER].top-4.*ypix*(double)StringHeight(windows[VIEWER].font); z=(float)windows[VIEWER].near; wavefunctionAnnotation[1]=makeAnnotation(wavefunctionAnnotation[1], COORDINATES, x, y, z, stdcol[BLACK], black, 0, 0, c); for (i=0; iset) { if ((which->value == BASIS_IN_MO || which->value == MOLECULAR_ORBITAL) && molecules[windows[VIEWER].set].imo == (-1)) { word=getStringResource(topShell, "noMOselected"); sprintf(line, word, molecules[windows[VIEWER].set].title); messgb(topShell, 2, line, button, 1); XtVaSetValues(widget, XmNset, False, NULL); return; } *(which->var)=which->value; if (which->value > DENSITY) { i=which->value-DENSITY-1; XtVaSetValues(slider2, XmNsensitive, False, XmNvalue, molecules[windows[VIEWER].set].gridObjects[i].ngridpoints[0], NULL); gridres=(double)molecules[windows[VIEWER].set].gridObjects[i].ngridpoints[0]; } else XtVaSetValues(slider2, XmNsensitive, True, XmNvalue, (int)gridres, NULL); } if (*(which->draw) != NULL) (*(which->draw))((Widget)0, (caddr_t)0, (caddr_t)0); } void GetAutomatic(Widget widget, caddr_t which, XmToggleButtonCallbackStruct *data) { int *w; w=(int *)which; if (data->set) *w=TRUE; else *w=FALSE; } viewmol-2.4.1/source/window.c0100644000272700027270000000302207752677513014336 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * W I N D O W . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: window.c,v 1.6 2003/11/07 11:17:31 jrh Exp $ * $Log: window.c,v $ * Revision 1.6 2003/11/07 11:17:31 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:19:04 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:27:59 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 21:59:50 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:49 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:44:28 jrh * Initial revision * */ #include #include #include #include "viewmol.h" void setWindowTitle(Widget widget, char *title) { if (title != NULL) XtVaSetValues(XtParent(widget), XmNtitle, title, NULL); /*XTextProperty text; if (XStringListToTextProperty(&title, 1, &text)) { XSetWMName(XtDisplay(widget), XtWindow(widget), &text); XFlush(XtDisplay(widget)); } */ } viewmol-2.4.1/source/xfont.c0100644000272700027270000000612010114370041014133 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * X F O N T . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: xfont.c,v 1.7 2004/08/29 15:02:57 jrh Exp $ * $Log: xfont.c,v $ * Revision 1.7 2004/08/29 15:02:57 jrh * Release 2.4.1 * * Revision 1.6 2003/11/07 11:17:38 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:19:30 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:28:08 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 22:00:25 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:52 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:44:32 jrh * Initial revision * */ #include #include #include #include #include #include #include #include #include "viewmol.h" extern void *getmem(size_t, size_t); extern void fremem(void **); extern int drawingDevice; extern char *textPointer; XFontStruct *makeRasterFont(Display *display, char *font, GLuint *base) { XFontStruct *fontInfo, *f; Font id; unsigned int first, last; /* leaks memory */ if ((fontInfo=XLoadQueryFont(display, font)) == NULL) return(fontInfo); id=fontInfo->fid; first=fontInfo->min_char_or_byte2; last=fontInfo->max_char_or_byte2; if ((*base=glGenLists((GLuint)last+1)) == 0) { XFreeFont(display, fontInfo); return((XFontStruct *)NULL); } /* leaks memory */ f=(XFontStruct *)getmem((size_t)1, sizeof(XFontStruct)); memcpy((void *)f, (void *)fontInfo, sizeof(XFontStruct)); glXUseXFont(id, first, last-first+1, *base+first); return(f); } void printString(char *s, double x, double y, double z, double width, GLuint base, char align) { double xaligned=0.0; switch (align) { case 'l': xaligned=x; break; case 'r': xaligned=x-width; break; case 'c': xaligned=x-0.5*width; break; } glRasterPos3d(xaligned, y, z); glListBase(base); glCallLists(strlen(s), GL_UNSIGNED_BYTE, (GLubyte *)s); } int StringWidth(XFontStruct *font, char *string) { if (font) return(XTextWidth(font, string, strlen(string))); else return(0); } int StringHeight(XFontStruct *font) { if (font) return(font->ascent+font->descent); else return(0); } int StringAscent(XFontStruct *font) { if (font) return(font->ascent); else return(0); } void deleteFontList(GLuint base, XFontStruct *font) { if (font) { glDeleteLists(base, font->max_char_or_byte2-font->min_char_or_byte2+1); fremem((void **)&font); } } viewmol-2.4.1/source/zoom.c0100644000272700027270000001571707752677530014030 0ustar jrhjrh/******************************************************************************* * * * Viewmol * * * * Z O O M . C * * * * Copyright (c) Joerg-R. Hill, October 2003 * * * ******************************************************************************** * * $Id: zoom.c,v 1.6 2003/11/07 11:17:44 jrh Exp $ * $Log: zoom.c,v $ * Revision 1.6 2003/11/07 11:17:44 jrh * Release 2.4 * * Revision 1.5 2000/12/10 15:19:37 jrh * Release 2.3 * * Revision 1.4 1999/05/24 01:28:10 jrh * Release 2.2.1 * * Revision 1.3 1999/02/07 22:00:33 jrh * Release 2.2 * * Revision 1.2 1998/01/26 00:49:55 jrh * Release 2.1 * * Revision 1.1 1996/12/10 18:44:37 jrh * Initial revision * */ #include #include #include #include "viewmol.h" extern void drawSpectrum(Widget, caddr_t, caddr_t); extern void drawMODiagram(Widget, caddr_t, caddr_t); extern void setWindowColor(int, Pixel, const float *); extern void pixelToWorld(int, double *, double *); extern void *getmem(size_t, size_t); extern void *expmem(void *, size_t, size_t); extern void fremem(void **); extern void setMenuItem(int, int); extern void redraw(int); extern struct WINDOW windows[]; extern struct MOLECULE *molecules; extern int swapBuffers, nbasfu; static int mouseInitX, mouseInitY, window, zoomRec=0; static struct ZOOM *zoomOld=NULL; void zoomIn(Widget widget, XmDrawingAreaCallbackStruct *data) { /* This subroutine is called when the user wants to zoom into the spectrum or into the MO diagram. It is called when the middle mouse button is held down and the mouse is moved. */ Dimension width, height; swapBuffers=FALSE; if (widget == windows[SPECTRUM].widget) { drawSpectrum((Widget)0, (caddr_t)0, (caddr_t)0); window=SPECTRUM; } else if (widget == windows[MO].widget) { drawMODiagram((Widget)0, (caddr_t)0, (caddr_t)0); window=MO; } swapBuffers=TRUE; XtVaGetValues(windows[window].widget, XmNwidth, &width, XmNheight, &height, NULL); glEnable(GL_LINE_STIPPLE); /* Dotted lines */ glLineStipple(1, 0x5555); glLineWidth((GLfloat)1.); setWindowColor(FOREGROUND, windows[window].foreground, windows[window].foreground_rgb); glPushMatrix(); glLoadIdentity(); glOrtho(0.0, (double)width, 0.0, (double)height, 0.0, 1.0); glBegin(GL_LINE_LOOP); glVertex2i(mouseInitX, mouseInitY); glVertex2i(mouseInitX, height-data->event->xmotion.y); glVertex2i(data->event->xmotion.x, height-data->event->xmotion.y); glVertex2i(data->event->xmotion.x, mouseInitY); glEnd(); glDisable(GL_LINE_STIPPLE); glXSwapBuffers(XtDisplay(widget), XtWindow(widget)); glPopMatrix(); } void initZoom(Widget widget, XmDrawingAreaCallbackStruct *data) { Dimension height; XtVaGetValues(widget, XmNheight, &height, NULL); mouseInitX=data->event->xbutton.x; mouseInitY=height-data->event->xbutton.y; } void saveZoom(int window) { if (zoomOld == NULL) zoomOld=(struct ZOOM *)getmem(zoomRec+1, sizeof(struct ZOOM)); else zoomOld=(struct ZOOM *)expmem((void *)zoomOld, zoomRec+1, sizeof(struct ZOOM)); zoomOld[zoomRec].window=window; zoomOld[zoomRec].left=windows[window].left; zoomOld[zoomRec].right=windows[window].right; zoomOld[zoomRec].bottom=windows[window].bottom; zoomOld[zoomRec++].top=windows[window].top; } void endZoom(Widget widget, int x, int y) { Dimension height; double xpix, ypix, save; /* Copy final values and be careful that these are not equal to the start values. */ pixelToWorld(window, &xpix, &ypix); XtVaGetValues(widget, XmNheight, &height, NULL); saveZoom(window); if (window == SPECTRUM) { save=windows[window].left; if (mouseInitX < x) { windows[window].left=(mouseInitX-windows[window].horizontalMargin)*xpix+save; windows[window].right=(x-windows[window].horizontalMargin)*xpix+save; } else if (mouseInitX == x) { windows[window].left=(mouseInitX-windows[window].horizontalMargin)*xpix+save; windows[window].right=(mouseInitX-windows[window].horizontalMargin+1)*xpix+save; } else { windows[window].left=(x-windows[window].horizontalMargin)*xpix+save; windows[window].right=(mouseInitX-windows[window].horizontalMargin)*xpix+save; } } y=height-y; save=windows[window].bottom; if (mouseInitY < y) { windows[window].top=(y-windows[window].verticalMargin)*ypix+save; windows[window].bottom=(mouseInitY-windows[window].verticalMargin)*ypix+save; } else if (mouseInitY == y) { windows[window].top=(mouseInitY-windows[window].verticalMargin+1)*ypix+save; windows[window].bottom=(mouseInitY-windows[window].verticalMargin)*ypix+save; } else { windows[window].top=(mouseInitY-windows[window].verticalMargin)*ypix+save; windows[window].bottom=(y-windows[window].verticalMargin)*ypix+save; } if (window == SPECTRUM) { drawSpectrum((Widget)0, (caddr_t)0, (caddr_t)0); setMenuItem(SPECTRUM_ZOOMOUT, True); } else if (window == MO) { drawMODiagram((Widget)0, (caddr_t)0, (caddr_t)0); setMenuItem(MO_ZOOMOUT, True); } } void zoomOut(Widget widget, caddr_t window, XmDrawingAreaCallbackStruct *data) { register int i, j, w; w=(int)window; for (i=zoomRec-1; i>=0; i--) { if (zoomOld[i].window == w) { windows[w].left=zoomOld[i].left; windows[w].right=zoomOld[i].right; windows[w].bottom=zoomOld[i].bottom; windows[w].top=zoomOld[i].top; for (j=i+1; jorbitals[0].energy; zoomOld[i].top=1.05*mol->orbitals[mol->nbasfu-1].energy; } found=TRUE; break; } } return(found); } viewmol-2.4.1/viewmolrc0100644000272700027270000001646710123047010013277 0ustar jrhjrh#******************************************************************************* # * # Viewmol * # * # V I E W M O L R C * # * # Copyright (c) Joerg-R. Hill, October 2003 * # * #******************************************************************************* # # $Id: viewmolrc,v 1.7 2004/08/29 15:21:07 jrh Exp $ # $Log: viewmolrc,v $ # Revision 1.7 2004/08/29 15:21:07 jrh # Release 2.4.1 # # Revision 1.6 2003/11/07 13:03:59 jrh # Release 2.4 # # Revision 1.5 2000/12/10 15:18:46 jrh # Release 2.3 # # Revision 1.4 1999/05/24 01:29:12 jrh # Release 2.2.1 # # Revision 1.3 1999/02/07 21:59:33 jrh # Release 2.2 # # Revision 1.2 1998/01/26 00:49:45 jrh # Release 2.1 # # Revision 1.1 1996/12/10 18:49:10 jrh # Initial revision # # option bio $VIEWMOLPATH/$OSNAME/bio '%s' "BIOSYM" option bio $VIEWMOLPATH/$OSNAME/bio '%s' "DIMENSION" option dmol $VIEWMOLPATH/readdmol '%s' "D M o l" option dmol $VIEWMOLPATH/readdmol -v '%s' "DMol" option dmol $VIEWMOLPATH/readdmol '%s' "DDDDDDDD" option gamess $VIEWMOLPATH/$OSNAME/readgamess '%s' "GAMESS" option gauss $VIEWMOLPATH/$OSNAME/readgauss '%s' "Gaussian" option gulp $VIEWMOLPATH/readgulp '%s' "GENERAL UTILITY" option mopac $VIEWMOLPATH/$OSNAME/readmopac '%s' "MOPAC" option pdb $VIEWMOLPATH/$OSNAME/readpdb '%s' "ATOM" option pdb $VIEWMOLPATH/$OSNAME/readpdb '%s' "HEADER" option pqs $VIEWMOLPATH/readpqs '%s' "PQS" option python python "python" option tmmsi $VIEWMOLPATH/$OSNAME/tm -msi '%s' "type=car" option tm $VIEWMOLPATH/$OSNAME/tm '%s' "$coord" option tm $VIEWMOLPATH/$OSNAME/tm '%s' "$scratch" option tm $VIEWMOLPATH/$OSNAME/tm '%s' "$natural orbital" option tm $VIEWMOLPATH/$OSNAME/tm '%s' "$symmetry" option vamp $VIEWMOLPATH/$OSNAME/readmopac '%s' "VAMP" # output car $VIEWMOLPATH/writecar car '%s' output arc $VIEWMOLPATH/writecar arc '%s' output gauss $VIEWMOLPATH/writegauss.py '%s' output mol $VIEWMOLPATH/writemol '%s' output tm $VIEWMOLPATH/writetm '%s' # radius colour from to # r g b r g b h 0.46 0.50 0.50 0.50 0.80 0.80 0.80 he 1.60 0.50 0.50 0.50 0.80 0.80 0.80 li 0.68 0.00 0.00 0.00 0.30 0.30 0.30 be 0.35 0.00 0.00 0.00 0.30 0.30 0.30 b 0.82 0.00 0.00 0.00 0.30 0.30 0.30 c 0.85 0.30 0.30 0.30 0.50 0.50 0.50 n 0.75 0.00 0.75 0.00 0.00 1.00 0.00 o 0.74 0.00 0.00 0.30 0.00 0.00 1.00 f 0.72 0.00 0.50 0.00 0.00 0.75 0.50 ne 1.12 0.00 0.00 0.00 0.30 0.30 0.30 na 1.54 0.30 0.30 0.30 0.30 0.30 0.30 mg 1.37 0.30 0.30 0.30 0.30 0.30 0.30 al 1.33 0.20 0.20 0.20 0.50 0.50 0.50 si 1.17 0.50 0.30 0.00 1.00 0.50 0.00 p 1.06 0.80 0.00 0.00 1.00 0.00 0.20 s 1.02 0.80 0.80 0.00 1.00 1.00 0.00 cl 0.99 0.00 0.50 0.00 0.00 0.75 0.50 ar 1.54 0.00 0.00 0.00 0.30 0.30 0.30 k 1.33 0.00 0.00 0.00 0.30 0.30 0.30 ca 1.74 0.00 0.00 0.00 0.30 0.30 0.30 sc 1.91 0.00 0.00 0.00 0.30 0.30 0.30 ti 1.63 0.00 0.00 0.00 0.30 0.30 0.30 v 1.10 0.00 0.00 0.00 0.30 0.30 0.30 cr 1.55 0.00 0.30 0.00 0.00 0.80 0.00 mn 1.42 0.00 0.00 0.00 0.30 0.30 0.30 fe 1.37 0.50 0.00 0.00 1.00 0.50 0.00 co 1.26 0.00 0.00 0.00 0.30 0.30 0.30 ni 1.55 0.00 0.00 0.00 0.30 0.30 0.30 cu 1.17 0.30 0.30 0.00 1.00 0.50 0.00 zn 1.47 0.00 0.00 0.00 0.30 0.30 0.30 ga 1.52 0.50 0.00 0.60 0.90 0.00 1.00 ge 1.53 0.00 0.00 0.00 0.30 0.30 0.30 as 1.55 0.75 0.75 0.15 0.75 0.75 0.15 se 1.46 0.00 0.00 0.00 0.30 0.30 0.30 br 1.44 0.00 0.00 0.00 0.30 0.30 0.30 kr 1.60 0.00 0.00 0.00 0.30 0.30 0.30 rb 2.78 0.00 0.00 0.00 0.30 0.30 0.30 sr 2.45 0.00 0.00 0.00 0.30 0.30 0.30 y 2.08 0.00 0.00 0.00 0.30 0.30 0.30 zr 1.89 0.00 0.00 0.00 0.30 0.30 0.30 nb 1.73 0.00 0.00 0.00 0.30 0.30 0.30 mo 1.56 0.00 0.00 0.00 0.30 0.30 0.30 tc 1.65 0.00 0.00 0.00 0.30 0.30 0.30 ru 1.63 0.00 0.00 0.00 0.30 0.30 0.30 rh 1.65 0.00 0.00 0.00 0.30 0.30 0.30 pd 1.68 0.00 0.00 0.00 0.30 0.30 0.30 ag 1.75 0.00 0.00 0.00 0.30 0.30 0.30 cd 1.79 0.00 0.00 0.00 0.30 0.30 0.30 in 1.93 0.00 0.00 0.00 0.30 0.30 0.30 sn 1.71 0.00 0.00 0.00 0.30 0.30 0.30 sb 1.75 0.00 0.00 0.00 0.30 0.30 0.30 te 1.73 0.00 0.00 0.00 0.30 0.30 0.30 i 1.63 0.00 0.00 0.00 0.30 0.30 0.30 xe 1.70 0.00 0.00 0.00 0.30 0.30 0.30 cs 2.95 0.00 0.00 0.00 0.30 0.30 0.30 ba 2.47 0.00 0.00 0.00 0.30 0.30 0.30 la 2.17 0.00 0.00 0.00 0.30 0.30 0.30 ce 1.82 0.50 0.50 0.00 0.80 0.80 0.00 pr 2.12 0.00 0.00 0.00 0.30 0.30 0.30 nd 2.11 0.00 0.00 0.00 0.30 0.30 0.30 pm 2.11 0.00 0.00 0.00 0.30 0.30 0.30 sm 2.10 0.00 0.00 0.00 0.30 0.30 0.30 eu 2.29 0.00 0.00 0.00 0.30 0.30 0.30 gd 2.09 0.00 0.00 0.00 0.30 0.30 0.30 tb 2.06 0.00 0.00 0.00 0.30 0.30 0.30 dy 2.05 0.00 0.00 0.00 0.30 0.30 0.30 ho 2.04 0.50 0.50 0.50 0.80 0.80 0.80 er 2.03 0.00 0.00 0.00 0.30 0.30 0.30 tm 2.03 0.00 0.00 0.00 0.30 0.30 0.30 yb 2.24 0.00 0.00 0.00 0.30 0.30 0.30 lu 2.02 0.00 0.00 0.00 0.30 0.30 0.30 hf 1.86 0.50 0.50 0.50 0.80 0.80 0.80 ta 1.73 0.00 0.00 0.00 0.30 0.30 0.30 w 1.58 0.00 0.00 0.00 0.30 0.30 0.30 re 1.67 0.00 0.00 0.00 0.30 0.30 0.30 os 1.64 0.00 0.00 0.00 0.30 0.30 0.30 ir 1.66 0.00 0.00 0.00 0.30 0.30 0.30 pt 1.69 0.00 0.00 0.00 0.30 0.30 0.30 au 1.74 0.50 0.30 0.00 0.90 0.80 0.00 hg 1.80 0.50 0.50 0.50 0.80 0.80 0.80 tl 2.00 0.00 0.00 0.00 0.30 0.30 0.30 pb 2.05 0.00 0.00 0.00 0.30 0.30 0.30 bi 1.85 0.00 0.00 0.00 0.30 0.30 0.30 po 1.48 0.00 0.00 0.00 0.30 0.30 0.30 at 1.81 0.00 0.00 0.00 0.30 0.30 0.30 rn 1.90 0.00 0.00 0.00 0.30 0.30 0.30 fr 3.15 0.00 0.00 0.00 0.30 0.30 0.30 ra 2.52 0.00 0.00 0.00 0.30 0.30 0.30 ac 2.18 0.00 0.00 0.00 0.30 0.30 0.30 th 2.10 0.00 0.00 0.00 0.30 0.30 0.30 pa 1.91 0.00 0.00 0.00 0.30 0.30 0.30 u 1.69 0.00 0.00 0.00 0.30 0.30 0.30 np 0.95 0.00 0.00 0.00 0.30 0.30 0.30 pu 1.81 0.00 0.00 0.00 0.30 0.30 0.30 am 1.61 0.00 0.00 0.00 0.30 0.30 0.30 cm 0.91 0.00 0.00 0.00 0.30 0.30 0.30 bk 0.90 0.00 0.00 0.00 0.30 0.30 0.30 cf 0.89 0.00 0.00 0.00 0.30 0.30 0.30 es 0.88 0.00 0.00 0.00 0.30 0.30 0.30 fm 0.87 0.00 0.00 0.00 0.30 0.30 0.30 md 0.86 0.00 0.00 0.00 0.30 0.30 0.30 no 0.85 0.00 0.00 0.00 0.30 0.30 0.30 lr 0.84 0.00 0.00 0.00 0.30 0.30 0.30 rf 0.84 0.00 0.00 0.00 0.30 0.30 0.30 db 0.84 0.00 0.00 0.00 0.30 0.30 0.30 sg 0.84 0.00 0.00 0.00 0.30 0.30 0.30 bh 0.84 0.00 0.00 0.00 0.30 0.30 0.30 hs 0.84 0.50 0.50 0.50 0.80 0.80 0.80 mt 0.84 0.00 0.00 0.00 0.30 0.30 0.30 rg 0.84 0.00 0.00 0.00 0.30 0.30 0.30 # Bond bd 0.15 0.00 0.00 0.00 0.60 0.60 0.00 # Unit cell uc 0.15 0.20 0.20 0.20 0.50 0.50 0.50 # Positive isosurface ps 0.00 0.50 0.00 0.00 1.00 0.00 0.00 # Negative isosurface ms 0.00 0.00 0.00 0.50 0.00 0.00 1.00 # Miller plane mp 0.00 0.70 0.70 0.70 0.90 0.90 0.90 alpha 0.75 # Default for unknown atoms ?? 0.10 0.00 0.00 0.00 0.00 0.00 0.00 viewmol-2.4.1/kde/0040755000272700027270000000000010132003453012100 5ustar jrhjrhviewmol-2.4.1/kde/icons/0040755000272700027270000000000010123052370013215 5ustar jrhjrhviewmol-2.4.1/kde/icons/64x64/0040755000272700027270000000000010123052370014010 5ustar jrhjrhviewmol-2.4.1/kde/icons/64x64/mimetypes/0040755000272700027270000000000010130257466016037 5ustar jrhjrhviewmol-2.4.1/kde/icons/64x64/mimetypes/molecule.png0100644000272700027270000000623310123052370020340 0ustar jrhjrh‰PNG  IHDR@@ªiqÞbKGDÿÿÿ ½§“ pHYs  ÒÝ~ütIMEÓ   û±"‹ (IDATxœí›[LTWÇs`faATlA8JEÕVlÓKRmÒ4mbljc/¾ô’¦Išô¡iÒ´M¬h+&Æš4¨µT‰Њ vA†¹™3gfö÷ðÅóÕÔ—2ÍgW2sr²ÖÿÏÚ{¯õ?ûÀ¿ö¯ÅÌz{{…Ãá]]]"Vt± |ìØ1a±X0™L¸\.L&O<ñÄŒã‘f:àmkiiÁn·c6›éïïçÀ1Á¡IT`hhˆÔÔT¢Ñ(###dggÇGÌ2`õêÕŒ#IN§“M›6ÅGÌðù|$&&’——G\\eee1YbF@4EN§C§‹ÙZ;dY¦µµ•¡¡!:::b#v!´ß#™Bü¯öy$ ðûýÌ;‡ÃAff&§NŠI5ê¿úê+át:1ÄÅʼnDe™´´4Þ{ï½Å4ãðñÇ‹?þøƒh4J8&‰DB`³Ù8tèÐŒfÂŒpõêU‚Á @UUÑëõƒAdYFQöïß?m±ìv»°Ûí÷%ô¾tvvŠ‹/ŠsçΉ‘‘‘iy2Á`¿ßÇãaÖ¬YlذÄÄD¼^/>ŸEQ¦# Ân·344Äùóçï‰ýžœ9sFtuu‰D8vìØ”Aõôôˆ@ @0$ 122Âo¿ýÆèè(Š¢ ( @€žžž)‘]__/zzzeY–¹qãõõõwõyO‚Á }}}FdYfdd„¶¶61:::apÝÝÝbïÞ½âÀ,]ºEQ…B8š››q¹\„B!‚Á ?þ8µµµìÛ·O\¿~}±z{{Err2ƒƒƒÈ²L àÖ­[ƒÁ»ÞÏnpll §ÓÉùóç‰D"äççF¹ví?ýô“(..¦  à+vCCƒ8xð )))¬_¿ž––~ÿýwt:ƒI’ˆD"E¡¤¤„ŠŠ ZZZ8xð gΜëÖ­Óâtww‹þþ~"‘7nÔ®ŸcccD"/^LYYœ={–ññqÖ¬YCvv6{öì!99I’P…ªª*–,YÂÞ½{1”••áñx8qâ7oÞ䥗^bÏž=Ìš5 ½^ªª,]º”eË–qøða-ZDuu5ééé´¶¶"Ë2•••ܼy‡ÃABBÑh¿ßÏÚµk±Ûíܼy“òòr, ×®]£««‹5kÖ I .dÙ²ewëCï¹âË/¿$S]]Åb¡µµ‡ÃÅb!!!I’‡Ãøý~TUÅjµ’’’ÂñãDZÙl<÷ÜslÛ¶M‹ÙÔÔ$š››±Z­¬ZµJ»þÝw߉#GŽ››Kuu5’$ñóÏ?“””„ÉdB¯×#„@QÜn7ÙÙÙX­VNŸ>M{{;ÅÅÅ|òÉ'5¶ 555¢®®ŽÜÜ\ÒÒÒp»Ý˜Íf€Ûéìr¹˜?>mmmÌ›7-[¶°zõê ÅÛ±c‡¦  —ËEJJ ƒ¸¸8B¡>Ÿh4ŠÓédþüùlÙ²«ÕúÐq&]u½ûî»âÖ­[¤§§c6›™7o‹…ÞÞ^¼^/‡ÁÁA>ûì3–/_>é8/^~ø!óæÍ#99™””JJJ¤¯¯Y–q:<ûì³lß¾}Âq&]eÇCFF„Ãa|>²,ãõz§4x€+Vè¼^/²,ã÷û‰D",X°³ÙŒßïÇï÷ ']?Lš€²²2m?‡Ã\½z•ºº:Ün7ªª )))™¬û;¬¤¤„P(„ªª8NêêêhooGUUTUE–e***&å{ÒTVVêÜn·¶}ŽŽÒßß,ËZi;]¼ñÆx½^nQÃÃøÝn­ª,,,œ´¤>¥^àÛo¿ettǃ×ëÅï÷ãõz'''‡wÞygZ:;«Õª[´hccc¸Ýnmq»Ý óÚk¯MÚ÷”655‰šš:::$ I’زe ;wîœö¶öÒ¥Kb×®]¬ZµŠÎÎNæÎËîÝ»§gÊÝ`ee¥Îjµ’ŸŸÏ|€Édú[ÿÍ„„„*++IKKÃjµNÙç´µÃ3¥ðN·Ž8­zÀLi{ÑhôŸEÀmóÏBçßiÓ™mÓ:fBâþGO™².—‹Ù³gãp8ÈÎÎæøñãË\8~ü¸X¹r%ÝÝÝÚÛäîîî)Åš2o½õ–ÈÈÈÐÄÛí°Åba×®]Ó6>ÿüs1>>ŽÙl&>>^k‡ÇÇÇÙ¾};EEE3_ ~úé§Â`0ÜUâîé顽½}Z2¡¶¶VØl6¢Ñ(ªªj}A8¾cÒ¾§D@kk«ÖªªJ||<@@“¼kkk§â^³––­¿$%%§ýWU•šššI‘=i¾þúk ñù|Z;üÔSO!I’&q777OÖývþüy­ÏˆF£TVV²páB<>Ÿ@  eÃDmÒ¤§§k_(bhhˆ+W®àv»QE{ùa³Ù¦4 l6›°X,š’<>>Ι3gèèèЦC0ÄãñLÊÿ„›Í&éïï§££ƒ`0øIìöâ´víZTU%33“Õ«W³téÒ ÅÛ½{·°ÛídddpøðaRSS1š&¨ª*~¿Ÿ¬¬,òòòðù|¬]»–'Ÿ|ò¡ãLèToo¯øá‡HKKcÆ $%%qôèQ :NÓC¡ÙÙÙ,X°€Ë—/óã?ÒÐÐ Ö¯_‡ÄÝ××Gnn.yyyÚõ_~ùE466âv»YµjCCC Ün7‘HDÛB¡n·“ÉDnn.F£‘¦¦&Ξ=+ÒÓÓ)..~ ÷½addD¨ªŠN§ãúõëÄÇÇ“˜˜Hww7õõõdff’››ËÞ½{1›ÍH’„ªªQVVF]]‹-bÓ¦M ®\¹B  ªªŠ¾¾>ñññD"|>ëÖ­ã×_Åd2Q^^N$áĉôöö²yóf¾ÿþ{ŒF#Bü~?ß|ó ííí9r„üü|¶nÝŠÙlÆår¡ÓéHLLDQ”;Tç‡" ««K\½z•œœ­Ï×ëõ\ºt‰“'OòôÓOß!B~ñÅB¯×SQQAUU•v}ß¾}âÈ‘#ðÌ3Ïàt:ijj"))IKçh4Š¢(¸\.JKKÉÍÍåÔ©S\»vÍ›7óúë¯?ðI^¸pA:tˆ9sæðØc1{öl„$$$0<zô¨¸qãÅÅÅFZZZ%>´æþgp‡f``€ÒÒRHNNÖŠ'EQðù|ÚB—••ÅÖ­[Y±bÅ„bµµµ‰ÆÆF\.Ë—/';;›†† ©®®~xjkkEww7K–,Àf³QPPÀ+¯¼2éêîòåËâý÷ß'++ ³ÙŒÅb¡´´”žžñûýŒŒŒ°iÓ&vìØ1¥*rçÎ"//½^ÏØØ………¼üòËñyÏmðÕW_Õ%&&ÒÑÑAgg' S<@EE….hröm‰Û`0à÷ûµÂfÙ²eS À›o¾ÉåË—ikkCQ”»blnn’$MèmËý¬´´Täää0kÖ,L&©©©ø|>íçp88wîÜŒ“y`!´råJÝt þ+qû|>­´Âãñhÿ‹ŠŠ¦+ÔCYLImÛ¶Môöö’””¤í@‡ÃAkkëÿ÷!)€ššÝóÏ?,ˇÉÊÊšñÁC ¡·ß~[g4©ªªÂb±P^^1•Äþ,mÅê´hÌ5ÁGš€¢¢"²²²(//'999&bž·ß%p\À€ 6+  o_gÌØÄœpXèz÷¢“°èNÐ0.‰Xliæ–ýWÒüÝöµÏ?P ,4 c]-* ‹J€a\ºþ¡=Lh¾„ì'*±)ösn$! ˆaL¡ëþü–ƒa xCÀlÓP` 0+IJE|E¦mÐ%àwB×ÿ{QHX 0Œ¤ÐõO‘fÞ¬AξJy)ˆ’x<‚`PP[ P´ÿ®Ùßmj0ŒsÀ¿ŠXlhA‰Xð­Æ0Æ„®Ž1 ´ßE®oª‚Ç£( i ~¿Âô´`h(išHòT`0€ËHáA×›1Œ­î###`ÅŠ×|öºÄãq155E>ŸçŽ;î ©©éºÏ‡ÃÝ"›A®c˜AÎâ€EQXºÔEM^AÓ䧪Âà`‘sçòd29[5Ð )—"g,¶pxùUu:xð …B(ŠB:桇ºês×\†aˆ¾¾>{6`ÿþý×ÃN8ü™ˆÅrHçåCÎà›ˆÇë- ih°X½Ö®Uhi–X²ÄBÓLü~¹D2À4ÒŠ2³$þ˜XläŠ%ÑÙÙ)Μ9C:&NsöìY:;;¯ºt®I@6›åüùóÒé4‰D‚žž166vEGáðE,–¨î¥¼­¹€"ª*Á;²d‰IS“Es³Âòå˜%Qé ¦m]6‰ÎnDú…pøÀ,]DMM ÃÃäÓi2™ CCCd³Ù«â¼f.0>>N2™ä“O>Á4Mn¿ýv,Ë¢··—÷Þ{O¬_¿ž¶¶6%þˆÅ‘ÎjÒj”MUZ€ßÁ  ”ŸšVÄíö`Y.LSà÷Kðšfâñ˜äó– Úé+ämb´Yªëú‰;køôÓO¡©©‰ÖÖVŽ;†ªª ³mÛ¶«â¼îš~å•WÄøø8¦iÒÚÚʽ÷ÞËòåËéêêâ‹/FxóÍœ ¼ÞÝ¥c¦AÀ‹Ë¤®N¡¾jjT4MEÓ¼hšŸO¥X,P,æ™™áa•sç LM9`“@?0Š\R5ÈeVD.“ 0ÃÚµSìÞ}µµµôööÒ××Ç–-[PU•ææfî¾ûî«bó.ÇÅ®]»(‹<úè£<ñÄÿ|ü’Šî¼ÈY’¢(&^¯Ÿ@ H0è)×4B˜%L³@6k’LúH¥¤/˜Î wŸM€Çž® !ÇdinfýúõD£Ñ9a»ámpïÞ½âý÷ßç÷¿W&›„:¤I:ݹ‘ !ý€¼¸Ý߯ïÿšæÅãQ)ó‹L3o“ ï ¿ ¶œNÛ„„K!sáðá_rÿý÷Ï×¼ã]ÿ{aCÀ2fϾByh8NP*8†4ézT5 ܆ee™=›iûyŸ Øg÷7ŠŒÔ ÀY$ G$²ŽŽŸß¦yDt}†Ñ‹œáœ ´rSñSöµIÙM§±¬ï÷ÙjT‚rSvt¦-VEyÊÀë4º¾ŽŽŽÃ1o 8tèØ¸ñ‘³ï(.ÊàA"l¥å,A I‚ ¬@.§,¬ã?öÿ„ݧB¼Óoèºa<7 ß#ÊUGÔ %ræ (à8,Ùíí÷£ëØ÷::^£¼ÏkÈ%àX€£²“5b÷9C$ò3::ž¿µ|öÙgâ¹çþ†\΃Ç㥯ω×ðRñHäEÀD×7oœÓ˜‘ȯEW×q ãOý9Ö’'Ö˜&ÛE8ø ½½½¬Zµšïÿ>À¤£ã¥êÕ÷ìÙ#ž}öYqàÀ±}ûöE-^lݺU|ðÁbÇŽâõ×_¿é±¬ „@Qeq'BQk!Ú‚D¼Ó,Ëú¿E€bÖçb·…´¶] iš·jœª ÞL[Hnêlp4^à‹ýûñ;Ç2!øËS§øÏhT€Ü¹ë昕ͥí5ñîùóô÷÷—N“ûûûE[[ۼǘ÷Ç C\ÐuVRNwœ¸O0;të:>]ÇßÞN(þÚ1³†!r† LE£¥,CAÒ3ÀHk+[Zlhà‰W_åÎ;yð§hTŒE£¬Bžå8¹[% f…8phŒFKAs¶«‹l,VŠñ$¡NŒç¶ïÝÈ<1‰Ì)++ià™yb™7ÿ¢Yó­µe©­8Ì/˜ºX”Ëœ.f¹•OÅgY™B¢ ~X¹kýâ7Œg^N°×0Äe ŒTÈEÊ peyÔK¹: Q.lùmÑ*ž¯Ì+r¨ÆíñR”It* )ÀŸJÍÊüœ`apÙV®²“¶¥i !{'s#;ù\å'ªJÞ²0+ÆqH˜@κcú9[2ÈI ø¼«k>Pn| œ>}ZüÃ~€w``–éW^/±¥Y, Ù — Ün·Ün°ïq»Á4!ÆÊd0‹ÅÒ21‘Á¤-ÓÈ™wH.!-pSG<òá98Úy000 Þzë-˜œ¤ëW¿*¬$Á©Ù†ìûeÈ“A7 ÖÔ@S³Á«*d2NK™™‘dä󜂡 &¾BÀ²Xv xµ³“cÇŽ±yófX¿~ý×â»î‰DB EáäÉ“x<|>ýýýì~ùe¼—.á¯ë˜}iK•À½Øž=D]³uåJ…Ê ³ÁONb]¾Œ56Fw±XŸDÎxéP³öß.µ›6qÏæÍ<ùä“„B!R©Š¢àóùÈårlÞ¼ùÆÊâ}}}âøñã´´´”ò|·ÛÍáÇùðÃÙºu+Ÿÿö·Ä £th¬ „´†f ŒýJ„ǃkõj\--¸Ö¬Aih³?3ƒ¸|k|+‘’LRœžæc`¢‚‡€ röÿ-Ãòùx÷Ýwijjbݺu466"„Àëõ2::J}}=[¶l¹ï5`?/^¤±±‘@ ÀÑ£Gò,öíÛ§ìÛ·€{@h”÷ú)› Ç ¼ÈÀE(pg2X™ V.‡êñ€¢`™¦\û33XŽd2L ×|Ê–q[&íñ¾ÛÞκº”ápIïžžqðàA¾üòK6lØ@CC‡Æï÷sµvM&&&H$ 0::J[[O?ýô,÷/è:E¤‡w껓H‹h¤\Ç€•NãÊdp¥Ó¨‰„$#“ÁšžÆœžÆ²Å4ÍÒî2^A‚CÊÝííüGוEлîºKx饗D<çäÉ“¤R)Rר&¯<óÌ3ŠÏçãĉÄãq¼^ïàÐueað=]gšra{†²×®,dç³Y ™ ùéi²e9ž\2IvjŠl.GÚî'kƒvH˜¾×ÞΛW_Ù^|ñEŽ9BOO¹\ާžzj~GcÝÝÝBUÕ9¶ìŽDÄë¥0×,žÖb:ªŠû¶ÛPkk¥Ùg2ˆt+›Å*°ŠE ”#¿Ï‘oŒ =þŽH„¿ëèX°kÁ“÷nÃÿrÄ0¨EVü›Ÿ O½€{éR„ibåóˆBAæøö÷³9ãÇ‘¯HœG:»o`ŸK[´êÅÏu] +$|Ø€ y+O+G H'êÌþ Ð ÄZð°ˆ<¯ëbÔ0¸i­ÈÀÈ©ò;o bßO }G iîg‘ü2cÃ"€‡E®½aÊ2]ç 0„<D&MIäž@îëSöýyäAøYàðW‘È¢‡[ô²ô_ëºHÍÈ­ÒÉüœÊIoïÓÐÞÎ_ãío¶Ý²Ó”t]ôF)ý RŽýH+˜¡ø¬¹Æ>¿Ðí–'ý:ott”À‘éò´-;"òÀß.àVw½Vµó´nÃÿ¼s'u.Å`‡ô#^xyáÎçÚªö‹‘ekÖ°í¹çظq#§N¢®®®*zTí\à£>¢±±‘\.G]]ñx¼*zT€ÎÎN.\¸€ËåâÂ… WEª-ÇœxÏc=öÿëGRß´?“ö¿e¼ï?3£=IEND®B`‚viewmol-2.4.1/kde/icons/64x64/mimetypes/solid.png0100644000272700027270000000773610123052370017656 0ustar jrhjrh‰PNG  IHDR@@ªiqÞbKGDÿÿÿ ½§“ pHYs  ÒÝ~ütIMEÓ  /ƒýïýkIDATxœíš{pÕå™Ç?¿srNN.$H$¹)%\"H¹ÖVŠ •mõRÚ],-º;³SÚi“t:­:atשb-kǶtAa]1'¶T!F$„[HbîÉɹýÎïþÛ?ÞßÉ J¸†Áéä™yçÜÞËó|ßç÷<Ï÷=/ É É É É`K¬¼Ô¾Ù:\‰Hƒ5‘\^j»>.Å› ’H[ÍÌó#ÝU‚gâ²A[o°äºÒÎìè«~†gƒ”¤.§YNÓ@—AÍõ“²¨„´Û¾:@\—"ò™€­½æ'+ ¤T p“ÀF *X t!ýñr²&5@p]ëÀð©€Ý¾ÍOª—¤ÑpqH%ñ»íŸš~»Œîºò¯DŒ¸&šjöñ­~Ò= I$wÚÌš-º¥¸`˜*½lP ¸^¹&jv–áv ƒ\`ôkúÀŸÝ&¸-À†,üßk%7Ý ®€ú£;XWŽeƒ¢C\KGšh Iâµß÷º²ª!æ:¼£l°ì¸fI¹Úçj˜6(†0Æ«‰ï}xLÒ¼0üðz@–!ÂÖM4âÄ41N1Àíls®^®Ú, Â*„)â5¢BT…¸îÆÎ SaÂ}fz1E"¢|y\L‡Úon00mÙ²Å^¶lp•m_›áp˜ööv6nÜxÃR怀Ûí¦­­ÐÛÛ{£Ö¿¤Œ7ŽyóæQWWgÞœ´ªªÊÞ·o^¯—+V0{öl `Ç ¥ö›ÛöSÿ‘yã+Y8þ2½æ_ŠDÖ¨\²òóHIËB‹tÑûyÑ`Õ‰azâІSݰ½ê%bÚhJJ²)+»°8Ú¾}»mYñxü†yÁ€1 ¸¸Xêíí¥  €@ Ð÷ýK»cGÍ~öÖý’Ÿ½SÁS{nòc˜ ›6‘În:OŸ¡óäqºÎ6 †1L0LÐLÐ Ð ñ^Ö ¦M**N|I‡uëÖI---dffòúë¯ßXqYTׯ_oÏŸ?Ÿ… ²aƒLyy60H#‰ŸÍÜ1ïñ»îÁã·KH¶ †- V ô<.ÈLƒá0i¤Ðན·ó·ÓÙ”¼üÜ.ô‚êêj»¢¢‚¶¶6ž~úéA÷‚ËNøê«¯Úš¦ñÎ;gصk9p+0HgÁøJ_Š(õæŽ9À‹kÂí—– ¦%v[’`Ü-Ÿ ®4’¤I¢¯Z4ã åøq-,Á7) Ä–-[좢"† ÆÊ•+/ÐY=[n§Nºv^qEW¬Xa?øàƒ|¼»œ5'øúÔ*\^À¶)(¯¦ÀÏöoâàéI<·ú_q%<Àåï챞Rà%I˜$’%´&“ƒs~vöî2y晿²yóArrrX>-Û?ù©>p%h·!t°òü° Ï„+äŠ:~øÆsö¡‹ÖÖVž™ðlÒ7¢6Cì`OþR]Ȥœ:,[ü>w,ŒÌ†”tÇx3VrZb‡5êqè Áª–ðã個)SþÌÏn±k×yfç(¹ÿwIf%Çkíö\!í¾l!ªØãª6Óqt'sæÌaÏ<ᾉÅ݈Ïp§Bîpx´¸Ý‚P&Œ¢êþÄé‹Í[-Õ+ïø€yP_ÿ0»ww³zu>ÛŽ>ȲßüB¬Ýo}<àõAFW€Ðöe„ë/_d]€®º€Ýø[?™©p~ 555|êy€ÚΜ }'ñÞÄã™ù"¦8ñÀe WMxË@M2ÀmƒG¯.*sP³Ù½û DZrå.uó ÔMºPáív ÚÝüâåi÷%¨üµŸìTQ³çŘ©ì&??Ÿ÷»_œòZ"ð¹\¢4ÎðŠ `8Æõ±ÃþDIãæhÎ ŠòLù.’¢¼ô’—%K–0gÎQÇ /J»±“´û£g.]Í@åKí¬T1ŸddÂw&œäàÁƒdMYM}oÁE)¯Ë¡¼=1F¢Š© ª`«€ X)šÞ,°<  T‡W$X£ |£¸’)SRp»ƒ´¶frâ„—{ïQ¶gÆÀ:Ø"g¦Â¡?L»à£?—B‰¸³ƒè°Äû>Š¢ð^×B‡ör嵊üÖgÕ’(êSÀ4=0b Œ™ c§Âˆ,Ë‹¬ b*D’QañR‰;ïôâóE.öì9ÉÔ©Sùæ7;.ªƒaTC€pø/Óîp»@5A6…© j°îö&:î$sÊ*Þ .¬Q`§‚ †£üû§ïB1…!zè‹V@ö ÃÎ  b ŸHÔ“Õ×'è´DÿʽeÔÖö¢ª@ãøñ‰TWW³|y'ÌBHºÛñ²˜"tŽ;§ë¹à¢Ô~°cšX¼‹8;¹êÖ3tuuQ%/†‚Bì¬ÑÄuw-~6ðCâºð€˜Óïmva™^pç'LŠ.‰>ª3Fwšs~ðé§Ç1 ñü(¼õVœ‘#Gò^÷|È» 3#‡˜*u¼&A»CŠÿ§ÿºøcpQ>« ÑœÝKì†,^Cª›;Ƹé8yÂÂBžþßI©Ù„L/A§Ï¡ÆiÈè–¨M[ÄËÙNÉ(]-Xõ¯aŸøo”®&´˜Œíüž¨ KÌ!k`š! „cRuöîÝKÆØ%œŠÞêÉ"¤¹ûtè'Ï¢ÚÀ^pQT' +†x M3@5lTÍâ[Ó£;v oî?PÛäEÓí¾qäóð,4'’¦0DwŒŠGe‚ÍOV¬¯&ØØŒ•Eß~ýÁ‚ºÎ5@èz€ÏÙ²úS~ºÊ,Ël=˜®š¨ú…º'š¬‰y®€Â¹~>…,;¹‹†aë23«Y¾#äååQÞv;š¢aÙ°í£{.:¢Ó‰hbqÅQJïÇcá=Í-t7µ EQ ÍH€œÇ"ßššš8›½BÐnËÚL.ëPüµ‹—Åf‚~±TLñšØ¡X4N¸»—j9²,³[]b€i@Pù¸ùŸèNÄŽ8DÁ°_€ëÿ>êɰ{zdîƒß¯ÝÁ›íáÑÙµIÀ4‹X8Æxw; •ÿÃøñãÙ¿¯Ô¸“½B*L_:™°æ‰R:cŽ :»(ë"-ößÁ{Ƕq¦r'‹/æCm.šB@˜S]«9Ò<Ö¨0&$'ƒSHuj5ù9‘2{d±ó§ºÀãvê,ÙÉññ~z<1á(UUUŒš¹‚³jQЈ ]1X³¾ô꘻À/˜ê§3&ްBN Œ¨ÎN%š3¤jš››és÷V"žÕ. ›ŠsÿÎáÆ©´D -*ê‘E¥Ø#;-.>wÅ =-HË„§ÖL¥)Ž% ªÈS«£;ö“––Æ)ßB e1_NáRf/˜^òdþo5 e߸Û_lk Å9à0œ€¨9E†b@š¤RñY9‹–s´QgjʻԴނHj2ç{gÓ#«øWb¿ýû2ÆdAºWPUËñk«þ¥ŒÞÞ^ž|òɋ̽ΆB —w¿ÿ}¦Œ„‘™æ©ÿA‰ *Nåàf0  ã®É»˜=á(ô>x]âv¼ÁÙŒ³é‹ùöº¤§§sß}÷]ÿHBß\&í¨A*Z[Â̵%j„OÚ ês(Z[¬µ%üÛ¯^á7Þ ##ƒúúú/•ž¥¥~ ™'æÿ ·+yJl}‘Ñé°tb7ÉÊ/ Diˆü€ÌY‰N<ÈÛ§×8;“OZá£Fxó³yÌZ[ÂO~¹•ãÇS[[KMMÍeDý”µ¦¦Æ®¨¨àܹslݺõKóûý?²¿•ùÓGC~ŒH”5Ý nHnÀç…ôt¤ÇnGx@6nw&£F`:==˜f‘qÚ:`›°iÓ&{Μ9ƒAžzê©KÚxÍ$’¢¢"©££ƒ °wïÞ/í@ ð‚דT7A ¢*( Øî 5ÆRúX#d ŽiFim=Kgg³c¼ Ä€0K—æ÷­ñüóÏK•••dffRWWwI/¸!ÿ¶TUUÙû÷ïÇçóaÆXⲉD˜1cáp˜ 6 hçUÿ=~%R\\,mÞ¼Ù?~<¹¹¹7b‰ËJ^^ªªrøðáKö»)•6Ü…=%òœ•*ÎSS +w·ŒOêÈIXJ˜hËzÎ7ñЖq¸i2àC”)ŒÍ>ɺšÿ±ùší¸!p9‘u‡òšIÆ©›¢Ð‰õôbÛ6¾®NLCG†ÑTWx—¸þ.ÿyh"ªas÷m 4ôˆôE×¥ËM`Ò,?цqŸ¨RSÄ)®[ ³+Ø„™(|œÊóá¢sã¢d+0­Ø\ûU›AÏW"÷¯/¥KNp}§,6.$8Šn_ÀìT9îPå# —2ë®ë»oxS(šï—FOóTMN[]@ U±~g‹Q%yL׌õz妰êŸK9Õí1‡"ÇïU¿…âЃ¦0x'^ÿîÃMÊ 9r(`?û?“s`x}7Mw l’¬/ꜴGÁuëRžÛqy¢s%rÓïë9°÷l+¥óD€Ü ÈðˆC˹fìPÞÞ¸`÷¬+á»›ËMï›@Bª? Ø»_,å̱éÁ çH<ªÁýëKxäÉÁ3ü+/G*7ýí É É Éß¹ü?Ê‹H&ºIEND®B`‚viewmol-2.4.1/kde/icons/64x64/apps/0040755000272700027270000000000010130257466014766 5ustar jrhjrhviewmol-2.4.1/kde/icons/64x64/apps/viewmol.png0100644000272700027270000001033310123052370017140 0ustar jrhjrh‰PNG  IHDR@@ªiqÞbKGDÿÿÿ ½§“ pHYs  ÒÝ~ütIMEÓ  6$HÄhIDATxœí[YŒUÛ~j饺¦»géf³#c E/L¸’Kc\5Þ(zcLøo]ˆCL f&&$ŠQÔĹ`Fggq&³Ð=ÓÓ]ÕµuUõù.øÎùª—öûþióçÿ+9éššªSïyλ=ï9ü?¸¿óå###D’$äóyD"Äb±ªËó·000@‰¢Ñ(!Ðu·oßFoo/ZZZª&_­ÑãìÙ³dzz²,Ãï÷Cˆ¢ˆ@ €úúzüôÓO˜™™!Õ’§ªLNN’¥¥%€mÛÈårÈår°, ¶mÃu]øý~œ>}ºj2U€¯¿þ¶mÃ4MèºMÓ`š& À¦iÐu†a@E|þùçUÑ‚ª044MÓÉdÉdñxMMMÐ4 étŠ¢@UUR+«ò–ªªBUUˆ¢×uÑÔÔI’`Û6 Ã`ƒ×4 ŽãTE¦ªÍfas€sss0MŠ¢0Ÿ`š&lÛ®ŠLU 7ÃÃÃä»ï¾ÃÜÜ$I‚Ïçƒ ÝC뺰m¶mCUU¼ôÒKØ´iӪʸê ’cÇŽ!‰  Âï÷Ãçóçy‚Žã˜½;ŽÃ@0MÙl>ú(8°jr®ºŸÄÑ£GWMÆŠ#ãããddd¤¢Ùøõ×_Éðð0xþÎ+òùjjj I\×…¢(°, ù|¶mÃqæ 5MC<GmmmAÿ¹\†aà±ÇC D"øý~p˲ ª*\מ}ûÊŽuE8sæ ‘$ ˜0¹\Ž §( EažÎ¬(Šðù|ðù|hkkƒã8,¾ÓfÛ6dYFss3âñ8Z[[Q__BãÞû%IBCCë×ï÷Ãï÷# "ãçŸÆìì,DQdÚAÍGd³Yœ={¶¬ •`hhˆŒÃ¶m–³kšV³OLLxvúëuxápÁ`ÅvJ|!$ ÍÍÍèééÁúõ뙉Y–˲ ÀjmmÏó¬y#ÏóEÓÓÓ°, †a°fš&,Ë‚ã8˜››Ã—_~YBYnÞ¼ ˲ ( 2™ EAmm-âñ8DQÄÌÌ 2™ spuoXîxñÎÎNmŽã°’e¢(²Yó:Fš.G"‘û§MQ CÓ4fjÙlÙl–‘®ÁÁÁ’±–M…i&&Ë2»FÕMŒ3a¼ÞšžçKþ‹Å°¼¼Ìf,—ËAUUÌÍÍÁqFt]/…®ë¢±±ù|<Ï#ŸÏ8MÚ?Í!&''ÑÙÙ‰¶¶6Àüü!PUKKK¨««ÃsÏ=W’ Ü5~ûí·¹P(„‰‰ ܼy³Ä›ÓBÐÔÔ„­[·"C’$ð<_Ò¨Êz£žžSmòö¡P­­­èééA<‡,Ë,Ùñ¾ƒÒßß……ÌÎÎ"‰à½÷Þûk‰=Ž;ÆíÞ½ËËË%ªO…ö OgÜ›ß{½ºëº%Óç,Ë*È«þ„ø|>„Ãa6»Ôws zîóùðꫯâÝwß]1ã­¨"´k×.ôõõ•%,4¬¥ÓiLOOCUU†T*MÓ X}Ö²,æÕ0þ@«Âô^ê7hØœ™™a,71 £,›¤­££;vì¸kº_»wïæzzzM`¼¶KO&“°m‰D‚&šõG¯côÀq\AñæüÉdù|‰D–e!•JÁ4Í‚|ÀË,mÛÆƒ>xϱU\|ùå— ´À;Ct–’ÉdI"ä* mÛP¥ BÂáp¹xÙ"Õ,A@mÛ%µï; ÃÀC=tO¶[q=`ÇŽÌvËÙ¿—Ƨ³ÞS_qðàA r¿ýö700À:t¨Ä·÷AÙ!õåê ´ÿÇW4®Šèííåzzz˜³Z „bÏîý¥ü^×uìØ±£ ÿW^y…Ëd2¬ÿ»õ]¬êô—>kšfIÿÿ5Ð××Çiš˲à÷ûaš&Óˆâè°’`š¦áã?Æž={JÔó“O>®ëQán z£}F×u<óÌ3ؽ{wE…Ô¿´.044DÞyç„Ãá‚"¥ÅårõâÙWU555eû‡Ãضm[Ù*Rq*ìµ{:xÓ4‘Éd°oß¾ŠÇ´b&XîX\\BëM]+±S¯ÃŸÏ‡¾¾¾‚âÄéÓ§‰·¢s¯âiqòCï€[·náÔ©SQ+^pxä‘GHcc#dYfêIK`ÔèyqöWlÙl555hoopgFçççÙuªeTÓ(ÿX‰{û7 Ùl­­­xÿý÷ÿgÂà/¿üBxž/xYqóûýŒÅb1ø|¾²Ò¶mH’„ÎÎN„B!H’Y–ÑÑÑÁ̤ÁáyÑh¬BT®oªׯ_¯hb+àÊ•+%H“¡h4ŠÖÖVlذ­­­ˆF£¬ÈY®ÆGgÖ[Líêê*!Z”DÕÕÕ¡­­ ñxÍÍ͈D"tº˜ ÀåË—ïi÷ ™L’X,V6¦Ó_Žãàóù°fÍlÙ²MMMŒ°WƒƒÁ "‘ëŸzuŽãXt)AƒA´··cëÖ­ŒrÓþË%h®ë¢¿¿ÿž“{WΟ?OnÜ¸ŽŽlذaEH£l6‹D"UUY ÷ú‚|>ÎÎNÖqMb±XYºL5úoT)N·é½Û¶mÃ… îª+ðé§ŸÃ0Àó<öïß_àܼ„….”üñǸzõ*&&&J¥JØZ}}}Y~à½&IèÖ9ÚLÓD:Æää$®^½ŠÉÉIF¶VâGŽ,Ëp]ßÿýŠ ”`tt”PöEU,ãñÇ_1¾' LMMall “““H$ŒÇS°¢Ñè=æëºhii)ز,ܾ}“““¸yó&þüóOÆ:‹óÇq°nÝ:ttt°°˜J¥pæÌ™² ”ÍÇÇÇYÚ*Š"ÇA4ž}ûðã?–°AÌW*ZÖÕÕ1çD‹¨4Ù).…;ŽƒššèºÎúËf³Ðu½ ò¼ÛÜ»w/t]g[o,ËÂìì,FFFHwwwAh,› jšv´¾¾žqó@ €îînÄb1¤R)LMM•¬õÓ•£ÂÀ’–÷Y–‹ÅP[[ ŸÏÇRYjóÇ•”±ËÕ¼ÏårØ»w/öïßXXX`ÑT*AðÙgŸdˆe5 —Ë!›ÍB’$p‡P(ÄV\{zzðÃ?@+CÅ+ETÈ@ À™ …B¨­­E[[¢Ñ(’É$Çaû„(<Ï35¿ðF¦‡~õõõÃ0Xe;›Í2 ¼'O?ý4.^¼È„I§ÓÏóX\\DWWÆÆÆÏçÙnÏr%.ºbD«Á€ššƒA´µµ¡½½„,,,°rö\9€½)±eYسgnß¾P(ÄM³OÃ0*`óæÍøê«¯XæææØŒ¬_¿333l)‹&4Þ˜î]à(^6§ñ]UU,//3áŠ#‚·ÈIûðj€WõkjjF±°°€T*ÅÀô¦ß›7o® €íÛ·s¯½öI¥Rà8ŽãÀçó±s]×F‘H$ («W@×uYþ^6u]ÇÒÒFGG1;;‹t:¥¥¥’°Fišf ^Û7Ml!­EÚ¶ÍÖï»ï>ìܹ³„Ü•,¼þúë$‘H ‰°|€n:hiiASS>úè#„B!¶)6×u !ËrÉžç‰D˜T…©{1¹¡Õe¯‰QÕÏårðûýèîîFCC[¶îD¦L&ƒÙÙY¼ùæ›Øµk×_Nœ8A&&&0<< A°qãFtww¬²\ºt‰\¹r¥€ãÇ#‹1Âã-ž¬´c¬œSÓuªª²­µô¹íÛ·ãÀÎ;±gÏîÔ©Säܹs¨­­e뚦¡½½O>ùäŠÒUÛ÷Á¾¾>ȲŒP(„@ P@9§æ€nxH§Ó8~üxEe®'Nê·žþù{Þ¿ª%7nÜHb±dYF `ûŒ¼°¿÷Ö»ººÐ××·*²®*ýýýäðáÃl« ÝÛS ðï¸N횪ÿÒÒnݺõ¿s§hoo/wâÄ (ŠÂöÐFëÞFÿGŸªª8yòäjŠXÍÒýýýäàÁƒ¨©©)©$(Ø7@ó÷-[¶à…^¨¸¼ýŸUû8é‹/¾ ׯ_Gss3¢Ñ(dYÆÚµk‰D055Åöò,..bbb~øaUd«Ú÷´`¢( ËíÃá0êëëY2Dwu™¦Y-±ª@.—c{ ý~?²Ù,æç硪*’Éd0 £ZbUºžOËg†a`hh¢(6u]Ǻuëª%Võ>š:|ø0×ÖÖEQXqƒzzº•MUU¤Ói¬_¿¾ZbU÷«±`nnKKKX^^f_¥Ói¤R)$“I444àСCUsÎUÿtöÚµkä7Þ@KK B¡Ûb£( öïßgŸ}¶ª2ýmO_»vüþûïŒaVsÖÿÿðÿá]ož¡”öÄIEND®B`‚viewmol-2.4.1/kde/icons/48x48/0040755000272700027270000000000010123052370014014 5ustar jrhjrhviewmol-2.4.1/kde/icons/48x48/mimetypes/0040755000272700027270000000000010130257466016043 5ustar jrhjrhviewmol-2.4.1/kde/icons/48x48/mimetypes/molecule.png0100644000272700027270000000403210123052370020337 0ustar jrhjrh‰PNG  IHDR00Wù‡bKGDÿÿÿ ½§“ pHYs  ÒÝ~ütIMEÓ  3h¨ƒ§IDATxœí™[HTíÆ3Œ3ŽŽæ˜iZJJÍ,#K;]DÔgAÝYtÔtt¸)º‰‚º(;Aç(º(”™ Ò3RÓÆ‘Tt¬Ù³g3³÷œz¿«†ïÿuš17|ÁÝl6{¿Ï³žw­½özßþo?·>=ñ z ˆ¾¾>rss ƒ¬ZµJ.£ ]]]|üø£ÑÈ«W¯hhhÐ%&=@ŠŠŠhmmÅï÷ãt:9sæÌŸE‹E¡¢¢‚­[·êE£_$IÂëõ’’’¢‡np»Ýx<€nº B „®UT?ýýýbÖ¬Yhš†ÇãÁápè¢D—ÊÐÓÓ#.]º„ÝnÇd2‰De™ºº:,X0©œºD`ÿþý„B!ü~?@€P(Äõë×'ë»UÈãñˆþþ~RSSIII¡¤¤$©Y …BȲŒÍf£ººšû÷ïãõzy÷î]Ò‹ÁÁA, £££lÚ´é|ùn®^½J8ÆápÐÛÛ›á³gÏ„ÕjEÓ4\.H’„¦i¤§§ÓÜÜœð· I’èèèÀív‡éììüæï  ··§ÓÉüùóinn=ú)ñãÇÅáÇ…Ë墼¼EQðûý á÷û‘e™mÛ¶166Æ‘#GÄÓ§OÅ¿Çÿ󾡡Aôõõ1gκººhooÇf³}ÃûÝÔèêꤧ§c±X˜5k‡«ÕJNN/_¾Äjµ‡ÉÌÌ$++ UUÉËËãéÓ§X, ¹víV«•@ ÀÙ³g¹uëÁ` 6 ( ½½½âñx0›ÍhšFFF²,SVV†Åb¡³³“ÊÊJ"‘[¶lùÆß_ævOO¸yó&©©©X,FFFÈÊÊÂl6FQ…¼¼dYNÊy€Å‹ü~?>Ÿp8LQQªª2>>Ž¢( 9Ÿ”€’’4MÃívs÷î]\.š¦QZZš LÜJKKÑ4±±1¡ª*3gÎüí«¾¾>1{öl4MC’¤¤ñ’žÂ}ûö‰ÜÜ\, ÑhY–Ù±c¥¥¥Icuww‹‹/’Ùl&‰ Iuuu”••MþìÎ;ˆ÷=š¦‹Å8tèP²¾ðµ«ªJ8FUUb±·oßN#)gΜ‰·É•••FE! &í<@kk+Š¢FY»v-áp¯×Kkkk p:Âf³ðù|¼{÷I’ƒžzôH¤¥¥ ñx<<~ü8ÞJ¤¥¥ñïõÂ,¡<;þ¼$‰ôôt±Ûí¤¤¤‹Å§¸¸˜ââbÌf3kÖ¬aöìÙ?Äu:¢¥¥UUåÅ‹L™2%ÞN+ŠBee%óæÍãýû÷ìß¿»ÝþC¼>ƒ‡ÃÁ`àÇ455±yóf._¾ŒÕj%‰0wî\¦M›†ÉdbÉ’%8N²²²ÈÏϧ¹¹™ŒŒ B¡UUUŒŽŽ"Ë2 , ££UU)((àÆ¤¦¦‡Ù¾};ƒƒƒ!¨©©Áf³a±X0äçç“mø¥€»ÝN,Ãf³ÑÖÖ†ÃáàÔ©Sñ÷Oœ8!êëëã÷çÎMMMlܸ‘éÓ§ÓÜܯ.±X EQ˜1cV«•¦¦&6mÚÄÎ;8oÞ¼W¯^eݺu|ùò…ÜÜ\Þ¾}ûM£÷]€úúz±~ýzdYæùóçìÙ³‡òòò„ÒíÊ•+âÞ½{ñ…Ovv6>Ÿ/ÞÁæää$Õ°;vL¤§§S\\LKK Gýõ®DUU­­­¼yó†½{÷&ì<@mm­ÁívÇ«ÓÊ•+BÄ[æd»Í„<|ø’’’ožë²3·{÷n!I™™™Øív|>>Ÿ¡¡!ÚÚÚþû;s»víB’$|>£££ñ:}úô¤sévFöâÅ qûömb±ÝÝÝ;vŒÊÊÊIçÓm=°|ùròeË(++#%%Eçá?² ùÓõˆ)-- “ÉDNNŽnº °Ùlº Ð5…\.üõ×_ þYçÄÃÃÃáp8‡Ãºpè´´4ZZZèï裡¨HO*ýìÂ… úSþéö7˜~®uK†ÞqIEND®B`‚viewmol-2.4.1/kde/icons/48x48/mimetypes/qc.png0100644000272700027270000000455110123052370017143 0ustar jrhjrh‰PNG  IHDR00Wù‡bKGDÿÿÿ ½§“ pHYs  ÒÝ~ütIMEÓ  awM…öIDATxœí™]lT×Çw¿mïú;.Ö”Ön!”$?ð°wÓKˆÞB)êK¢…‡*°Nwêר…lh ”Wo£¦ÅvÔ™Òà|úû‚&“×量!­­»ik{ú¾ø–ÔN·´làÌ™ë(o{4 ‡þTMãšH8¥ –èg˵¸5øÂyM`Ól¤­íþ˜–Û>'O>ù,~½½Sš„åÉÁàVLs¦¹P¨yAÝ­­¯KGG¶Ýͽ,>óèŒSÆ€s‹Â¶äMÆçŸ.ï½÷¹\Žîîn8@sóÂ`ï7Z[ÿ,`ðÖ[o±yó|>/›6mÆ4·«þ{,Ëð±cÇ$‹qüøqΜ9³âV0”§žzŠŠŠ žxâ‰%é+ÚŽl)£P(,ûÝe cu·¸"ËkJ—Õ$±\ð°DqÛ–qË’ú÷ßç§§N±»¯qË’˜e-AOOlذT*Åèèè’–ä«¡Ô…ÃxP¥GPY|¦$9M¯iRkY êMÙ¶dl·,\¨¤9ŠªÝ=Æx"ÁÞW^áG¡Ðêg¡÷A@•"‡Ÿ×r¨2–Òä|ú‡6dhÀž9’FÕì(ªÑ˜¼¦ÉÛ^¶EO¡-KF€~-ÃÚ¸UcKP ‚_“«˜ó]©&ã…Y¯;QQ¼¥AçQP¸hÛ‹…µxÿêè`pëZ¾F5 دÁWk©p:©p» 8óHDµ#nr/£¨ˆóÍE­…E…é7Þ¿=ó ë€ZÔz@ÿ]Ô?Öÿ;Ün¨ªG‰Û Äã09I!™D²YÆkÚw¸×ƒÞ€Ú–ÖlÛÆ‹/¾HUUÕ·âüÖfnhhH à ‰`;öï§óµ×H B>…Zx•(¯åPÞw®ÚZŒ„’p¹ “ÉI˜œÄ16Fáî]"É$·`V⨵s ¸]QÁ/y„;wÒ××Ç•+WÄáp°víZª««ï¿'>yò¤Ü¸qƒH$‚ßï§««‹”ÓÉAÛ&¦ô½ZzP]ý4ÊfI'“ä<dãFhlDÖ­#_UEÆéd:&‘J1¦õDuµ¬ 971aìÝ»—“'O222ÂÀÀ‰D‚>ø`q°m›ÇœX,ÆÙ³gÙ·oÏ?ÿ¼ñꫯòË’#–EV{m”{ vÈ‹PˆÇÉÇã¸R)$—£“›˜ ?1A~r’l¡À8j®ÏÍ@›ƒAÚ;: €­[·555RVV†Ë墿¿Ö#ÐÜÜLgg'—.]bÿþý<üðóa{βŒ§[[g;þq`ˆÍDH%¤¦¦˜$qõ*ñž’Ñ(ÉXŒD*5»÷š!0ü,ä°?w¼üòˆˆðÑGÑÔÔ4ë²{s¶-í–Å%ÛÆ<ìCm8½N'®†(ÈÇã ™ ù\ŽŒ&ùСÉ ‡i^dáZ53ãPk«mkc#ÐìBŸÓy½2DA¶„?\Ðþ´ð«BàKÛ–?˜&?¶ë¹·Iô À'QÇYwP þ<ð»p˜í+«xÉ÷¥mËM“­¨š0sÜåFÕ‰aTÖFe®ß†Ãl[!xXå[Ê/m[~oš³çl3mEªnÜA‘ØÙÚÊsmm«b{Õ/ÞÎÙ¶\ ‡ùk[•¨›Ce«Æ`ͦÉoV <ñžàØ‘#rɶ¹91Á;~X[E%ðöÛoKcc#±XŒ¦¦&êëëWÝ^Ñ††¨¯¯'‰ÉdŠb£¨§¥¥¥|úé§ôõõQ___LSŇþþ/ò~Èã?ºƒú¬ªâIEND®B`‚viewmol-2.4.1/kde/icons/48x48/mimetypes/solid.png0100644000272700027270000000563210123052370017653 0ustar jrhjrh‰PNG  IHDR00Wù‡bKGDÿÿÿ ½§“ pHYs  ÒÝ~ütIMEÓ  )+[Qµ 'IDATxœí™ylU×Ç?÷>¿Í»ÃÖ€™LÁ)Ô!!4~n;ŒÒ”IÂÐH™¤m¦U´"Òt$"Ác&hÒé¨jÚt& bšŒª6r”@H—IBãG‚ ˆ%@‚Yí¼óü6¿åÞûîræsmÇ ÒŒøI?ÙºïÜóû~Ïòû}ϹpÓnÚMû?mÊgyÉÞö¾^?à§ùˆ¥Ê¿ùL}~V»ª`fwT˜¿ ,‚€P°ÀÉA,¥·Rz{ó…ˆz¥ sQ‘})L ð!ÁÊU?ÔT@lk3ñ“­âÆ@žhWD v"*zþ-ŒÏë>p£îŽ<Žë€P¡,?i¾þh/aWDàÄë›P@ ›®>ñ¿ëªª€€¾²ñ†ÏÂe t~N´¢[Õ¡`€0°Š@ÀPÁ}®-€íÀ¾_oºÑø)º\ƒ³D1 ­C°Šm–Qkg@YİÎ÷‘7l²ºl›ÒÁ°n8þ‰YhÇŽ¢¤¤„\.w]ƒqñJêííå©§žºæL5aæÌ™C[[Ùl–¹sçÐqp7±“Qª‚Pê… ¼)¾ejq5vº—L,ŽY°0lÐLÈËÁ¾óOÒÔ¤O‹sìØ1¦M›Æ©S§D}}ý5‘˜@`Ñ¢EJ$•••¬ZµJxáGoŠ-ïÞG™¿œ%u{øî=›(õCÐWDeIoq¼žd$@Sâ&ô0ƒ£Gïäèуüô§«&]¿~½Ø¿ÿµ`.QÈ8 Þyç‹?N8f@aq]”ïܽ‘e·½G‘ ªª`;ÓÍ’ë_(ñàGûÖàXC<óë Î/nÛ¶m¶mSSS36X×…@KK‹bóæbïnaÙm‡P…¶îå@–-ßOãŒý¨ Ø –Üà·UCh*(~Æç×[‡\eϽǪôóÏ?/Çaݺuc8ìî¨ðÌ _1¡InذAtw—óxé¯i¾ãŠW¶&èYxæ7O2«ò}î¬ëÀàQ`É ()Š]ð·3™f5H§ íÖ·ùÚß,¤²²‡H¤élžºOðDœ©aœ»6â›=¹,™´ÌP{X¾¼œ™ó†PJ+(J1«àG«¶°zQI 2:̪¯ñQÿdHáFò€ÏóN­`aíIR©FZZ.0sæu?ü%Ñžúñ8¥àIFQ^kfx[xÒ‚xI½/6‹5þ_PøøvXß—­T”+à<>¨*ƒÙÕPâ“ÙIY©?Y­­qW(RdûµŸ—E®½ýŸèì¬cùò6½±FÆç"?ø£œ}áÒ$."ÐþÏÍ‚ó­xTXîÛ…ßïçw½wëWûª I ŠT™:íR^Ãu}ü™(€eÊýÒPeþÔ·P”~üãFx`*gFjˆvL—1ìñ8<=QNo¿XšL Ð}4*Fδâ8 lh¨H2t¸…®òµ|Ø?e‚öQLðØÐÝ–ò!­ƒ¦ƒ£ÂÓ¤[^ òŒh²mÁ†ïkgút`çÎ*V®Ìý04>nÕG@Çö‹¥ÉƒQ3]Ý£Ãת’Édx7y¨ÅR÷è`ê0¢ÃGCÈC< ’yÑUœêP¿æ~«¼–t^!©É6ñ¼|'PÅÅy Áž=çY¼¸œ%Ký@PΜ†!ãh–\]Ñ—'·ÚwK£É¥‘Ö`aµÎìØ+”Ìÿ*§ƒKe!òšBZƒÍø¹‚lŸrÁ'ò6‹°Ôr¨þ ”.¡ ‚$ uì÷¤&gkwû€A<^Æoå|Õ_Á¬;q|UdóÊ÷6äÌMN`o+‰< ça8'=®yxxq3gÎp0û%Ì` £ˆá¼ß]OÆÓÓK¸5Á0É^¸€õáV¬ÓÛÉ%RX–íH•j9Rèå´ –•R@5DÓ4þ%:Ÿ¼¯j ð‹)™‡½m»''ÒA·dçº-7›a:yƒ¹ì'§„xýX5FÁ¡`ÃÞZNžæ¾cXò‚%Hôö3xdG“ŠÉç¶ìW7å’0Ì,0ô²tæ>^yâ0±oQR×ÈG}~ ¶|g´oÍ‚EM“xüû –QktTmAâ\‡N’èx‹ ¡ULÓHÓœÏpNŠ·¼ yKf¤¼á0’Ì’IçÈ4Kî­|AÖ¡,t'óí»ZxiõkÄ»ÏñŸ?I<g_®k‡ë†%xRsÂ$õq0Ú(­@¢ˆ?Éÿ˲ØkÝív”'ž¯çØàBâî§uq52.àÑ3E"1wmÿü¡ßð»omã›KŽ`Øшu÷Rqö¿(¯ÿ3>¶nE³$–Œ!7ÿ¼ÅáÉ ,¼+¬TׇI¹&ãõéþí¯¢×¯åŒb@œ½çâøôg¤„Îg¥¸ë±œôþ ø‚PêwÉê0R€¬¹‚ô/VvÒÞÞÎÁ)ßfÄÍBI Êooâ Ë&ÊŠ‹ ÙWŸˆðqBNq<ç¦F÷„•ÒáÁª}¤R)ºŠ¿È vÝdŒ*vv<űèŒC߈ôþpÿö¥¡s<X¶p.oŸùkÎ¥ –uÓ°&ûOº~·±P(Ä¢‘Á œ‰Ãƒù4Ü1¹5fÿ¾õ¥M¿x=yëõ—™5L÷’s§òܹæ5½÷·Ü¿f5Šçtg? Íg Sœ#kÈeËI2e%ð—Ëaõ=ðòž¥ì8ü$]‰03*w⸙©à®ñ\Kc_gŽYËåXûïùÞÏZ/}ø_Ôèá½Q±sk„Ä©(ðÉÆº%—“ÙðwTVVòì³Ï~ªïXÀæ?ßÂç¦uPS÷ÌŇTš*(O|ø0Py__ÑGàÂ?R샀G¦bÝ‚®l) ZO àé§Ÿ¾$ÖËêîmQqêP+~¯KÀ„ú%aüeSØ»w/uuu¬\¹r¬Ÿhô¸øÆÃ~ö¯r{ Ô•AiÔQ¥ªÂ¦ÿ¾›È›Óñx¦pï½ TTø9´ç?© ¼ãdÈ›ƒt%+---bpp+V°`Á‚‹ð^öV¢ñÞK.¤&yî¹ç„iš~ ‡ÿTy÷åˆ~ûUr®> ð}05DøÞ̶£­íªêÁ4çÒO ÐGS“A×îÃ<òÈ#ʆ D{{û%ñ]ÓúСCb×®]TWWsÇwŒ=ï:²›ôéV*ƒPâ•—\^ü¥¨SBà+%²¥¨B^²¹P,¤JßB8ü9Ž?@ss3óæÍ›€ùš¯5Ö­['B¡ÐEÏåúßíÖÖÖòØc]_—²×^ŒˆÛ#Ì®†P T ØåUåTÝ6o ”Ì`/‰ž~þõ½¶ìŸx¹¿þ¦ÝÍ®³‰+ÆuÙ=ðY,[’A7]meƒ×†lj„‚vÕãÁÔ –à‰Æ#|}Ñb9èMƒQÛÄ®³»/ĵv‡ÿèˆÆ[áÖ ¨ B™Eòô¦*²¾¶” i.de±ZóÃV-½òo Wü}àjíþoEÊJœÒÇ5Ò¨.ÕFi]Vü Y¨œ×tUàáÎÀÖ†…r>Êô ¨p÷W•giË‘Ë+£Ëjí›ÝÄß¿¸ûªñÜðÏ@¿za£xï—›¨+ƒr¿¼Wõ¨îÙÀ’#_UßÄ3[¯<üŒÚÖ†EχQÊýPä‘êsNC=¡á*—ÍM»i7íÿ‘ýkˆó…%>WIEND®B`‚viewmol-2.4.1/kde/icons/48x48/apps/0040755000272700027270000000000010130257466014772 5ustar jrhjrhviewmol-2.4.1/kde/icons/48x48/apps/viewmol.png0100644000272700027270000000566410123052370017157 0ustar jrhjrh‰PNG  IHDR00Wù‡bKGDÿÿÿ ½§“ pHYs  ÒÝ~ütIMEÓ  |)>D AIDATxœåZKlåÚ~f<_qÛ‰Iœ&„$D¥ )"5,‘XÄ¢ U¶¨‹nÎAbĆ%RƒP7USB¨¨j©¨ª"Bi¥!–­†Kê$_ÆÏ}<ßY}ßoÇIøõ×HÿÑi[3~/ß÷<ïû¼3þÃîï2¼¾¾NÇA½^G4E&“A2™ìº¿¿%k×®Y–‹Å Š"\×E¥R®ëxùå—»ê“ï¦1¸qãQžçÁqض Û¶áû>ªÕ*666H7ýu=/¿üš¦¡Z­Â0 Ȳ MÓP«Õ ë:¾øâ‹®úëz†a Z­BQˆ¢ˆ¡¡!¸® EQP©T°´´ÔUBW­ „À0 ¬­­¡X,¢X,BÓ4˜¦‰`0ØU]#Ô½{÷Èõë×Q(‡!Š"8Ž!Íf®ëÂ0 à½÷ÞëŠï®AèòåËøí·ß 8ŽÇýO|ô;Ïóüñ>ú裮¹+ œ={–är9¶Ú¾ï£ÙlîyBÀqr¹.\¸ðÐIÈ|>O$I‚çyãv_Ëår „àܹsH$h6›ð<<σžçÙNÐkžç¡ÙlpíÚ5BÁää$år™èºŽr¹ŒD"`0ˆþþþØí‰ÃrçÎ$“IH’ĪH$Áêê*677!Ë2[ñ\.žç‡!Ë2Ã$A8†a0 žçÁu]X–Ã0àû>žxâ fÇu] ¢¿¿ñx½½½žç¡R© ãøñãm1w@hccƒ\½z²,|߇ïûe7oÞÄÎÎ ”žCCC¬iY–˲ †‡‡155…L&ŽãØ5˲`Û6> I’Ø)Ë2¶··±¸¸ŽãX®ë‚ã8Ü»w¯£v$ðí·ß¶mhšMÓØçµµ5躞ç4èÇ‘L&Û’H¥R˜™™A2™D `;ŽƒT*ÕFvJržç!Š"VWW¡i°FhY¾úê+˜Àòò2TU…¢( „`||Ç!ŸÏïIRß÷AA2™„ëº ã†a X,â×_Åöö6LÓd¿ñ<©TŠ}Þm «hcccà8ÅbårËËËmñvXUUÔj5H’UUQ(°²²ß÷ÛØoèµÞÞ^hšß÷¡ª*²Ù,ØËÏó8{öìÃ%°²²‚D"Á0Êq3Îó|[b­Zhuuóóó$—ËÁ÷}ܽ{}}}mvhi¡­P4›M‚€ååeòôÓOïɃ9pîÜ9âû~©(Vc±Òé4zzzày^GJ§ÓP½½½èëëC&“av(D<ÏC__†††Ø@Ô*·Çëºî½tÈp‚ °ÕîééÁàà &&&ÚÄåmÛjƒÙðð0 ŒÂ(‰`ppSSS¸ÿ>Êå2TUm³ãºîA!î¿ëëë„vÎVIà8púûû!I|ßgÄu]¤R©Ž…þ-âZïó}Ç! 1Hµ^§g(Â×_M …BÇ ½ç\¹r… ÌÌÌà‡~Àöö6$Ib˜m4øý÷ßaTUe´ÙlBE$“I&—[  … Ë2<Ïcâíþýû̕ܭ mtt‡†¦iøþûï‘ÏçÉøøøþjô»ï¾#›››‡Ãày}}}¸}û6+<ÏÃ÷}Ôëu(ŠEQ ë:sØÓÓQÛ”(­.TèºÎŠA½^G©TB©T‚eYì^Ê——^z áp˜õ—••\¹råŸûBèöíÛ¨Õj¨T*Ð4 ³³³xüñÇ;„m4º®·Çqƒ[(B*•B$a›çy¶ ”´š¦1R·BçСCxá…ÀqJ¥TUÅúúúÁøñÇ¡ª*Sš±X ¯¾újG÷muDOžçY Èd2˜žžÆÈÈ“ܦij»mPû¦iâÅ_„çyÐuA¬ÑhÌ×^{ KKK°mår7oÞ„¦ixî¹çðÓO?Á÷ý=;13ÇaƒO(Âèè(LÓÏó°m»­_Ð~Òj‡îÔc=†íímܸqº®Ã²,躎C‡œÀøø8._¾ŒP(B!$ ÇAÓ4&¨c:iÑ1’çy躎ÍÍMöL§u&n…akB<Ï#™L¢^¯³‡š¦AQ¼óÎ;øðÃY¼{v·ÕÕUòñÇ#‘H€>™«Õj…BŒH’$µýæ‘Gas3M& !²,4 ¶ú¶mÃ0 Ôj5Ö•)w¦§§qâÄ \¿~©T ²,³7}šd³Y¶ »µ>]ý©©)¼ùæ›8qâÄÿ¯`nnŽLLL #‹a``ªª¢Z­¢Ñh`kk ß|óM×üvýY__FGG‘J¥0<<Œ¹¹9äóyÖá»}tý-å©S§Øì[,±´´„l6Ë*OµZíª¿®'099ÉàR«ÕËåP©TÐh4 ª*^yå•®úëz333\8Æææ&ŠÅ"EA±XÄÖÖâñø¾OØþ¯ÇßöÏwïÞ%/^ÄÚÚ¦§§1>>¾o3ú¯>þâ`^›IEND®B`‚viewmol-2.4.1/kde/icons/128x128/0040755000272700027270000000000010123052370014152 5ustar jrhjrhviewmol-2.4.1/kde/icons/128x128/apps/0040755000272700027270000000000010130257466015130 5ustar jrhjrhviewmol-2.4.1/kde/icons/128x128/apps/viewmol.png0100644000272700027270000002203610123052370017305 0ustar jrhjrh‰PNG  IHDR€€L\öœtRNSÿÿÿ7X}tIMEÓ 7$nØÔ IDATxœí]il\åÕ~ïìûØNƉã%4qLVB6’B©•–¤jÿTð£Q 4”ŠTUmi¥¶¨µµ•¨Ø’”µ´@QiEU$B" &{b;q6 q<žõÎr—ïÇóÝ£3ïOâ”™|ç‡5ž¹sç¼g?ç=罊išâs¨8êÀÿwøœu†ÏPgpÕK‡¾¾>¯×+„0 Ã4Íh4:mÚ´z#uÑ \qNøàÁƒƒƒƒ¡P(¸ÝnEQLÓ4 #—Ëù|¾P(´hÑ¢zãxp%1àÌ™3ù|> y<·Ûít:EB†Q,s¹œªª£££«W¯ž1cF½ñ­ ®pîܹíÛ·g³YŸÏGÔw¹\N \.—×ëõûýÍÍÍï¼óÎÙ³gërMpe0àäÉ“¯¿þz0ôx|¸Þ‹¨Î2/ü…¦ijšæóùœN§Ûí¦iº\.!D6›¥ë¹W¨÷"ªA£3€›~0@a†ä{ñ/Š …B}—P0åd 4‡ªª‰Dö'ŸÏ'‰L&c¥§‹Åz/¢4:î¼óÎmÛ¶¹\.„¡†¹\î“O>)‹>Ÿ¯P(Äãqbâ" œTU­÷"ªAC3àßÿþ÷|ÐÕÕåv»Ýn·išPÔ!ÆÇÇÏž=KÅD¤Á¤N§3 ù|¾h4:00ÐÓÓSßµT‚­†ö÷÷ÿþ÷¿ƒ^¯×ív»\.—˺S!U ­‚´/àTUmooÿéOZ§ÕTƒFÌúûû}ôQ*½qºÓ_\É_ðª}…êB§OŸ~øá‡ë¶¤ÊÐp èëë{øá‡=‰<‘R0ŠTzGa ßvÛmGýlR#4|ðAÇc·3eM%ì>ÿ/$… 2µßïíµ×þû‹¸h,üêW¿òz½¼Ö/ú²ä.û‘Ä âèÀÀÀ_ÿú×ÿúJj†bÀÏ~ö³cÇŽÁèã)©hc€îÌÂétþãÿ8xðàg¿À²Ð( xî¹ç8õEeº#Ρö×Ò}„Š¢¸Ýî¿ýíoõY§ …‡–vA/‰ ¹íRÏ/“®ÁAúûûŸyæ™:®—à󀑑‘ñññD"‘N§i0Ï™3'‹] ׭[‡ý~¿ÇãAô‰ w‡ÃA‘(…¡Âæ?¤Ê*ET.M&“o½õÖ% zyá¢3á³gÏ¢ Çãñ477£3Ç4Í|>ðàÁd2ÙÝÝ}Í5×H_ü裆††Þ|óMìîr2¥R)•Ä–*Ïà.Ý_,•B’$ðê…¤ ‡ãå—_nnnÆ¿ta_ÿú×+-ÿ“O>O&“<Ó4u]ojj ƒóæÍ»XbЋՀ÷ßÿĉÍÍÍÈQ!¤d1H¸Òé´ËåZ»v­bÛ¶mƒƒƒ'OžD=@7$ª ‹E¯×‹ €_LŒ=' ×`RY+DŤ@ÒétöôôP‰›;Œb±ØÙÙyóÍ7Ï™3‡P=sæÌG}T( yˆ•éú\.—J¥|>ßM7Ýôßb¢·h4ü~?*°X0)x6›M&“>ŸïÍ7ß H©$K „H$ƒƒƒX ÄÉþ€è1Ä–Y±X,ë¤ú(6 fÍšÕÔÔ$E\øK&+—Ë­]»vݺu{öìjnn…Bø], ¿¦ …L&322ò•¯|¥³³³FªÖj‚N:•H$b±˜&rѬàv»; !Ë•Ê8Ä€¦¦¦P(”ËåPm†ñ!À9Î`0|>µ&æóy§Ó™N§ …ÙØˆ?ï™0 »iÄQ.þBb¹ËåÚ¾}ûÛo¿ÝÓÓÓÙÙ áà2Ä ^Pܦ¦¦·ß~ûæ›oîè訅°5EAƒƒƒ/¾ø":a…Õ @ µ„`å©Tê“O>!Aºu;̘1ƒ w%0 Ãívû|¾`0‡Ãáp4 ‡Ã¡P\Q¥,b’íííÀ‡ü¼ýJ°Ççó}úé§X‹`áw-H^0|å•Wj!l­ xã7@}¨ßë M(Š1°Ôááa¬RF¯¹á¥)R$ ƒÜhØÙ,„Eü~$‰Åb­­­---¨<ÂÑ~€ú¸s[[ŒR ô Ð=›ÍŽIÖŒ:”è‡(@ðz½›7o®…¶5™ 'N̘1ƒ,#©ÌÿW×õb±¸wïÞd2 ͉ôÂ’&2sæÌÙ¿?p¸ý1MÓëõBÙ}>_SSÓ”)S<O&“QûÆ«Ëîð" ¢oW ¥$LˆdaNœ8‹Å`~ñ&},'ÆÀ~~üñÇÇçn¼,L¬¯¼òŠ¢(¼÷†wà€Ûn·[×u¼ùé§ŸŽK’.l!£xÐÝÝÝÕ(š„€.'477·¶¶F"0†n¿ËãKÃ0¦OŸ^6‡à`²„‰Dâüùó¼1‰„ö¥±{ ¼þúë’wb p:†Õ™CFP×u»X,4MËf³¹\nhh¨:¹íŸ æÆÑøŸÍfùD8a)º¶ØŸˆ.½cF0 …Bd²92?{÷î]³f®ë.—+Ã02™L>Ÿç!1ãäÉ“’wb xÿý÷©Ñ2®ªªªªè …B‘HæÛår‘øó;Øåƒý,L"4¨InFUÕT*uáÂ…³gÏŽ ä8õù[[[í8T¢¾$1€ãÇ«ªêr¹ZZZZ[[§M›†TmHªªâÈeƪ“wb سgϬY³@}ÒÃ0<^{<2ÃÃÃÒ8‰)¸$´3À0ŒX,–N§s¹¿×Ó>;r½|>¿Édúa”8 6L:Nž¸Â&ï’>ñkEnoo÷z½à Ã( n·›ñòù¼ªª`€®ë‡ºöÚk'Å]×A}DÁ„=®\.—H$[ö÷÷§R)t0Ð:Òº]!«L™2åÌ™3õMÓ,‹ÙlÎV×õt:¹\.“Éd2UU9Õ8¦NjZvL”z‰úvàŸž:uª££Ã4M—ËU,!y ‘½wx¶°‰°aÆ7Þxƒ‚-Â)—ËÅãqÇ“J¥à>üðCô.py/KýJ>À´Lv hii—¨`š¦ªª :d…4d³Ù|>o§¾išííí†US≞ióôuîÀù¿CCC×^{­ªªñxÜ4Íl6«ª*ú±ylJ.a² àýÆœ UUÕï÷kšöá‡K8mZ°/›ØyÀÝ&™8‰üb±¨ª*2aÃ㥨[¥E=IÌRÓo–óêÿùÏÖ­[—ÉdLÓ7XùçI2 ¦Zкuë¦OŸÞÔÔ„*µŠPz•H$Ž9"•q¤D×¾fiÁ\Ð(w—­ «`€› Bå4â÷™2eJ àÈ[”Éñ){JÁ ‹K–,™>}ºv  ¦ÓéñññsçνýöÛÕi[S"ÖÓÓ322‹PŠUƒÄëÁÁA HÚm§,V‹Ü’:ma=¡[Ò²u]èpÜt(ŠÏo'œ`uX3¤)œ²œ‹(¸Úm@ÊEHÒûúúHGyz N RX¿~ý„´­‰ëׯÿÅ/~Á§TÖÆápœ:ujll 5]׉ú¦UØÂŨ“ø|¾@ €-!„¦iù|ž;O.wº®;NÐÚÁê€Ü“K<à·òûýv>A¼^/*z¸-ÅÙ†-°—Fâñøùó盚šL+–rÕl6»`Á‚ iëüå/9áE¹\îÈ‘#<Û$ä:$‰(ÂJ¦@8Á`¦ŒêÉPIåÁ6Dv¬ÌÒ^2ø‹Ÿ°_©(J @ Ïï÷c'ŽAi·?$“ÉX,Ù§üKUÕL&“H$ººº6lØ0!mk-GoܸñÀ§OŸÖ­Í ¸?þ˜Pä ZPëóù q¡Pµ3Ã0²Ù¬¢(ÐUU¹šS9J@²_Ö‘ˆR‹‡›(Š‚Åd~²dP@奸tJ£ æZ H8ÆÆÆŽ;ÖÕÕ‚à§R©‘‘‘—_~¹Â^Ä–äc=öøãÿóŸÿDŒÝ«'Nø|>Ø ;ˆ"4KíñxB¡P,CN4>>Ž(v€œ—;2ë²ír¹2™Ì-·Ü²qãÆ‹¢ç%άX±b÷îÝ»wï–4€ˆND!µ 8VòN¥D+i…\“à ¬9ÅÎn|ø5È¢yàX,†ní®p9àøHˆÑeÓ¦M[¶lÙ]wÝu ”¼ô Ó¶ïaXF–¤LXVÛ° ÚªªŽ;Žd2išf*•J&“(¢I[êvñ'6S""9ú©£¤(@ÒTUU“ɤÛíN¥R˜sRU•Ò~³4­òbñâÅ—FýI1`ùòåO<ñ„$¶v uVU•B=T…¹\.›Í¦ÓiTÍreš¦)lD ,„e÷$Q ËàiQɸpáBÃ0R©T&“A=ÒP;̪ •àÒpýõ×#B/K)aÛiA×Ì|¹{&“I§Ó”¬Ú—Í5ÀdÛ¢ÔÜáþ•nEP)›ÍBc`Óé4B *r ™ ú0@±lÙ²þþ~n"ìˆBëA, qÏ„±½cçŸHôy>H/È‚š†a8N. ‚IC>ŸO¥R ºÇã’0JRIUTˆÀ%ÓpR XµjÕÑ£GyLV @ EQP[¥`ðÂ;Á(.ñRr¨´pD 0MUϲ2+,äQe"UÖn}?§ì݈ô…Bá¾ûî«à$‰ªíÄ\Éß©²NIÙ¨`ò”ûX¤ÓÈiù·èIˆyènô©„ƒ%ŽLõ ¯ aR ¸á†P6Ñ4R-$ÃË „û –ÊÒGÒš ð ÌÆï¿ÿ~!Ä{ï½·sçN¢ò–-[øÅøQÂD±JžRE0,K}»u刋Åþð‡“¡ádÇTÿð‡?<ýôÓTQð©Ò²¥ü²97J÷yµ•W:¦§§'£FBM¾Rg*Ǥl(%˜Ñ'k#!C®+‘H|ôÑG“!àd46mÚ´xñbé(.¶•ÄyÂwxí…³á?øA%d¾ÿýïSZgLJçz\®kÇÓŽOdj„Ë0!sÏ=÷ p¦5ÓÖ„öÅH«åor‰ƒd2™{ï½·&e¥¡,Ýk;ÿøvc.—«½æS jÚ¨º®÷ööòBŠ#J>°º§-+nPùgžy¦zçw[[Û«¯¾ÊÇêEi°TÉø¬0ÎÈüå/¹þúë'I½ËvTÁ7Þ‰DÐ![igXQ”t:‰Dð•sçÎ !ÚÚÚPÀâjÔ;suöÍ›7¯ZµjBLþøÇ?>õÔSpK. ø´R ÿK›–¤vƒÌܹsko®—ç°Ž—^z骫®Â&ªjg€(Ñ.l QVâ²Ùìððp- øêW¿úÁÐ!ãp8²Ùl4%œ;w]ütÊëŒ3¨‰› Úì¥a˜ËB}qY4àÈ‘#¿þõ¯1´êó5KP6ð°[$îE)þÉd2<ð€}úŒÃáÇ|ðA̱LˆŒ¨Ð–b°R ]°ñÒÙÙù›ßüf’¤—Å ?ðÀÈæ¹‘Ò+ÃPÛ©o°ê YjEQ\.ׄó½?ÿùÏ ñ» 2v4ì(ñ)V#—Ãá8tèÐä©7Y<ÿüóÔ¨ÂsÎJ”å`ÿHZ9'hÚßßÿì³ÏVBcF¹1º^Q”½{÷.[¶ì’i8)<õÔSÑhT’Ý*Žc©´¬½4Ì…“Z2öl¶½½½µµÕÁF´ð×çóiš666ÆïSIáHÈ]Cí$1—аc¨(ÊþýûëÀÇ;\R¸˜sÙ7­Þ, ÏñÝb±ˆ~û|¯QZ½ éëêêRJ.#‘ljj-+ œ¦ø.&ý¤†8ì å©v¢[» ûöí»dNŠŽÒqmiÙ’ñ1Mã¥hFÃŽ˜a8Ñ´6Ê%¡³k@[[›È›ÌÜG£ÑP(•*k|¹Ë§½ àӑ©Q•¤ÁÜN†“Š‚ì*‹+>¢ù^L©Çb±)S¦„B!êw7­!dé»Ô*:::¤r/2;Ž3fTa!Y4IbÌ(677‡ÃaÀÇ®†½ª*QŸ¬ÐŸþô§K¦á¤ÚRìöZتo†µOë´ó‚¶8ŸÏ‡¡3ìÄÚfµÓ®­­;O½•‹D"Ó¦M;þ<”@·™uEQã3MMMápØåraâEÓ4¸(jT•ì¡]LÓt²ãG>#>|˜[[.:Û¡6­f4²nmnnŽF£èÆA›ÊFë§OŸ‰D$§j碭­ 3~zé^91˜8N>íL&u]G‡,µU²Q—FCÀE› üë_ÿ]³fMY9•ÄD/è…upVÛ£Ó’š¦‰q‰š¦-~{¦OŸn7Aô]‰Ñ¥h4ŠigžÒ‹Ò);ÝùëóçÏŒŒ\.BNŸ>ÝßߟËåPvv»ÝW_}õðð°¤RاX T×Ìd2ñx!ïDã"OÔÇ‹ÖÖV‰âe3 º]ÿ0#ü†ˆ%T݆«8v¬hÉÝÝÝ7ÝtÓ¡C‡vìØ±fÍš‹}š_­2'Ož|ë­·p@|¦Óélmmݵk—½Þ)°ŽÊƒˆ !4MËf³‰D"£ @ËæòåóùP4æ7ä`–+ø¸\®x<.ù ü WD{ך¦a¤ GaѸ«^5;1¬Mù;øx½ÞL&ƒ,½F¨Uz{{¡¤Nëˆ,!DOOÏ7¿ùÍmÛ¶fÖ†EÔQ¬f4ݦiªªŠ0”Ï÷êVüJ_Äb1ƒuBÏÌr㥜^ˆ2ù´7!C£t©TJ‘N§N'ZµÐšˆ@V”¦Äe™1gΜyóæ!›ÁÁ°Ç?}úô·¾õ­ËÉ€­[·f³Ù––ükX9—išk×®8uê”]UŠUÑ…5áMGPd³ÙL&“ÍfÉ:ó¯#^ä‹·ëAY 0M³³³s``€ªXÇke³Yä_Åb§¿éºŽFUð€ß§ìÍÁ€o|ã&Ë«‘ÜÅãñwß}÷Ë_þòåa@ÿéÓ§aÚ t”»Ãì|ík_{òÉ'%üD©QF\‘N§Ñ>…kÓ4±¿Asqö; ®'d$³Æñ4K‹h¸IKKK"‘°ßÍX:kÅÒ0íMÍq¢4ž6KÅÖ¬Y³gφÛÐ4ͰšïœNç®]»¦OŸ^Ë™ù3`hhHÁ»kæ èììœ9sæÙ³g9 «i2‹= 3'„uÚ¼]¾8Œ##Q_)­FHâiF$);noF6›Ec(TÁ°š«àÃy0sæÌ»ï¾[³†×y‡Âívoß¾ýò0àÕW_íèè°Wƒñä7ÝtÓÖ­[y D–GØ*ÀféôD%Ú9N0€“ÀîÞE9û`²œ. ¥Ói⟰ºTa´Ò³ì§p@zgõêÕ˜š2ÙæÐƒ{NHÛš °ÓšÖÐ/̉F£---N§3 nß¾ýÔ©SR DH;J$¶K®(µ œn5£ fÄL-â¦Y'QÚ)¥[ÓÞ_9JGkL[5¡ìCüçÍ›çr¹à6(Ȧs}иÿòË/ßzë­ÕÉ;A"öôÓOÓ!Dü° ˜ÎP(‡#‘H8Þ¸q#ÅѦ-nã`ÚMû;°¤e3;<,•Î)¯ƒAŸÏ'lå)Z¦ËâPVÞËÇaݺu±XlÚ´iÈàˆ2tX~öïß?¡|O¬4ýÍOÊ$¡º€×+V¬Ø»w/*Y\šì )öR”j·ÓÏ‘ã¡ù^(išTR%#N·½«K¿HQ¬=«¨d‚8¾ô¥/-X° c÷?™L†Sø fÅb±–gÈÕÄ€”©ÓX,^d³ÙyóæíÙ³G±ŠqÎÒrí¶Û¾l©†”Ä(¢y½^h¦½Óé4¨ù^©†ª9N2÷&Õ=¹YZŽniiY¾|9®¤³yËiì° :¼i² X´hÑk¯½FgÕpáÂ!vX[*•+ óçÏïïï̶’ü*•g»$¡Ãܺ°‰?UUÝnw8ž:u*&¤qhÕÑ(²2X% ?ª³“%ì¤vŽŒ`û£ÄBŠpæÏŸOsmÈçQM¡`Tc'x" œV®\IN† ‚ÃáÈd2çÎÃl-òMÓæÎ;22‚“Œ„¥¦åCnÐ,õÛ’“Ü,¿Ì¨pVGFX¡6ýäïꫯ6 #ŸÏŒŒàp6Ôy!O·ÎîÈår—‡ .üûßÿN§uó½@NPRÕh4:sæÌ“'OÒ‚¥M+QNH6r%UPŸ·Š¦Ói”T5M“æ{%–H¼¡L¾Š=äL·6ŰqFI2NöÀk»ñ†ßýîw/–.]ÚÕÕuþüy0@ŠîIš «:X(ÚÚÚúûûqX€Ã6ReÍ.—˨\Ñ3 ’…ƒ„5MƒæÓÞ”Ùeßd6#à&ˆ_ â†B¡åË—‹Ea©;}—$zX•Nxfn­ BüùÏ^³f ¢.R|l1)+bVUU§NJ.ÚÞ#-JMaE´’Ì fÄ›ö¦J*¼<0æ{‰F¢Ô£rNh¥ÓÞÉs=éîî¦ é4g€ý¼²ýèG—BˆGyäÇ?þ1ÙDŒºÓ)–d1A}"NÛg¸y!S†e{<ž²¦ƒó£X,¦R)ÓšéE¤Kó½•Jª’\ÃŒT2AÄ*¬ˆJÍô°P’<|‘.ƒìc»é¡‡Z²dI-„­uC¦­­mîܹÃÃß~ú)w8”'#Á£.\¸pë­·nݺ5—˽ûî»’IÕK ;ŽRPJGé8Ûè+$qˆÁø¡gv¢K¿.¹MŠvÈ”­çŸß´iÓŠ+ìÃ_O>ùä‹/¾FqÀa‚è+—ËÍž=ûÛßþöu×]wQ”lˆÇÙvwwÓ|Ÿ4æ<°%é&’ø›¥ý<Üb ‚òÔSOÝpà ‹êÞ½{·lÙÒ××GÈ,X°àšk®©.yU !°{÷î 6`»Ÿó`B•@þ†<‡ªªóæÍ{á…ê¼l!Dƒzô¨Ýâ‹ %UI*™ .þ\ &ÓÏ|y¡QexÏ=÷ ¢«•‚^nl‹—Ž"IDATÚ`U6ÉÖóˤòå¨ .ÄQ—aPû²@WW—¦i4íí° 'JÅ\”³9<á*KýB¡°páÂ_|ñ³^^eh¸ï¾ûz{{ûúú`^hø à´NxžÐ¶*&í¦Óé»ï¾».«« á„ vîÜùï|›MðÆöxT©\Pâ °S?“ÉlÙ²å‹_übýÖW‹€õë×:tˆ¢RéäîŸVP"Cd–gNÉW'|ÆÐˆ BÜzë­G%8lOá£+y¤Ä= >rÔçž{®ÑdР BìÞ½ûöÛo§†TɉÒYì~˜ŠE‹-jœçgÛ¡q „x衇‰žTˆ6: $‰477{½Þ|>kyUU‡†††††ÚÛÛ@ƒ„y• ¢ ;8p ££ƒ÷„Á²ã9˜sB;6d¨ÐÖÔÔÔÓÓÇOœ8QïEL ͪñ'™êºŽ‡ÆaÒÑ0 ´‡ !…?gÐÞyØ€ÐÐ jÒ\1PdB¤’C±†‡ÕÒ{hh X¹reWW×èè(í‘QÞË÷ Ö™®`‹¼»»»Þ+˜:¬^½º££#‰H¹X¥Îœt:H$Î;·cÇŽº"^4´ <úè£ñx<™L¢õJ-šŒ@G`llì‘G©7â5Á Bˆ}ûöýä'?iiiá•jªQvÛãñøoûÛû¢êW„½½½/½ôÒÐÐŽ·ñz½´3CAg&“™9sæúõë/¶7¤ŽpÅ0ðøã÷÷÷ øý~ê“€ì§ÓéÛn»í{ßû^½q¼8¸ÂسgÏÁƒig¦P(\òS¤êW$þ/Áý߆ÏPgøœu†ÿ¾™³~ Þ¿ tEXtTitleBenzeneö,„DtEXtAuthorJoerg-Ruediger HillD˜§ÆtEXtSoftwareViewmol 2.4‘r]¢'tEXtCreation Time7 Nov 2003 08:55:36 +0000zûâZIEND®B`‚viewmol-2.4.1/kde/icons/128x128/mimetypes/0040755000272700027270000000000010130257466016201 5ustar jrhjrhviewmol-2.4.1/kde/icons/128x128/mimetypes/molecule.png0100644000272700027270000001575010123052370020506 0ustar jrhjrh‰PNG  IHDR€€L\öœtRNSÿÿÿ7X}tIMEÓ 7:êaå·øIDATxœí}ylT×õÿ{³¯ž±gì±=ØÆ6`Œ1Æxa5Ð@‰QE)Hi!(§a©UjÓ4R“ •HQE¡$P5´eKHªˆ4¥ 6ñ¼xÁvðØƒ—ñlžyó¶yófÞï#îodúÆÆãá¥|þ¨\3yþ¼û¹÷ÜsÏ=ç .öɃ$Ùþ×ñD€$ã‰IÆ’Œ'$²d˜"zzzFFFt:Ïó†åççgff&›ÔT€‹Ñ mll”H$F£Q.—G£Qš¦GFF–.]šlj“†øLÐ7\.— Ç…B!ŽãÂá°L&ûøã“Mm*ŸçÎc† ˆ`0(MÓÁ`¢¨H$òÙgŸ%›Ý¤!>(Šòûý^¯—çù´´4Çãóù‚ˆF£Éf7iˆoƒAH¥Ò@ 0<<ìt:)Š¢(Š$IŽã’ÍnÒŸ~¿ŸaFãñxššš"‘H(b& %›Ý¤!>ô»ßýÎãñÀà÷û ‚ ÂçóY,–òòòd³›4Ä'@ii©Ùl¦iZ„yóæiµÚp8ìõz÷íÛ—ljSøÀ0¬¼¼\£Ñ¤¦¦VVVΚ5K¯×K¥Òd“š"D)†a‚ ÀÇqÇ“Mgê«0úâÕ@”ÀÜcåaˆR‚ :::nݺEÄÝ»wÛÛÛív{²IM¢AñÀ’ q €=Ù„“‹h4*Þ¡ˆ[€ï€ _0Ã0ƒÁ V« ÃÝ»wY–MKK¯K*²+É»wï^¹reddD¡PÈår˜þÑh”ã8–e³²²~þóŸ'›ãä &z{{>¬×ëU*•\.—J¥HžçÃá0Ã0™™™6lX°`A²ÉÆ Ñì]]]ï¾û®R©DãŽá ‰D"•JÇ;3,’S€høío+“É0 !F£ÑH à7†á8®R©ÞxãdóâàÔ©S …ÇñH$Âó<þ!€†õõõµ¶¶&›u\‡ííí‘H=ü<σ-â8’S*‚ ܹs'Ù¬ã‚8hmmåy: …B!žçSSSsrr¬V«V«E¿G™B---3ÃÍétÚíö . ÷õõMö?ŸÜ9àÊ•+‰D¯×G"ÇSUUe6›'û'§4ñ% XµZm2™JKK)ŠbfllŒeY$ÏóÍÍÍ3@Ìårµµµ¥§§[­ÖññqŠ¢Îž=[]]mµZã|Â$VÀ¥K—0 KIIQ(jµÚl6777Ûl¶©Ÿ$@€XS‰DAP«Õ …B0PÈ Á‰f500PWW§T*Á/€,UFóùçŸÇÿx¸víšÓéäy> ±,˲,$á´µµ}óÍ7S`?zzz`ÜÁÛÿ%Irll¬¹¹ù«¯¾òx<¡P¹F°  †„²Â0ìüùó<ÏCJMÓžÄ0 †a/^Œó!Ò·Þz+žÏ8pÀ`0Èd2At:]8†”¿ßÙ S~oÇ¥K—Î;iXpø’H$`ˆ EÎív{<p`îCšPyyù—_~ Ùs‰ ÖÑÑÑÖÖÑ@Ç‹‹‹ …ÝnãããCCC«W¯Žç9ñ®†a€×ëeYvöìÙ^¯×çó–eoݺåt:áuþ úûûõ«_555)йsçÆ:9ànÒ4 I‰±.)È`6›ÓÒÒ …Íf{ýõ×ûûû§‘˜Çãikk#¢´´” ˆ@ @QØ’$!OéÚµkq>-ÞM8$©T*ý~¿Ýn§(Цiš¦Õjuvvv4íëëëííSöoG__ßÕ«W‡‡‡a·×étUUU:–‚D"Áq<ÂRÀ0 ö4ýY–ݽ{wJJJkk+EQ:îÔ©SV«uõêÕsçÎ}Dnuuuz½^.—cf6›Íf3LM›ÍÆqMÓ,ËRµ}ûö8¯ jiiaF©Tbæt:Ýnw(¢(êé§Ÿ–Ëå ÃÈår™Löüƒ$ÉGYõ ÿú׿†èBIIÉúõë ‚èêêº{÷.Êÿ´tFþÃ00@EEEK—.F£>ŸOŠ¢ÚÛÛ»»»«ªª¦F¬¾¾þøñãápØjµ†ÃaƒÁŸŸ?{öìææfÇišfÒ¶ÇÆÆ6mÚg±B¼Á¸¶¶¶?üáV«¼ AB¡V«­ªª*..…BÃÃÃ.—«½½]’$_yå•‚‚‚ /088Øßßöé§Ÿ^¿~}ìêêê®_¿®V«áÄ›››»|ùòp8|ùòåîîndp´Zí„`œ  ˲$IæææjµZ­V»`Á‚uëÖ!A"‘„B¡šššïÿûðG{zzÇ¥K—4D"nÙÙÙ¹¹¹7n„Ïô÷÷ÿùÏÖét@líÚµÅÅÅ‚ tttØíöû÷ï³, S“a·Ûý‹_ü¢´´4žQ„†}õÕWûöí3›Í*• Ã0’$óòòôz½Éd*))ÉÍÍmmmmoo§iZ*•F"«ÕºfÍš9sæ\¸páÚµkJ¥F &o8fYÖjµîÞ½ûÞ½{W¯^’H$‘HÄh4®X±"==ýúõëÍÍÍ@€¦i¿ß¿eË’$Ož< Þ§L&ƒ ­€âââ;w~ðÁƒƒƒƒA£Ñ †ÊÊÊšš‚ ¾üò˱±1(‘$Y[[ÛÑÑqíÚ5NˈF£`ʲ²²fÍšåv»‡‡‡át:]eee~~¾Ëåêîî.—Ën·ëõzA ô£-^¼8Î!œ€¿ÿýï 6Ïóÿþ÷¿óòòÒÒÒàÊÊÊ222Z[[{zz"‘ˆD" ‡Ã.—K¯×k4…B{0gyžgÆï÷gddÈd²h4ªP(ÊÊÊ.\ØÝÝ}åÊ•ÑÑQ–e ‚ÈÏÏߺuë²eË0 »yófkkë‘#G`­à8Îó|YYÙ’%KöîÝ $m6ÛÉ“'ïÝ»—’’¢R©,KMMÍ¢E‹ZZZH’”H$@ ‰hµZ¥R)“É€òè!¸ÍqÜöH$’âââ%K–ŒŒŒ\¼x1§¤¤x½Þ´´´M›6-Z´hRcøHLÀéÓ§³³³ûûûµZmIIɺuëärySS“Ãáà8Ž¢(}…Bñð¶ .#œ® «««ƒÁ`}}}oo/˲Á`Ðår>|¸²²r ÜZZZvíÚ•‘‘¡ÓéT*U~~þúõë­Vk{{{WW—Ëå’Ëå*• âû rg¥RiqqñòåË#‘HCCCgg'¸ü …bãÆ/½ôÒ£Œ6-26›íĉ½½½è¦°²²rõêÕ@àÈ‘#p/ʇ•†ˆ$É]»v©Tªÿüç?mmmÁ`¦éñññ-[¶¼òÊ+HïÈ‘#gΜIKKÓh4°1<õÔSííí6›M«ÕÂÌ@Î39`S ƒ¿ùÍo¾øâ ›ÍÆ0äääüõ¯}Db€i»knn>qâĽ{÷ôz½Z­¶X,*•jll ¦?\¤Ä Þ @Ó4ØPÇCÓ4A¹¹¹/½ôÒÊ•+§…†a;vìp8hŠøý~à W›À Ã0Çc…B4Ms‡ã8‚‚­[·.]ºtºˆMó•dìª_ Ù˜er¹\"‘p¦Þ¼·H$Â0 ¼á”Åo¬Ôþþ~¥R©R©ÐÒJ*•J­VÃ]9€@€ã8ŸÏ÷§?ýijÆð[;á÷ßÿ“O>1°ýÊårÀd2eddH¥R¯×;66'Xˆ!C¹ËóÏ?¿{÷îiç‹–––_þò—F£Q§Óc&—Ë5Mnn®Åb …B÷ïßw:ˆ?9Î[·n%‚OBîvíÚÅ0 ˜xг,FFã¼yó,Xšš*•JY–……ø~8NôècVQQĸ…B2™Ìd2•••èt:H³@W ° Ä'QyA(8 ¶\LÇu:N§“Éd°L¸çJ™X8pqC».D Ü …bãNÈN&ˆOÂ@˲>Ÿ¯££C&“¹\.Š¢b  A‚ÈÄâµ×^;}ú4„íÀë! ê …B(ÎÄ***Ä'QìÞ½ûôéÓ(_¶Ü¡¡!(ñ%EðÑÁ‡¦é‘™pº@{©TFY–u8ccc‚ 0 ›rÓÚ÷^„D ¦vìù+ Ábç>¼ä®]»DföìÙsúôiŽã`uâ8X‚È Eë’eÙÄ%Ü%03î§?ýi__ŸV«U«Õ(ØJ`†^’aõÌd"Iii©ÉdŠëM8 £EI’d~~þ©S§Ä$Y;wî$IÝ_‚G|øÂ÷EmÛ¶-qLƱcÇàúa”K~@G0†aŠŠŠ7úX¢sCoݺõꫯêt:X±Á8t ffΜ9'OžLÿŠ?þñ'Nœ€ã Æal#Ì ¿ßÿ—¿üeÅŠ‰£‘ðäÜæææÚÚZˆº@>3ÜgE"Õmß¾=Y)Í6›mÇŽ( ŠR}áø’è¹˜‰ìh ôÑGáp¸ººÚb±466â8ž——W[[»|ùòDøv¼÷Þ{ü±^¯¯ªªr:>ŸïàÁƒ3Cl& 4V¬X±bÅŠ³gÏ,^¼¸¬¬Ìn·{½ÞŠŠŠ¤>†a8ŽF“Éôì³ÏÂ…R8ž1b3—šK-¶ªëq«.JJÁSrC·ºFd„Qí™ä6ÓÄβÇG„ïò àqwÔxåÂ=Î+ )UÇÉà1A¬#>óûÓþ?ž˜ ämI©ØészÉÇdôc&ÇwÜ¡ œÇÿ»^Ðc‚ ›ð Ó›¡f}}}V«5555 uwwC±Ëåš™¿þ-èíí%I2+++==ÝápQXX(•J/]º”———¸Ê„™ˆ†8pÀår¡»'ø%dÝÐ4][[;ïù_ñùçŸ_½zê àÂÃ0¸›„Pù pK¸Öh4ˆ®$á>R²Ö®]ûÜsÏ%”ÆÃØ¿¿Ëå‚ËtYûpƒ¤Õôôô7ß|3q4»¼óÎ;v»õ•yØÚJ$…BQ__ßÝÝP&ÐÕÕÕßß[â ø%$R:ŽÎÎÎÄ1Ià xã7ÆÆÆ Cåà£]e£@©“ÏçûðÃÄäalÙ²%55¦?JOn¨FnL)Šr»ÝŸ~úi‚˜$ptwwÃíclŠú!6õL™L6cœ8M’¤Óé„| 6!A1Ad%€Ñh„¹ƒ2p9Žóx<]]]v»ÝívØJkøpzzz‚ø ÔÕÕ¥¦¦†´þ€ìh†aFFFÀ ºÝîØü\}“Étùòå …ÍÓ‚éwCQYóùóçF#*Q’Éd2™L£ÑH¥R°°hr1 C’¤L&[µjT'¢ÃªFöz½­­­)))¨F ÜP¨`€´mä8@ÍÚ’%K222(ŠÚ¹sç„ôGÄt €z<@Î÷½{÷†††b}mt@sLÔˆmܸR©yž·X,k×®?þtq;zô¨ÓéDÕÈP@Ç`t€Çvž izñâÅYYYP],ÂôN‘i ¡¡áÚµk`ß%Éüùó+**^|ñET¥²£‘èÄOÓô3Ï<óÃþÐf³ À8Ž[½zõºuë‘X}}ýõë× ü_T¼wï^¨žP'Ûú–æþýûsrrîܹÓÕÕ…¦HQQQMMMü±þ/ÄÛ¬ã[ðõ×_ß¹s§©© \ÏY³fmذ!--­®®Îív“$‰>Ûn2Ö$IR£Ñð<¿jÕªÂÂBøZ<™L644táÂŽã¦Ö夿¿ÿþýn·*¢2226lØ——wåÊ•óçÏ3 CQö 45¶ßZ— ÃhµÚ—ËUQQ±hÑ"ȤÇq¼²²ÒårÁöð(£÷H+Àív A©{__Ÿ×ë]±bEFFÆ7l6›ßï§iÚáp( ¨•D+Í2˜þ2™,;;[­Vgdd¬ZµjñâŇãöíÛPNóðª¿xñ¢Ãá¸ÿ>,8ðŸzê©ÜÜ\^ööö^½zuddŒ¡F£©¨¨(,,lmm½~ýºÇã3ÃÃô(ЇY–ÏÊÊ‚L¯×———ï{߃—2 д&(•JÇ9Ž›¬išœ.—ëþýûápX"‘Œƒmb«ôôt•JÕÛÛÛØØ822‚zù䓆††ÌÌL£ÑFÓÒÒôz}qq±^¯ïêêòù|^¯÷›o¾9xð`BeeåíÛ·Ÿyæ™û÷ïÇö–ˆ Ù«T*N‡=hÂgápxttÔétnÚ´éæÍ›Ó^å[YYùÖ[o­^½š¢(ˆ§vttØl6è` ý4ã|T¼@—"ôÇššš‚Á 8™™™‰«qܽ{÷_|a287€¡ç8Î`0äää‚Ëþ ‚Û,Ë>ûì³µµµ "†aؼyó|>tmu»Ýƒƒƒ0A ‚xþùçã|H¼&hëÖ­gΜ.aÇÁ&L„Ëåzíµ×¦ú ñ•µ¢Î‰D­V¦§§³,;44ïØ[hq–8TTT¬_¿þêÕ«<Ï«Õj©TÊqœßïOKK{ñÅã|È$¢¡ûöí{óÍ7óòò´Z-ô:ñx<¯¿þúÂ… §Ä@Q#TË '5èñ€öCž:¯íÛ·WTTüú׿6™L‰„¦i«ÕúöÛoÇÿ„©4íÓh4ï¿ÿ~mmíüùó—,Y2IÎSÁ¶mÛÀ)Bá3“Éd±X”J¥Ïç†]5¯ôûý êð3½˜ô}ô„ݼyóôsù¿QUUÕ××· ÐÇqÇC’$·Ñ?¡ƒzœ!Ž/pØ»w/º%Gvn¯H’DI ±>ÒŒµþxDˆC Ã^~ùeèë€d@^il^ ˜ ‚ PÑÇ¢ù&½={ö´¶¶Âw„À)lÂõJeƒ|ðA²ùÆ 1}‘Û7Ž;v÷î]ơα­?H’K–,1›ÍYYYEEE7oÞ ‡Ã?øÁf éâ´C4›ðètºôôô’’’^x!;;[«ÕÂý”è V&,ÜÇ­ì)~ˆU,¦¸N¼£‰Zì¡u Fˆ[€ïÄ*@rï^xáÇ?þq²IMbà;ñíß1< Éx"@’ñD€$ã‰IÆÿÖh¸Nºšì tEXtTitleBenzeneö,„DtEXtAuthorJoerg-Ruediger HillD˜§ÆtEXtSoftwareViewmol 2.4‘r]¢'tEXtCreation Time7 Nov 2003 08:55:58 +0000ì«€IEND®B`‚viewmol-2.4.1/kde/icons/128x128/mimetypes/qc.png0100644000272700027270000002004610123052370017276 0ustar jrhjrh‰PNG  IHDR€€L\öœtRNSÿÿÿ7X}tIMEÓ 8Ïžˆ 6IDATxœí}il\Ç•îw×ÞØ­æ&Ê”eŠ¢,É–µS²-À楲¼‰’<†1b{ Ïžñy€ÍÀÈ  2yŽ=3ÉŒí80;HâäÙRäEÝ-xÓF9²™’lÉ’(RT7ÙÛíźªÛM*M…d“‰ WÅV/u¿¯êÔ©S§ÎåÇÁu©ŸðõnÀ_»\' Îr€:Ëuê,× ¨³ˆõnÀ5ÊàààÅ‹LÓÐÙÙ¹dÉ’z7êZ„[ˆfèþýûyžF£’$Ù¶],/^¼xûí····×»iÓ–…§‚Þ~ûíÑÑQÇqt]×4M×uÃ0DQ|ñÅëÝ´k‘…GÀ+¯¼R*•r¹\>Ÿw§X,æóyUU-Ëzùå—ëݺiËÂ#@UÕL&“N§MÓìêêjjjJ¥Rccc¹\ζíz·nÚ²ð&á|>ŸËåAÈf³CCC###ªªªªZ(t]¯wë¦- €L&S*•‚Á`*•zï½÷,ËÒ4­T*åóùÕ«W×»uÓ–…§‚¾óï¤R)2d2™\.—Ë寯ÆÚÚÚ6mÚTïÖM[ëÖ­kii)‹Žã¬Zµ* †‘N§Ÿxâ‰z7íZdá`Ó¦MÁ`°±±±»»û­·6_º´\„z7êeA.Äî¿?1:š:p`3 <à47ôøã[úúšëÝ´iË‚! ™T‰b2YŠÇË€ˆ€8€€®(²¢úúŒ[b¾Ðß? ð±Øe ·àE_Zl@t@ŒXlqOOƒ¢Dê}Bæ5ýýC±Ø(àc½Lp LÊÁ•‹-íëë¨óL-ó—€d2«(|€ð²}àx p¼h€”Åw×óf¦–yJ@29®(ï3èûhqiૺ¿[7¼UQüñøu¾«Éd>š¡ÉdJQÞõ*weqŠâ´Èä͉D6û¨Î76™Ì»LŽ*Ê[ÞŽÏV@ÐëAq˜Š;ˆQDºPI%¿SQZçú–®*ónô÷Àô}·ð€h‘G ÏÌ2à$wÒÛ›L$.ÕíÞ&“ùEÀŽ{ãñ¦/ €Q R½æ=ÕÂQMågП`¢·÷DbxŽî§™GìØñ›x| A 4Ò|¼³.®J™Î~f(Ƚ½¿K$.ÎîÍÔ,ó…€;~!ÚÙ]ÜU;SAÈœA !ÃȽ½ÿ/‘¸0ëwUƒÌ úûßÇ/ Ê@*¡)ÌMLUç8ö»9Š{Ð[½½¿îïw®nqJ©¿”L¦%dhM@h¤Épgž¨sEHgš(•,ºP ¢9 OKF(JG_ߊ²t®n·RêLÀŽïÆãc€ äX ´m@+ƒ¾K€+Èòo9Ž ˆ EŠ~>tº b±;úúê³T®';v¼gPŠ@% …1öY8Žƒ \Aœ\ ’Äiš“ÉX™ŒeYfÙ  dsÀIà25['®Š²¬¯o‹¢Ü0— ^$“iE9HÔi&¨jÈ˄Ç牆¹‚5¹2L€ã¸lÖ·2KÓLÀ¦ö(ñéÀ'À)à `²è»WEiÇÿfZ÷222R*•×­[W,o¾ùæi}|zÄãqžçÃá°eY©TjëÖ­---Óú=É䘢¢æ9¨§ÁT@ 43çóqÁ /Ë.ú•ŸÔK%'“±…‚âºð4àÀ `¼zö^Q×r/£££Gmmmõù|Ç©ªzñâÅmÛ¶-]Zë¤2 +èõ×_‰DdY---‡:xð`íß`ÇŽƒŠr„º\é¡ &AP,Y¶}>»¡hlD4ÊE£ˆF¹ÆF46’: I¶$ْ䈢ÃóäKlêÕ2PJÏü(ëÜžà ·7ÞÛ›ø“÷röìÙ½{÷ú|>ÇqlÛ&QªÁ`ð·¿ýmí€ÔJÀFFFLÓÔ4­\.—Ëe„sìØ±Ó§O×ø%;vŠÇóŒkÓET|Ì‹Û-I²ey¢ø|v8ìÒÀ^9Irô¢hK’Íó,‘~i@Dªš$f‘Ì:-ˆó.õ'{öì1M“„$‹EžT*•ìÛ·¯FLj%àW¿ú•ªª¹\.›ÍòDÑ'w®€*],œ;°Ý¿ªL8²L”-I6¹uD§‡þ¨C{·Èª8ú_ì6Ãéï?Äþ¹wïÞ>úˆ¨ß–––––MÓ²ÙìÁƒßÿýb±X.—UU}øá‡k¶ÖÐÄÎÎNUUC¡P>Ÿ?|ø0¸sçNžç …‚$IÇýà?¸í¶Û>÷¹ÏQô?U”Ý@QÈ–¡ õ'»ÑµÇñ² Y&WȲÃÖEŽÃTU ¼J$É&d&DѶ,–‘Ñû¥*܉ÁdîÛI$†z{_ŒÇ¿òÚk¯½õÖ[mmm›7oÖu=¶··/]ºôÙgŸå8ŽP¢iZ>Ÿ[µjUÀ ±X¬–÷577¿ñÆ’$ á˜Åb1 -^¼¸««+‰ …Ë—/Ÿ?þÂ… {öìéêê:~|\Qþ›Q/®Ú±(ÉN,w^–ù@ü~ŠÏgH’Åó†ãØ–åXgšœ®Û¥’Y*™†¡[–mš0 [×m]w ÃÖu‹éþ ›”Dà™2b´m&ˆgÏŽÅãoø|C¢(ªªºlÙ²5kÖ„B¡ãÇ £ë:ÑÒ###ßøÆ76nÜX#ÓX?~ü‰'žhiiñûý …BGGG8nnn^»víM7Ý400@†¡ \zöÙõA²W™qшìn ­s€Àó¾`…ø`Ð lY6eY$\%IežTlÛ¶mË-ºUs9n|Ü·r9˶ Ùd^Éi ¤s² g2c}R/凶n»­¡»»»³³sttôĉãããÙlvttôÌ™3ápØqœ®®®ûï¿¿vô§G‘çž{Îçó0MóÕW_íèèhjjjhh$iÆ ‹/xíµßÿøÇ7d€ñ_Y^1ZHòÒà—e+tDÑ¢pW ?Qá8°è“bšN±(ªª˜É “± Ãd´PÈP ^ô}Ï€ÎV+åŸþô3+WúöíÛgF$I§ÓMMM_üâׯ_?- ÿ,*ä…^Ø¿{{û'Ÿ| …Ö®]ÛØ¸ò¡‡žŸ}™BO„ŸŒbž! ŠþjÐݺ(rŽcÛ¶eY–ãX¶mY–í8‘RI(å|ž/—Ù­Í0Œ)`œÚÄîªÐö¢ïr`%¶zµt÷Ý—ˆÉ/ËòÎ;zè¡?½ ÀÁƒŸþù“'O.Z´(ŒaÏž"ºËßkt&%t?]à¸6QŒV£/IÇ9Þ¾ïÑE–ek§ª’iú¨[ € d€q` H`༈›“‘a­Y“½ñÆô²eËžyæ™?· fÊwèСçŸþã?‡Ã¿øE 1ûPä*¹? 8”± }B’ \®Å%¢(¹è‹"7)îŲà8~&®«L ƒ@c´ÿ¤Ê§‚ýoÿ¶ù[ßzàöÛoŸÐ0ƒ'd¶mÛ¶mÛ¶£G>öØcÑè¢LF¤àÊÌ À»‚ªi@d‚mM2ûcÀiÓl4Íõº¾\C’Àv¡w“-^ìxjYÉ´¸6kŒ–¦†ÞdLÕâæÍwÍ ú˜%wôÎíÝû)¢%HÍÏOÓkE÷'í!7LÜgEêDÓ%ÀfŽ[ã8¾*°Xí¡Sà$fcǦk=£‹xjûWtv«ª˜@Úq^›Y¬f…€dò˜¢ü/ 4Ð~'xíVØî,bÂè^M‘Vl Ø Ü€úyÌ*صž»ëà^ɬP jug·wÅÄú±§ç†DâG3‹Õ¬ÒëéÙè€ÄxÝ•NõŽ®AabƒmÝ›7¨"*% ˜À‡À p°h¬®íÈ./àrt+@OUL@S”u3ŽÕl’ Š¥’è.¬\¥ì O;)V¹Š¨D9Й7 K.@¬"@ð®òÄ*èmï.ÿՙТ¢Lc…U£ÌÖ–dÿOb±Ÿ¡Š½Ž*\cÔÒÓ ‡«̪wàé&škÈ£j-Q_S î7¸ÖW5 PÆgz»OµÈlY&½U . /"tf»‹[·€!`"`Náäpç}ÇÛDj°4)]ëëûÇÙj7å9nýèWsP~bVõD °¼¿àèëûçê_N&‰cÞî/SEg{^ª7 ÷¥xüвmæQš=’ÉC_ùÊ?øýO?-Vi!Á«ˆœªŽyÅéë{pe«¢LÏÅ~”L$ì^#ý9â‚e¡‡—îL™¿è8Gÿ|LªevÃR>üè£644Ó§3Žã¢Ñhssó—¾ô%²¡444‹=>7¿>wáéd¨Ù¶ÍÑøqÎH^wqgî›T‡óä&çú®vnÍeÛæš¶—Í\ùK•ù†;iþJTÐ|ìü4gRO扰†øÜÏO× ¸"×UP}ÄêrXh®×îMÎôYq;Ç_¸ ây~^¡ÿ×kÍ©˜„ç¸ysá Ò’I-‘ø»³g#ãã—ׯ?qâÄ¢E‹DQƒ_¿ºœEñ+Jc_ßl4‰-™Ô û~÷»Ž‘‘¡+Ò+WŽ­\ ÀqÃ0t]WUu×®]³ÍÁlp®¿,#©$º¹E\-S¡ïžj´YQŠÒs÷Ýår¹P(´¶¶~ûÛßž‘fL*³EÀŽkš€( Ër9¨Æð슱;â~E (Jë4™ ˆÈÅb<ƒ5ÏT8®Ò˜‹ê¨ÄË7Þ8¼xñ?üë¿.V”‡•Y!`$™|[Qšhª7_Çp0U÷¯Üfê‹c1TÅ8fb1v«zO‹Ÿ¬pÔü(QT Gϸq^î‹îù|}”òÞ‘#wÌR³DÀ`<Þh@~²WÍ[U‹k{'j¶ï»qkl@ç%rR0ú v:…Û}Eߢ‘¹W_  0ìíï'Aqï@6ªÈðSlÞ;\/ôœÖŠ0Ox£®¸*uä[—½]ž¼Á¢/êL`ð,É̯„SýC2v潉ª*^ÉÓ{«8Ëꞟwƒ }4°Ÿ=Ò膽è V×»_+зhÌ;™UšYT¥6ÊA‰”ðòB™ŽÅã­´ûUŸÍ«mÐ3»&w„)f¼½Uã€Ì>®0Y*†KŽA¶è=À*éþeࣚs’LKf˜€çûûIVL´¯~ï+¤S“ÓÓd~vÏ(aƒ¯ Ïqà8â¸Ï»…7 É0,Û®¦ÁE_òL¿& TÌ*,æ<©¼ý ÿ{Ù²GydÅŠ3ˆØLpêÔ©ÓgΓuÿI‹NÕˆ{|0òjFAX”§,¶ Àaº.†mY$o—¿1f 4”é1T–rl¬À¼³„B¡^xaéÒ¥===]]]3ÚŒ-ÄÞ|óÍœzë­áýûƒ€*·RQ\.{ßZ™åÁ ü~°4¼qn… Ó„a@ׯ\ Ã1M۶ݵE¡¨Ìñ3ƒéþîµÈd&ãfYOÏÚÏ|†dëY½zõ]wÝU{f¬©dFÀ|0<<|ðàAI’Vß}wqx8wâ„EAõñ-ƒj yµ‰@ob—c¢Y†ß`‚07ÛñÉ+¤û{ч®s†!è:LÓ±mÛq.yçUwнúǦ.Š3?«À—ÿ韊ÀÙ³gyžïìì<}úô5$‰›I._¾|áÂ…R©‰D–/_žN§·oß~ËòåßøáEÔ–pµÍ¤ÊÇÇh!žèÐhÞ&,‹#yS|>ƒ¤I”Ó¬F¢bÐ4NÓÆt½ä8%¯V)1ƨ‹¾MÍh•¡á¶{îI—J½½½ëׯ?wë>Ÿ/NòÉ'+V¬ 9ãt]Ÿ®jšž =þ¼a<σAY–-Ër§µµÕï÷Ÿ?<zôh ƒ>ŸÏï÷›¦išf$éìì´mûàÁƒ¿ùÍoR©TÙ¶sg§R`ºî½U|ìÀ—&æÌ˜@Ÿ²ìø|\(Ä54 ¡ÁàDñù Šʼnl¢‚žwÇ4-]·5Í.—írÙ6Œ<0ê=v\bþ,3ÉýtÊ!à'ñøßÜ{ïÏ~ö3A4ME1“É477wtt8Ž“ËåDQ$‘÷äðøïÿûH$FkAµÖ…ØG}ôòË/sgš¦®ëä)¾årùæ›onkkûàƒÞxã¡¡!]×GFFvîÜyøÄ‰[¥â:Eš¹¶ºd,cVCWÎì)¶iZ†a;Ž#ËX´$[b8Œp¡Ø’d¦išºn꺥ë¤b†á8* 1feÑ«‹ Ôæq¡ÏSôoW”îîî#GŽ|á _H§Ó…BáÓO?Çãï¼óN H¥R¥RÉMÝW*•,ËzóÍ7k¶V´wïÞÁÁÁöööH$‡eYÎd2ªª’Í#’øàTÜÖÓó“Dâ)åÀõ+˜4«LÍVЃîD@   Ã1M®X$#c"KœaÀ4ÙA0ÁíþØŠë°Úô§ÐweÕªU¯¾új8&†P:6 ƒd®¼÷Þ{k¶V¾öµ¯ýüç?ÄÚåyÞ0Œ\.7::úõ¯ýêŸÝÚÓ³QQ wØUîe Çha"d ¬R ‘µéþn!ê:¹’¬}Žã°ŠÅ¤ t+Ð×ôZú¶lÙòÙÏ~6™Lš¦AÐu=“É455}õ«_­ñK¦a†Þzë­/½ôÏó$C`&“þæ7¿YKÆ´¿{øáîÞÞógÏ^8{–Ý ³½Ó€å4‹´Ç<’º²ìpœ],Úª:QŠÅ+‹v©d뺥i$g¢ëXÎ ä¼ÉWÜTAÿ³¯ïÿ<÷\hÙ¸qcWW×îÝ»5MËd2###Ñhô{ßû^íßp-Iû‚ÁàÓO?½k×®5kÖlÞ¼yZ2ûÏþ~ö(´«‹x ´÷«½>}àe™F‰`’¾ÏTlÓ„mÛL÷×€ ´ {­ â }fŠ)w¶¥Ï8”L>‹M$Df«€ „0ÐÜG p%Õ ð‘ߨÈ.ܶ®_™‡ ¶íX˜¸ 7ÈE†(CtÁAºÿÆžžÇb±º º@äÉXì?úûÝÙ˜B”€`ð?€ó àÃa>qçJg7MÇ4aYî]ˆ3‡ÝgÖ€‹Ì £#`COÏó5+ýÙ:œ’$òx,öl"±QQÜÍXVá€cÌÜè.‰Í|ÞÌdÌLÆÌå¬BÁ.—mÓ´ÇöÂ]öœ×ãF¦ßGúúê‹>ê8\!C¡éþaZVÑTL{Å$n™„’ÓWTêÙvÉ .’­õ2p†¿ïëûçÙÙæ–ÔŸ‡“ÉÇ% Dô «&&‡ ¨‹b*d[V£Ï%€$Íí¬ÙØŸm©› bekOÏÓ‰D–‰”rA£@n!”™,Š¡DnQ½jgœÉӚƀ1 kÞ y2ˆN&ÿEQš&  hš2,š&ë)Äï ¸Ì¨×Ò/xûþç ú˜W€á ™á  XD½ú4//‘4uë³èCÀÓu²÷§’ùE€ÃÉäãt¸W÷y?ìcOÜ ghŒ2‹[v·+C x*ß6ŸÐÇ<$À‘dòqEqQÄ‹;7ÇÖùÉú>)ä‰OÎ?ô1? €—_Uß¼Q‹2õ¤ê4œå ¤ÿoècZθ¹”öåË Ž{/‘ЙÈwóV¯ ³(Ó}Í\Ujx ¯ïžšŸª3Ç2OG‘§b±ÿèï¯xÆÚ¤uË»¥îF•€5==ÏÍ'³§Bæ5D%“‡ãñÿìŽÝ`˜ØØÓ³EQæÃr÷*²påP2ùï±Ø@"Ár@RÏ» oèéÙ¢([e^ÙšW‘…D€+?ŠÅž{òIklŒ„éÀêžž¦ÖÖÿÅ/êܲéË\œ”Ÿqù—Xì“'7lØp~`à[ÿöo{öì9þü­·ÞZïv]‹,H¬]»¶££ãŽ;î(—Ëííí¢(’§É.8Y*è—¿ü¥,ËÍÍÍd+Ü4ÍB¡péÒ¥¶¶¶»ï¾»Þ­›žÌ oè´äĉgΜ)‹…B¡P(°0UUu]ß¿½[7mYx  …L&“N§ƒÁ`gg§eYccc$PìØ±cõnàôdáÍ$F/ 0 ÃqòÍ|>_(ÜL°ðÈårªªjš¦iÚþð‡sçÎe³Y£—Íf·nÝZïNOž zä‘G.^¼Hb³s¹ÜÈÈéû™LæÆo¬wë¦- Ò zÿý÷¿ûÝï.]º4 ‚`F6›miiéïï¯wÓ¦- ’GŽÙ½{÷¹sç$I*•J÷ÝwßpaÚ6r!;[ô R_“àˬs1ÎŨ„®"™°®¾ø#fÎ/™ã-Ù¦__“O/‚ÞQ=ãy[ï Îe€è0u¨*bø#õ×}8a8œøé5¾¦A'€.&šLS‡¬"šÁä»šŠ¯ˆœ§ÖN”œ/ŽÿäšpS‘‚Îøœó—ÍW=ã|f6  ²ŠÞ*77•ÎŽœO”œ—ih믺›|"x\Ó‡GõÈGÂûë„h,Ï¡,€®Ÿlnk>mž(9÷¼ý/×°'›üx êNu Æ{ê‘ÿØ}†XžGií?Ü8ÔÚ|Λ=QrŽØóÐ5Ìɦ€žË‚â4~ÆûØ}ÆûRþ €ç ò( àà¿n8Ò|n[>Qr.húî5ôD“_€À‚cÁX¼ ÄŒVº÷yä¿ÊÄ2”ÏBâQÀÞ‡6žÃ–O œ3ºµd7ID   äkœŒõ/õ¼÷U€RP à° ‡°ˆ¬?WŸ@9g¼ýljÀX †‚qu–Éé/ÓóN°Ôn¥À0à9y¦á\5~åÜÐõNK¢½‰³ü5¥;®®Ï⢜õ…¡À2Øó»úsÒþ ”sÀîßÙá0( zí›ÎH7ó¾YøN†äÜ‘I` BÁ‡7ÿpÑÁ9 ãí–áÖ&Ž˜&…A`è&ŒÑ÷êÚûÀõç_†€˜ÐMè:AaRP€eà°ó—õ¼ (瀾CÍ"†Ia˜&tÄ«Vc”ê­9æ˜H˜€ ÄfB3m\Mð,výöâ6‚sÀ‹×[³õ‚á¯hÖÈ5aš …úe!øà !†?)Far  &4º@·00¡[0P;T³,Z÷5ð^L”œXØ#Tw.ƒØ*³,@7 ›0 7Ãʆ*F¸áR„J*F°¢&c!d:ßf}³á|³‘ÿµ&Aû›Í¼%ç`GÌtª ̀ʂcaŃ\–“‚Pp,xž' ðá!à‡$‚å@)tœÊÁÍÈ&¡†cL^Ûw1 PH¸‹y_õƒð»Ÿ4˜–0 ñàMp8'ñ`9k§ „aXQðsR¾!JÁ‡@5(1 ¦J 膡›,SPL¨Tç¯æ¸£·w·Üx×UÄDÉiرc‡ßïg˜Ñ²<É_xîG©™á‘á pàYûbp,XÆsñ,§ú zÙRp>z jŒ**1SPÕ-»!¦õ—À$0¨tªÀ¤c8ƒ7Þxã=u›RZYYY[[ûž>u>dìý€gžyfÿþýápøÂ7èÂ¥t``à+_ùÊ‚ &¶%c[€¦i+W®¬ªªºÀ º0F·oßÞØØø_€T*•H$º»»9Ž{î¹ç4M»ÀÍ:¯Â0ÌwÜQSSÓÑÑÑÖÖ6wî܉lÌé¶$×®];gΜ{î¹ç¥—^êêê*--s°ØÝÒy %(Â/ÀJ…ž!0 8ž|>Á'ñ’ÄJaH¥`%À„–¤jÜP]Q E54ÍŽÎâÎtRîO5¡ÈêΠ+v Ù ‘Hõ™ûüûßÿ~îܹ_øÂ~ûÛßö÷÷?ùä“\ï[N„yä‘ï}ï{[·n½æšk†‡‡+**î¸ãŽÑoËïþó±Š0Ê8  ˆð ðñ9ܥĢj2­¦3š,ºNœO¹(õ$³Ý NRë0 ˆõõ;ÎÜçŸýìgÑh´©©iþüùápøå—_þ ZüÂÕ×ןîµòòò­[·Æãñ›nº©µµuÛ¶mŸúÔ§ ÞÓÒý§_¶¿ç[]±ëâöèu­ƒùý;õ‡ú7¤/[RÝâ:k«€a@M““RBtÓÔuCUuYÖ²ŠšÉj™¬–• ¡–êMÀ$yÎÇp B³ü†¤‚ã#KSê"@@niÙ__ÿ‘3w[–åC‡1 ³téÒ“'OîÙ³gýúõ\›ïCδˆ\¾|yUUUoookkë’%KJKKŸyæïZZ†#‘Ž‘ìÇ€ 襼ӿá—o5üÕ ÍoöDÜô™;©×MN¤äx"‹gG♑x6— 5“5Mâ¾-çý) Ó^XOj&âòb@t@tÀ·Ûwß}÷©S§öíÛW\\2{öì{î¹çÙgŸ¼ë®»–,Y2úmVQ ÇÁ0¡ž£Ú…³àõ×_ðÁçÌ™ó•¯|å©§ž|üñÏáµ5­‘™¾¹þ‘€A°GŸ¥«Ô‚Pt´_óZ×êW:êvŸZÈK«wþø¦û݉)ò –ÿ)ñaF ‚.¹šw´_@ïuD>ŸÅLP†S‡¢B®ŠTÝÝäíTCà 9ò$!»Ö¬Y³hÑ¢-[¶TTT|ë[ß ´4ˆÒMõ,–³±§0AMd ¡õº ߆÷‰Ç{`G?ñÄÛ·oÿøÇ? …^}õUùøðeï\7o?'€qé·¬g6”Ï.¡&­u·üú'@fIõ?¸ñÛ6È-µ,çQSŠ’|"XÁìæò-΃bÉãWSª†”ŒlUdÆ=M ÑúzÙµZ€_¶ìï.Ù¼yó®]»Nžúh6›½þúëß}÷]™7ÖWüyj±’甽ƒ”ÍwÍ,8³*z¿¹æqäÏ^9Ê;Á᜻·v`($ÓŠ– ‰à0\þwºn§À¼’O}d((…I týáÑÆ¿þémÎÂÅžA¤ReÕÕ/¥R©ë¯¿¾½½ý[_¼rkí䓵•…Á†Ë 9`í® <ȉæáí ºÉøgFÎ 2™Ì‘#GTU]³fMggg_V\[ÙQ¨tÎcžšË@ä°®öÀ×Wÿñ?[WÔ”³g;ÎþÏ¢ºE>HD †ÏWýèáï(:Ï“Ö2ÂzPî™3iwcûžZhÚTŽû³ß?0kÖ,QMóÔwËþÏoDæ½Q3¹?¯SÞ¬0Æ€e ñ0»š¶6¨&ºü¬`x۩鎖Oœºo*툳bÏÊâG[:)’ ðX>%=•;qâD__ßüùó»ÍYè¸rlÕ~&àðD•aT…‘Ñ 8{ , ޱM›‡â8šV=ú¯÷_ 0΋sùÕ,x·.)dtÅãK^yåï^}õÕÚÚÚâââÕ«÷••uÿû{ÍíWŒáúFwÍŠ ,8~þ¾æÝÿ4ŽŒÀH{KÛ#‘b ¢–XÜ~yÇðððöíÛëêê‚ÁàŽ‘ucÐü çWÂP¦UsÁCP]„ŠBR®5,Æ¥÷ÒÓhß{‡JÁQp µ} >Ÿžÿ@~+ÉÐм^øËíÛ·oذÁçó­\ù&ÀBó7äõˆŽÕ;&×5†ÏÁ/BìmÞùgÂ`¢m-þ%RìƒÈƒcÀ2 Àšú-—سgÏŠ+‚Áàó'—Ѹ3´•‚±ߟG4Ãä–g"²âð>C °,Í%e€cð©ùßÉÿ 0j›š4–e§Nzʼn)SNhn×ÜZ3~ïJíò9D=͇ÿTÿ>8ú|C‘‘·={ÝôՅݽ½½¯¿þú´iÓÊÊÊ^\up¨|´ÿ=Ýe5ØB”aÑ6ˆ d/ìY© ƒØî›E׃HZðj¿š€zR{Væƒa ñ¸¢âe@T@4ëjlüê“O¶YYÒ+àžÙ˜gˆ£ÁpV3V× ‰C@ÀÉ-§%°ž €½O5$6Y™eœ™$µïôƒÈX,ÖØØhYëÖ¾c»…ÑÜ*Ü À;}X0È¥ƒÜ4œM*%c©žŒú{HL’cqN>ÜRÓÇç|W’LQ4XÖÂÀÚÕQgöööΟ?Ö¬Ô‚û4·ÕŽíñ<–ÊÐ\QÀ€cÀ³àXø8|zl#8ûÿP/°¶º­%+k鎀!X699=ÞÖÖfÆŒ3zÌ+ÚbSÆpÇ£F¥[saMmšŽ# äj ò’ –Ö\~õhåRàÁ \ÅÚá`S‡Bª9Ü^—_mE‚¹“^­®++…²2V4w[­¯oÒ¯~uxÙ²eÁ`píÚ>{«ç ^‘Ú]cœZÆ7ÇâÐ3 ]šßþuCØg'ˈ“žÌ‹„·_~Ì2‚õë×K’ôÞÙT8TÇj+ã Ž,“KZ‰h—ÝnñA5—_mxØíà zo B%ð‡À .·¦SUàp{ À´ï{ÅBm­4i’TRÂqœêlìÈ;wÖìÙ³gåÊ•@àškÞÔ1êJòÇã€ÁĹ‘ówÿn GtZÞøm}ž[p¨G¿WOÉT‘öžžžãÇ/Z´¨¬¬ìO Çñ˦35t=-ÜäÒÍQ—ÍpLÁX0‚E•Ø„‹,F°¼da`y÷rL-&«êXصs®¹†©¬ÃaN k]ýýE¯¿þzuuuYYÙ•WJ“&ÅǶÂ|;`H®kV³c>‹X{sÇþB#€—Ñ’À2“sʺÃú÷úåÇ®;:44´cÇŽ… †B¡—ckr­,ðÎF®¹ÄÃ;æ Í€f±n ›ð£š…¬wÍ€nÀ)_"‹.C¸ ¡‹ …à V´íÆÈû¬E«¶.ë›-°gÎÂܹ(+cð¼æÈ{öL·ö,%IZ¾œŒ. ‰Åª×<,Û‰ÇÎ_ÁØtîoáY{DF±”-gêúå[¦Úµkך5k‚Áàw^ Á^#€2£‡Œ;65‚ï®äYû±æ2ŸKñªÌBÈ„ÎITðA ÂFø2”,BÉb] |ASðkœO%lÁ÷(®J>º‰'iWM¥ˆa¦©{õÚÛjmmµ‚Üå—ÛÒÓ úÁIŸ 9žxcx–^` XÝÏÎÚßlÊYx£"Éaàúå»®ìíîîÞ»woyyyEEÅ ?ïˆ2áR„Šá ƒ½iaÝ3ô µ|“Pg„šyXÊRtçÅ€FXƒuÎGüÕ/@iÊV h!5„÷›¼dr¢ ÎÆOÏÇÀÈÜ­;êÇv}祗Hoo*“I©ªâ® WŒŒŒXAÎçóýsëu¶Ó C ¼·˜Çí…‘€·ÄaTšê40Œ­bÍmk¾KÍóË~¸öp<ollŒD"¢(néYdÆPüap’ëv¼nÁ0Ñ9òºImªÏ˜cßÂ@Õ¡X—Éꄳ§¯ü$øf ¼%WÁ7† šàUÊ©„õÂæµ$oy権³s`hh01M½Àu:4£»»Û r%%%Ïž˜p ‚ÅÁÃ{‹y¼]s‡©}SkÈRÞÛ<v·X£R5$]ãÕ=ðèK«é©cÇŽ¥ÓéY³fõ(SÛRS*†¿¾ ¤ Nù5íüK€æl‹Ø³äLMÏÿ× Œn2ºÉP‚p Ÿï¡—f < ¾""5Χq’j0Nù¯nîOÝoÕyy¹ˆyDDkåì.5‰%&1th#Èöbä0¢o!s Ê05bšÄ4 1©»äöÒ/<·pé:,§MSu•î°»t‹ìuð`Ùàà äü~ÿ?n­Ep*$;ÞhŒà ]cœ¥I+2äRÇ€c= @Ï·¸zWuç¯Õ€Ng„ºË¥J¡§¯¯ïðáÃK—.-))yv9¤JÊK„—tVP ãút«qÖ6½fÚ‹Bò0 à.?15ÍPU]Qhª±VD÷apF!u³†ª™ªN ÓúˆWûö×"§}›]j·$§ñü¿jåeá‘={öXA®?SÚ ±„òáD •7æ»0¸ïÍ7ZƱ+âÔ|0s›'ž[ª„Ó G)ûøæ ‹F7wîÜp8üòAæí"Àë„Õ §˜Œ70þèµ/YÝËh¹úwâeõºª÷^BuEÑeEËdÕTÂ9FßÂЛdøˆ–ˆªéŒ.˺ª˜¦Yð=^“ÊYeëžtêµKeLʘ fN-nMÏÃséZ>su t7gâ’d=† zÛíU3_»¾ü²}ÿþý@`Ê”)}JÙá>‘˜1 %žAý³=Ÿ¶Vü&1t’»‘—“ëZF½×„®(J*%'’Ùx"‹gFbÙX\N$äDÊ¥÷ä}›Û÷Fî-F²sÜô Y ãh?þÂý¯®›£Züö5þ‘‘‘-[¶XSÒWNN5uÃ4Mjš³$uà@ÈAn1ÿê ã ÐI^`¤ï™§}ëyÃ0TUWT]ÎÒÄñ[¯R]Ò«$I[»¦ëŠj¨!ÄÛD§“ÅÐ\γáyžqdz]6µÓ8š¬*ÉTv$ž‰eGâÙX\N$Õ¬£}ŠÞÎç¦äžÇ&ÑŒs¥4’@|åŒc+¦÷éŠbd⫦%n¹ ½½½V+**z¾}²¡¨†¦Ã3s•È78jßñª•‘qØüͼ32JõîÌÄzl¦!«ZVVSi51²¤| ZìëììŒÅb³gÏî3«Ÿ=Vi¨*õºÀkroòsI²n»KÛþL§(Õ®iμ&Ñ5]•UU–5E3 ÓÌt]¨wø“ºVH“ ¤5 f¦)Gé) ŒC˧µýú/^ÖeEÍd•TZ |qÉààà ävÆ®<8 Zå$î0=ÃŒËZñ¨æx.€jäf&Þ/òÚ¯‹ ¡ÐEM¥äT*›HʱÄÍW 766®Zµ*ìÕ¯¶¢¢ëLoëðÀ) ²n‡ýÜ•¹ìoø1<úÍ9ÉÅ(pÄž£?]±iI¥ˆ#Î5ô=qË ¿øÜB¨šÍ¨©´’Lɉdv$vãÌžh4ê¹?§Q§œ„x"VAP®žÇÄ¢åãY€lþÌÄ["áÅ çÝLªÉŠO*‰d6_PšúXuçÀÀÀþýûëêêÂápKf©—ûøžë¼©í®ØçcYdõÜ*Ï{2„~< ‘Èxyû ÞÚbOT²:’*ŽF¯€ èº—M=¸ÿþ?ÖM²;n5‘ãI9ÏÆâŸŸ›BO¾õÖ[Á`pÊ”)1ßìãÊ»kÞrO«Üd¾Àò5yŒMKx¦c³·i œ[ïÈ‚±öÝsÉà0“(ˆiššn¨ª¡¨sB#¿i-Ëd2ýèG»ººŽgËJ”ãÅ‚l5e_ÏÌý½s¼|.p•áw¬¢>ι£õåöÆaHxç—îß..¯ÝÒ‚næ4ÖDЭñ‹+ S‹(ËF¯™Õ±¸ªëËW½ó÷yû“ózç˜@ëÞ”R¢¦¦ªf¨J˜&^‹Vº\ñaÍ?‡kwUïŽ;S`ææëiÑ îøzžÂÇ®’œ{UäÙÇáã!rLð, ÇÀdÁR0Ä1! Ë¡°5‰IÀÀ°±èàÁ‘Š—^ziýúõ/¾øâ›ÚŠé¤Ñr#”@ÀxÀ8»íÊÉ¿ ‰ð 9pr‡$ðÎN>Ç€°`)XÖá"YÔRØ«e×=º¦[NzÖ¨Y ³Ë1³¬Ó'À/@â!q0ˆ½émÏ`XPb“ºˆI`˜[¤—v;~<<222{öìÖV³)>uè°á&eŒåñ²:2n½÷UmUÓjöìjI v ¼=$Ý¢_†µÍs…ÉmJçy½ùeòA©7ÅÔÕÕ%“É W¢v˜ŒI0Ê»¿|k£C´‹jt“›>hsâ<ÊuíÀëXûÈ Ëùº±×t¶wÜ´’Wû²Ž¬Ž”Š„ EÇååNý,cŸ³i]£¥À¡Iâ‘Êx<þÉO~²½½ý„6i1󦻗gäÙ@FCRE ýºù¬PQUûò³Oú»Ê×m(ãR¦œ†z×pVüV[CLjo¬*•JmÚ´©µµ5¦ûkh»¥_ï_çð]mm'”…ñPPd1˽‹gZM‘«âó.©r»ùÞÝ ou±Ž¤‚„‚þ&–À3ö³öA§Vk\çãö‹É›äLUQ:åòp8\SSÓßߟUÔI´ÏðœQe-€eYi 17|õ¥ùsÐ3P5½f÷k-ÉÁ.‘·båœñèÅ ·Â„ãŽ=#¥LÒßêeâF ¶¶6œÑã‰ô$vP3ñ»·Wzè–¶’{×ø…ÃAqÈ‹²õÀàŽw2jÎãú_wß±@û½I&&ÇØ{n¿à0'ÝQåÎsÜ®Í %Ÿî(Ëd2›6mêêê:¡”3>Fv!ל™®;ü5üÏ€e¯<û¤‡À{B®wlÂöz¦bVPZ^ÝÒSH$n¸á†£G”ý§n^IDATö“fêûtû'E3Eì-ÿžÄ¿p$(F] ¼³iâD]oÁe»ÝI#º*°ÒVYö¼•¥híÄAà<å‚ \íç2"ùîŽÌðÇÞNV«ªºzõêÎÎΘ.U›Ç¼Ï>¥!–Å ÿmŒá?ÕÓkÞØÕ’ìbÝñè©ktYl9;°UãŒPkò«ÈÊIµÜï÷Ï™3§§§çhÜ_MÞL mC“Ǩå€Ñ“XëÚBâ°¥ÓóµÞ$ZnöIó}޳3%uÇ ¨ŽöoÇU³°ô~1­ø9Ÿ`Ïë¬îx¿Müp`ð.z\ã+ÔÃQi ÍÔÕÕ¥R©¨ÌI™.ÎÈØÏ@FGJEJE ßÿÍÔUÕ>÷Ô“Ö¡ˆPWõîÐp“6^½PL¤þóÝREQ®½öÚS§N¥M?—x÷ÊÒ®Ûjœà²mìŒ|Ob•oˆ#Ö0§î‡íslíç½Ü&”‰¬n‡Ü´†”Фо¼W]ކg¯mn]ͬ™ÜæÎ­½¸¹k×ÝOjÒð8=‰$§«’Éä¦M›ÚÚÚÚåªiÊœö$ ¤ñÝ'šª¦Õ¼¦N¯™W·ñÙQ·ûßBzgMT%ÅÚ²Õ²,¯[·îøñã ÃÌ›VÜ·¿·"Ÿb »WOr)¥Ç9&Nœ„„;Ó÷nf¹sMkÛϵý¬ã| ¢YT–ãþP7 6~ï D1jR«'_,ÀÀëKi¾;%ù]Ó)Šý>d¬©© ƒÉd2–ÌHÚ`FCJµµ_ÿïMc:Ÿ³`L (“[ÓÛôxÝ3Rü¬v,&Ž(ìÒ¥KE‰ÉŒë 2Ñò`OLÖ3gýçIÊ«@v0=÷T¢R5›v=¾înn8‡FXÞÆr¸–ê³:Râ †³¨,ǽ›pçFT—@Ãs«›[—A@RŒËR«&_°×}L~<¿_®ü9¡áׇ«âñø7ÞxìØ±*¤è¾³ÔþY0ƒ\ô$ j;oâÅë-Õ¥W%‰O|â­­­}¤Š ÐLmÙÊÙ?úÝ®®Ž®®w© d¬|¤NÌÁtEwb‘fj<3ɨ}vªŒŽŒ†´u©H«É¢²÷^/o°U ¾óÌŠ®èe€ßªSŒi©U“‚Ï[ÓPo–…:®ot~?lLè&2Ùì0­ðù|sçÎíîîîW‚úHçÙhx/U’{_kùö—"•E‰xV"ÁZ ¹3@þ¤ˆ@3±m芊˯þìg?›J¥öïßßsð•²ÒÒŸþ¡Ù½EKËÎÉ& 744Ór ((öT†Þ ûŽ•ZDë$",Ø$FÙÀü*,+§áªšüÒ" ˜/Ý Ô“zæÛ54ü²¾þ%`ŠçP 銊ãâ;±,z“(òAâaP,™Š5€UXêV«*êcî¼ ˜TE@ÈsÚ‚XØ¿dÚϦ…w%œ3§räp碰{äš‹j O Oº¶®®nýúõÏ=÷\eeåßüÍßœ>ß[•$€%+#·ßWŸR°{W‹;#t}±æPÞË/;³À¬ŒŽ„‚d*kú*AX¸pá©S§öîÝ{æƒz"‘Å ÿ×ñö²ùΫþýŠŠèŒ,›ŠÅÕXR«§az‰g%å.X „¢á……@<çŠX³9S1§fø;ÍàÇþSj¶ËJ-äuÍYaÈΕu&ZŠª dEò‹-Ò4íäÉ“555ãêó}:û¥oÔ¿p„^û¥zHa …¡ ¢ gÍb$‹á,†3ˆf1”Á`)ô¥Ð9ŒÏ|aó©S§vïÞ]QQQ^^>000îA=õõŸs¶JÒ€\[zhQU«¥eï~µ—z=sÖý7oÏ]öì+,«pœÿú¹×ïØt_³Tµ¡?Á4†Òv׆³‘•Í"šÁPƒ)ô§Ð›Dé>óÙÛ\$I=ôÐÙhò=[€W¯ˆÜv_ýHW,‹ g™Öc]ÖÔÛJxÅeD3èMâ–¯=0cQdê‚ÈŸj®[YºtéöíÛ³ÙìÆ=Úßß¿zõê3Ü%YÜÒòzW× 5fo]üÌÌòX@„•-ç8;•f¥Ù±F½—ÙÂ0lóÑŽI Ž)؉qŸ/ IŽ|áZüåö‘¿§ÿÞþ‘Ä»# ¶HʈÉL£sxú±á+Þáø»ç¿òWõËW­UUõí·ß®¬¬¬¨¨Éf³óæÍ;³ÏÁÙÑw}³ÀïÏ=óØ÷ë—­Š\½:2æû­ÓèÚÛÛW­ZU[[{6gG65=¼qãß47÷M+î™7ù¸åؽ;½º –58U$ž”2à†”Œ²ûÝ„˜ét*yçœ<)é:Ç3©T¢kø‹†¡¶ÞæXììÇ€ØèöôÎ;ïüÍo~³cÇŽÍ›7···¿üò˵µµcýáÊy9÷zó_ןNû–Ü~ûí^ÒëÃ?<îw65=‰TÎ(iµþu7é ϼÐåe3ŸcHp"|!Ñç„¿1ØåÙl*èíêê;uªw` /‹†–ÿußžÇ3¹ù曇††^}õU‹F7îA\ç€qeåÊ•·ÜrKOOOkkëâÅ‹‹‹‹Ÿ{î¹q?ÕÔôý ‘™ÞŸ%p7/s´m‡wmºå4àà!XŒP B%®&â›îpâÜwÙlbhh ¯¯g` 7‹jšì}5Ÿ@熓œÜsÏ=—]vÙÞ½{KJJ***úúúZ[[ÏЩ‰ÀwÞi1 ®¼òÊP(ôÒK/8p`ÜOõ~ÑE¥v³oyå&t”²ð…,B¨áR„K›ÿ¹ \Ô BT]ÏêºLé˜o°´¯`¨¾þk¼õÖ[-bN$‘$iË–-gèÑ„ÇZwîÜiÓèÎâØ<–ñló:Ìo›¨çaSõ9 bÐþŽÐdÏDQí†UþÈâ!@Îg$ºƒÚ𦤠x¢î¢ ¤xàs£YWW7uêÔcÇŽ¥R©™3gvww?õÔS§ëÑÄü¤¹%÷Þ{oGGǾ}û®¾úêÉ“'www{ }Å‚r>hR3ú=ip¬µ£££§§çÆoœØÆ¼9›á›L&‰„ªªc¾:Áøüç?ÿàƒ>ÿüó,;‘é¼J&“I§Óc¾4Á.È’½{÷9räløýO¿S$! æŽfr‰3–á%Ñ:-Ÿ“üJÁÁ00²PFLU¶ŽÊßÕÞ}²Ò>€4wú©»WJïomWÈÿðãœÎ>ZdY¾ûî»Ç|é¿g/Ÿ˜ËÌ(CEÅÂü¢“¶äívÑÄÂC úý%ž¢° ñÁbF*¨I#WÓi%™’ãI5“}íDù^[¼·»<‡ÃQgµ¥2¯ ŸQÚùú‰Ì9ìÑÄ» ÷$Y=·ï&录0VŠØú!WЕÍd†¡„ šÆò# Ú†a(Š–‘ÕLVWUBéÕÓ£O|ö•½6û±Ý—;¦ ÔzÖ–õ®žq<,eŸã]dðÛŸ4¼üdýäJ|°|Q@€O€hm ±¶SâÙÁ”ã9)|>^’XžeÀÓ4TMW-“5 Ãåué£kOwh_w¹IÍÙ#³Ê²Öo\ÁP¡Yþõ·Íç°G™x©(^:4G¬U°¬çT°€a*©´¡¨œ(°Ç0ŒM"ÖuBˆ»µbzöŽV¦gW¤-N‘¬çøº‰e«"ç¶Góë"ÿñs{Å«šLðxb³†9…éfCPĤ„hŒ¦1`„R p[Ñ»óîO,ƒpWÝÖ¾ÿ¹•‹Ìø_Ø8ÜÞ\@±aÑùÉÁÞÅ=?!ijy{¹«[—~RÀupkÛ­áŸÕÒT0œÅña¼ÒqŽÕuñM½o»¯>©ØÕj>;ÈÊŒTjpr%ž´Tꦵ½§ÃXi¥¬¤‚¿E.ÿàrñY€¿ýÂÆ‘¶æò J|‰Š9 X{2Ê9tn7;ä­ò°§LÞŠ3Ïá.¡ÚþÑ :GÎýðÇÅhn»·>©Bö¤?s‡XäÿòpÁ›Qxµïr{Ýb¦ïÿºé|ôå" –,[µaÆ¢ÈH{³_€u®Ñh!<±Ž¥¹áo“á žà=ÔIÖí+£¡fц%gAòyrQZ€Ûï«ÉH(Hi6 @õœ z‰ñœ£çÓLÜC T£p“Ǫ'°8Õq·ÞWž:rQÆKìniøjdRÈ™ g-fM‡œìûcn °–Ðîð·Š2õ|íÇD³øûŸ7-^9O½¸ˆÀXøˆ–ö8Ï4Ô>ÒSKm:?Pì†õj;ÈÇ $æVÖ‚@à ðÔÕRÏ*Ìôœ’é®ï2**†2ç]ûøA~’ó»®Ö•[ˆ9v@¼ìZØk]Õù©2+ê^€±oɇv·üÝ—"e„$›2lU8‹îö€»*Î?PÀ-8°ÊZdi1ß}âBh,yâõO?ÖPæGH‚_@@ÈA²îŠ y• .m;ë¨þ–Í|éõ¬Í*,yò‘ú§ÿ­¡4€ Áùcw‹†a<Ù§®$­!®`ú‚ ?ù}óní‡K~ñHýS6ø„Ü/J[û`œÔ¿³2P ÌZ¼áŽûëWä£qaäC €+û^k9°»Iä°wË¡=Í ‹+ë6,[±N¬¹ïoë'¶y~þ‹ËÅšŠøÐÈ%&X.0Ár € –KL°\`‚å,—˜`¹ÀËÿìS4ñ5‹ tEXtTitleQuartz`>¢tEXtAuthorJoerg-Ruediger HillD˜§ÆtEXtSoftwareViewmol 2.4‘r]¢'tEXtCreation Time7 Nov 2003 09:33:28 +0000ÞSúIEND®B`‚viewmol-2.4.1/kde/icons/32x32/0040755000272700027270000000000010123052370013776 5ustar jrhjrhviewmol-2.4.1/kde/icons/32x32/apps/0040755000272700027270000000000010130257466014754 5ustar jrhjrhviewmol-2.4.1/kde/icons/32x32/apps/viewmol.png0100644000272700027270000000324710123052370017134 0ustar jrhjrh‰PNG  IHDR szzôbKGDÿÿÿ ½§“ pHYs  ÒÝ~ütIMEÓ  àª]$4IDATxœÕ—ßKTÝÆ?{ö83Ž3ïXÚ¤f#þ̊̌꺠‹ 袠À›n‹è"ˆþ ­®"¢+» %o* $14,£fÔišMÛýsöž™õ^¼¸Á£ž÷èËáp¬›ëù>ëù>ûY{ÁÿóÈçó"‹‚!ítãØØ˜¨ªªÂï÷“Éd8xð ÛÆóì¤øÈȈˆÇ㬮®bYº®sÿþý@팀mÛ$“I à¡¡ååe4MÛmK6??/ÆÆÆÈf³øý~dY¦X,bš&ÕÕÕܼys[˜ÛV`dd„D"Çó×V!þò ,ˬ¬¬pïÞ½m™Ò»Ùb.—Š¢ÐÒÒâžæÅ‹bbb‚OŸ>±k×. …årÇC¹\ƶmJ¥‹‹‹¼~ýZH’„mÛ8p€Ÿ?â8455­Shƒ\/_¾áp˜ÊÊJÒé4‹‹‹¤R)|>BæææˆD"êêêˆF£$ òù<¦iâ8H’„ã8Ȳ̩S§…Bhš†ªªœ={Ö­»® bii‰ÕÕULÓ$“ɰ²²‚Ï磢¢‚ŠŠ jkkÑuMÓ¨©©áĉøý~t]G×uZ[[ñx|! 8ŽCee%ýýýnë7MÂgÏž‰¡¡!ÚÚÚ¸páoß¾¥²²€ÇF …Bø|>dYFáÏçóìÝ»—îînnݺåâ?zôHtuuÑÝÝýïHþn Š¡¡!7v×~ÍÇAÓ4šššxøðጻ£wÁ•+WÄ÷ïß ƒîumYííí\»v¾¾¾ÿ.€7nˆÎÎNΜ9C2™dvv–ÖÖVΟ?¿-Ì-£øïF<§®®ŽÉÉI7£Ñè¶qv¬Àìì¬ R, ‡ÃܹsgÇx;Ož<333ÿèú?ºÔ¬ž·(IEND®B`‚viewmol-2.4.1/kde/icons/32x32/mimetypes/0040755000272700027270000000000010130257466016025 5ustar jrhjrhviewmol-2.4.1/kde/icons/32x32/mimetypes/molecule.png0100644000272700027270000000210610123052370020321 0ustar jrhjrh‰PNG  IHDR szzôbKGDÿÿÿ ½§“ pHYs  ÒÝ~ütIMEÓ  ù¶¡ÓIDATxœåV=Hrm¾Ž–y´ 22D«A #J„h‰Ú¢¡!j‰(ˆ–joii-—hh ¢‚†Œ¨()‚$Tú­Äü=õ(öcáó }ù÷êð ï5>çþ¹¸žç¾Î üí ÊI>>>&<*• …¢¤Z¼rìîîÂívãõõµäå!jµºd%Ë" …J¥Ê)QÞÐ4x<^’¥ÛÚÚ"v»"‘Ñhccchkkûãz¿`†¸\.R(Ñd2ã8h4p›Í–7žarqqA"‘ÈÚ¿lnnÂï÷Ãétæ$±¿¿O‰D`6›Á²,<ŽŽŽ²æpG‚Á noo|û%ÙÊÊ I$èíí…Ïçƒ^¯‡ÇãŸÏÇÛÛX–Åûû;¢Ñ(<îîî P( ÕjAÓ4d2|>b±är9*++‘N§QWW‡ÁÁA*/olll»ÝŠ¢ ‰ÀçóÁ0 jjj T*111ñ+×ápÕÕU…B( D"øý~ôõõa||(ŠBOO•“€Õj%ÇáòòJ¥ƒ!«åF455eY¼¼¼ ¿¿?§ë¹\.r~~އ‡,--ýóë jkk±··‡ááá¬Í-W§ÓaˆD"Äb1¼–ÛÚÚJuuuaddäÇyÉ ‰Åb!‹‹‹H$H§ÓÀÔÔTY[vI˜-Êrs¡¬:;;!‹KÎ/k+€úúzH$’’óËRÀår‘††x<žÿ‡@2™„ÙlF2™,§Ì_Žƒ¾²Š•ö_ÙIEND®B`‚viewmol-2.4.1/kde/icons/32x32/mimetypes/qc.png0100644000272700027270000000223710123052370017124 0ustar jrhjrh‰PNG  IHDR szzôbKGDÿÿÿ ½§“ pHYs  ÒÝ~ütIMEÓ  $ù_b,IDATxœí–OLuÇ?³,0ËJWþHŠYÙLƒ’B7©zèÎIo&œ´šžL/ž¯lCâI—¶.hh”„pk‚itfÚpe«°]þT .ÛÀ²üYè²ìó0SR «^ô›Lfï÷¾ß÷~ï½yð? ÀÊÊŠÌÎÎJ!>œ…ŽF£ìîîâ¥ÃW®Œ ãóÕ UäëX£3k«EÓÆ º[…¢ae¼€Xïm1Ñ´»ÿœÃX²"Ï äDQöÄåÊ ì ¤¾M°-Âa×0Š‹¦EPq¹rx½yΚ›§s (cIà+Ñõä>! Ï{¦p"‘ˆ(Š‚ÏçÃãñ(Á`Xt½Ô2Wp8ÎP__Bs³J}}1³³Yt}“tzøÞŠ« È¡ëhk{xÎC[§¯¯Oº»¿azºhÀ®¿"SÕ2<žfe— ²Ù52™b`ø(V€—.½È;ŸÈe£wߨµÒêÊ,’9+Â6Ì»O[ kÙlèú5‚AÿÉhÚGb¿ZÑ;€=`‡®®€'aPÂõë_å–beaøáP[Ók``@ææ–ñûýƒléíí·ÛMggç‘ö¶ÚPDðz+m“loo£(Ï7·% ŸÏãpØd2[v¶3Ífm“?1 ñ..ÚÊÀs-FAÎZßyÌòÚÊC!À,3Åz2¡*fIÎ ¼wÏ‘¦ C~Ô4^Ε˜5ŸÃl@0Ói‰+Âì•`ø˜>9‚çÈ+ø¶§‡qàð67P­ª¼äñPUSƒçôi<..E! Ä€_€80¼ñ¢LLLøƒ:p#Z]]•D"ÁØØÆíÛ<¶"Z~ÞÔª*ŠZ[áÔ)ØÜDY\D™›#šJ¦±FS ÀÙŽÖ××–¦¦&*++•CLNNÊèè(ÉdUUùÌ0øXÓXæW€7€½t𠍶–Üü<»[[d××YZn†Ã á0ñx\I¥RG%ÝÄÐÐоtÝ3 iy¤d dÁáäùó²ì÷Ë¢Ï'ón·üòH;ȇÀß¿˜Üèê’·@>y2SV&1‡C¦@îƒÜ¹r_×m“{‘Œ†ôhÌ®paVx¤n„öýžh“†tk•–³@˾<ù‰<ÅÍ®.Yœš¢ÄíæË—y=ü÷Vó§èïï—‘‘‘Üñþ0ÀívSSSS¨›ÿ0þh‘±H«CŸúIEND®B`‚viewmol-2.4.1/kde/icons/32x32/mimetypes/solid.png0100644000272700027270000000327510123052370017636 0ustar jrhjrh‰PNG  IHDR szzôbKGDÿÿÿ ½§“ pHYs  ÒÝ~ütIMEÓ  "Áþ|xJIDATxœí—[lgÇ3»^ï®íÝ/ÝÔ79©ëÖ‰h"$w7€Ú¨‘’Š<@@¥â¡\ADª× –€V 5 ÇjšKM©“:-¥…t×ABÜÇ®cœ‹/Ûñ^½;·Ýáa6ÛËÁôq¤ÑÌ|óÿÿæ|çÌ7ð[¦eÿ0>\a©‡±? û@»°YÙÀýÙÀ’¾+0ð‚ßX— bóvÀb @5Û¾Z±q±Áé¡áš "ŠyRÈäÏ9(› qûjpÅiYTÀß^iGÑA‘ÁÐí h h:\êi_)?Ö».\(DsáD€yÏç7À®­Èv7¨I2š„$ì0>·Ð ªªŠ¦¦¦e§Fèîî6jkkXz²`âÆâo^EêêêØ»wï½ 8vì˜áv»Ùµk—PYÒc¬.-çë[;ð¯ QærPVYN*#‘ˆÊ0‡þëÐõ^Á`~ÿÃ…`\.{öìY–ˆÂ¤Ë—/çÎãìY?Á`=à,|ªæ-ºžz«Ù¤4ð8aÍýà(#Ù*Ææ6lkü•+WŒ¾¾>8poŽ9bÌ^ãÀúçí@Þ½úiÎ 4²{ýqô4{¡f5P‡+H…ì<Œˆ>ž}ý·<ð@/••N:îßèC£ÊGvs¶ÿÎUÐëÅÙäe$ë§I²ý‘‹ÚsœÒb(¶ByIÞËȹ|$¨ˆ†Xý1§N5áñ\cï«ûÁB)ˆñb¯Ÿë>cQ#‡ýÆVãfº¹áùªYÿ¹<‰œyzÆŒ³<•ü¡B. ÔQÕutvú¨þäƒ^k-ˆÄŽé×N· L^ ñ‘  v{¯rnPg,Z[ T˜N@\†;iH¦ —)†ÚO€§ŽLJ –2ŸÕ¸Î³s§•‰‰ ‚ SãÍš8y¬lÞÿ͇ýCÿ{ˆX<‘†§Ý¯ÒugT®EK‹DSðÜï¿Ëôí]ŠÙĤ e‹Op¬õNœ ¢lÎ"»×QRžnñöµ\œ€±Œ'L ñ8ÜŒÂèÈ"ŒF6Nšëi. Ql£=LU~á´—‰8´~¹­ Àr÷â¿Þlßñ9_`vê&™¤3˜j'¦hØâÇj›¡ªºž×ÿTE8YÁM¢2LÄÁf‡Ûàƒ¹íüâü± á, £ç@Ò Ø’cb2̪M_äVÒÊ^x©ÐŒ¬|ľÝN½Øf¼ÑÕN…ôÔmð2|[åPç~€Š‡‘H1û[ߦ¾¬%€ ^ÓSÀ-z‚Q­²:ö#Š•~Tj7T2zGç›ÅáW,p.«_=== /dev/null 2> /dev/null ret=$? if [ $ret -eq 1 ] then /bin/cat /usr/local/lib/viewmol/kde/mimelnk/magic >> $DIR/share/mimelnk/magic fi /bin/grep "Chemical MIME" $DIR/share/magic > /dev/null 2> /dev/null ret=$? if [ $ret -eq 1 ] then /bin/cat /usr/local/lib/viewmol/kde/mimelnk/magic >> $DIR/share/magic /usr/bin/file -C -m $DIR/share/magic fi exit 0 fi echo -n "KDE files will be ${prgname}ed in $DIR ..." umask 022 if [ "$prgname" = "install" ] then /bin/cp -r mimelnk/chemical $DIR/share/mimelnk else /bin/rm -f $DIR/share/mimelnk/chemical/x-dmol.desktop $DIR/share/mimelnk/chemical/x-gamess-output.desktop \ $DIR/share/mimelnk/chemical/x-gaussian-log.desktop $DIR/share/mimelnk/chemical/x-gulp.desktop \ $DIR/share/mimelnk/chemical/x-mopac.desktop $DIR/share/mimelnk/chemical/x-msi-*.desktop \ $DIR/share/mimelnk/chemical/x-pdb.desktop $DIR/share/mimelnk/chemical/x-pqs-output.desktop \ $DIR/share/mimelnk/chemical/x-turbomole-*.desktop /bin/rmdir $DIR/share/mimelnk/chemical fi echo -n "." if [ "$prgname" = "install" ] then /bin/cp icons/32x32/mimetypes/*.png $DIR/share/icons/default.kde/32x32/mimetypes /bin/cp icons/32x32/apps/*.png $DIR/share/icons/default.kde/32x32/apps echo -n "." /bin/cp icons/48x48/mimetypes/*.png $DIR/share/icons/default.kde/48x48/mimetypes /bin/cp icons/48x48/apps/*.png $DIR/share/icons/default.kde/48x48/apps echo -n "." /bin/cp icons/64x64/mimetypes/*.png $DIR/share/icons/default.kde/64x64/mimetypes /bin/cp icons/64x64/apps/*.png $DIR/share/icons/default.kde/64x64/apps echo -n "." /bin/cp icons/128x128/mimetypes/*.png $DIR/share/icons/default.kde/128x128/mimetypes /bin/cp icons/128x128/apps/*.png $DIR/share/icons/default.kde/128x128/apps echo -n "." else for i in 128x128 64x64 48x48 32x32 do /bin/rm -f $DIR/share/icons/default.kde/${i}/mimetypes/solid.png \ $DIR/share/icons/default.kde/${i}/mimetypes/molecule.png \ $DIR/share/icons/default.kde/${i}/mimetypes/qc.png \ $DIR/share/icons/default.kde/${i}/apps/viewmol.png done fi echo -n "." export APPLNK=`/bin/ls $DIR/share | /bin/grep applnk` if [ "$prgname" = "install" ] then /bin/cp applications/viewmol.desktop $DIR/share/applications /bin/ln -s $DIR/share/applications/viewmol.desktop $DIR/share/$APPLNK/Graphics/viewmol.desktop else /bin/rm -f $DIR/share/applications/viewmol.desktop /bin/rm -f $DIR/share/$APPLNK/Graphics/viewmol.desktop fi echo -n "." if [ "$prgname" = "install" ] then /bin/mkdir -p /usr/local/lib/viewmol/kde/mimelnk /bin/cp ./install /usr/local/lib/viewmol/kde/uninstall /bin/cp mimelnk/magic /usr/local/lib/viewmol/kde/mimelnk fi echo " done." viewmol-2.4.1/kde/applications/0040755000272700027270000000000010130257466014603 5ustar jrhjrhviewmol-2.4.1/kde/applications/viewmol.desktop0100644000272700027270000000055510123052370017647 0ustar jrhjrh# KDE Config File [Desktop Entry] Encoding=UTF-8 Name=Viewmol Name[ru]=Viewmol MimeType=chemical/x-msi-car;chemical/x-dmol;chemical/x-mopac;chemical/x-gaussian-log;chemical/x-gulp;chemical/x-pdb;chemical/x-turbomole-control;chemical/x-turbomole-coord; Comment=Viewmol Type=Application Exec=/usr/local/bin/viewmol %f Icon=viewmol.png MiniIcon= Path=$HOME Terminal=0 viewmol-2.4.1/scripts/0040755000272700027270000000000010143446545013043 5ustar jrhjrhviewmol-2.4.1/scripts/demo.py0100644000272700027270000002034110143442257014332 0ustar jrhjrh#!/usr/bin/python #******************************************************************************* # * # Viewmol * # * # D E M O . P Y * # * # Copyright (c) Joerg-R. Hill, October 2003 * # * #******************************************************************************* # # $Id: demo.py,v 1.2 2003/11/07 13:19:53 jrh Exp $ # $Log: demo.py,v $ # Revision 1.2 2003/11/07 13:19:53 jrh # Release 2.4 # # Revision 1.1 2000/12/10 15:04:03 jrh # Initial revision # # import os import viewmol import molecule import spectrum import atom import element import energylevels import history import label import light ON=viewmol.__dict__['ON'] OFF=viewmol.__dict__['OFF'] WIREMODEL=viewmol.__dict__['WIREMODEL'] STICKMODEL=viewmol.__dict__['STICKMODEL'] BALLMODEL=viewmol.__dict__['BALLMODEL'] CPKMODEL=viewmol.__dict__['CPKMODEL'] PERSPECTIVE=viewmol.__dict__['PERSPECTIVE'] LINE=viewmol.__dict__['LINE'] SURFACE=viewmol.__dict__['SURFACE'] ORTHO=viewmol.__dict__['ORTHO'] MO=molecule.__dict__['MO'] DENSITY=molecule.__dict__['DENSITY'] IP_LOG=molecule.__dict__['IP_LOG'] REACTANT=molecule.__dict__['REACTANT'] PRODUCT=molecule.__dict__['PRODUCT'] REACTION=viewmol.__dict__['REACTION'] ANIMATE=spectrum.__dict__['ANIMATE'] ARROWS=spectrum.__dict__['ARROWS'] GAUSSIANS=spectrum.__dict__['GAUSSIANS'] class demo: def rotate(self, mol, axis, speed): n=0 fps=viewmol.getFramesPerSecond() if fps>50.0: increment=2*speed else: increment=5*speed while n<180: mol.rotate(n*axis[0], n*axis[1], n*axis[2]) viewmol.redraw() n=n+increment def translate(self, mol, direction): n=0.0 while n<10.0: mol.translate(n*direction[0], n*direction[1], n*direction[2]) viewmol.redraw() n=n+0.5 def drawingModes(self, molecule): size=viewmol.getWindowSize() label1=label.label() label1.translate(20, size[1]-20, 0) label1.text('Viewmol supports different representations') label2=label.label() label2.translate(20, size[1]-40, 0) label2.text('such as wire frame models ...') viewmol.model(WIREMODEL) self.rotate(molecule, (1.0, 0.0, 0.0), 1.0) label2.text('... stick models ...') viewmol.model(STICKMODEL) self.rotate(molecule, (0.0, 1.0, 1.0), 1.0) label2.text('... ball-and-stick models ...') viewmol.model(BALLMODEL) self.rotate(molecule, (0.0, 0.0, 1.0), 1.0) label2.text('... or CPK models.') viewmol.model(CPKMODEL) self.rotate(molecule, (1.0, 1.0, 0.0), 1.0) label2.delete() label1.text('There is also a perspective mode.') viewmol.projection(PERSPECTIVE) self.rotate(molecule, (0.0, 1.0, 1.0), 10.0) label1.text('And you can turn lights on and off and move them.') lights=viewmol.getLights() lights[0].switch(OFF) self.rotate(lights[1], (0.0, 1.0, 0.0), 10.0) lights[1].rotate(0, 0, 0) lights[0].switch(ON) label1.text('You can also change drawing style and resolution.') viewmol.drawingMode(LINE) n=10 while n<30: viewmol.sphereResolution(n) viewmol.redraw() n=n+4 viewmol.drawingMode(SURFACE) viewmol.sphereResolution(20) label1.delete() viewmol.projection(ORTHO) viewmol.model(WIREMODEL) def vibrations(self, molecule): size=viewmol.getWindowSize() label1=label.label() label1.translate(20, size[1]-20, 0) label1.text('Viewmol can also show vibrational spectra.') viewmol.model(STICKMODEL) spectrum1=molecule.getSpectrum() spectrum1.show() spectrum1.mode(27) spectrum1.display(ANIMATE) self.rotate(molecule, (1.0, 0.0, 1.0), 1.0) label1.text('Of course, it doesn\'t have to be animated.') spectrum1.display(ARROWS) spectrum1.style(GAUSSIANS) self.rotate(molecule, (0.0, 1.0, 0.0), 1.0) spectrum1.deselect() del spectrum1 label1.delete() def MOs(self, molecule): size=viewmol.getWindowSize() label1=label.label() label1.translate(20, size[1]-50, 0) label1.text('Viewmol can show energy levels and MOs ...') energylevel1=molecule.getEnergyLevels() energylevel1.show() energylevel1.selectMO(21) viewmol.isosurface(0.05) molecule.showElectrons(MO, 20, IP_LOG) self.rotate(molecule, (1.0, 1.0, 1.0), 1.0) label1.text('... or the electron density.') del energylevel1 molecule.showElectrons(DENSITY, 20, IP_LOG) self.rotate(molecule, (0.0, 1.0, 1.0), 1.0) n=0.05 while n>0.001: viewmol.isosurface(n) viewmol.redraw() n=n-0.001 molecule.showElectrons(OFF) label1.delete() def history(self, molecule): size=viewmol.getWindowSize() label1=label.label() label1.translate(20, size[1]-20, 0) label1.text('Viewmol can show the history of an optimization.') history1=molecule.getHistory() history1.show() molecule.showForces(ON) n=1 while n < 9: history1.iteration(n) viewmol.redraw() n=n+1 molecule.showForces(OFF) del history1 label1.delete() def buildMolecule(self, molecule1): size=viewmol.getWindowSize() label1=label.label() label1.translate(20, size[1]-20, 0) label1.text('Viewmol can also be used to build molecules.') viewmol.model(STICKMODEL) atoms=molecule1.getAtoms() atoms[11].replace('C') viewmol.redraw() molecule1.addAtom('H', atoms[11]) molecule1.addAtom('C', atoms[11]) viewmol.redraw() molecule1.addAtom('C', atoms[11]) viewmol.redraw() del atoms atoms=molecule1.getAtoms() molecule1.addAtom('O', atoms[14]) viewmol.redraw() molecule1.addAtom('N', atoms[14]) viewmol.redraw() del atoms atoms=molecule1.getAtoms() molecule1.addAtom('H', atoms[16]) molecule1.addAtom('H', atoms[16]) viewmol.redraw() molecule1.addAtom('H', atoms[13]) molecule1.addAtom('H', atoms[13]) self.rotate(molecule1, (0.0, 1.0, 0.0), 1.0) del atoms label1.delete() def thermodynamics(self): size=viewmol.getWindowSize() label1=label.label() label1.translate(20, size[1]-20, 0) label1.text('Viewmol can handle reaction thermodynamics.') viewmol.showWarnings(OFF) viewmolpath=os.getenv("VIEWMOLPATH") molecule1=viewmol.load(viewmolpath + '/examples/reaction/hio3.outmol') molecule1.reaction(PRODUCT) text='Lets load a number of molecules: ' + molecule1.title() label2=label.label() label2.translate(20, 40, 0) label2.text(text) self.translate(molecule1, (-1.0, 1.0, 0.0)) molecule2=viewmol.load(viewmolpath + '/examples/reaction/i2.outmol') molecule2.reaction(REACTANT) molecule2.rotate(90.0, 0.0, 0.0) text=text + ', ' + molecule2.title() label2.text(text) self.translate(molecule2, (1.0, 1.0, 0.0)) molecule3=viewmol.load(viewmolpath + '/examples/reaction/hno3.outmol') molecule3.reaction(REACTANT) text=text + ', ' + molecule3.title() label2.text(text) self.translate(molecule3, (-1.0, -1.0, 0.0)) molecule4=viewmol.load(viewmolpath + '/examples/reaction/no.outmol') molecule4.reaction(PRODUCT) text=text + ', ' + molecule4.title() label2.text(text) molecule4.rotate(90.0, 0.0, 0.0) self.translate(molecule4, (1.0, -1.0, 0.0)) molecule5=viewmol.load(viewmolpath + '/examples/reaction/h2o.outmol') molecule5.reaction(PRODUCT) text=text + ', ' + molecule5.title() label2.text(text) viewmol.showThermodynamics(REACTION) def run(self): viewmolpath=os.getenv("VIEWMOLPATH") molecule1=viewmol.load(viewmolpath + '/examples/turbomole/control') self.drawingModes(molecule1) self.vibrations(molecule1) self.MOs(molecule1) self.history(molecule1) self.buildMolecule(molecule1) viewmol.delete(molecule1) self.thermodynamics() def register(self, language): viewmol.registerMenuItem("Demonstration") #------------------------- if __name__ == '__main__': demonstration=demo() demo.run(demonstration) viewmol-2.4.1/scripts/setAtomColors.py0100644000272700027270000003072007752716004016214 0ustar jrhjrh#!/usr/bin/python #******************************************************************************* # * # Viewmol * # * # S E T A T O M C O L O R S . P Y * # * # Copyright (c) Joerg-R. Hill, October 2003 * # * #******************************************************************************* # # $Id: setAtomColors.py,v 1.1 2003/11/07 13:20:04 jrh Exp $ # $Log: setAtomColors.py,v $ # Revision 1.1 2003/11/07 13:20:04 jrh # Initial revision # # import sys import os import shutil import string import tempfile import gettext import viewmol from molecule import getAtoms from atom import name import element try: from Tkinter import * from tkCommonDialog import Dialog import tkMessageBox except ImportError: viewmol.write('setAtomColors.py: Tkinter or one of its components not found.\nPlease install it before running this script again.\n') raise ImportError try: dir=os.environ['VIEWMOLPATH'] except KeyError: dir='/usr/local/viewmol' #catalog=gettext.translation('Viewmol', localedir=dir + '/locale', languages=['en_US']) catalog=gettext.translation('Viewmol', localedir=dir + '/locale') _ = catalog.gettext def N_(message): return message class setAtomColors: "Set atom colors" moduleName=_('Set atom colors') canvas=[] elementOldColors={} elementColors={} window=0 transperancyScale=None shininessScale=None selected=0 def run(self): colors=[N_('Color'), N_('Emission'), N_('Ambient'), N_('Specular')] elements=[] for molecule in viewmol.getMolecules(): for atom in molecule.getAtoms(): element=atom.getElement() name=element.getSymbol() if elements.count(name) == 0: elements.append(name) color1=element.darkColor() color2=element.lightColor() atomColor="#%02x%02x%02x" % (127.5*(color1[0]+color2[0]), 127.5*(color1[1]+color2[1]), 127.5*(color1[2]+color2[2])) color=element.emissionColor() emissionColor="#%02x%02x%02x" % (255.0*color[0], 255.0*color[1], 255.0*color[2]) color=element.ambientColor() ambientColor="#%02x%02x%02x" % (255.0*color[0], 255.0*color[1], 255.0*color[2]) color=element.specularColor() specularColor="#%02x%02x%02x" % (255.0*color[0], 255.0*color[1], 255.0*color[2]) shininess=element.shininess() transperancy=element.transperancy() self.elementColors[name]=(element, atomColor, emissionColor, ambientColor, specularColor, shininess, transperancy) self.elementOldColors[name]=(element, atomColor, emissionColor, ambientColor, specularColor, shininess, transperancy) if elements == []: return None self.window=Tk() try: import Pmw except ImportError: tkMessageBox.showerror(_('Module Missing'), _('Module Pmw (Python Mega Widgets) not found. Please install it before running this script again. It can be found at http://pmw.sourceforge.net/.')) self.window.destroy() else: Pmw.initialise(self.window) row=Frame(self.window) selectElement=Pmw.OptionMenu(row, labelpos="w", label_text=_('Select element'), items=elements, command=self.displayElement) selectElement.pack(expand=1, fill=X) row.pack() self.canvas={} frame=Frame(self.window) i=0 for t in colors: self.canvas[_(t) + " ..."]=Canvas(frame, height="32", width="64") self.canvas[_(t) + " ..."].grid(row=i, column=0, sticky=E+W+N+S) button=Button(frame, text=_(t) + " ...") button.bind("