• R/O
  • HTTP
  • SSH
  • HTTPS

fermisurfer: Commit

fermisurfer Git


Commit MetaInfo

Revision4e6f3b09e92c6881095ddbce80fe5ae27fd81c0f (tree)
Zeit2015-12-08 15:39:31
Autormitsuaki1987 <kawamitsuaki@gmai...>
Commitermitsuaki1987

Log Message

modify menu
ifdef for Mac

Ändern Zusammenfassung

Diff

--- a/doc/manual_right_en.html
+++ b/doc/manual_right_en.html
@@ -459,6 +459,6 @@ http://sourceforge.jp/projects/fermisurfer/forums/
459459 <p>When you want to join us, please contact me as follows.</p>
460460 <p>The Institute of Solid State Physics</p>
461461 <p>Mitsuaki Kawamura</p>
462- <p><code>mkawamura@issp.u-tokyo.ac.jp</code></p>
462+ <p><code>mkawamura__at__issp.u-tokyo.ac.jp</code></p>
463463 </body>
464464 </html>
--- a/doc/manual_right_ja.html
+++ b/doc/manual_right_ja.html
@@ -499,6 +499,6 @@ Fermi energy shift :
499499 <p>開発に参加したい方は以下の連絡先にて受け付けております.</p>
500500 <p>東京大学物性研究所</p>
501501 <p>河村光晶</p>
502- <p><code>mkawamura@issp.u-tokyo.ac.jp</code></p>
502+ <p><code>mkawamura__at__issp.u-tokyo.ac.jp</code></p>
503503 </body>
504504 </html>
--- a/src/Makefile-mac
+++ b/src/Makefile-mac
@@ -1,5 +1,5 @@
11 fermisurfer:fermisurfer.c
2- cc fermisurfer.c -framework GLUT -framework OpenGL -lm -o fermisurfer
2+ cc fermisurfer.c -framework GLUT -framework OpenGL -lm -o fermisurfer -D MAC
33
44 install:
55 cp fermisurfer /usr/local/bin/fermisurfer
--- a/src/fermisurfer.c
+++ b/src/fermisurfer.c
@@ -37,9 +37,13 @@
3737 #include <stdlib.h>
3838 #include <stdio.h>
3939 #include <math.h>
40+#ifdef MAC
41+#include <GLUT/glut.h>
42+#else
4043 #include <GL/glut.h>
4144 #include <omp.h>
42-/**
45+#endif
46+ /**
4347 * Input variables
4448 */
4549 int ng[3]; /**< BZ grids */
@@ -59,6 +63,11 @@ int lcolorbar = 1; /**< Switch for colorbar */
5963 int lstereo = 1; /**< Switch for the stereogram */
6064 int lmouse = 1; /**< Switch for the mouse function */
6165 /**
66+ Menu
67+*/
68+int ibandmenu, ibgmenu, icsmenu, ibzmenu, inlmenu,
69+icbmenu, itetmenu, istereomenu, imousemenu, imenu;
70+/**
6271 * Variables for Brillouin zone boundaries
6372 */
6473 int nbzl; /**< The number of Lines of 1st Brillouin zone */
@@ -1834,17 +1843,14 @@ void main_menu(int value /**< [in] Selected menu*/){
18341843 void menu_mouse(int value /**< [in] Selected menu*/){
18351844 /**/
18361845 if (value == 1 && lmouse != 1){
1837- printf("Mouse drag : Rotate \n\n");
18381846 lmouse = 1;
18391847 glutPostRedisplay();
18401848 }
18411849 if (value == 2 && lmouse != 2){
1842- printf("Mouse drag : Scale \n\n");
18431850 lmouse = 2;
18441851 glutPostRedisplay();
18451852 }
18461853 if (value == 3 && lmouse != 3){
1847- printf("Mouse drag : Translate \n\n");
18481854 lmouse = 3;
18491855 glutPostRedisplay();
18501856 }
@@ -1856,11 +1862,9 @@ void menu_mouse(int value /**< [in] Selected menu*/){
18561862 void menu_band(int value /**< [in] Selected menu*/){
18571863 /**/
18581864 if(draw_band[value] == 0){
1859- printf("band # %d : On \n", value + 1);
18601865 draw_band[value] = 1;
18611866 }
18621867 else{
1863- printf("band # %d : Off \n", value + 1);
18641868 draw_band[value] = 0;
18651869 }
18661870 glutPostRedisplay();
@@ -1871,15 +1875,14 @@ void menu_band(int value /**< [in] Selected menu*/){
18711875 */
18721876 void menu_bgcolor(int value /**<[in] Selected menu*/){
18731877 if(value == 1 && blackback != 1){
1874- printf("Background color becomes BLACK. \n");
18751878 glClearColor(0.0, 0.0, 0.0, 0.0);
18761879 blackback = 1;
18771880 glutPostRedisplay();
18781881 }
18791882 else if(value == 2 && blackback != 0){
1880- printf("Background color becomes WHITE. \n");
18811883 glClearColor(1.0, 1.0, 1.0, 0.0);
18821884 blackback = 0;
1885+ glutPostRedisplay();
18831886 }
18841887 /**/
18851888 }/* bgcolor change*/
@@ -1890,25 +1893,21 @@ void menu_colorscale(int value /**<[in] Selected menu*/){
18901893 /**/
18911894 if(value == 1 && fcscl != 1){
18921895 fcscl = 1;
1893- printf("##### Automatic color scale mode ##### \n");
18941896 max_and_min();
18951897 glutPostRedisplay();
18961898 }
18971899 else if(value == 2 && fcscl != 2){
18981900 fcscl = 2;
1899- printf("##### Manual color scale mode ##### \n");
19001901 max_and_min();
19011902 glutPostRedisplay();
19021903 }
19031904 else if(value == 3 && fcscl != 3){
19041905 fcscl = 3;
1905- printf("##### Unicolor scale mode ##### \n");
19061906 max_and_min();
19071907 glutPostRedisplay();
19081908 }
19091909 else if(value == 4 && fcscl != 4){
19101910 fcscl = 4;
1911- printf("##### Periodic color scale mode ##### \n");
19121911 max_and_min();
19131912 glutPostRedisplay();
19141913 }
@@ -1920,7 +1919,6 @@ void menu_colorscale(int value /**<[in] Selected menu*/){
19201919 void menu_bzmode(int value /**<[in] Selected menu*/){
19211920 if(value == 1 && fbz != 1){
19221921 fbz = 1;
1923- printf("##### First Brillouin zone mode ##### \n\n");
19241922 free(kvp);
19251923 free(nmlp);
19261924 free(clr);
@@ -1939,7 +1937,6 @@ void menu_bzmode(int value /**<[in] Selected menu*/){
19391937 }
19401938 else if(value == 2 && fbz != -1){
19411939 fbz = -1;
1942- printf("##### Primitive Brillouin zone mode ##### \n\n");
19431940 free(kvp);
19441941 free(nmlp);
19451942 free(clr);
@@ -1962,12 +1959,10 @@ void menu_bzmode(int value /**<[in] Selected menu*/){
19621959 */
19631960 void menu_nodeline(int value /**<[in] Selected menu*/){
19641961 if(value == 1 && nodeline != 1){
1965- printf("Nodeline : on \n\n");
19661962 nodeline = 1;
19671963 glutPostRedisplay();
19681964 }
19691965 else if(value == 2 && nodeline != 0){
1970- printf("Nodeline : off \n\n");
19711966 nodeline = 0;
19721967 glutPostRedisplay();
19731968 }
@@ -1978,17 +1973,14 @@ void menu_nodeline(int value /**<[in] Selected menu*/){
19781973 */
19791974 void menu_stereo(int value /**<[in] Selected menu*/){
19801975 if(value == 1 && lstereo != 1){
1981- printf("Stereo : Off. \n\n");
19821976 lstereo = 1;
19831977 glutPostRedisplay();
19841978 }
19851979 if(value == 2 && lstereo != 2){
1986- printf("Stereo : On. Parallel eyes \n\n");
19871980 lstereo = 2;
19881981 glutPostRedisplay();
19891982 }
19901983 if(value == 3 && lstereo != 3){
1991- printf("Stereo : On. Crossed eyes \n\n");
19921984 lstereo = 3;
19931985 glutPostRedisplay();
19941986 }
@@ -1998,12 +1990,10 @@ void menu_stereo(int value /**<[in] Selected menu*/){
19981990 */
19991991 void menu_colorbar(int value /**<[in] Selected menu*/){
20001992 if(value == 1 && lcolorbar != 1){
2001- printf("Color bar : on \n\n");
20021993 lcolorbar = 1;
20031994 glutPostRedisplay();
20041995 }
20051996 if(value == 2 && lcolorbar != 0){
2006- printf("Color bar : off \n\n");
20071997 lcolorbar = 0;
20081998 glutPostRedisplay();
20091999 }
@@ -2012,6 +2002,7 @@ void menu_colorbar(int value /**<[in] Selected menu*/){
20122002 * Change tetrahedron
20132003 */
20142004 void menu_tetra(int value) /**<[in] Selected menu*/{
2005+ int imenu2;
20152006 /**/
20162007 if(value != itet){
20172008 printf("Tetra patern %d \n", value + 1);
@@ -2031,83 +2022,202 @@ void menu_tetra(int value) /**<[in] Selected menu*/{
20312022 glutPostRedisplay();
20322023 }
20332024 } /* menu_tetra */
2025+ /**
2026+ Munu
2027+ */
2028+void FS_ModifyMenu(int status)
2029+{
2030+ int ib;
2031+ char ibstr[20] = { 0 };
2032+ if (status == GLUT_MENU_IN_USE) {
2033+ glutPostRedisplay();
2034+ }
2035+ else {
2036+ /**/
2037+ glutSetMenu(imousemenu);
2038+ for (ib = 0; ib < 3; ib++) glutRemoveMenuItem(1);
2039+ if (lmouse == 1) glutAddMenuEntry("[x] Rotate", 1);
2040+ else glutAddMenuEntry("[ ] Rotate", 1);
2041+ if (lmouse == 2) glutAddMenuEntry("[x] Scale", 2);
2042+ else glutAddMenuEntry("[ ] Scale", 2);
2043+ if (lmouse == 3) glutAddMenuEntry("[x] Translate", 3);
2044+ else glutAddMenuEntry("[ ] Translate", 3);
2045+
2046+ /* Band menu */
2047+ glutSetMenu(ibandmenu);
2048+ for (ib = 0; ib < nb; ib++) glutRemoveMenuItem(1);
2049+ for (ib = 0; ib < nb; ib++) {
2050+ if (draw_band[ib] == 1) sprintf(ibstr, "[x] band # %d", ib + 1);
2051+ else sprintf(ibstr, "[ ] band # %d", ib + 1);
2052+ glutAddMenuEntry(ibstr, ib);
2053+ }
2054+
2055+ /* Background color */
2056+ glutSetMenu(ibgmenu);
2057+ for (ib = 0; ib < 2; ib++) glutRemoveMenuItem(1);
2058+ if (blackback == 1) glutAddMenuEntry("[x] Black", 1);
2059+ else glutAddMenuEntry("[ ] Black", 1);
2060+ if (blackback == 0) glutAddMenuEntry("[x] White", 2);
2061+ else glutAddMenuEntry("[ ] White", 2);
2062+
2063+ /* Color scale mode */
2064+ glutSetMenu(icsmenu);
2065+ for (ib = 0; ib < 4; ib++) glutRemoveMenuItem(1);
2066+ if (fcscl == 1) glutAddMenuEntry("[x] Auto", 1);
2067+ else glutAddMenuEntry("[ ] Auto", 1);
2068+ if (fcscl == 2) glutAddMenuEntry("[x] Manual", 2);
2069+ else glutAddMenuEntry("[ ] Manual", 2);
2070+ if (fcscl == 3) glutAddMenuEntry("[x] Unicolor", 3);
2071+ else glutAddMenuEntry("[ ] Unicolor", 3);
2072+ if (fcscl == 4) glutAddMenuEntry("[x] Periodic", 4);
2073+ else glutAddMenuEntry("[ ] Periodic", 4);
2074+
2075+ /* Brillouin zone */
2076+ glutSetMenu(ibzmenu);
2077+ for (ib = 0; ib < 2; ib++) glutRemoveMenuItem(1);
2078+ if (fbz == 1) glutAddMenuEntry("[x] First Brillouin zone", 1);
2079+ else glutAddMenuEntry("[ ] First Brillouin zone", 1);
2080+ if (fbz == -1) glutAddMenuEntry("[x] Primitive Brillouin zone", 2);
2081+ else glutAddMenuEntry("[ ] Primitive Brillouin zone", 2);
2082+
2083+ /* Nodeline on/off */
2084+ glutSetMenu(inlmenu);
2085+ for (ib = 0; ib < 2; ib++) glutRemoveMenuItem(1);
2086+ if (nodeline == 1) glutAddMenuEntry("[x] On", 1);
2087+ else glutAddMenuEntry("[ ] On", 1);
2088+ if (nodeline == 0) glutAddMenuEntry("[x] Off", 2);
2089+ else glutAddMenuEntry("[ ] Off", 2);
2090+
2091+ /* Colorbar on/off */
2092+ glutSetMenu(icbmenu);
2093+ for (ib = 0; ib < 2; ib++) glutRemoveMenuItem(1);
2094+ if (lcolorbar == 1) glutAddMenuEntry("[x] On", 1);
2095+ else glutAddMenuEntry("[ ] On", 1);
2096+ if (lcolorbar == 0) glutAddMenuEntry("[x] Off", 2);
2097+ else glutAddMenuEntry("[ ] Off", 2);
2098+
2099+ /* Stereogram */
2100+ glutSetMenu(istereomenu);
2101+ for (ib = 0; ib < 3; ib++) glutRemoveMenuItem(1);
2102+ if (lstereo == 1) glutAddMenuEntry("[x] None", 1);
2103+ else glutAddMenuEntry("[ ] None", 1);
2104+ if (lstereo == 2) glutAddMenuEntry("[x] Parallel", 2);
2105+ else glutAddMenuEntry("[ ] Parallel", 2);
2106+ if (lstereo == 3) glutAddMenuEntry("[x] Cross", 3);
2107+ else glutAddMenuEntry("[ ] Cross", 3);
2108+
2109+ /* Tetrahedron */
2110+ glutSetMenu(itetmenu);
2111+ for (ib = 0; ib < 16; ib++) glutRemoveMenuItem(1);
2112+ for (ib = 0; ib < 16; ib++) {
2113+ if (itet == ib) sprintf(ibstr, "[x] tetra # %d", ib + 1);
2114+ else sprintf(ibstr, "[ ] tetra # %d", ib + 1);
2115+ glutAddMenuEntry(ibstr, ib);
2116+ }
2117+ glutPostRedisplay();
2118+ }
2119+}
20342120 /**
2035- * Glut init function
2036- */
2037-void init(void)
2121+Munu
2122+*/
2123+void FS_CreateMenu()
20382124 {
20392125 int ib;
2040- int ibandmenu, ibgmenu, icsmenu, ibzmenu, inlmenu,
2041- icbmenu, itetmenu, istereomenu, imousemenu;
2042- char ibstr[20]={0};
2126+ char ibstr[20] = { 0 };
20432127 /**/
2044- glClearColor(0.0, 0.0, 0.0, 0.0);
2045- glEnable(GL_DEPTH_TEST);
2046- glEnable(GL_LIGHTING);
2047- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE );
2048- glEnable(GL_LIGHT0);
2049- glEnable(GL_LIGHT1);
2050- glEnable(GL_NORMALIZE);
2051- /* Stereogram */
20522128 imousemenu = glutCreateMenu(menu_mouse);
2053- glutAddMenuEntry("Rotate", 1);
2054- glutAddMenuEntry("Scale", 2);
2055- glutAddMenuEntry("Translate", 3);
2129+ if (lmouse == 1) glutAddMenuEntry("[x] Rotate", 1);
2130+ else glutAddMenuEntry("[ ] Rotate", 1);
2131+ if (lmouse == 2) glutAddMenuEntry("[x] Scale", 2);
2132+ else glutAddMenuEntry("[ ] Scale", 2);
2133+ if (lmouse == 3) glutAddMenuEntry("[x] Translate", 3);
2134+ else glutAddMenuEntry("[ ] Translate", 3);
20562135 /* Band menu */
20572136 ibandmenu = glutCreateMenu(menu_band);
2058- for(ib =0;ib < nb; ib++){
2059- sprintf(ibstr,"band # %d",ib + 1);
2137+ for (ib = 0; ib < nb; ib++) {
2138+ if (draw_band[ib] == 1) sprintf(ibstr, "[x] band # %d", ib + 1);
2139+ else sprintf(ibstr, "[ ] band # %d", ib + 1);
20602140 glutAddMenuEntry(ibstr, ib);
20612141 }
20622142 /* Background color */
20632143 ibgmenu = glutCreateMenu(menu_bgcolor);
2064- glutAddMenuEntry("Black",1);
2065- glutAddMenuEntry("White",2);
2144+ if (blackback == 1) glutAddMenuEntry("[x] Black", 1);
2145+ else glutAddMenuEntry("[ ] Black", 1);
2146+ if (blackback == 0) glutAddMenuEntry("[x] White", 2);
2147+ else glutAddMenuEntry("[ ] White", 2);
20662148 /* Color scale mode */
20672149 icsmenu = glutCreateMenu(menu_colorscale);
2068- glutAddMenuEntry("Auto",1);
2069- glutAddMenuEntry("Manual",2);
2070- glutAddMenuEntry("Unicolor",3);
2071- glutAddMenuEntry("Periodic",4);
2150+ if (fcscl == 1) glutAddMenuEntry("[x] Auto", 1);
2151+ else glutAddMenuEntry("[ ] Auto", 1);
2152+ if (fcscl == 2) glutAddMenuEntry("[x] Manual", 2);
2153+ else glutAddMenuEntry("[ ] Manual", 2);
2154+ if (fcscl == 3) glutAddMenuEntry("[x] Unicolor", 3);
2155+ else glutAddMenuEntry("[ ] Unicolor", 3);
2156+ if (fcscl == 4) glutAddMenuEntry("[x] Periodic", 4);
2157+ else glutAddMenuEntry("[ ] Periodic", 4);
20722158 /* Brillouin zone */
20732159 ibzmenu = glutCreateMenu(menu_bzmode);
2074- glutAddMenuEntry("First Brillouin zone",1);
2075- glutAddMenuEntry("Primitive Brillouin zone",2);
2160+ if (fbz == 1) glutAddMenuEntry("[x] First Brillouin zone", 1);
2161+ else glutAddMenuEntry("[ ] First Brillouin zone", 1);
2162+ if (fbz == -1) glutAddMenuEntry("[x] Primitive Brillouin zone", 2);
2163+ else glutAddMenuEntry("[ ] Primitive Brillouin zone", 2);
20762164 /* Nodeline on/off */
20772165 inlmenu = glutCreateMenu(menu_nodeline);
2078- glutAddMenuEntry("On",1);
2079- glutAddMenuEntry("Off",2);
2166+ if (nodeline == 1) glutAddMenuEntry("[x] On", 1);
2167+ else glutAddMenuEntry("[ ] On", 1);
2168+ if (nodeline == 0) glutAddMenuEntry("[x] Off", 2);
2169+ else glutAddMenuEntry("[ ] Off", 2);
20802170 /* Colorbar on/off */
20812171 icbmenu = glutCreateMenu(menu_colorbar);
2082- glutAddMenuEntry("On",1);
2083- glutAddMenuEntry("Off",2);
2172+ if (lcolorbar == 1) glutAddMenuEntry("[x] On", 1);
2173+ else glutAddMenuEntry("[ ] On", 1);
2174+ if (lcolorbar == 0) glutAddMenuEntry("[x] Off", 2);
2175+ else glutAddMenuEntry("[ ] Off", 2);
20842176 /* Stereogram */
20852177 istereomenu = glutCreateMenu(menu_stereo);
2086- glutAddMenuEntry("None",1);
2087- glutAddMenuEntry("Parallel",2);
2088- glutAddMenuEntry("Cross",3);
2178+ if (lstereo == 1) glutAddMenuEntry("[x] None", 1);
2179+ else glutAddMenuEntry("[ ] None", 1);
2180+ if (lstereo == 2) glutAddMenuEntry("[x] Parallel", 2);
2181+ else glutAddMenuEntry("[ ] Parallel", 2);
2182+ if (lstereo == 3) glutAddMenuEntry("[x] Cross", 3);
2183+ else glutAddMenuEntry("[ ] Cross", 3);
20892184 /* Tetrahedron */
20902185 itetmenu = glutCreateMenu(menu_tetra);
2091- for(ib =0;ib < 16; ib++){
2092- sprintf(ibstr,"tetra # %d",ib + 1);
2093- glutAddMenuEntry(ibstr,ib);
2186+ for (ib = 0; ib < 16; ib++) {
2187+ if (itet == ib) sprintf(ibstr, "[x] tetra # %d", ib + 1);
2188+ else sprintf(ibstr, "[ ] tetra # %d", ib + 1);
2189+ glutAddMenuEntry(ibstr, ib);
20942190 }
2095- /*
2096- Main menu
2191+ /*
2192+ Main menu
20972193 */
2098- glutCreateMenu(main_menu);
2099- glutAddSubMenu("Band",ibandmenu);
2194+ imenu = glutCreateMenu(main_menu);
2195+ glutAddSubMenu("Band", ibandmenu);
21002196 glutAddSubMenu("Mouse Drag", imousemenu);
21012197 glutAddMenuEntry("Shift Fermi energy", 2);
2102- glutAddSubMenu("Background color",ibgmenu);
2103- glutAddSubMenu("Color scale mode",icsmenu);
2104- glutAddSubMenu("Brillouin zone",ibzmenu);
2105- glutAddSubMenu("Node lines",inlmenu);
2106- glutAddSubMenu("Color bar On/Off",icbmenu);
2107- glutAddSubMenu("Stereogram",istereomenu);
2108- glutAddSubMenu("Tetrahedron",itetmenu);
2109- glutAddMenuEntry("Exit",9);
2198+ glutAddSubMenu("Background color", ibgmenu);
2199+ glutAddSubMenu("Color scale mode", icsmenu);
2200+ glutAddSubMenu("Brillouin zone", ibzmenu);
2201+ glutAddSubMenu("Node lines", inlmenu);
2202+ glutAddSubMenu("Color bar On/Off", icbmenu);
2203+ glutAddSubMenu("Stereogram", istereomenu);
2204+ glutAddSubMenu("Tetrahedron", itetmenu);
2205+ glutAddMenuEntry("Exit", 9);
21102206 glutAttachMenu(GLUT_RIGHT_BUTTON);
2207+}/**
2208+ * Glut init function
2209+ */
2210+void init(void)
2211+{
2212+ glClearColor(0.0, 0.0, 0.0, 0.0);
2213+ glEnable(GL_DEPTH_TEST);
2214+ glEnable(GL_LIGHTING);
2215+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE );
2216+ glEnable(GL_LIGHT0);
2217+ glEnable(GL_LIGHT1);
2218+ glEnable(GL_NORMALIZE);
2219+ /* Menu */
2220+ FS_CreateMenu();
21112221 } /* init */
21122222 /**
21132223 * Main routine
@@ -2128,8 +2238,10 @@ int main(
21282238 /**/
21292239 max_and_min_bz();
21302240 /**/
2241+#ifndef MAC
21312242 #pragma omp parallel
21322243 printf("Threads : %d \n", omp_get_num_threads());
2244+#endif
21332245 /**/
21342246 printf("\n##### First Brillouin zone mode ##### \n\n");
21352247 query = 1;
@@ -2159,6 +2271,7 @@ int main(
21592271 glutMotionFunc(motion);
21602272 glutKeyboardFunc(keyboard);
21612273 glutSpecialFunc(special_key);
2274+ glutMenuStateFunc(FS_ModifyMenu);
21622275 init();
21632276 glutMainLoop();
21642277 return 0;
Show on old repository browser