projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
SignalBase: Always hook into signal data, not just for analog
[pulseview.git]
/
pv
/
view
/
cursor.cpp
diff --git
a/pv/view/cursor.cpp
b/pv/view/cursor.cpp
index 0ea6f5ab7b0c5e3edbc21b64600bc06e2f1346dd..f22680b9f46f547bfbb315f43f9131140a588dc0 100644
(file)
--- a/
pv/view/cursor.cpp
+++ b/
pv/view/cursor.cpp
@@
-14,14
+14,14
@@
* 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 "cursor.hpp"
*/
#include "cursor.hpp"
-#include "view.hpp"
#include "pv/util.hpp"
#include "pv/util.hpp"
+#include "ruler.hpp"
+#include "view.hpp"
#include <QApplication>
#include <QBrush>
#include <QApplication>
#include <QBrush>
@@
-32,11
+32,14
@@
#include <cassert>
#include <cstdio>
#include <cassert>
#include <cstdio>
+#include <limits>
+using std::abs; // Force usage of std::abs() instead of C's abs().
using std::shared_ptr;
namespace pv {
using std::shared_ptr;
namespace pv {
-namespace view {
+namespace views {
+namespace TraceView {
const QColor Cursor::FillColour(52, 101, 164);
const QColor Cursor::FillColour(52, 101, 164);
@@
-52,7
+55,11
@@
bool Cursor::enabled() const
QString Cursor::get_text() const
{
QString Cursor::get_text() const
{
- return pv::util::format_time(time_, view_.tick_prefix(), 2);
+ const shared_ptr<Cursor> other = get_other_cursor();
+ const pv::util::Timestamp& diff = abs(time_ - other->time_);
+
+ return Ruler::format_time_with_distance(
+ diff, time_, view_.tick_prefix(), view_.time_unit(), view_.tick_precision());
}
QRectF Cursor::label_rect(const QRectF &rect) const
}
QRectF Cursor::label_rect(const QRectF &rect) const
@@
-60,7
+67,7
@@
QRectF Cursor::label_rect(const QRectF &rect) const
const shared_ptr<Cursor> other(get_other_cursor());
assert(other);
const shared_ptr<Cursor> other(get_other_cursor());
assert(other);
- const float x =
(time_ - view_.offset()) / view_.scale
();
+ const float x =
get_x
();
QFontMetrics m(QApplication::font());
QSize text_size = m.boundingRect(get_text()).size();
QFontMetrics m(QApplication::font());
QSize text_size = m.boundingRect(get_text()).size();
@@
-72,11
+79,13
@@
QRectF Cursor::label_rect(const QRectF &rect) const
TimeMarker::ArrowSize - 0.5f;
const float height = label_size.height();
TimeMarker::ArrowSize - 0.5f;
const float height = label_size.height();
- if (time_ > other->time())
+ const pv::util::Timestamp& other_time = other->time();
+
+ if (time_ > other_time ||
+ (abs(time_ - other_time).is_zero() && this > other.get()))
return QRectF(x, top, label_size.width(), height);
else
return QRectF(x, top, label_size.width(), height);
else
- return QRectF(x - label_size.width(), top,
- label_size.width(), height);
+ return QRectF(x - label_size.width(), top, label_size.width(), height);
}
shared_ptr<Cursor> Cursor::get_other_cursor() const
}
shared_ptr<Cursor> Cursor::get_other_cursor() const
@@
-87,5
+96,6
@@
shared_ptr<Cursor> Cursor::get_other_cursor() const
cursors->second() : cursors->first();
}
cursors->second() : cursors->first();
}
-} // namespace view
+} // namespace TraceView
+} // namespace views
} // namespace pv
} // namespace pv