📄 style_dialog.cpp
字号:
ID_CONN_SHOW, ID_CONN_RENDER, ID_CONN_COLOR, ID_CONN_USER) && GetGeneralStyle(&(settings->helixObjects), ID_HELX_SHOW, ID_HELX_RENDER, ID_HELX_COLOR, ID_HELX_USER) && GetGeneralStyle(&(settings->strandObjects), ID_STRN_SHOW, ID_STRN_RENDER, ID_STRN_COLOR, ID_STRN_USER) && (checkbox = wxDynamicCast(FindWindow(ID_VSS_SHOW), wxCheckBox)) != NULL && GetChecked(checkbox, &(settings->virtualDisulfidesOn)) && (button = wxDynamicCast(FindWindow(ID_VSS_USER), wxButton)) != NULL && ConvertColor(button->GetBackgroundColour(), &(settings->virtualDisulfideColor)) && (checkbox = wxDynamicCast(FindWindow(ID_HYD_SHOW), wxCheckBox)) != NULL && GetChecked(checkbox, &(settings->hydrogensOn)) && (button = wxDynamicCast(FindWindow(ID_BG_USER), wxButton)) != NULL && ConvertColor(button->GetBackgroundColour(), &(settings->backgroundColor)) && fpSpaceFill->GetDouble(&(settings->spaceFillProportion)) && fpBallRadius->GetDouble(&(settings->ballRadius)) && fpStickRadius->GetDouble(&(settings->stickRadius)) && fpTubeRadius->GetDouble(&(settings->tubeRadius)) && fpTubeWormRadius->GetDouble(&(settings->tubeWormRadius)) && fpHelixRadius->GetDouble(&(settings->helixRadius)) && fpStrandWidth->GetDouble(&(settings->strandWidth)) && fpStrandThickness->GetDouble(&(settings->strandThickness)) && GetLabelStyle(&(settings->proteinLabels), ID_S_PROT, ID_C_PROT_TYPE, ID_C_PROT_NUM, ID_K_PROT_TERM, ID_K_PROT_CONTRAST) && GetLabelStyle(&(settings->nucleotideLabels), ID_S_NUC, ID_C_NUC_TYPE, ID_C_NUC_NUM, ID_K_NUC_TERM, ID_K_NUC_CONTRAST) && (checkbox = wxDynamicCast(FindWindow(ID_K_ION), wxCheckBox)) != NULL && GetChecked(checkbox, &(settings->ionLabelsOn)) ); if (!okay) ERRORMSG("StyleDialog::GetValues() - control/parameter mismatch: invalid style?"); return okay;}static bool SetChoiceToString(wxChoice *choice, const string& name){ int field = choice->FindString(name.c_str()); if (field < 0) return false; choice->SetSelection(field); return true;}static bool SetButtonColor(wxButton *button, const Vector& color){ if (!button) return false; wxColour wxcol( static_cast<unsigned char>((color[0] + 0.000001) * 255), static_cast<unsigned char>((color[1] + 0.000001) * 255), static_cast<unsigned char>((color[2] + 0.000001) * 255) ); // set both foreground and background colors, so that if e.g. on wxGTK themes are // used (and thus backgrounds are not user-selectable), at least the text (foreground) // color will indicate the user's color choice button->SetForegroundColour(wxcol); button->SetBackgroundColour(wxcol); return true;}bool StyleDialog::SetBackboneStyle(const StyleSettings::BackboneStyle& bbStyle, int showID, int renderID, int colorID, int userID){ string name; wxChoice *choice; wxButton *button; return ( BackboneTypeStrings.Get(bbStyle.type, &name) && (choice = wxDynamicCast(FindWindow(showID), wxChoice)) != NULL && SetChoiceToString(choice, name) && DrawingStyleStrings.Get(bbStyle.style, &name) && (choice = wxDynamicCast(FindWindow(renderID), wxChoice)) != NULL && SetChoiceToString(choice, name) && ColorSchemeStrings.Get(bbStyle.colorScheme, &name) && (choice = wxDynamicCast(FindWindow(colorID), wxChoice)) != NULL && SetChoiceToString(choice, name) && (button = wxDynamicCast(FindWindow(userID), wxButton)) != NULL && SetButtonColor(button, bbStyle.userColor) );}static bool SetChecked(wxCheckBox *checkbox, bool isChecked){ if (!checkbox) return false; checkbox->SetValue(isChecked); return true;}bool StyleDialog::SetGeneralStyle(const StyleSettings::GeneralStyle& gStyle, int showID, int renderID, int colorID, int userID){ string name; wxCheckBox *checkbox; wxChoice *choice; wxButton *button; return ( (checkbox = wxDynamicCast(FindWindow(showID), wxCheckBox)) != NULL && SetChecked(checkbox, gStyle.isOn) && DrawingStyleStrings.Get(gStyle.style, &name) && (choice = wxDynamicCast(FindWindow(renderID), wxChoice)) != NULL && SetChoiceToString(choice, name) && ColorSchemeStrings.Get(gStyle.colorScheme, &name) && (choice = wxDynamicCast(FindWindow(colorID), wxChoice)) != NULL && SetChoiceToString(choice, name) && (button = wxDynamicCast(FindWindow(userID), wxButton)) != NULL && SetButtonColor(button, gStyle.userColor) );}static bool SetInteger(wxSpinCtrl *spinctrl, int value){ if (!spinctrl) return false; spinctrl->SetValue(value); return true;}bool StyleDialog::SetLabelStyle(const StyleSettings::LabelStyle& lStyle, int spacingID, int typeID, int numberingID, int terminiID, int whiteID){ string name; wxSpinCtrl *spinctrl; wxCheckBox *checkbox; wxChoice *choice; return ( (spinctrl = wxDynamicCast(FindWindow(spacingID), wxSpinCtrl)) != NULL && SetInteger(spinctrl, lStyle.spacing) && LabelTypeStrings.Get(lStyle.type, &name) && (choice = wxDynamicCast(FindWindow(typeID), wxChoice)) != NULL && SetChoiceToString(choice, name) && NumberTypeStrings.Get(lStyle.numbering, &name) && (choice = wxDynamicCast(FindWindow(numberingID), wxChoice)) != NULL && SetChoiceToString(choice, name) && (checkbox = wxDynamicCast(FindWindow(terminiID), wxCheckBox)) != NULL && SetChecked(checkbox, lStyle.terminiOn) && (checkbox = wxDynamicCast(FindWindow(whiteID), wxCheckBox)) != NULL && SetChecked(checkbox, lStyle.white) );}bool StyleDialog::SetControls(const StyleSettings& settings){ wxCheckBox *checkbox; wxButton *button; bool okay = ( SetBackboneStyle(settings.proteinBackbone, ID_PBB_SHOW, ID_PBB_RENDER, ID_PBB_COLOR, ID_PBB_USER) && SetGeneralStyle(settings.proteinSidechains, ID_PSIDE_SHOW, ID_PSIDE_RENDER, ID_PSIDE_COLOR, ID_PSIDE_USER) && SetBackboneStyle(settings.nucleotideBackbone, ID_NUC_SHOW, ID_NUC_RENDER, ID_NUC_COLOR, ID_NUC_USER) && SetGeneralStyle(settings.nucleotideSidechains, ID_NSIDE_SHOW, ID_NSIDE_RENDER, ID_NSIDE_COLOR, ID_NSIDE_USER) && SetGeneralStyle(settings.heterogens, ID_HET_SHOW, ID_HET_RENDER, ID_HET_COLOR, ID_HET_USER) && SetGeneralStyle(settings.solvents, ID_SOLV_SHOW, ID_SOLV_RENDER, ID_SOLV_COLOR, ID_SOLV_USER) && SetGeneralStyle(settings.connections, ID_CONN_SHOW, ID_CONN_RENDER, ID_CONN_COLOR, ID_CONN_USER) && SetGeneralStyle(settings.helixObjects, ID_HELX_SHOW, ID_HELX_RENDER, ID_HELX_COLOR, ID_HELX_USER) && SetGeneralStyle(settings.strandObjects, ID_STRN_SHOW, ID_STRN_RENDER, ID_STRN_COLOR, ID_STRN_USER) && (checkbox = wxDynamicCast(FindWindow(ID_VSS_SHOW), wxCheckBox)) != NULL && SetChecked(checkbox, settings.virtualDisulfidesOn) && (button = wxDynamicCast(FindWindow(ID_VSS_USER), wxButton)) != NULL && SetButtonColor(button, settings.virtualDisulfideColor) && (checkbox = wxDynamicCast(FindWindow(ID_HYD_SHOW), wxCheckBox)) != NULL && SetChecked(checkbox, settings.hydrogensOn) && (button = wxDynamicCast(FindWindow(ID_BG_USER), wxButton)) != NULL && SetButtonColor(button, settings.backgroundColor) && fpSpaceFill->SetDouble(settings.spaceFillProportion) && fpBallRadius->SetDouble(settings.ballRadius) && fpStickRadius->SetDouble(settings.stickRadius) && fpTubeRadius->SetDouble(settings.tubeRadius) && fpTubeWormRadius->SetDouble(settings.tubeWormRadius) && fpHelixRadius->SetDouble(settings.helixRadius) && fpStrandWidth->SetDouble(settings.strandWidth) && fpStrandThickness->SetDouble(settings.strandThickness) && SetLabelStyle(settings.proteinLabels, ID_S_PROT, ID_C_PROT_TYPE, ID_C_PROT_NUM, ID_K_PROT_TERM, ID_K_PROT_CONTRAST) && SetLabelStyle(settings.nucleotideLabels, ID_S_NUC, ID_C_NUC_TYPE, ID_C_NUC_NUM, ID_K_NUC_TERM, ID_K_NUC_CONTRAST) && (checkbox = wxDynamicCast(FindWindow(ID_K_ION), wxCheckBox)) != NULL && SetChecked(checkbox, settings.ionLabelsOn) ); if (!okay) ERRORMSG("StyleDialog::SetControls() - control/parameter mismatch: invalid style?"); return okay;}// same as hitting done buttonvoid StyleDialog::OnCloseWindow(wxCloseEvent& event){ StyleSettings dummy; if (GetValues(&dummy)) { if (changedSinceApply) { *editedSettings = dummy; GlobalMessenger()->PostRedrawAllStructures(); GlobalMessenger()->PostRedrawAllSequenceViewers();// structureSet->SetDataChanged(StructureSet::eStyleData); } } else wxBell(); EndModal(wxOK);}void StyleDialog::OnButton(wxCommandEvent& event){ switch (event.GetId()) { case ID_DONE: { StyleSettings dummy; if (GetValues(&dummy)) { if (changedSinceApply) { *editedSettings = dummy; GlobalMessenger()->PostRedrawAllStructures(); GlobalMessenger()->PostRedrawAllSequenceViewers(); }// if (changedEver)// structureSet->SetDataChanged(StructureSet::eStyleData); EndModal(wxOK); } else wxBell(); break; } case ID_APPLY: { StyleSettings dummy; if (GetValues(&dummy)) { *editedSettings = dummy; GlobalMessenger()->PostRedrawAllStructures(); GlobalMessenger()->PostRedrawAllSequenceViewers(); changedSinceApply = false;// structureSet->SetDataChanged(StructureSet::eStyleData); } else wxBell(); break; } case ID_CANCEL: if (changedEver) { *editedSettings = originalSettings; GlobalMessenger()->PostRedrawAllStructures(); GlobalMessenger()->PostRedrawAllSequenceViewers(); } EndModal(wxCANCEL); break; default: if (!HandleColorButton(event.GetId())) event.Skip(); }}// return true if bID does actually correspond to a valid color buttonbool StyleDialog::HandleColorButton(int bID){ // just a filter to make sure the button pushed is really a user color button switch (bID) { case ID_PBB_USER: case ID_PSIDE_USER: case ID_NUC_USER: case ID_NSIDE_USER: case ID_HET_USER: case ID_SOLV_USER: case ID_CONN_USER: case ID_HELX_USER: case ID_STRN_USER: case ID_VSS_USER: case ID_BG_USER: break; default: return false; } wxButton *button = wxDynamicCast(FindWindow(bID), wxButton); if (!button) { ERRORMSG("StyleDialog::HandleColorButton() - can't find button of given ID"); return false; } wxColour userColor = wxGetColourFromUser(this, button->GetBackgroundColour()); if (userColor.Ok()) { button->SetBackgroundColour(userColor); wxCommandEvent fake; OnChange(fake); } return true;}void StyleDialog::OnChange(wxCommandEvent& event){ TRACEMSG("control changed"); StyleSettings tmpSettings; if (!GetValues(&tmpSettings) || !structureSet->styleManager->CheckStyleSettings(&tmpSettings) || !SetControls(tmpSettings)) { ERRORMSG("StyleDialog::OnChange() - error adjusting settings/controls"); return; } changedSinceApply = changedEver = true; if ((wxDynamicCast(FindWindow(ID_ALWAYS_APPLY), wxCheckBox))->GetValue()) { *editedSettings = tmpSettings; GlobalMessenger()->PostRedrawAllStructures(); GlobalMessenger()->PostRedrawAllSequenceViewers(); changedSinceApply = false; }}END_SCOPE(Cn3D)//////////////////////////////////////////////////////////////////////////////////////////////////// Three of four of these following functions are taken *without* modification// from wxDesigner C++ code generated from render_settings.wdr. The function LayoutDetailsPage()// is modified from wxDesigner output in order to use custom FloatingPointSpinCtrl's//////////////////////////////////////////////////////////////////////////////////////////////////wxSizer *LayoutNotebook( wxPanel *parent, bool call_fit, bool set_sizer ){ wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); wxNotebook *item2 = new wxNotebook( parent, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize, 0 ); wxNotebookSizer *item1 = new wxNotebookSizer( item2 ); wxPanel *item3 = new wxPanel( item2, -1 ); LayoutSettingsPage( item3, FALSE ); item2->AddPage( item3, "Settings" ); wxPanel *item4 = new wxPanel( item2, -1 ); LayoutLabelsPage( item4, FALSE ); item2->AddPage( item4, "Labels" ); wxPanel *item5 = new wxPanel( item2, -1 ); LayoutDetailsPage( item5, FALSE ); item2->AddPage( item5, "Details" ); item0->Add( item1, 0, wxALIGN_CENTRE|wxALL, 5 ); wxBoxSizer *item6 = new wxBoxSizer( wxHORIZONTAL ); wxButton *item7 = new wxButton( parent, ID_DONE, "Done", wxDefaultPosition, wxDefaultSize, 0 ); item7->SetDefault(); item6->Add( item7, 0, wxALIGN_CENTRE|wxALL, 5 ); wxButton *item8 = new wxButton( parent, ID_CANCEL, "Cancel", wxDefaultPosition, wxDefaultSize, 0 ); item6->Add( item8, 0, wxALIGN_CENTRE|wxALL, 5 ); item6->Add( 20, 20, 0, wxALIGN_CENTRE|wxALL, 5 ); wxStaticText *item9 = new wxStaticText( parent, ID_TEXT, "Apply after each change?", wxDefaultPosition, wxDefaultSize, 0 ); item6->Add( item9, 0, wxALIGN_CENTRE|wxALL, 5 ); wxCheckBox *item10 = new wxCheckBox( parent, ID_ALWAYS_APPLY, "", wxDefaultPosition, wxDefaultSize, 0 ); item10->SetValue( TRUE ); item6->Add( item10, 0, wxALIGN_CENTRE|wxALL, 5 ); wxButton *item11 = new wxButton( parent, ID_APPLY, "Apply", wxDefaultPosition, wxDefaultSize, 0 ); item6->Add( item11, 0, wxALIGN_CENTRE|wxALL, 5 ); item0->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 ); if (set_sizer) { parent->SetAutoLayout( TRUE ); parent->SetSizer( item0 ); if (call_fit) { item0->Fit( parent ); item0->SetSizeHints( parent ); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -