20 #include "data/model/SparseOneDimensionalModel.h" 37 setObjectName(tr(
"AlignmentView"));
43 #ifdef DEBUG_ALIGNMENT_VIEW 44 SVCERR <<
"AlignmentView " <<
getId() <<
"::keyFramesChanged" << endl;
96 disconnect(
m_above,
nullptr,
this,
nullptr);
123 disconnect(
m_below,
nullptr,
this,
nullptr);
157 #ifdef DEBUG_ALIGNMENT_VIEW 158 SVCERR <<
"AlignmentView " <<
getId() <<
"::paintEvent" << endl;
161 bool darkPalette =
false;
173 QPainter paint(
this);
174 paint.setPen(QPen(fg, 2));
175 paint.setBrush(Qt::NoBrush);
176 paint.setRenderHint(QPainter::Antialiasing,
true);
178 paint.fillRect(rect(), bg);
187 #ifdef DEBUG_ALIGNMENT_VIEW 188 SVCERR <<
"AlignmentView " <<
getId() <<
"::paintEvent: painting " 197 #ifdef DEBUG_ALIGNMENT_VIEW 199 <<
", we have a relationship with the pane above us: showing " 200 <<
"mappings in relation to that" << endl;
205 sv_frame_t af = km.first;
206 sv_frame_t bf = km.second;
209 #ifdef DEBUG_ALIGNMENT_VIEW 210 SVCERR <<
"AlignmentView: af " << af <<
" < m_leftmostAbove " <<
m_leftmostAbove << endl;
215 #ifdef DEBUG_ALIGNMENT_VIEW 216 SVCERR <<
"AlignmentView: af " << af <<
" > m_rightmostAbove " <<
m_rightmostAbove << endl;
224 if (ax >= 0 || ax < w || bx >= 0 || bx < w) {
225 paint.drawLine(ax, 0, bx, h);
232 #ifdef DEBUG_ALIGNMENT_VIEW 234 <<
", we have no relationship with the pane above us: showing " 235 <<
"mappings in relation to the reference instead" << endl;
240 sv_frame_t af = km.first;
241 sv_frame_t bf = km.second;
246 if (ax >= 0 || ax < w || bx >= 0 || bx < w) {
247 paint.drawLine(ax, 0, bx, h);
258 vector<ModelId> toConnect {
263 for (
auto modelId: toConnect) {
264 if (
auto model = ModelById::get(modelId)) {
265 auto referenceId = model->getAlignmentReference();
266 if (!referenceId.isNone()) {
267 toConnect.push_back(referenceId);
272 for (
auto modelId: toConnect) {
273 if (
auto model = ModelById::get(modelId)) {
274 auto ptr = model.get();
275 disconnect(ptr, 0,
this, 0);
278 connect(ptr, SIGNAL(completionChanged(ModelId)),
280 connect(ptr, SIGNAL(alignmentCompletionChanged(ModelId)),
289 #ifdef DEBUG_ALIGNMENT_VIEW 290 SVCERR <<
"AlignmentView " <<
getId() <<
"::buildMaps" << endl;
293 sv_frame_t resolution = 1;
295 set<sv_frame_t> keyFramesBelow;
297 keyFramesBelow.insert(f);
300 foreach(sv_frame_t f, keyFramesBelow) {
317 sv_frame_t prevAf = -1;
318 sv_frame_t prevBf = -1;
320 foreach (sv_frame_t af, keyFrames) {
325 if (prevBf > 0 && bf > prevBf) {
334 bool mappedSomething =
false;
336 if (resolution > 1) {
337 if (keyFramesBelow.find(bf) == keyFramesBelow.end()) {
339 sv_frame_t af1 = af + resolution;
343 for (sv_frame_t probe = bf + 1; probe <= bf1; ++probe) {
344 if (keyFramesBelow.find(probe) != keyFramesBelow.end()) {
346 mappedSomething =
true;
352 if (!mappedSomething) {
357 #ifdef DEBUG_ALIGNMENT_VIEW 358 SVCERR <<
"AlignmentView " <<
getId() <<
"::buildMaps: have " 373 auto model = ModelById::getAs<SparseOneDimensionalModel>(m);
378 resolution = model->getResolution();
380 vector<sv_frame_t> keyFrames;
382 EventVector pp = model->getAllEvents();
383 for (EventVector::const_iterator pi = pp.begin(); pi != pp.end(); ++pi) {
384 keyFrames.push_back(pi->getFrame());
393 vector<sv_frame_t> keyFrames;
400 if (rate == 0)
return keyFrames;
404 f += sv_frame_t(rate * 5 + 0.5)) {
405 keyFrames.push_back(f);
419 if (qobject_cast<TimeInstantLayer *>(view->
getLayer(i))) {
421 if (ModelById::isa<SparseOneDimensionalModel>(mm)) {
sv_frame_t alignFromReference(sv_frame_t) const
sv_frame_t m_leftmostAbove
void viewManagerPlaybackFrameChanged(sv_frame_t) override
bool getGlobalDarkBackground() const
virtual void viewAboveZoomLevelChanged(ZoomLevel, bool)
int getId() const override
Retrieve the id of this object.
virtual int getLayerCount() const
Return the number of layers, regardless of whether visible or dormant, i.e.
virtual void modelChanged(ModelId)
sv_frame_t alignToReference(sv_frame_t) const
sv_samplerate_t getMainModelSampleRate() const
The sample rate of the current main model.
void propertyContainerAdded(PropertyContainer *pc)
void viewCentreFrameChanged(View *, sv_frame_t) override
void setBelowView(View *view)
std::multimap< sv_frame_t, sv_frame_t > m_fromReferenceMap
virtual Layer * getLayer(int n)
Return the nth layer, counted in stacking order.
ModelId getSalientModel(View *)
void globalCentreFrameChanged(sv_frame_t) override
sv_frame_t getModelsStartFrame() const override
AlignmentView(QWidget *parent=0)
View is the base class of widgets that display one or more overlaid views of data against a horizonta...
void setReferenceView(View *view)
sv_frame_t m_rightmostAbove
virtual ModelId getModel() const =0
Return the ID of the model represented in this layer.
sv_frame_t getModelsEndFrame() const override
void paintEvent(QPaintEvent *e) override
virtual void viewCentreFrameChanged(View *, sv_frame_t)
std::vector< sv_frame_t > getKeyFrames(View *, sv_frame_t &resolution)
std::multimap< sv_frame_t, sv_frame_t > m_fromAboveMap
void zoomLevelChanged(ZoomLevel level, bool locked)
void setAboveView(View *view)
virtual void globalCentreFrameChanged(sv_frame_t)
std::vector< sv_frame_t > getDefaultKeyFrames()
int getXForFrame(sv_frame_t frame) const override
Return the pixel x-coordinate corresponding to a given sample frame.
virtual void viewBelowZoomLevelChanged(ZoomLevel, bool)