Skip to content

Commit

Permalink
Add function to change the color of section and Fermi surface (Band-i…
Browse files Browse the repository at this point in the history
…ndex mode)
  • Loading branch information
mitsuaki1987 committed Dec 26, 2020
1 parent 4ab2a5e commit b5e1012
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 58 deletions.
2 changes: 1 addition & 1 deletion src/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ static void draw_bz_lines() {
+ trans[j];
for (j = 0; j < 3; j++)vertices[j + 3 * ibzl] = bzl2[j];
}/*for (ibzl = 0; ibzl < nbzl2d; ++ibzl)*/
glColor3fv(gray);
glColor3fv(SectionColor);
glNormal3fv(secvec2);
glVertexPointer(3, GL_FLOAT, 0, vertices);
glDrawArrays(GL_TRIANGLE_FAN, 0, nbzl2d);
Expand Down
2 changes: 2 additions & 0 deletions src/fermisurfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ int nbragg; //!< Number of Bragg plane og 1st BZ
*/
int *ntri; //!< The number of triangle patch [::nb]
int *draw_band; //!< Switch for drawn bands [::nb]
GLfloat**rgb_band; //!< Switch for drawn bands [::nb]
GLfloat ****nmlp; //!< Normal vector of patchs [::nb][::ntri][3][3]
GLfloat ****kvp; //!< @f$k@f$-vectors of points [::nb][::ntri][3][3]
GLfloat***** arw;
Expand Down Expand Up @@ -206,6 +207,7 @@ GLfloat green[4] = { 0.0, 1.0, 0.0, 1.0 }; //!< Green color code
GLfloat blue[4] = { 0.0, 0.0, 1.0, 1.0 }; //!< Blue color code
GLfloat BackGroundColor[4] = { 0.0, 0.0, 0.0, 1.0 };//!< BackGround color code
GLfloat LineColor[4] = { 1.0, 1.0, 1.0, 1.0 };//!< Line color code
GLfloat SectionColor[4] = { 0.5f, 0.5f, 0.5f, 1.0 };//!< Line color code
GLfloat BarColor[5][4] = { { 0.0, 0.0, 1.0, 1.0 } , { 0.0, 1.0, 1.0, 1.0 } ,
{ 0.0, 1.0, 0.0, 1.0 } ,{ 1.0, 1.0, 0.0, 1.0 } ,{ 1.0, 0.0, 0.0, 1.0 } };
/*
Expand Down
44 changes: 3 additions & 41 deletions src/free_patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,51 +439,13 @@ shared(nb,ntri,matp,clr,BarColor,color_scale,kvp,arw,patch_max) \
private(itri, j)
{
int i, ib;
GLfloat mat2;

for (ib = 0; ib < nb; ib++) {
/**/
if (nb == 1) mat2 = 0.5f;
else mat2 = 1.0f / (GLfloat)(nb - 1) * (GLfloat)ib;
mat2 *= 4.0f;
/**/
if (mat2 <= 1.0) {
#pragma omp for nowait
for (itri = 0; itri < ntri[ib]; ++itri) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri]
= BarColor[1][j] * mat2 + BarColor[0][j] * (1.0f - mat2);
}
}
}
else if (mat2 <= 2.0) {
mat2 = mat2 - 1.0f;
#pragma omp for nowait
for (itri = 0; itri < ntri[ib]; ++itri) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri]
= BarColor[2][j] * mat2 + BarColor[1][j] * (1.0f - mat2);
}
}
}
else if (mat2 <= 3.0) {
mat2 = mat2 - 2.0f;
#pragma omp for nowait
for (itri = 0; itri < ntri[ib]; ++itri) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri]
= BarColor[3][j] * mat2 + BarColor[2][j] * (1.0f - mat2);
}
}
}
else {
mat2 = mat2 - 3.0f;
#pragma omp for nowait
for (itri = 0; itri < ntri[ib]; ++itri) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri]
= BarColor[4][j] * mat2 + BarColor[3][j] * (1.0f - mat2);
}
for (itri = 0; itri < ntri[ib]; ++itri) {
for (i = 0; i < 3; ++i) {
for (j = 0; j < 4; ++j) clr[ib][j + 4 * i + 12 * itri] = rgb_band[ib][j];
}
}
}/*for (ib = 0; ib < nb; ib++*/
Expand Down
147 changes: 132 additions & 15 deletions src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ enum
itext_roty,
itext_rotz,
ibutton_rotate,
icheck_band,
itext_BackGroundR,
itext_BackGroundG,
itext_BackGroundB,
Expand All @@ -136,7 +135,11 @@ enum
ibutton_section,
itext_BZ_number0,
itext_BZ_number1,
itext_BZ_number2
itext_BZ_number2,
itext_SectionR,
itext_SectionG,
itext_SectionB,
icheck_band
};

void MyFrame::button_refresh(
Expand Down Expand Up @@ -213,6 +216,68 @@ void MyFrame::textctrl_LineColor(
}
}
/**
@brief Change section color (::blackback)
*/
void MyFrame::textctrl_Section(
wxCommandEvent& event //!<[in] Selected menu
)
{
int ierr;
double dvalue;

if (event.GetId() == itext_SectionR) {
if (event.GetString().ToDouble(&dvalue)) {
SectionColor[0] = (GLfloat)dvalue;
Refresh(false);
}
}
else if (event.GetId() == itext_SectionG) {
if (event.GetString().ToDouble(&dvalue)) {
SectionColor[1] = (GLfloat)dvalue;
Refresh(false);
}
}
else if (event.GetId() == itext_SectionB) {
if (event.GetString().ToDouble(&dvalue)) {
SectionColor[2] = (GLfloat)dvalue;
Refresh(false);
}
}
}
/**
@brief Change band color (::blackback)
*/
void MyFrame::textctrl_Band(
wxCommandEvent& event //!<[in] Selected menu
)
{
int ierr;
double dvalue;
int ib = (event.GetId() - icheck_band) / 4;

if (event.GetId() == icheck_band + 4 * ib + 1) {
if (event.GetString().ToDouble(&dvalue)) {
rgb_band[ib][0] = (GLfloat)dvalue;
paint();
Refresh(false);
}
}
else if (event.GetId() == icheck_band + 4 * ib + 2) {
if (event.GetString().ToDouble(&dvalue)) {
rgb_band[ib][1] = (GLfloat)dvalue;
paint();
Refresh(false);
}
}
else if (event.GetId() == icheck_band + 4 * ib + 3) {
if (event.GetString().ToDouble(&dvalue)) {
rgb_band[ib][2] = (GLfloat)dvalue;
paint();
Refresh(false);
}
}
}
/**
@brief Change background color (::blackback)
*/
void MyFrame::textctrl_BackGround(
Expand Down Expand Up @@ -283,7 +348,7 @@ void MyFrame::check_band(
wxCommandEvent& event //!<[in] Selected menu
)
{
int ib = event.GetId() - icheck_band;
int ib = (event.GetId() - icheck_band) / 4;
if (draw_band[ib] == 0) {
draw_band[ib] = 1;
}
Expand Down Expand Up @@ -912,36 +977,51 @@ wxT("8"), wxT("9"), wxT("10"), wxT("11"), wxT("12"), wxT("13"), wxT("14"),

Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &MyFrame::check_colorbar, this, icheck_colorbar);
wxCheckBox* check = new wxCheckBox(panel, icheck_colorbar, wxT("Color bar"));
gbsizer->Add(check, wxGBPosition(15, 1), wxGBSpan(1, 1));
gbsizer->Add(check, wxGBPosition(16, 2), wxGBSpan(1, 1));
check->SetValue(true);
// debug fileMenu->Check(menu_colorbar_check, true);

Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &MyFrame::checkvalue_equator, this, icheck_equator);
gbsizer->Add(new wxCheckBox(panel, icheck_equator, wxT("Equator")), wxGBPosition(16, 1), wxGBSpan(1, 1));
gbsizer->Add(new wxCheckBox(panel, icheck_equator, wxT("Equator")), wxGBPosition(17, 2), wxGBSpan(1, 1));

Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &MyFrame::check_nodeline, this, icheck_nodeline);
gbsizer->Add(new wxCheckBox(panel, icheck_nodeline, wxT("Nodal line")), wxGBPosition(17, 1), wxGBSpan(1, 1));
gbsizer->Add(new wxCheckBox(panel, icheck_nodeline, wxT("Nodal line")), wxGBPosition(18, 2), wxGBSpan(1, 1));

Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &MyFrame::radiovalue_section, this, icheck_section);
gbsizer->Add(new wxCheckBox(panel, icheck_section, wxT("Section")), wxGBPosition(18, 1), wxGBSpan(1, 1));
gbsizer->Add(new wxCheckBox(panel, icheck_section, wxT("Section")), wxGBPosition(16, 3), wxGBSpan(1, 1));

Bind(wxEVT_COMMAND_BUTTON_CLICKED, &MyFrame::button_section, this, ibutton_section);
gbsizer->Add(new wxButton(panel, ibutton_section, wxT("Section file")),
wxGBPosition(19, 1), wxGBSpan(1, 1));
wxGBPosition(17, 3), wxGBSpan(1, 1));

wxString choices_light[] = { wxT("Both"), wxT("Unoccupy"), wxT("Occupy") };
Bind(wxEVT_COMMAND_RADIOBOX_SELECTED, &MyFrame::radio_lighting, this, iradio_lighting);
gbsizer->Add(new wxRadioBox(panel, iradio_lighting, wxT("Lighting"),
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(choices_light), choices_light,
1, wxRA_SPECIFY_COLS), wxGBPosition(16, 2), wxGBSpan(4, 1));
1, wxRA_SPECIFY_COLS), wxGBPosition(15, 0), wxGBSpan(4, 1));

wxString choices_BarColor[] = { wxT("BGR"), wxT("CMY"), wxT("MCY")};
Bind(wxEVT_COMMAND_RADIOBOX_SELECTED, &MyFrame::radio_BarColor, this, iradio_BarColor);
gbsizer->Add(new wxRadioBox(panel, iradio_BarColor, wxT("Bar Color"),
wxDefaultPosition, wxDefaultSize,
WXSIZEOF(choices_BarColor), choices_BarColor,
1, wxRA_SPECIFY_COLS), wxGBPosition(16, 3), wxGBSpan(4, 1));
1, wxRA_SPECIFY_COLS), wxGBPosition(15, 1), wxGBSpan(4, 1));

gbsizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Section (RGB) : ")),
wxGBPosition(19, 0), wxGBSpan(1, 1), wxALIGN_RIGHT);
Bind(wxEVT_COMMAND_TEXT_UPDATED, &MyFrame::textctrl_Section, this, itext_SectionR);
textbox_SectionR = new wxTextCtrl(panel, itext_SectionR, wxT(""));
gbsizer->Add(textbox_SectionR, wxGBPosition(19, 1), wxGBSpan(1, 1));
Bind(wxEVT_COMMAND_TEXT_UPDATED, &MyFrame::textctrl_Section, this, itext_SectionG);
textbox_SectionG = new wxTextCtrl(panel, itext_SectionG, wxT(""));
gbsizer->Add(textbox_SectionG, wxGBPosition(19, 2), wxGBSpan(1, 1));
Bind(wxEVT_COMMAND_TEXT_UPDATED, &MyFrame::textctrl_Section, this, itext_SectionB);
textbox_SectionB = new wxTextCtrl(panel, itext_SectionB, wxT(""));
gbsizer->Add(textbox_SectionB, wxGBPosition(19, 3), wxGBSpan(1, 1));
textbox_SectionR->ChangeValue(wxT("0.5"));
textbox_SectionG->ChangeValue(wxT("0.5"));
textbox_SectionB->ChangeValue(wxT("0.5"));

SetSizer(sizermain);
SetAutoLayout(true);
Expand All @@ -966,19 +1046,56 @@ void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
}

void MyFrame::modify_band() {
int ib, width, height;
int ib, width, height, j;
wxCheckBox** check;
wxTextCtrl** textbox_BandR, ** textbox_BandG, ** textbox_BandB;
GLfloat mat2;

radiobox_color->SetSelection(color_scale - 1);

check = new wxCheckBox * [nb];
textbox_BandR = new wxTextCtrl * [nb];
textbox_BandG = new wxTextCtrl * [nb];
textbox_BandB = new wxTextCtrl * [nb];

for (ib = 0; ib < nb; ib++) {
Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &MyFrame::check_band, this, icheck_band + ib);
check[ib] = new wxCheckBox(panel, icheck_band + ib,
wxString::Format(wxT("Band %d"), ib));
gbsizer->Add(check[ib], wxGBPosition(14 + ib, 0), wxGBSpan(1, 1));
Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &MyFrame::check_band, this, icheck_band + 4*ib);
check[ib] = new wxCheckBox(panel, icheck_band + 4*ib,
wxString::Format(wxT("Band %d, RGB :"), ib));
gbsizer->Add(check[ib], wxGBPosition(20 + ib, 0), wxGBSpan(1, 1));
check[ib]->SetValue(true);

if (nb == 1) mat2 = 0.5f;
else mat2 = 1.0f / (GLfloat)(nb - 1) * (GLfloat)ib;
mat2 *= 4.0f;
if (mat2 <= 1.0) {
for (j = 0; j < 4; ++j) rgb_band[ib][j] = cyan[j] * mat2 + blue[j] * (1.0f - mat2);
}
else if (mat2 <= 2.0) {
mat2 = mat2 - 1.0f;
for (j = 0; j < 4; ++j) rgb_band[ib][j] = green[j] * mat2 + cyan[j] * (1.0f - mat2);
}
else if (mat2 <= 3.0) {
mat2 = mat2 - 2.0f;
for (j = 0; j < 4; ++j) rgb_band[ib][j] = yellow[j] * mat2 + green[j] * (1.0f - mat2);
}
else {
mat2 = mat2 - 3.0f;
for (j = 0; j < 4; ++j) rgb_band[ib][j] = red[j] * mat2 + yellow[j] * (1.0f - mat2);
}

Bind(wxEVT_COMMAND_TEXT_UPDATED, &MyFrame::textctrl_Band, this, icheck_band + 4 * ib+1);
textbox_BandR[ib] = new wxTextCtrl(panel, icheck_band + 4 * ib+1, wxT(""));
gbsizer->Add(textbox_BandR[ib], wxGBPosition(20 + ib, 1), wxGBSpan(1, 1));
Bind(wxEVT_COMMAND_TEXT_UPDATED, &MyFrame::textctrl_Band, this, icheck_band + 4 * ib+2);
textbox_BandG[ib] = new wxTextCtrl(panel, icheck_band + 4 * ib+2, wxT(""));
gbsizer->Add(textbox_BandG[ib], wxGBPosition(20 + ib, 2), wxGBSpan(1, 1));
Bind(wxEVT_COMMAND_TEXT_UPDATED, &MyFrame::textctrl_Band, this, icheck_band + 4 * ib+3);
textbox_BandB[ib] = new wxTextCtrl(panel, icheck_band + 4 * ib+3, wxT(""));
gbsizer->Add(textbox_BandB[ib], wxGBPosition(20 + ib, 3), wxGBSpan(1, 1));
textbox_BandR[ib]->ChangeValue(wxString::Format(wxT("%f"), rgb_band[ib][0]));
textbox_BandG[ib]->ChangeValue(wxString::Format(wxT("%f"), rgb_band[ib][1]));
textbox_BandB[ib]->ChangeValue(wxString::Format(wxT("%f"), rgb_band[ib][2]));
}
gbsizer->Layout();
if (lbatch == 1) {
Expand Down
5 changes: 5 additions & 0 deletions src/menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class MyFrame : public wxFrame
wxTextCtrl* textbox_BZ_number0;
wxTextCtrl* textbox_BZ_number1;
wxTextCtrl* textbox_BZ_number2;
wxTextCtrl* textbox_SectionR;
wxTextCtrl* textbox_SectionG;
wxTextCtrl* textbox_SectionB;

private:
void OnExit(wxCommandEvent& event);
Expand All @@ -96,6 +99,8 @@ class MyFrame : public wxFrame
void radio_BarColor(wxCommandEvent& event);
void button_section(wxCommandEvent& event);
void textctrl_BZ_number(wxCommandEvent& event);
void textctrl_Section(wxCommandEvent& event);
void textctrl_Band(wxCommandEvent& event);
//wxDECLARE_EVENT_TABLE();
};

Expand Down
6 changes: 5 additions & 1 deletion src/read_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ int ng0[3]
n2d = new int[nb];
nequator = new int[nb];
draw_band = new int[nb];
for (ib = 0; ib < nb; ib++) draw_band[ib] = 1;
rgb_band = new GLfloat *[nb];
for (ib = 0; ib < nb; ib++) {
draw_band[ib] = 1;
rgb_band[ib] = new GLfloat [4];
}

scl /= sqrtf(bvec[0][0] * bvec[0][0] + bvec[0][1] * bvec[0][1] + bvec[0][2] * bvec[0][2]);
linewidth /= scl;
Expand Down
2 changes: 2 additions & 0 deletions src/variable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ extern int nbragg; //!< Number of Bragg plane og 1st BZ
*/
extern int *ntri; //!< The number of triangle patch [::nb]
extern int *draw_band; //!< Switch for drawn bands [::nb]
extern GLfloat** rgb_band; //!< Switch for drawn bands [::nb]
extern GLfloat ****nmlp; //!< Normal vector of patchs [::nb][::ntri][3][3]
extern GLfloat***** arw;
extern GLfloat ****kvp; //!< @f$k@f$-vectors of points [::nb][::ntri][3][3]
Expand Down Expand Up @@ -152,6 +153,7 @@ extern GLfloat green[4]; //!< Green color code
extern GLfloat blue[4]; //!< Blue color code
extern GLfloat BackGroundColor[4];//!< Background color code
extern GLfloat LineColor[4];//!< Line color code
extern GLfloat SectionColor[4];//!< Line color code
extern GLfloat BarColor[5][4];
/*
Others
Expand Down

0 comments on commit b5e1012

Please sign in to comment.