Mercurial > hg > svgui
comparison layer/Colour3DPlotLayer.cpp @ 1471:f2525e6cbdf1 by-id
More layer updates
author | Chris Cannam |
---|---|
date | Mon, 01 Jul 2019 14:17:13 +0100 |
parents | 11a150e65ee1 |
children | 886c1cd48f9d |
comparison
equal
deleted
inserted
replaced
1470:696e569ff21b | 1471:f2525e6cbdf1 |
---|---|
141 } | 141 } |
142 | 142 |
143 void | 143 void |
144 Colour3DPlotLayer::setModel(ModelId modelId) | 144 Colour3DPlotLayer::setModel(ModelId modelId) |
145 { | 145 { |
146 SVDEBUG << "Colour3DPlotLayer::setModel(" << modelId << ")" << endl; | 146 auto newModel = ModelById::getAs<DenseThreeDimensionalModel>(modelId); |
147 | 147 |
148 if (!modelId.isNone() && !newModel) { | |
149 throw std::logic_error("Not a DenseThreeDimensionalModel"); | |
150 } | |
151 | |
148 if (m_model == modelId) return; | 152 if (m_model == modelId) return; |
149 | |
150 auto model = ModelById::getAs<DenseThreeDimensionalModel>(modelId); | |
151 if (!model) throw std::logic_error("Not a DenseThreeDimensionalModel"); | |
152 | |
153 //!!! const DenseThreeDimensionalModel *oldModel = m_model; | |
154 m_model = modelId; | 153 m_model = modelId; |
155 | 154 |
156 connectSignals(m_model); | 155 if (newModel) { |
157 | 156 connectSignals(m_model); |
158 connect(model.get(), SIGNAL(modelChanged()), | 157 |
159 this, SLOT(handleModelChanged())); | 158 connect(newModel.get(), SIGNAL(modelChanged()), |
160 connect(model.get(), SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), | 159 this, SLOT(handleModelChanged())); |
161 this, SLOT(handleModelChangedWithin(sv_frame_t, sv_frame_t))); | 160 connect(newModel.get(), SIGNAL(modelChangedWithin(sv_frame_t, sv_frame_t)), |
162 | 161 this, SLOT(handleModelChangedWithin(sv_frame_t, sv_frame_t))); |
163 m_peakResolution = 256; | 162 |
164 if (model->getResolution() > 512) { | 163 m_peakResolution = 256; |
165 m_peakResolution = 16; | 164 if (newModel->getResolution() > 512) { |
166 } else if (model->getResolution() > 128) { | 165 m_peakResolution = 16; |
167 m_peakResolution = 64; | 166 } else if (newModel->getResolution() > 128) { |
168 } else if (model->getResolution() > 2) { | 167 m_peakResolution = 64; |
169 m_peakResolution = 128; | 168 } else if (newModel->getResolution() > 2) { |
170 } | 169 m_peakResolution = 128; |
171 | 170 } |
171 } | |
172 | |
172 invalidatePeakCache(); | 173 invalidatePeakCache(); |
173 | 174 |
174 emit modelReplaced(); | 175 emit modelReplaced(); |
175 //!!! emit sliceableModelReplaced(oldModel, model); | 176 //!!! emit sliceableModelReplaced(oldModel, model); |
176 } | 177 } |
898 Colour3DPlotLayer::getVerticalScaleWidth(LayerGeometryProvider *, bool, QPainter &paint) const | 899 Colour3DPlotLayer::getVerticalScaleWidth(LayerGeometryProvider *, bool, QPainter &paint) const |
899 { | 900 { |
900 auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_model); | 901 auto model = ModelById::getAs<DenseThreeDimensionalModel>(m_model); |
901 if (!model) return 0; | 902 if (!model) return 0; |
902 | 903 |
904 // Qt 5.13 deprecates QFontMetrics::width(), but its suggested | |
905 // replacement (horizontalAdvance) was only added in Qt 5.11 which | |
906 // is too new for us | |
907 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | |
908 | |
903 QString sampleText = QString("[%1]").arg(model->getHeight()); | 909 QString sampleText = QString("[%1]").arg(model->getHeight()); |
904 int tw = paint.fontMetrics().width(sampleText); | 910 int tw = paint.fontMetrics().width(sampleText); |
905 bool another = false; | 911 bool another = false; |
906 | 912 |
907 for (int i = 0; i < model->getHeight(); ++i) { | 913 for (int i = 0; i < model->getHeight(); ++i) { |
957 paint.setFont(font); | 963 paint.setFont(font); |
958 } | 964 } |
959 | 965 |
960 int msw = paint.fontMetrics().width(maxstr); | 966 int msw = paint.fontMetrics().width(maxstr); |
961 | 967 |
962 QMatrix m; | 968 QTransform m; |
963 m.translate(cw - 6, ch + 10); | 969 m.translate(cw - 6, ch + 10); |
964 m.rotate(-90); | 970 m.rotate(-90); |
965 | 971 |
966 paint.setWorldMatrix(m); | 972 paint.setWorldTransform(m); |
967 | 973 |
968 PaintAssistant::drawVisibleText(v, paint, 2, 0, minstr, PaintAssistant::OutlinedText); | 974 PaintAssistant::drawVisibleText(v, paint, 2, 0, minstr, |
975 PaintAssistant::OutlinedText); | |
969 | 976 |
970 m.translate(ch - msw - 2, 0); | 977 m.translate(ch - msw - 2, 0); |
971 paint.setWorldMatrix(m); | 978 paint.setWorldTransform(m); |
972 | 979 |
973 PaintAssistant::drawVisibleText(v, paint, 0, 0, maxstr, PaintAssistant::OutlinedText); | 980 PaintAssistant::drawVisibleText(v, paint, 0, 0, maxstr, |
981 PaintAssistant::OutlinedText); | |
974 | 982 |
975 paint.restore(); | 983 paint.restore(); |
976 } | 984 } |
977 | 985 |
978 paint.setPen(v->getForeground()); | 986 paint.setPen(v->getForeground()); |