44 #include <wx/msgdlg.h>
45 #include <wx/textctrl.h>
46 #include <wx/stattext.h>
47 #include <wx/statbox.h>
49 #include <wx/clrpicker.h>
50 #include <wx/bitmap.h>
51 #include <wx/listctrl.h>
52 #include <wx/button.h>
53 #include <wx/imaglist.h>
181 Create(parent,
id, caption, pos,
size, style);
187 SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
188 wxDialog::Create( parent,
id, caption, pos,
size, style );
193 GetSizer()->SetSizeHints(
this);
198 wxImageList *il =
new wxImageList(16, 16,
true, 2);
201 m_SelList->AssignImageList(il, wxIMAGE_LIST_SMALL);
204 itemCol.SetText(
wxT(
"Select"));
205 itemCol.SetWidth(60);
208 itemCol.SetText(
wxT(
"Name"));
209 itemCol.SetWidth(370);
241 wxBoxSizer* itemBoxSizer2 =
new wxBoxSizer(wxVERTICAL);
242 itemDialog1->SetSizer(itemBoxSizer2);
244 wxStaticBox* itemStaticBoxSizer3Static =
new wxStaticBox(itemDialog1,
wxID_ANY, wxEmptyString);
245 wxStaticBoxSizer* itemStaticBoxSizer3 =
new wxStaticBoxSizer(itemStaticBoxSizer3Static, wxHORIZONTAL);
246 itemBoxSizer2->Add(itemStaticBoxSizer3, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
248 wxBoxSizer* itemBoxSizer4 =
new wxBoxSizer(wxVERTICAL);
249 itemStaticBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
251 wxBoxSizer* itemBoxSizer5 =
new wxBoxSizer(wxHORIZONTAL);
252 itemBoxSizer4->Add(itemBoxSizer5, 0, wxALIGN_LEFT|wxALL, 5);
254 m_SelList =
new wxListCtrl( itemStaticBoxSizer3->GetStaticBox(),
ID_SEL_LISTCTRL, wxDefaultPosition, wxSize(540, 200), wxLC_REPORT|wxLC_NO_SORT_HEADER|wxLC_SINGLE_SEL|wxLC_HRULES|wxLC_VRULES );
255 m_SelList->SetHelpText(
_(
"List of saved selections"));
257 m_SelList->SetToolTip(
_(
"List of saved selections"));
258 itemBoxSizer5->Add(
m_SelList, 1, wxGROW|wxALL, 5);
260 wxStaticBox* itemStaticBoxSizer7Static =
new wxStaticBox(itemStaticBoxSizer3->GetStaticBox(),
wxID_ANY,
_(
"Update Selection Name, Color or Order"));
261 wxStaticBoxSizer* itemStaticBoxSizer7 =
new wxStaticBoxSizer(itemStaticBoxSizer7Static, wxHORIZONTAL);
262 itemBoxSizer4->Add(itemStaticBoxSizer7, 0, wxALIGN_LEFT|wxALL, 5);
264 wxStaticText* itemStaticText8 =
new wxStaticText( itemStaticBoxSizer7->GetStaticBox(), wxID_STATIC,
_(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
265 itemStaticBoxSizer7->Add(itemStaticText8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);
267 m_SelectionName =
new wxTextCtrl( itemStaticBoxSizer7->GetStaticBox(),
ID_SELECTION, wxEmptyString, wxDefaultPosition, wxSize(180, -1), 0 );
269 itemStaticBoxSizer7->Add(
m_SelectionName, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
273 itemStaticBoxSizer7->Add(
m_SelColorPicker, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
275 m_ButtonUp =
new wxButton( itemStaticBoxSizer7->GetStaticBox(),
ID_BITMAPBUTTON_UP, wxEmptyString, wxDefaultPosition, wxSize(24, -1), 0 );
277 itemStaticBoxSizer7->Add(
m_ButtonUp, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
281 itemStaticBoxSizer7->Add(
m_ButtonDown, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);
285 itemStaticBoxSizer7->Add(
m_DeleteBtn, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 5);
288 itemStaticBoxSizer7->Add(
m_AddSelectionBtn, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
290 wxBoxSizer* itemBoxSizer15 =
new wxBoxSizer(wxHORIZONTAL);
291 itemBoxSizer2->Add(itemBoxSizer15, 0, wxALIGN_RIGHT|wxALL, 5);
293 wxButton* itemButton16 =
new wxButton( itemDialog1, wxID_OK,
_(
"OK"), wxDefaultPosition, wxDefaultSize, 0 );
294 itemBoxSizer15->Add(itemButton16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
338 vector<CPhyloTree::TTreeIdx> currently_selected;
340 std::sort(currently_selected.begin(), currently_selected.end());
346 vector<CPhyloTree::TTreeIdx> last_query_results;
350 vector<CPhyloTree::TTreeIdx> last_query_selection;
352 std::sort(last_query_selection.begin(), last_query_selection.end());
360 if (last_query_selection != currently_selected)
368 std::vector<CRgbaColor> current_colors;
373 if (currently_selected.size() != 0) {
387 vector<CPhyloTree::TID> currently_selected;
389 std::sort(currently_selected.begin(), currently_selected.end());
390 for (
size_t i = 0;
i < sel_sets.size(); ++
i) {
391 if (!sel_sets[
i].GetSelected())
392 current_colors.push_back(sel_sets[
i].
GetColor());
394 if (name == sel_sets[
i].GetName()) {
395 vector<CPhyloTree::TID> already_selected = sel_sets[
i].GetSelectionSet();
396 std::sort(already_selected.begin(), already_selected.end());
398 if (already_selected == currently_selected) {
422 current_colors.push_back(c);
428 float num_colors = (float)ctcmap.size();
429 float color_step = num_colors ? (180.0f / num_colors) : 0;
430 float rotate_angle = color_step + 100.0f;
432 float max_color_dist = 0.0f;
437 for (
size_t i = 0;
i < 2 * current_colors.size(); ++
i) {
440 while (c_dist < 0.7f) {
445 float min_color_dist = 1e10f;
448 for (
size_t j = 0; j < current_colors.size(); ++j) {
450 if (dist < min_color_dist) {
451 min_color_dist = dist;
457 if (min_color_dist > max_color_dist) {
458 max_color_dist = min_color_dist;
477 for (
size_t i=0;
i<sel_sets.size(); ++
i) {
480 item.SetText( sel_sets[
i].GetName() );
490 info.SetText(sel_sets[
i].GetName());
493 info.SetImage(sel_sets[
i].GetSelected() ? 1 : 0);
511 if (
m_SelList->GetSelectedItemCount() == 1) {
522 info.SetId(event.GetIndex());
523 info.m_mask = wxLIST_MASK_TEXT;
536 if (event.LeftDown())
540 if (item > -1 && (
flags & wxLIST_HITTEST_ONITEMICON))
544 info.m_mask = wxLIST_MASK_IMAGE ;
545 info.m_itemId = item;
548 is_checked = (
info.m_image == 1);
552 m_SelList->SetItemImage(item, (is_checked ? 0 : 1));
556 sel_sets[item].SetSelected((is_checked ? 0 : 1));
603 wxColour c =
event.GetColour();
621 info.m_mask = wxLIST_MASK_TEXT;
649 vector<CPhyloTree::TID> currently_selected;
651 std::sort(currently_selected.begin(), currently_selected.end());
652 int max_cluster_id = 500;
655 if (currently_selected.size() > 0) {
660 for (
size_t i=0;
i<sel_sets.size(); ++
i) {
661 vector<CPhyloTree::TID> selected = sel_sets[
i].GetSelectionSet();
662 std::sort(selected.begin(), selected.end());
663 if (selected == currently_selected) {
664 wxMessageBox(
"Current selection set is identical to existing set:\n" + sel_sets[
i].GetName(),
"Unable to Add Selection", wxOK | wxICON_WARNING);
668 if (sel_sets[
i].GetClusterID() >= max_cluster_id)
669 max_cluster_id = sel_sets[
i].GetClusterID()+1;
678 sel_sets[sel_sets.size()-1].SetColor(
CRgbaColor(c.Red(), c.Green(), c.Blue(), c.Alpha()));
680 sel_sets[sel_sets.size()-1].SetSelected(
true);
702 int max_cluster_id = -1;
705 for (
i=0;
i<
t->GetSize(); ++
i) {
706 max_cluster_id =
std::max(max_cluster_id,
t->GetNodeValue(
i).GetClusterID());
710 max_cluster_id += 500 +
t->GetSelectionSets().GetSets().size();
713 t->GetSelectionSets().RenumberClusterIDs(max_cluster_id);
void OnSelColorPickerColourPickerChanged(wxColourPickerEvent &event)
wxColourPickerCtrl * m_SelColorPicker
wxButton * m_AddSelectionBtn
void OnDeleteSelBtnClick(wxCommandEvent &event)
CRef< CPhyloTreeDataSource > m_DS
wxIcon GetIconResource(const wxString &name)
void OnLeftDown(wxMouseEvent &event)
void OnBitmapbuttonDownClick(wxCommandEvent &event)
void OnBitmapbuttonUpClick(wxCommandEvent &event)
bool Create(wxWindow *parent, wxWindowID id=10054, const wxString &caption=_("Save Selection"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
~CPhyloSaveSelectiondlg()
wxTextCtrl * m_SelectionName
void OnOkClick(wxCommandEvent &event)
wxBitmap GetBitmapResource(const wxString &name)
void OnSelListctrlSelected(wxListEvent &event)
void OnSelectionTextUpdated(wxCommandEvent &event)
void x_EnableCurrentSelection(bool b)
static bool ShowToolTips()
void SetSelections(CRef< CPhyloTreeDataSource > ds, string name)
void OnAddCurrentSelBtnClick(wxCommandEvent &event)
vector< CPhyloSelectionSet > & GetSets()
const TClusterToColorMap & GetClusterToColorMap() const
Get map that translates cluster-ids to color indices.
std::map< int, size_t > TClusterToColorMap
CPhyloSelectionSetMgr & GetSelectionSets()
CTreeGraphicsModel & GetModel()
Get model for rendering.
Tree subclass also has functions and data needed for rendering and selection.
void ClearSelection()
Sets selection state of all nodes to eNotSelected and clears m_Selected.
void GetSelectedIDs(vector< TID > &sel) const
Returns the node ids of selected nodes.
void SetSelection(TTreeIdx idx, bool sel, bool sel_children=true, bool sel_parents=true)
Select or deselect the node at the specified index and, optionally, its parents and children as well.
void GetExplicitlySelected(vector< TTreeIdx > &esel) const
Returns only indices of nodes explicitly selected, not their parents or children, i....
void GetSelected(vector< TTreeIdx > &sel) const
Returns indices of selected nodes.
class CRgbaColor provides a simple abstraction for managing colors.
CRgbaGradColorTable * GetColorTable()
Get color table used a 1D texture map for edges and nodes.
CRgbaColor & GetColor(CSeqFeatData::ESubtype subtype)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
CRgbaColor & GetColor(size_t i)
static CRgbaColor RotateColor(const CRgbaColor &c, float degrees)
Rotate the hue of the color by degrees.
unsigned char GetRedUC(void) const
Get specific channels in unsigned char values.
static float ColorDistance(const CRgbaColor &c1, const CRgbaColor &c2)
returns the distance in the RGB color cube between the two colors, scaled to a range [0,...
unsigned char GetGreenUC(void) const
unsigned char GetAlphaUC(void) const
static CRgbaColor GetColor(const string &color_type)
return a color based on a string.
unsigned char GetBlueUC(void) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
void iter_swap(Iter it1, Iter it2)
constexpr auto sort(_Init &&init)
const struct ncbi::grid::netcache::search::fields::SIZE size
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
static const char * checked_xpm[]
static const char * down_xpm[]
static const char * up_xpm[]
static const char * unchecked_xpm[]
#define ID_SEL_COLOR_PICKER
#define ID_BITMAPBUTTON_DOWN
#define ID_BITMAPBUTTON_UP
#define ID_DELETE_SEL_BTN
#define ID_ADD_CURRENT_SEL_BTN
string ToStdString(const wxString &s)