projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Only show sampling points when zoomed in far enough.
[pulseview.git]
/
pv
/
view
/
ruler.cpp
diff --git
a/pv/view/ruler.cpp
b/pv/view/ruler.cpp
index 6313ee5df288abfc794fdedf5f0462cf9d3715c5..be715ec104385576b3c66042325e51ddc14d982a 100644
(file)
--- a/
pv/view/ruler.cpp
+++ b/
pv/view/ruler.cpp
@@
-14,8
+14,7
@@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <extdef.h>
*/
#include <extdef.h>
@@
-33,12
+32,13
@@
using std::shared_ptr;
using std::vector;
namespace pv {
using std::vector;
namespace pv {
-namespace view {
+namespace views {
+namespace TraceView {
-const float Ruler::RulerHeight = 2.5f;
// x Text Height
+const float Ruler::RulerHeight = 2.5f; // x Text Height
const int Ruler::MinorTickSubdivision = 4;
const int Ruler::MinorTickSubdivision = 4;
-const float Ruler::HoverArrowSize = 0.5f;
// x Text Height
+const float Ruler::HoverArrowSize = 0.5f; // x Text Height
Ruler::Ruler(View &parent) :
MarginWidget(parent)
Ruler::Ruler(View &parent) :
MarginWidget(parent)
@@
-128,8
+128,7
@@
shared_ptr<ViewItem> Ruler::get_mouse_over_item(const QPoint &pt)
void Ruler::paintEvent(QPaintEvent*)
{
if (!tick_position_cache_) {
void Ruler::paintEvent(QPaintEvent*)
{
if (!tick_position_cache_) {
- auto ffunc = [this](const pv::util::Timestamp& t)
- {
+ auto ffunc = [this](const pv::util::Timestamp& t) {
return format_time_with_distance(
this->view_.tick_period(),
t,
return format_time_with_distance(
this->view_.tick_period(),
t,
@@
-138,12
+137,12
@@
void Ruler::paintEvent(QPaintEvent*)
this->view_.tick_precision());
};
this->view_.tick_precision());
};
- tick_position_cache_
.emplace(
calculate_tick_positions(
+ tick_position_cache_
=
calculate_tick_positions(
view_.tick_period(),
view_.offset(),
view_.scale(),
width(),
view_.tick_period(),
view_.offset(),
view_.scale(),
width(),
- ffunc)
)
;
+ ffunc);
}
const int ValueMargin = 3;
}
const int ValueMargin = 3;
@@
-154,7
+153,6
@@
void Ruler::paintEvent(QPaintEvent*)
const int minor_tick_y1 = (major_tick_y1 + ruler_height) / 2;
QPainter p(this);
const int minor_tick_y1 = (major_tick_y1 + ruler_height) / 2;
QPainter p(this);
- p.setRenderHint(QPainter::Antialiasing);
// Draw the tick marks
p.setPen(palette().color(foregroundRole()));
// Draw the tick marks
p.setPen(palette().color(foregroundRole()));
@@
-174,6
+172,8
@@
void Ruler::paintEvent(QPaintEvent*)
// Draw the hover mark
draw_hover_mark(p, text_height);
// Draw the hover mark
draw_hover_mark(p, text_height);
+ p.setRenderHint(QPainter::Antialiasing);
+
// The cursor labels are not drawn with the arrows exactly on the
// bottom line of the widget, because then the selection shadow
// would be clipped away.
// The cursor labels are not drawn with the arrows exactly on the
// bottom line of the widget, because then the selection shadow
// would be clipped away.
@@
-197,8
+197,7
@@
Ruler::TickPositions Ruler::calculate_tick_positions(
{
TickPositions tp;
{
TickPositions tp;
- const double minor_period =
- (major_period / MinorTickSubdivision).convert_to<double>();
+ const pv::util::Timestamp minor_period = major_period / MinorTickSubdivision;
const pv::util::Timestamp first_major_division = floor(offset / major_period);
const pv::util::Timestamp first_minor_division = ceil(offset / minor_period);
const pv::util::Timestamp t0 = first_major_division * major_period;
const pv::util::Timestamp first_major_division = floor(offset / major_period);
const pv::util::Timestamp first_minor_division = ceil(offset / minor_period);
const pv::util::Timestamp t0 = first_major_division * major_period;
@@
-213,7
+212,7
@@
Ruler::TickPositions Ruler::calculate_tick_positions(
x = ((t - offset) / scale).convert_to<double>();
if (division % MinorTickSubdivision == 0) {
x = ((t - offset) / scale).convert_to<double>();
if (division % MinorTickSubdivision == 0) {
- // Recalculate 't' without using 'minor_period' which is
of type double.
+ // Recalculate 't' without using 'minor_period' which is
a fraction
t = t0 + division / MinorTickSubdivision * major_period;
tp.major.emplace_back(x, format_function(t));
} else {
t = t0 + division / MinorTickSubdivision * major_period;
tp.major.emplace_back(x, format_function(t));
} else {
@@
-226,9
+225,9
@@
Ruler::TickPositions Ruler::calculate_tick_positions(
return tp;
}
return tp;
}
-void Ruler::mouseDoubleClickEvent(QMouseEvent *e)
+void Ruler::mouseDoubleClickEvent(QMouseEvent *e
vent
)
{
{
- view_.add_flag(view_.offset() + ((double)e->x() + 0.5) * view_.scale());
+ view_.add_flag(view_.offset() + ((double)e
vent
->x() + 0.5) * view_.scale());
}
void Ruler::draw_hover_mark(QPainter &p, int text_height)
}
void Ruler::draw_hover_mark(QPainter &p, int text_height)
@@
-272,5
+271,6
@@
void Ruler::resizeEvent(QResizeEvent*)
invalidate_tick_position_cache();
}
invalidate_tick_position_cache();
}
-} // namespace view
+} // namespace TraceView
+} // namespace views
} // namespace pv
} // namespace pv