• R/O
  • HTTP
  • SSH
  • HTTPS

fermisurfer: Commit

fermisurfer Git


Commit MetaInfo

Revisionb5e1012661460f20223f1dce33b2900b6678ef4e (tree)
Zeit2020-12-26 18:49:10
AutorMitsuaki Kawamura <kawamitsuaki@gmai...>
CommiterMitsuaki Kawamura

Log Message

Add function to change the color of section and Fermi surface (Band-index mode)

Ändern Zusammenfassung

Diff

--- a/src/draw.cpp
+++ b/src/draw.cpp
@@ -308,7 +308,7 @@ static void draw_bz_lines() {
308308 + trans[j];
309309 for (j = 0; j < 3; j++)vertices[j + 3 * ibzl] = bzl2[j];
310310 }/*for (ibzl = 0; ibzl < nbzl2d; ++ibzl)*/
311- glColor3fv(gray);
311+ glColor3fv(SectionColor);
312312 glNormal3fv(secvec2);
313313 glVertexPointer(3, GL_FLOAT, 0, vertices);
314314 glDrawArrays(GL_TRIANGLE_FAN, 0, nbzl2d);
--- a/src/fermisurfer.cpp
+++ b/src/fermisurfer.cpp
@@ -135,6 +135,7 @@ int nbragg; //!< Number of Bragg plane og 1st BZ
135135 */
136136 int *ntri; //!< The number of triangle patch [::nb]
137137 int *draw_band; //!< Switch for drawn bands [::nb]
138+GLfloat**rgb_band; //!< Switch for drawn bands [::nb]
138139 GLfloat ****nmlp; //!< Normal vector of patchs [::nb][::ntri][3][3]
139140 GLfloat ****kvp; //!< @f$k@f$-vectors of points [::nb][::ntri][3][3]
140141 GLfloat***** arw;
@@ -206,6 +207,7 @@ GLfloat green[4] = { 0.0, 1.0, 0.0, 1.0 }; //!< Green color code
206207 GLfloat blue[4] = { 0.0, 0.0, 1.0, 1.0 }; //!< Blue color code
207208 GLfloat BackGroundColor[4] = { 0.0, 0.0, 0.0, 1.0 };//!< BackGround color code
208209 GLfloat LineColor[4] = { 1.0, 1.0, 1.0, 1.0 };//!< Line color code
210+GLfloat SectionColor[4] = { 0.5f, 0.5f, 0.5f, 1.0 };//!< Line color code
209211 GLfloat BarColor[5][4] = { { 0.0, 0.0, 1.0, 1.0 } , { 0.0, 1.0, 1.0, 1.0 } ,
210212 { 0.0, 1.0, 0.0, 1.0 } ,{ 1.0, 1.0, 0.0, 1.0 } ,{ 1.0, 0.0, 0.0, 1.0 } };
211213 /*
--- a/src/free_patch.cpp
+++ b/src/free_patch.cpp
@@ -439,51 +439,13 @@ shared(nb,ntri,matp,clr,BarColor,color_scale,kvp,arw,patch_max) \
439439 private(itri, j)
440440 {
441441 int i, ib;
442- GLfloat mat2;
443442
444443 for (ib = 0; ib < nb; ib++) {
445444 /**/
446- if (nb == 1) mat2 = 0.5f;
447- else mat2 = 1.0f / (GLfloat)(nb - 1) * (GLfloat)ib;
448- mat2 *= 4.0f;
449- /**/
450- if (mat2 <= 1.0) {
451445 #pragma omp for nowait
452- for (itri = 0; itri < ntri[ib]; ++itri) {
453- for (i = 0; i < 3; ++i) {
454- for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri]
455- = BarColor[1][j] * mat2 + BarColor[0][j] * (1.0f - mat2);
456- }
457- }
458- }
459- else if (mat2 <= 2.0) {
460- mat2 = mat2 - 1.0f;
461-#pragma omp for nowait
462- for (itri = 0; itri < ntri[ib]; ++itri) {
463- for (i = 0; i < 3; ++i) {
464- for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri]
465- = BarColor[2][j] * mat2 + BarColor[1][j] * (1.0f - mat2);
466- }
467- }
468- }
469- else if (mat2 <= 3.0) {
470- mat2 = mat2 - 2.0f;
471-#pragma omp for nowait
472- for (itri = 0; itri < ntri[ib]; ++itri) {
473- for (i = 0; i < 3; ++i) {
474- for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri]
475- = BarColor[3][j] * mat2 + BarColor[2][j] * (1.0f - mat2);
476- }
477- }
478- }
479- else {
480- mat2 = mat2 - 3.0f;
481-#pragma omp for nowait
482- for (itri = 0; itri < ntri[ib]; ++itri) {
483- for (i = 0; i < 3; ++i) {
484- for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri]
485- = BarColor[4][j] * mat2 + BarColor[3][j] * (1.0f - mat2);
486- }
446+ for (itri = 0; itri < ntri[ib]; ++itri) {
447+ for (i = 0; i < 3; ++i) {
448+ for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = rgb_band[ib][j];
487449 }
488450 }
489451 }/*for (ib = 0; ib < nb; ib++*/
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -125,7 +125,6 @@ enum
125125 itext_roty,
126126 itext_rotz,
127127 ibutton_rotate,
128- icheck_band,
129128 itext_BackGroundR,
130129 itext_BackGroundG,
131130 itext_BackGroundB,
@@ -136,7 +135,11 @@ enum
136135 ibutton_section,
137136 itext_BZ_number0,
138137 itext_BZ_number1,
139- itext_BZ_number2
138+ itext_BZ_number2,
139+ itext_SectionR,
140+ itext_SectionG,
141+ itext_SectionB,
142+ icheck_band
140143 };
141144
142145 void MyFrame::button_refresh(
@@ -213,6 +216,68 @@ void MyFrame::textctrl_LineColor(
213216 }
214217 }
215218 /**
219+@brief Change section color (::blackback)
220+*/
221+void MyFrame::textctrl_Section(
222+ wxCommandEvent& event //!<[in] Selected menu
223+)
224+{
225+ int ierr;
226+ double dvalue;
227+
228+ if (event.GetId() == itext_SectionR) {
229+ if (event.GetString().ToDouble(&dvalue)) {
230+ SectionColor[0] = (GLfloat)dvalue;
231+ Refresh(false);
232+ }
233+ }
234+ else if (event.GetId() == itext_SectionG) {
235+ if (event.GetString().ToDouble(&dvalue)) {
236+ SectionColor[1] = (GLfloat)dvalue;
237+ Refresh(false);
238+ }
239+ }
240+ else if (event.GetId() == itext_SectionB) {
241+ if (event.GetString().ToDouble(&dvalue)) {
242+ SectionColor[2] = (GLfloat)dvalue;
243+ Refresh(false);
244+ }
245+ }
246+}
247+/**
248+@brief Change band color (::blackback)
249+*/
250+void MyFrame::textctrl_Band(
251+ wxCommandEvent& event //!<[in] Selected menu
252+)
253+{
254+ int ierr;
255+ double dvalue;
256+ int ib = (event.GetId() - icheck_band) / 4;
257+
258+ if (event.GetId() == icheck_band + 4 * ib + 1) {
259+ if (event.GetString().ToDouble(&dvalue)) {
260+ rgb_band[ib][0] = (GLfloat)dvalue;
261+ paint();
262+ Refresh(false);
263+ }
264+ }
265+ else if (event.GetId() == icheck_band + 4 * ib + 2) {
266+ if (event.GetString().ToDouble(&dvalue)) {
267+ rgb_band[ib][1] = (GLfloat)dvalue;
268+ paint();
269+ Refresh(false);
270+ }
271+ }
272+ else if (event.GetId() == icheck_band + 4 * ib + 3) {
273+ if (event.GetString().ToDouble(&dvalue)) {
274+ rgb_band[ib][2] = (GLfloat)dvalue;
275+ paint();
276+ Refresh(false);
277+ }
278+ }
279+}
280+/**
216281 @brief Change background color (::blackback)
217282 */
218283 void MyFrame::textctrl_BackGround(
@@ -283,7 +348,7 @@ void MyFrame::check_band(
283348 wxCommandEvent& event //!<[in] Selected menu
284349 )
285350 {
286- int ib = event.GetId() - icheck_band;
351+ int ib = (event.GetId() - icheck_band) / 4;
287352 if (draw_band[ib] == 0) {
288353 draw_band[ib] = 1;
289354 }
@@ -912,36 +977,51 @@ wxT("8"), wxT("9"), wxT("10"), wxT("11"), wxT("12"), wxT("13"), wxT("14"),
912977
913978 Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &MyFrame::check_colorbar, this, icheck_colorbar);
914979 wxCheckBox* check = new wxCheckBox(panel, icheck_colorbar, wxT("Color bar"));
915- gbsizer->Add(check, wxGBPosition(15, 1), wxGBSpan(1, 1));
980+ gbsizer->Add(check, wxGBPosition(16, 2), wxGBSpan(1, 1));
916981 check->SetValue(true);
917982 // debug fileMenu->Check(menu_colorbar_check, true);
918983
919984 Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &MyFrame::checkvalue_equator, this, icheck_equator);
920- gbsizer->Add(new wxCheckBox(panel, icheck_equator, wxT("Equator")), wxGBPosition(16, 1), wxGBSpan(1, 1));
985+ gbsizer->Add(new wxCheckBox(panel, icheck_equator, wxT("Equator")), wxGBPosition(17, 2), wxGBSpan(1, 1));
921986
922987 Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &MyFrame::check_nodeline, this, icheck_nodeline);
923- gbsizer->Add(new wxCheckBox(panel, icheck_nodeline, wxT("Nodal line")), wxGBPosition(17, 1), wxGBSpan(1, 1));
988+ gbsizer->Add(new wxCheckBox(panel, icheck_nodeline, wxT("Nodal line")), wxGBPosition(18, 2), wxGBSpan(1, 1));
924989
925990 Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &MyFrame::radiovalue_section, this, icheck_section);
926- gbsizer->Add(new wxCheckBox(panel, icheck_section, wxT("Section")), wxGBPosition(18, 1), wxGBSpan(1, 1));
991+ gbsizer->Add(new wxCheckBox(panel, icheck_section, wxT("Section")), wxGBPosition(16, 3), wxGBSpan(1, 1));
927992
928993 Bind(wxEVT_COMMAND_BUTTON_CLICKED, &MyFrame::button_section, this, ibutton_section);
929994 gbsizer->Add(new wxButton(panel, ibutton_section, wxT("Section file")),
930- wxGBPosition(19, 1), wxGBSpan(1, 1));
995+ wxGBPosition(17, 3), wxGBSpan(1, 1));
931996
932997 wxString choices_light[] = { wxT("Both"), wxT("Unoccupy"), wxT("Occupy") };
933998 Bind(wxEVT_COMMAND_RADIOBOX_SELECTED, &MyFrame::radio_lighting, this, iradio_lighting);
934999 gbsizer->Add(new wxRadioBox(panel, iradio_lighting, wxT("Lighting"),
9351000 wxDefaultPosition, wxDefaultSize,
9361001 WXSIZEOF(choices_light), choices_light,
937- 1, wxRA_SPECIFY_COLS), wxGBPosition(16, 2), wxGBSpan(4, 1));
1002+ 1, wxRA_SPECIFY_COLS), wxGBPosition(15, 0), wxGBSpan(4, 1));
9381003
9391004 wxString choices_BarColor[] = { wxT("BGR"), wxT("CMY"), wxT("MCY")};
9401005 Bind(wxEVT_COMMAND_RADIOBOX_SELECTED, &MyFrame::radio_BarColor, this, iradio_BarColor);
9411006 gbsizer->Add(new wxRadioBox(panel, iradio_BarColor, wxT("Bar Color"),
9421007 wxDefaultPosition, wxDefaultSize,
9431008 WXSIZEOF(choices_BarColor), choices_BarColor,
944- 1, wxRA_SPECIFY_COLS), wxGBPosition(16, 3), wxGBSpan(4, 1));
1009+ 1, wxRA_SPECIFY_COLS), wxGBPosition(15, 1), wxGBSpan(4, 1));
1010+
1011+ gbsizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Section (RGB) : ")),
1012+ wxGBPosition(19, 0), wxGBSpan(1, 1), wxALIGN_RIGHT);
1013+ Bind(wxEVT_COMMAND_TEXT_UPDATED, &MyFrame::textctrl_Section, this, itext_SectionR);
1014+ textbox_SectionR = new wxTextCtrl(panel, itext_SectionR, wxT(""));
1015+ gbsizer->Add(textbox_SectionR, wxGBPosition(19, 1), wxGBSpan(1, 1));
1016+ Bind(wxEVT_COMMAND_TEXT_UPDATED, &MyFrame::textctrl_Section, this, itext_SectionG);
1017+ textbox_SectionG = new wxTextCtrl(panel, itext_SectionG, wxT(""));
1018+ gbsizer->Add(textbox_SectionG, wxGBPosition(19, 2), wxGBSpan(1, 1));
1019+ Bind(wxEVT_COMMAND_TEXT_UPDATED, &MyFrame::textctrl_Section, this, itext_SectionB);
1020+ textbox_SectionB = new wxTextCtrl(panel, itext_SectionB, wxT(""));
1021+ gbsizer->Add(textbox_SectionB, wxGBPosition(19, 3), wxGBSpan(1, 1));
1022+ textbox_SectionR->ChangeValue(wxT("0.5"));
1023+ textbox_SectionG->ChangeValue(wxT("0.5"));
1024+ textbox_SectionB->ChangeValue(wxT("0.5"));
9451025
9461026 SetSizer(sizermain);
9471027 SetAutoLayout(true);
@@ -966,19 +1046,56 @@ void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
9661046 }
9671047
9681048 void MyFrame::modify_band() {
969- int ib, width, height;
1049+ int ib, width, height, j;
9701050 wxCheckBox** check;
1051+ wxTextCtrl** textbox_BandR, ** textbox_BandG, ** textbox_BandB;
1052+ GLfloat mat2;
9711053
9721054 radiobox_color->SetSelection(color_scale - 1);
9731055
9741056 check = new wxCheckBox * [nb];
1057+ textbox_BandR = new wxTextCtrl * [nb];
1058+ textbox_BandG = new wxTextCtrl * [nb];
1059+ textbox_BandB = new wxTextCtrl * [nb];
9751060
9761061 for (ib = 0; ib < nb; ib++) {
977- Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &MyFrame::check_band, this, icheck_band + ib);
978- check[ib] = new wxCheckBox(panel, icheck_band + ib,
979- wxString::Format(wxT("Band %d"), ib));
980- gbsizer->Add(check[ib], wxGBPosition(14 + ib, 0), wxGBSpan(1, 1));
1062+ Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &MyFrame::check_band, this, icheck_band + 4*ib);
1063+ check[ib] = new wxCheckBox(panel, icheck_band + 4*ib,
1064+ wxString::Format(wxT("Band %d, RGB :"), ib));
1065+ gbsizer->Add(check[ib], wxGBPosition(20 + ib, 0), wxGBSpan(1, 1));
9811066 check[ib]->SetValue(true);
1067+
1068+ if (nb == 1) mat2 = 0.5f;
1069+ else mat2 = 1.0f / (GLfloat)(nb - 1) * (GLfloat)ib;
1070+ mat2 *= 4.0f;
1071+ if (mat2 <= 1.0) {
1072+ for (j = 0; j < 4; ++j) rgb_band[ib][j] = cyan[j] * mat2 + blue[j] * (1.0f - mat2);
1073+ }
1074+ else if (mat2 <= 2.0) {
1075+ mat2 = mat2 - 1.0f;
1076+ for (j = 0; j < 4; ++j) rgb_band[ib][j] = green[j] * mat2 + cyan[j] * (1.0f - mat2);
1077+ }
1078+ else if (mat2 <= 3.0) {
1079+ mat2 = mat2 - 2.0f;
1080+ for (j = 0; j < 4; ++j) rgb_band[ib][j] = yellow[j] * mat2 + green[j] * (1.0f - mat2);
1081+ }
1082+ else {
1083+ mat2 = mat2 - 3.0f;
1084+ for (j = 0; j < 4; ++j) rgb_band[ib][j] = red[j] * mat2 + yellow[j] * (1.0f - mat2);
1085+ }
1086+
1087+ Bind(wxEVT_COMMAND_TEXT_UPDATED, &MyFrame::textctrl_Band, this, icheck_band + 4 * ib+1);
1088+ textbox_BandR[ib] = new wxTextCtrl(panel, icheck_band + 4 * ib+1, wxT(""));
1089+ gbsizer->Add(textbox_BandR[ib], wxGBPosition(20 + ib, 1), wxGBSpan(1, 1));
1090+ Bind(wxEVT_COMMAND_TEXT_UPDATED, &MyFrame::textctrl_Band, this, icheck_band + 4 * ib+2);
1091+ textbox_BandG[ib] = new wxTextCtrl(panel, icheck_band + 4 * ib+2, wxT(""));
1092+ gbsizer->Add(textbox_BandG[ib], wxGBPosition(20 + ib, 2), wxGBSpan(1, 1));
1093+ Bind(wxEVT_COMMAND_TEXT_UPDATED, &MyFrame::textctrl_Band, this, icheck_band + 4 * ib+3);
1094+ textbox_BandB[ib] = new wxTextCtrl(panel, icheck_band + 4 * ib+3, wxT(""));
1095+ gbsizer->Add(textbox_BandB[ib], wxGBPosition(20 + ib, 3), wxGBSpan(1, 1));
1096+ textbox_BandR[ib]->ChangeValue(wxString::Format(wxT("%f"), rgb_band[ib][0]));
1097+ textbox_BandG[ib]->ChangeValue(wxString::Format(wxT("%f"), rgb_band[ib][1]));
1098+ textbox_BandB[ib]->ChangeValue(wxString::Format(wxT("%f"), rgb_band[ib][2]));
9821099 }
9831100 gbsizer->Layout();
9841101 if (lbatch == 1) {
--- a/src/menu.hpp
+++ b/src/menu.hpp
@@ -71,6 +71,9 @@ public:
7171 wxTextCtrl* textbox_BZ_number0;
7272 wxTextCtrl* textbox_BZ_number1;
7373 wxTextCtrl* textbox_BZ_number2;
74+ wxTextCtrl* textbox_SectionR;
75+ wxTextCtrl* textbox_SectionG;
76+ wxTextCtrl* textbox_SectionB;
7477
7578 private:
7679 void OnExit(wxCommandEvent& event);
@@ -96,6 +99,8 @@ private:
9699 void radio_BarColor(wxCommandEvent& event);
97100 void button_section(wxCommandEvent& event);
98101 void textctrl_BZ_number(wxCommandEvent& event);
102+ void textctrl_Section(wxCommandEvent& event);
103+ void textctrl_Band(wxCommandEvent& event);
99104 //wxDECLARE_EVENT_TABLE();
100105 };
101106
--- a/src/read_file.cpp
+++ b/src/read_file.cpp
@@ -57,7 +57,11 @@ int ng0[3]
5757 n2d = new int[nb];
5858 nequator = new int[nb];
5959 draw_band = new int[nb];
60- for (ib = 0; ib < nb; ib++) draw_band[ib] = 1;
60+ rgb_band = new GLfloat *[nb];
61+ for (ib = 0; ib < nb; ib++) {
62+ draw_band[ib] = 1;
63+ rgb_band[ib] = new GLfloat [4];
64+ }
6165
6266 scl /= sqrtf(bvec[0][0] * bvec[0][0] + bvec[0][1] * bvec[0][1] + bvec[0][2] * bvec[0][2]);
6367 linewidth /= scl;
--- a/src/variable.hpp
+++ b/src/variable.hpp
@@ -83,6 +83,7 @@ extern int nbragg; //!< Number of Bragg plane og 1st BZ
8383 */
8484 extern int *ntri; //!< The number of triangle patch [::nb]
8585 extern int *draw_band; //!< Switch for drawn bands [::nb]
86+extern GLfloat** rgb_band; //!< Switch for drawn bands [::nb]
8687 extern GLfloat ****nmlp; //!< Normal vector of patchs [::nb][::ntri][3][3]
8788 extern GLfloat***** arw;
8889 extern GLfloat ****kvp; //!< @f$k@f$-vectors of points [::nb][::ntri][3][3]
@@ -152,6 +153,7 @@ extern GLfloat green[4]; //!< Green color code
152153 extern GLfloat blue[4]; //!< Blue color code
153154 extern GLfloat BackGroundColor[4];//!< Background color code
154155 extern GLfloat LineColor[4];//!< Line color code
156+extern GLfloat SectionColor[4];//!< Line color code
155157 extern GLfloat BarColor[5][4];
156158 /*
157159 Others
Show on old repository browser