Commits
22 22 | //# 520 Edgemont Road |
23 23 | //# Charlottesville, VA 22903-2475 USA |
24 24 | //# |
25 25 | |
26 26 | |
27 27 | |
28 28 | |
29 29 | |
30 30 | |
31 31 | |
32 + | |
32 33 | |
33 34 | using namespace casacore; |
34 35 | namespace casa { |
35 36 | |
36 37 | ActionFlagAll::ActionFlagAll( Client* client ) |
37 - | : ActionTool( client ){ |
38 + | : ActionTool( client ), |
39 + | FlagActionUtil() { |
38 40 | std::cout << "ActionFlagAll instance is created" << std::endl; |
39 41 | itsType_ = TOOL_FLAG_ALL; |
42 + | |
43 + | auto plots = client->getCurrentPlots(); |
44 + | auto visibleCanv = client->currentCanvases(); |
45 + | for (auto plot = plots.begin(); plot != plots.end(); ++plot) { |
46 + | if ((*plot) == NULL) continue; |
47 + | |
48 + | auto canvases = (*plot)->canvases(); |
49 + | for (auto canv = canvases.begin(); canv != canvases.end(); ++canv) { |
50 + | |
51 + | // Only apply to visible canvases. |
52 + | // TODO: need to examine |
53 + | bool visible = false; |
54 + | for(unsigned int k= 0; !visible && k < visibleCanv.size(); k++) |
55 + | if(*canv == visibleCanv[k]) visible = true; |
56 + | if(!visible) { |
57 + | std::cout << "canvas " << (*canv)->title() << " is not visible. continue." << std::endl; |
58 + | continue; |
59 + | } |
60 + | |
61 + | std::cout << "canvas title is " << (*canv)->title() << std::endl; |
62 + | } |
63 + | } |
40 64 | } |
41 65 | |
42 66 | bool ActionFlagAll::doTool(PlotMSApp* plotms) { |
43 67 | std::cout << "ActionFlagAll::doTool" << std::endl; |
44 68 | std::cout << "toolEnabled = " << toolEnabled << std::endl; |
45 69 | |
46 70 | if (!toolEnabled) { |
47 71 | // Locate/Flag/Unflag on all visible canvases. |
48 72 | const vector<PlotMSPlot*>& plots = plotms->getPlotManager().plots(); |
49 73 | vector<PlotCanvasPtr> visibleCanv = client->currentCanvases(); |
79 103 | if(canv[j] == visibleCanv[k]) visible = true; |
80 104 | if(!visible) { |
81 105 | std::cout << "canvas " << j << " is not visible. continue." << std::endl; |
82 106 | continue; |
83 107 | } |
84 108 | |
85 109 | bool isCanvasMarkedForFlag = canv[j]->isMarkedForFlag(); |
86 110 | bool isCanvasMarkedForUnFlag = canv[j]->isMarkedForUnflag(); |
87 111 | |
88 112 | |
113 + | vector<PlotRegion> regions(1); |
114 + | regions[0] = canv[j]->axesRanges(PlotAxis::X_BOTTOM, PlotAxis::Y_LEFT); |
89 115 | if (isCanvasMarkedForFlag) { |
116 + | std::cout << "regions[0]: " << regions[0].bottom() << ", " << regions[0].left() |
117 + | << ", " << regions[0].top() << ", " << regions[0].right() << std::endl; |
118 + | // flag plotted data |
90 119 | std::cout << "canvas " << j << " is marked for flag." << std::endl; |
120 + | FlagActionUtil::flagRange(client, plot, j, regions, showUnflagged, showFlagged); |
121 + | // If this plot was flagged/unflagged, add it to the redraw |
122 + | // list. |
123 + | addRedrawPlot( plot ); |
91 124 | } else if (isCanvasMarkedForUnFlag) { |
125 + | std::cout << "regions[0]: " << regions[0].bottom() << ", " << regions[0].left() |
126 + | << ", " << regions[0].top() << ", " << regions[0].right() << std::endl; |
127 + | // unflag plotted data |
92 128 | std::cout << "canvas " << j << " is marked for unflag." << std::endl; |
129 + | FlagActionUtil::unflagRange(client, plot, j, regions, showUnflagged, showFlagged); |
130 + | // If this plot was flagged/unflagged, add it to the redraw |
131 + | // list. |
132 + | addRedrawPlot( plot ); |
93 133 | } else { |
94 134 | // get default background |
95 135 | // TODO: exclude all-flagged panels from the beginning |
96 136 | if (defaultBackground.null()) { |
97 137 | defaultBackground = canv[j]->background(); |
98 138 | } |
99 139 | } |
100 140 | } |
101 141 | } |
102 142 | |
134 174 | if(canv[j] == visibleCanv[k]) visible = true; |
135 175 | if(!visible) { |
136 176 | std::cout << "canvas " << j << " is not visible. continue." << std::endl; |
137 177 | continue; |
138 178 | } |
139 179 | if (visible) { |
140 180 | canv[j]->refresh(); |
141 181 | } |
142 182 | } |
143 183 | } |
184 + | redrawPlots(client, plot, visibleCanv); |
144 185 | } |
145 186 | |
146 187 | return true; |
147 188 | } |
148 189 | |
149 190 | ToolCode ActionFlagAll::getToolCode() const { |
150 191 | std::cout << "return FLAGALL_TOOL" << std::endl; |
151 192 | return FLAGALL_TOOL; |
152 193 | } |
153 194 | |