(m_SelectedIDs.begin(), m_SelectedIDs.end());
60m_SelectedIDs.erase(std::unique(m_SelectedIDs.begin(), m_SelectedIDs.end()),
66 if(sel_set->
HasField(
"selection-name") &&
70 if(sel_set->
HasField(
"color-red") && sel_set->
HasField(
"color-green") && sel_set->
HasField(
"color-blue") &&
78 if(sel_set->
HasField(
"selected") &&
82 if(sel_set->
HasField(
"cluster-id") &&
86 if(sel_set->
HasField(
"selection-ids") &&
90m_SelectedIDs.clear();
91 for(
size_t i= 0;
i<node_ids.size(); ++
i) {
92m_SelectedIDs.push_back(node_ids[
i]);
104uo_id->
SetStr(
"selection-set");
107uo_sel_set->
AddField(
"selection-name", GetName());
111uo_sel_set->
AddField(
"selected", GetSelected());
112uo_sel_set->
AddField(
"cluster-id", GetClusterID());
115vector<int> selected;
116 for(
size_tj = 0; j<GetSelectionSet().size(); ++j)
117selected.push_back(
int(GetSelectionSet()[j]));
119uo_sel_set->
AddField(
"selection-ids", selected);
129 for(
size_t i= 0;
i< m_SelectionSets.size(); ++
i) {
140 if(uo.
HasField(
"selection-sets") &&
144m_SelectionSets.resize(sel_sets.size());
145 for(
size_t i= 0;
i< sel_sets.size(); ++
i) {
146m_SelectionSets[
i].InitFromUserObject(sel_sets[
i]);
149x_SyncSelectionSets(tree_model);
151SetSelectionSetProperty(tree_model);
157 if(uo.
HasField(
"selection-sets")) {
158CUser_object::TData::iterator it = uo.
SetData().begin();
159 while(it != uo.
SetData().end()) {
160 if((*it)->IsSetLabel() && (*it)->GetLabel().IsStr() &&
161(*it)->GetLabel().GetStr() ==
"selection-sets") {
169 if(m_SelectionSets.size() > 0) {
172vector< CRef<CUser_object> > uo_sets;
174 for(
size_t i= 0;
i< m_SelectionSets.size(); ++
i) {
177uo_sets.push_back(uo_sel_set);
179uo.
AddField(
"selection-sets", uo_sets);
185 for(
auto& sel_set : m_SelectionSets) {
186sel_set.RemoveDuplicateIDs();
194 for(
size_t i= 0;
i<m_SelectionSets.size(); ++
i) {
195 if(m_SelectionSets[
i].GetSelected()) {
196 int id= m_SelectionSets[
i].GetClusterID();
197cluster_id_to_selection_map[id] =
i;
201 returncluster_id_to_selection_map;
208 size_tnum_nodes = tree_model->
GetSize();
216 for(
size_t i= 0;
i<num_nodes; ++
i) {
220 if(
n.GetValue().HasSelClusters())
221 n.GetValue().GetSelClusters().clear();
222 n.GetValue().GetBioTreeFeatureList().RemoveFeature(sel_feat_id);
225 stringcid =
n.GetValue().GetBioTreeFeatureList().GetFeatureValue(cluster_id);
229 if(sel_id || errno == 0)
232 n.GetValue().SetClusterID(cluster_id);
233 n.GetValue().SetClusterColorIdx(-1);
237 if(
n.GetValue().HasNodeMarker())
238 n.GetValue().GetMarkerColors().clear();
239 const string& marker =
n.GetValue().GetBioTreeFeatureList().GetFeatureValue(marker_feat_id);
241 if(!marker.empty()) {
242 n.GetValue().SetMarkerColors(marker);
245 catch(std::exception&){}
251 for(
size_t i= 0;
i<m_SelectionSets.size(); ++
i) {
252 if(m_SelectionSets[
i].GetSelected()) {
253 intcluster_id = m_SelectionSets[
i].GetClusterID();
257 for(
size_tj = 0; j<m_SelectionSets[
i].GetSelectionSet().
size(); ++j) {
258objects::CNode::TId node_id = m_SelectionSets[
i].GetSelectionSet()[j];
269 if(sel_clusters.length() > 0)
270sel_clusters +=
" ";
281 for(
size_t i= 0;
i< m_SelectionSets.size(); ++
i) {
282 if(m_SelectionSets[
i].GetName() == set_name) {
292 size_tset_idx = GetSelectionSet(set_name);
294 if(set_idx !=
size_t(-1))
295 returnm_SelectionSets[set_idx];
297vector<CRgbaColor> current_colors;
298 intmax_cluster_id = 500;
299 for(
size_t i= 0;
i< m_SelectionSets.size(); ++
i) {
300current_colors.push_back(m_SelectionSets[
i].
GetColor());
301max_cluster_id =
std::max(m_SelectionSets[
i].GetClusterID(), max_cluster_id);
306vector<objects::CNode::TId> ids;
311m_SelectionSets.push_back(new_set);
312 returnm_SelectionSets[m_SelectionSets.size() - 1];
317 size_tset_idx = GetSelectionSet(set_name);
319 if(set_idx !=
size_t(-1))
320 returnm_SelectionSets[set_idx];
322vector<objects::CNode::TId> ids;
326m_SelectionSets.push_back(new_set);
327 returnm_SelectionSets[m_SelectionSets.size() - 1];
335 floatnum_colors = (float)current_colors.size();
336 floatcolor_step = num_colors ? (180.0f / num_colors) : 0;
337 floatrotate_angle = color_step + 100.0f;
339 floatmax_color_dist = 0.0f;
344 for(
size_t i= 0;
i< 2 * current_colors.size(); ++
i) {
347 while(c_dist < 0.7f) {
352 floatmin_color_dist = 1e10f;
355 for(
size_tj = 0; j < current_colors.size(); ++j) {
357 if(dist < min_color_dist) {
358min_color_dist = dist;
364 if(min_color_dist > max_color_dist) {
365max_color_dist = min_color_dist;
383 for(
size_t i= 0;
i<m_SelectionSets.size(); ++
i) {
385vector<objects::CNode::TId> selected = m_SelectionSets[
i].GetSelectionSet();
386m_SelectionSets[
i].GetSelectionSet().clear();
388 for(
size_tj = 0; j<selected.size(); ++j) {
389objects::CNode::TId node_id = selected[j];
393m_SelectionSets[
i].GetSelectionSet().push_back(node_id);
398vector<CPhyloSelectionSet> selection_sets = m_SelectionSets;
399m_SelectionSets.clear();
401 for(
size_t i= 0;
i<selection_sets.size(); ++
i) {
402 if(selection_sets[
i].GetSelectionSet().
size() > 0) {
403m_SelectionSets.push_back(selection_sets[
i]);
412sel_set->SetClusterID(start_id--);
TSelClusterIDs & GetSelClusters()
CBioTreeFeatureList & GetBioTreeFeatureList()
void InitFromUserObject(CPhyloTree *tree_model, const objects::CBioTreeContainer_Base::TUser &uo)
CRgbaColor PickBestColor(const vector< CRgbaColor > ¤t_colors)
void SetSelectionSetProperty(CPhyloTree *tree_model)
void RenumberClusterIDs(int start_id)
Update all cluster ids using the starting-id as the lowest value.
void SaveToUserObject(objects::CBioTreeContainer_Base::TUser &uo)
size_t GetSelectionSet(const string &set_name)
Returns size_t(-1) if the name set_name is not an existing selection set.
map< int, size_t > GetClusterToSelectionMap()
CPhyloSelectionSet & AddSet(const string &set_name)
Add the new set set_name and return it. If it already exists, just return it.
void RemoveDuplicateIDs()
Remove duplicate IDs from individual sets.
void x_SyncSelectionSets(CPhyloTree *tree_model)
bool operator==(const CPhyloSelectionSetMgr &rhs) const
vector< CPhyloSelectionSet > m_SelectionSets
void SetColor(const CRgbaColor &c)
CRef< objects::CUser_object > SaveToUserObject() const
void SetClusterID(int cid)
CRgbaColor m_SelectionColor
void InitFromUserObject(CRef< objects::CUser_object > sel_set)
vector< objects::CNode::TId > m_SelectedIDs
bool operator==(const CPhyloSelectionSet &rhs) const
call RemoveDuplicateIDs first which sorts and removes dups
void RemoveDuplicateIDs()
remove duplicates form m_SelectedIDs. should be called before operator==
Tree subclass also has functions and data needed for rendering and selection.
TTreeIdx FindNodeById(TID id) const
Return index of the node with the given id or Null().
CBioTreeFeatureDictionary & GetFeatureDict()
Return feature dictionary.
class CRgbaColor provides a simple abstraction for managing colors.
TData & GetValue()
Return the value object for the node.
static TTreeIdx Null()
Return the index value that represents a NULL node.
size_t GetSize() const
Get the number of nodes currently in the array.
TNodeType & GetNode(TTreeIdx idx)
Return a reference to the node at the given index.
bool HasField(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase) const
Verify that a named field exists.
CUser_object & AddField(const string &label, const string &value, EParseField parse=eParse_String)
add a data field to the user object that holds a given value
const CUser_field & GetField(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase) const
Access a named field in this user object.
CRgbaColor & GetColor(CSeqFeatData::ESubtype subtype)
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
static CRgbaColor RotateColor(const CRgbaColor &c, float degrees)
Rotate the hue of the color by degrees.
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,...
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
@ fConvErr_NoThrow
Do not throw an exception on error.
unsigned int TBioTreeFeatureId
Feature Id.
void SetFeature(TBioTreeFeatureId id, const string &value)
Set feature value, feature if exists replaced, if not added.
TBioTreeFeatureId Register(const string &feature_name)
Register new feature, return its id.
const string & GetFeatureValue(TBioTreeFeatureId id) const
Get feature value by id.
const TStr & GetStr(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
TBool GetBool(void) const
Get the variant data.
bool IsInt(void) const
Check if variant Int is selected.
bool IsStr(void) const
Check if variant Str is selected.
TData & SetData(void)
Assign a value to Data data member.
TInt GetInt(void) const
Get the variant data.
TStr & SetStr(void)
Select the variant.
bool IsInts(void) const
Check if variant Ints is selected.
bool IsObjects(void) const
Check if variant Objects is selected.
TReal GetReal(void) const
Get the variant data.
void SetType(TType &value)
Assign a value to Type data member.
bool IsReal(void) const
Check if variant Real is selected.
bool IsBool(void) const
Check if variant Bool is selected.
const TInts & GetInts(void) const
Get the variant data.
const TObjects & GetObjects(void) const
Get the variant data.
constexpr auto sort(_Init &&init)
const struct ncbi::grid::netcache::search::fields::SIZE size
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4