mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 17:40:23 +08:00
Qt6 compatibility (#968)
* Qt6 Compilation success * Fixed qt5 backward compatibility * Fixed build for qt<=5.9 (bionic) * Added docker file for easy testing with latest Qt/VTK/PCL/OpenCV * Fixed cmake for qt
This commit is contained in:
9
guilib/src/3rdParty/QMultiComboBox.cpp
vendored
9
guilib/src/3rdParty/QMultiComboBox.cpp
vendored
@@ -11,7 +11,8 @@
|
||||
#include "QMultiComboBox.h"
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QWindow>
|
||||
#include <QScreen>
|
||||
|
||||
#include "rtabmap/utilite/ULogger.h"
|
||||
|
||||
@@ -46,7 +47,11 @@ QMultiComboBox::~QMultiComboBox()
|
||||
void QMultiComboBox::SetDisplayText(QString text)
|
||||
{
|
||||
m_DisplayText_ = text;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
const int textWidth = fontMetrics().horizontalAdvance(text);
|
||||
#else
|
||||
const int textWidth = fontMetrics().width(text);
|
||||
#endif
|
||||
setMinimumWidth(textWidth + 30);
|
||||
updateGeometry();
|
||||
repaint();
|
||||
@@ -88,7 +93,7 @@ void QMultiComboBox::showPopup()
|
||||
//QRect rec2(p , p + QPoint(rec.width(), rec.height()));
|
||||
|
||||
// get the two possible list points and height
|
||||
QRect screen = QApplication::desktop()->screenGeometry(this);
|
||||
QRect screen = this->window()->windowHandle()->screen()->availableGeometry();
|
||||
QPoint above = this->mapToGlobal(QPoint(0,0));
|
||||
int aboveHeight = above.y() - screen.y();
|
||||
QPoint below = this->mapToGlobal(QPoint(0,rec.height()));
|
||||
|
||||
@@ -70,10 +70,14 @@ IF(QT4_FOUND)
|
||||
#This will generate moc_* for Qt
|
||||
QT4_WRAP_CPP(moc_srcs ${headers_ui})
|
||||
### Qt Gui stuff end###
|
||||
ELSE()
|
||||
ELSEIF(Qt5_FOUND)
|
||||
QT5_ADD_RESOURCES(srcs_qrc ${qrc})
|
||||
QT5_WRAP_UI(moc_uis ${uis})
|
||||
QT5_WRAP_CPP(moc_srcs ${headers_ui})
|
||||
ELSE()
|
||||
QT6_ADD_RESOURCES(srcs_qrc ${qrc})
|
||||
QT6_WRAP_UI(moc_uis ${uis})
|
||||
QT6_WRAP_CPP(moc_srcs ${headers_ui})
|
||||
ENDIF()
|
||||
|
||||
|
||||
@@ -140,8 +144,14 @@ ENDIF(QT4_FOUND)
|
||||
SET(LIBRARIES "")
|
||||
SET(PUBLIC_LIBRARIES "")
|
||||
|
||||
IF(Qt5_FOUND)
|
||||
SET(PUBLIC_LIBRARIES ${PUBLIC_LIBRARIES} Qt5::Widgets Qt5::Core Qt5::Gui)
|
||||
IF(Qt6_FOUND)
|
||||
SET(PUBLIC_LIBRARIES ${PUBLIC_LIBRARIES} Qt6::Widgets Qt6::Core Qt6::Gui Qt6::OpenGL)
|
||||
SET(LIBRARIES ${LIBRARIES} Qt6::PrintSupport)
|
||||
IF(Qt6Svg_FOUND)
|
||||
SET(LIBRARIES ${LIBRARIES} Qt6::Svg)
|
||||
ENDIF()
|
||||
ELSEIF(Qt5_FOUND)
|
||||
SET(PUBLIC_LIBRARIES ${PUBLIC_LIBRARIES} Qt5::Widgets Qt5::Core Qt5::Gui Qt5::OpenGL)
|
||||
SET(LIBRARIES ${LIBRARIES} Qt5::PrintSupport)
|
||||
IF(Qt5Svg_FOUND)
|
||||
SET(LIBRARIES ${LIBRARIES} Qt5::Svg)
|
||||
|
||||
@@ -59,7 +59,7 @@ CameraViewer::CameraViewer(QWidget * parent, const ParametersMap & parameters) :
|
||||
imageView_->setImageDepthShown(true);
|
||||
imageView_->setMinimumSize(320, 240);
|
||||
QHBoxLayout * layout = new QHBoxLayout();
|
||||
layout->setMargin(0);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
layout->addWidget(imageView_,1);
|
||||
layout->addWidget(cloudView_,1);
|
||||
|
||||
@@ -95,7 +95,7 @@ CameraViewer::CameraViewer(QWidget * parent, const ParametersMap & parameters) :
|
||||
layout2->addWidget(buttonBox);
|
||||
|
||||
QVBoxLayout * vlayout = new QVBoxLayout(this);
|
||||
vlayout->setMargin(0);
|
||||
vlayout->setContentsMargins(0,0,0,0);
|
||||
vlayout->setSpacing(0);
|
||||
vlayout->addLayout(layout, 1);
|
||||
vlayout->addLayout(layout2);
|
||||
|
||||
@@ -40,6 +40,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <pcl/common/transforms.h>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QActionGroup>
|
||||
#include <QtGui/QContextMenuEvent>
|
||||
#include <QInputDialog>
|
||||
#include <QtGui/QWheelEvent>
|
||||
|
||||
@@ -58,7 +58,7 @@ DataRecorder::DataRecorder(QWidget * parent) :
|
||||
imageView_->setImageDepthShown(true);
|
||||
imageView_->setMinimumSize(320, 240);
|
||||
QVBoxLayout * layout = new QVBoxLayout(this);
|
||||
layout->setMargin(0);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
layout->addWidget(imageView_);
|
||||
layout->addWidget(label_);
|
||||
layout->setStretch(0,1);
|
||||
|
||||
@@ -31,7 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QDesktopWidget>
|
||||
#include <QColorDialog>
|
||||
#include <QGraphicsLineItem>
|
||||
#include <QtGui/QCloseEvent>
|
||||
@@ -1685,7 +1684,11 @@ void DatabaseViewer::updateIds()
|
||||
UINFO("Loading all IDs...");
|
||||
std::set<int> ids;
|
||||
dbDriver_->getAllNodeIds(ids);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
ids_ = QList<int>(ids.begin(), ids.end());
|
||||
#else
|
||||
ids_ = QList<int>::fromStdList(std::list<int>(ids.begin(), ids.end()));
|
||||
#endif
|
||||
lastWmIds_.clear();
|
||||
dbDriver_->getLastNodeIds(lastWmIds_);
|
||||
idToIndex_.clear();
|
||||
@@ -2222,10 +2225,18 @@ void DatabaseViewer::updateInfo()
|
||||
ui_->textEdit_info->append("");
|
||||
ParametersMap parameters = dbDriver_->getLastParameters();
|
||||
QFontMetrics metrics(ui_->textEdit_info->font());
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
int tabW = ui_->textEdit_info->tabStopDistance();
|
||||
#else
|
||||
int tabW = ui_->textEdit_info->tabStopWidth();
|
||||
#endif
|
||||
for(ParametersMap::iterator iter=parameters.begin(); iter!=parameters.end(); ++iter)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
int strW = metrics.horizontalAdvance(QString(iter->first.c_str()) + "=");
|
||||
#else
|
||||
int strW = metrics.width(QString(iter->first.c_str()) + "=");
|
||||
#endif
|
||||
ui_->textEdit_info->append(tr("%1=%2%3")
|
||||
.arg(iter->first.c_str())
|
||||
.arg(strW < tabW?"\t\t\t\t":strW < tabW*2?"\t\t\t":strW < tabW*3?"\t\t":"\t")
|
||||
@@ -3889,7 +3900,11 @@ void DatabaseViewer::regenerateCurrentLocalMaps()
|
||||
QSet<int> idsSet;
|
||||
idsSet.insert(ids_.at(ui_->horizontalSlider_A->value()));
|
||||
idsSet.insert(ids_.at(ui_->horizontalSlider_B->value()));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QList<int> ids(idsSet.begin(), idsSet.end());
|
||||
#else
|
||||
QList<int> ids = idsSet.toList();
|
||||
#endif
|
||||
|
||||
rtabmap::ProgressDialog progressDialog(this);
|
||||
progressDialog.setMaximumSteps(ids.size());
|
||||
@@ -6832,7 +6847,7 @@ void DatabaseViewer::sliderIterationsValueChanged(int value)
|
||||
if(graph.size() && localMaps.size() &&
|
||||
(ui_->graphViewer->isGridMapVisible() || ui_->dockWidget_occupancyGridView->isVisible()))
|
||||
{
|
||||
QTime time;
|
||||
QElapsedTimer time;
|
||||
time.start();
|
||||
|
||||
#ifdef RTABMAP_OCTOMAP
|
||||
@@ -7509,7 +7524,7 @@ void DatabaseViewer::updateGraphView()
|
||||
posesOut,
|
||||
linksOut);
|
||||
UINFO("Connected graph of %d poses and %d links", (int)posesOut.size(), (int)linksOut.size());
|
||||
QTime time;
|
||||
QElapsedTimer time;
|
||||
time.start();
|
||||
std::map<int, rtabmap::Transform> finalPoses = optimizer->optimize(fromId, posesOut, linksOut, ui_->comboBox_optimizationFlavor->currentIndex()==0?&graphes_:0);
|
||||
ui_->label_timeOptimization->setNum(double(time.elapsed())/1000.0);
|
||||
|
||||
@@ -465,7 +465,7 @@ void DepthCalibrationDialog::calibrate(
|
||||
ImageView * imageView2 = new ImageView(dialog);
|
||||
imageView2->setMinimumSize(320, 240);
|
||||
QVBoxLayout * vlayout = new QVBoxLayout();
|
||||
vlayout->setMargin(0);
|
||||
vlayout->setContentsMargins(0,0,0,0);
|
||||
vlayout->addWidget(imageView1, 1);
|
||||
vlayout->addWidget(imageView2, 1);
|
||||
dialog->setLayout(vlayout);
|
||||
|
||||
@@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QMouseEvent>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QActionGroup>
|
||||
#include <QInputDialog>
|
||||
|
||||
#include "rtabmap/gui/EditDepthArea.h"
|
||||
|
||||
@@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QMouseEvent>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QActionGroup>
|
||||
#include <QInputDialog>
|
||||
|
||||
#include "rtabmap/gui/EditMapArea.h"
|
||||
|
||||
@@ -62,7 +62,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QDesktopWidget>
|
||||
#include <QWindow>
|
||||
#include <QScreen>
|
||||
|
||||
#ifdef RTABMAP_CPUTSDF
|
||||
#include <cpu_tsdf/tsdf_volume_octree.h>
|
||||
@@ -1212,7 +1213,7 @@ void ExportCloudsDialog::viewClouds(
|
||||
}
|
||||
window->setMinimumWidth(120);
|
||||
window->setMinimumHeight(90);
|
||||
window->resize(QDesktopWidget().availableGeometry(this).size() * 0.7);
|
||||
window->resize(this->window()->windowHandle()->screen()->availableGeometry().size() * 0.7);
|
||||
|
||||
CloudViewer * viewer = new CloudViewer(window);
|
||||
if(_ui->comboBox_pipeline->currentIndex() == 0)
|
||||
@@ -4169,7 +4170,7 @@ void ExportCloudsDialog::saveClouds(
|
||||
#else
|
||||
QString extensions = tr("Save clouds to (*.ply *.pcd)...");
|
||||
#endif
|
||||
QString path = QFileDialog::getExistingDirectory(this, extensions, workingDirectory, 0);
|
||||
QString path = QFileDialog::getExistingDirectory(this, extensions, workingDirectory, QFileDialog::ShowDirsOnly);
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
bool ok = false;
|
||||
@@ -4394,7 +4395,7 @@ void ExportCloudsDialog::saveMeshes(
|
||||
}
|
||||
else if(meshes.size())
|
||||
{
|
||||
QString path = QFileDialog::getExistingDirectory(this, tr("Save meshes to (*.ply *.obj)..."), workingDirectory, 0);
|
||||
QString path = QFileDialog::getExistingDirectory(this, tr("Save meshes to (*.ply *.obj)..."), workingDirectory, QFileDialog::ShowDirsOnly);
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
bool ok = false;
|
||||
@@ -4799,7 +4800,7 @@ void ExportCloudsDialog::saveTextureMeshes(
|
||||
}
|
||||
else if(meshes.size())
|
||||
{
|
||||
QString path = QFileDialog::getExistingDirectory(this, tr("Save texture meshes to (*.obj)..."), workingDirectory, 0);
|
||||
QString path = QFileDialog::getExistingDirectory(this, tr("Save texture meshes to (*.obj)..."), workingDirectory, QFileDialog::ShowDirsOnly);
|
||||
if(!path.isEmpty())
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
@@ -1777,7 +1777,7 @@ void GraphViewer::restoreDefaults()
|
||||
|
||||
void GraphViewer::wheelEvent ( QWheelEvent * event )
|
||||
{
|
||||
if(event->delta() < 0)
|
||||
if(event->angleDelta().y() < 0)
|
||||
{
|
||||
this->scale(0.95, 0.95);
|
||||
}
|
||||
@@ -2039,7 +2039,7 @@ void GraphViewer::contextMenuEvent(QContextMenuEvent * event)
|
||||
if(QFileInfo(filePath).suffix().compare("pdf") == 0)
|
||||
{
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setOrientation(QPrinter::Portrait);
|
||||
printer.setPageOrientation(QPageLayout::Portrait);
|
||||
printer.setOutputFileName( filePath );
|
||||
QPainter p(&printer);
|
||||
scene()->render(&p);
|
||||
|
||||
@@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <QFileDialog>
|
||||
#include <QtCore/QDir>
|
||||
#include <QAction>
|
||||
#include <QActionGroup>
|
||||
#include <QGraphicsEffect>
|
||||
#include <QInputDialog>
|
||||
#include <QVBoxLayout>
|
||||
@@ -880,12 +881,12 @@ void ImageView::contextMenuEvent(QContextMenuEvent * e)
|
||||
if(QFileInfo(text).suffix().compare("pdf") == 0)
|
||||
{
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
printer.setOrientation(QPrinter::Portrait);
|
||||
printer.setPageOrientation(QPageLayout::Portrait);
|
||||
printer.setOutputFileName( text );
|
||||
QPainter p(&printer);
|
||||
p.begin(&printer);
|
||||
double xscale = printer.pageRect().width()/double(_graphicsView->sceneRect().width());
|
||||
double yscale = printer.pageRect().height()/double(_graphicsView->sceneRect().height());
|
||||
double xscale = printer.pageLayout().paintRectPixels(printer.resolution()).width()/double(_graphicsView->sceneRect().width());
|
||||
double yscale = printer.pageLayout().paintRectPixels(printer.resolution()).height()/double(_graphicsView->sceneRect().height());
|
||||
double scale = qMin(xscale, yscale);
|
||||
p.scale(scale, scale);
|
||||
_graphicsView->scene()->render(&p, _graphicsView->sceneRect(), _graphicsView->sceneRect());
|
||||
|
||||
@@ -168,6 +168,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent, bool sh
|
||||
_processingOdometry(false),
|
||||
_oneSecondTimer(0),
|
||||
_elapsedTime(0),
|
||||
_logEventTime(0),
|
||||
_posteriorCurve(0),
|
||||
_likelihoodCurve(0),
|
||||
_rawLikelihoodCurve(0),
|
||||
@@ -266,10 +267,10 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent, bool sh
|
||||
// Timer
|
||||
_oneSecondTimer = new QTimer(this);
|
||||
_oneSecondTimer->setInterval(1000);
|
||||
_elapsedTime = new QTime();
|
||||
_elapsedTime = new QElapsedTimer();
|
||||
_ui->label_elapsedTime->setText("00:00:00");
|
||||
connect(_oneSecondTimer, SIGNAL(timeout()), this, SLOT(updateElapsedTime()));
|
||||
_logEventTime = new QTime();
|
||||
_logEventTime = new QElapsedTimer();
|
||||
_logEventTime->start();
|
||||
|
||||
//Graphics scenes
|
||||
@@ -694,6 +695,7 @@ MainWindow::~MainWindow()
|
||||
this->stopDetection();
|
||||
delete _ui;
|
||||
delete _elapsedTime;
|
||||
delete _logEventTime;
|
||||
#ifdef RTABMAP_OCTOMAP
|
||||
delete _octomap;
|
||||
#endif
|
||||
@@ -1893,7 +1895,7 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
|
||||
{
|
||||
_processingStatistics = true;
|
||||
ULOGGER_DEBUG("");
|
||||
QTime time, totalTime;
|
||||
QElapsedTimer time, totalTime;
|
||||
time.start();
|
||||
totalTime.start();
|
||||
//Affichage des stats et images
|
||||
@@ -4968,7 +4970,12 @@ void MainWindow::drawKeypoints(const std::multimap<int, cv::KeyPoint> & refWords
|
||||
{
|
||||
_lastId = (*refWords.rbegin()).first;
|
||||
}
|
||||
_lastIds = QSet<int>::fromList(QList<int>::fromStdList(uKeysList(refWords)));
|
||||
std::list<int> kpts = uKeysList(refWords);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
_lastIds = QSet<int>(kpts.begin(), kpts.end());
|
||||
#else
|
||||
_lastIds = QSet<int>::fromList(QList<int>::fromStdList(kpts));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Draw lines between corresponding features...
|
||||
@@ -5211,7 +5218,7 @@ QString MainWindow::captureScreen(bool cacheInRAM, bool png)
|
||||
{
|
||||
QString name = (QDateTime::currentDateTime().toString("yyMMddhhmmsszzz") + (png?".png":".jpg"));
|
||||
_ui->statusbar->clearMessage();
|
||||
QPixmap figure = QPixmap::grabWidget(this);
|
||||
QPixmap figure = this->grab();
|
||||
|
||||
QString targetDir = _preferencesDialog->getWorkingDirectory() + QDir::separator() + "ScreensCaptured";
|
||||
QString msg;
|
||||
|
||||
@@ -126,13 +126,13 @@ OdometryViewer::OdometryViewer(
|
||||
|
||||
//layout
|
||||
QHBoxLayout * layout = new QHBoxLayout();
|
||||
layout->setMargin(0);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(imageView_,1);
|
||||
layout->addWidget(cloudView_,1);
|
||||
|
||||
QHBoxLayout * hlayout2 = new QHBoxLayout();
|
||||
hlayout2->setMargin(0);
|
||||
hlayout2->setContentsMargins(0,0,0,0);
|
||||
hlayout2->addWidget(maxCloudsLabel);
|
||||
hlayout2->addWidget(maxCloudsSpin_);
|
||||
hlayout2->addWidget(voxelLabel);
|
||||
@@ -151,7 +151,7 @@ OdometryViewer::OdometryViewer(
|
||||
hlayout2->addWidget(closeButton);
|
||||
|
||||
QVBoxLayout * vlayout = new QVBoxLayout(this);
|
||||
vlayout->setMargin(0);
|
||||
vlayout->setContentsMargins(0,0,0,0);
|
||||
vlayout->setSpacing(0);
|
||||
vlayout->addLayout(layout, 1);
|
||||
vlayout->addLayout(hlayout2);
|
||||
|
||||
@@ -170,7 +170,7 @@ void StatItem::setupUi(QGridLayout * grid)
|
||||
layout->addWidget(_value);
|
||||
layout->addWidget(_unit);
|
||||
layout->addStretch();
|
||||
layout->setMargin(0);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ StatsToolBox::StatsToolBox(QWidget * parent) :
|
||||
//Statistics in the GUI (for plotting)
|
||||
_statBox = new QToolBox(this);
|
||||
this->setLayout(new QVBoxLayout());
|
||||
this->layout()->setMargin(0);
|
||||
this->layout()->setContentsMargins(0,0,0,0);
|
||||
this->layout()->addWidget(_statBox);
|
||||
_statBox->layout()->setSpacing(0);
|
||||
_plotMenu = new QMenu(this);
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <vtkInformationVector.h>
|
||||
#include <vtkStreamingDemandDrivenPipeline.h>
|
||||
#include <vtkObjectFactory.h>
|
||||
#include <vtkVersionMacros.h>
|
||||
|
||||
namespace rtabmap {
|
||||
vtkStandardNewMacro(vtkImageMatSource);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include <QStyle>
|
||||
#include <QActionGroup>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
@@ -788,28 +789,44 @@ void UPlotCurve::draw(QPainter * painter, const QRect & limits)
|
||||
{
|
||||
QPointF intersection;
|
||||
QLineF::IntersectType type;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
type = lineItem->line().intersects(QLineF(limits.topLeft(), limits.bottomLeft()), &intersection);
|
||||
#else
|
||||
type = lineItem->line().intersect(QLineF(limits.topLeft(), limits.bottomLeft()), &intersection);
|
||||
#endif
|
||||
if(type == QLineF::BoundedIntersection)
|
||||
{
|
||||
!limits.contains(line.p1())?line.setP1(intersection.toPoint()):line.setP2(intersection.toPoint());
|
||||
}
|
||||
else
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
type = lineItem->line().intersects(QLineF(limits.topLeft(), limits.topRight()), &intersection);
|
||||
#else
|
||||
type = lineItem->line().intersect(QLineF(limits.topLeft(), limits.topRight()), &intersection);
|
||||
#endif
|
||||
if(type == QLineF::BoundedIntersection)
|
||||
{
|
||||
!limits.contains(line.p1())?line.setP1(intersection.toPoint()):line.setP2(intersection.toPoint());
|
||||
}
|
||||
else
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
type = lineItem->line().intersects(QLineF(limits.bottomLeft(), limits.bottomRight()), &intersection);
|
||||
#else
|
||||
type = lineItem->line().intersect(QLineF(limits.bottomLeft(), limits.bottomRight()), &intersection);
|
||||
#endif
|
||||
if(type == QLineF::BoundedIntersection)
|
||||
{
|
||||
!limits.contains(line.p1())?line.setP1(intersection.toPoint()):line.setP2(intersection.toPoint());
|
||||
}
|
||||
else
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
type = lineItem->line().intersects(QLineF(limits.topRight(), limits.bottomRight()), &intersection);
|
||||
#else
|
||||
type = lineItem->line().intersect(QLineF(limits.topRight(), limits.bottomRight()), &intersection);
|
||||
#endif
|
||||
if(type == QLineF::BoundedIntersection)
|
||||
{
|
||||
!limits.contains(line.p1())?line.setP1(intersection.toPoint()):line.setP2(intersection.toPoint());
|
||||
@@ -968,7 +985,7 @@ void UPlotCurve::setData(const std::vector<qreal> & x, const std::vector<qreal>
|
||||
|
||||
void UPlotCurve::setData(const QVector<qreal> & y)
|
||||
{
|
||||
this->setData(y.toStdVector());
|
||||
this->setData(std::vector<qreal>(y.begin(), y.end()));
|
||||
}
|
||||
|
||||
void UPlotCurve::setData(const std::vector<qreal> & y)
|
||||
@@ -1194,8 +1211,13 @@ void UPlotAxis::setAxis(qreal & min, qreal & max)
|
||||
}
|
||||
else
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
borderMin = this->fontMetrics().horizontalAdvance(QString::number(_min,'g',_gradMaxDigits))/2;
|
||||
borderMax = this->fontMetrics().horizontalAdvance(QString::number(_max,'g',_gradMaxDigits))/2;
|
||||
#else
|
||||
borderMin = this->fontMetrics().width(QString::number(_min,'g',_gradMaxDigits))/2;
|
||||
borderMax = this->fontMetrics().width(QString::number(_max,'g',_gradMaxDigits))/2;
|
||||
#endif
|
||||
}
|
||||
int border = borderMin>borderMax?borderMin:borderMax;
|
||||
int borderDelta;
|
||||
@@ -1303,10 +1325,18 @@ void UPlotAxis::setAxis(qreal & min, qreal & max)
|
||||
for (int i = 0; i <= _count; i+=5)
|
||||
{
|
||||
QString n(QString::number(_min + (i/5)*((_max-_min)/(_count/5)),'g',_gradMaxDigits));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
if(this->fontMetrics().horizontalAdvance(n) > minWidth)
|
||||
{
|
||||
minWidth = this->fontMetrics().horizontalAdvance(n);
|
||||
}
|
||||
#else
|
||||
if(this->fontMetrics().width(n) > minWidth)
|
||||
{
|
||||
minWidth = this->fontMetrics().width(n);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
this->setMinimumWidth(15+minWidth);
|
||||
}
|
||||
@@ -1592,7 +1622,7 @@ void UPlotLegend::addItem(UPlotCurve * curve)
|
||||
QHBoxLayout * hLayout = new QHBoxLayout();
|
||||
hLayout->addWidget(legendItem);
|
||||
hLayout->addStretch(0);
|
||||
hLayout->setMargin(0);
|
||||
hLayout->setContentsMargins(0,0,0,0);
|
||||
|
||||
// add to the legend
|
||||
((QVBoxLayout*)_contentLayout)->insertLayout(_contentLayout->count()-1, hLayout);
|
||||
@@ -1644,7 +1674,7 @@ void UPlotLegend::moveUp(UPlotLegendItem * item)
|
||||
QHBoxLayout * hLayout = new QHBoxLayout();
|
||||
hLayout->addWidget(layoutItem->layout()->itemAt(0)->widget());
|
||||
hLayout->addStretch(0);
|
||||
hLayout->setMargin(0);
|
||||
hLayout->setContentsMargins(0,0,0,0);
|
||||
((QVBoxLayout*)_contentLayout)->insertLayout(index-1, hLayout);
|
||||
delete layoutItem;
|
||||
Q_EMIT legendItemMoved(item->curve(), index-1);
|
||||
@@ -1671,7 +1701,7 @@ void UPlotLegend::moveDown(UPlotLegendItem * item)
|
||||
QHBoxLayout * hLayout = new QHBoxLayout();
|
||||
hLayout->addWidget(layoutItem->layout()->itemAt(0)->widget());
|
||||
hLayout->addStretch(0);
|
||||
hLayout->setMargin(0);
|
||||
hLayout->setContentsMargins(0,0,0,0);
|
||||
((QVBoxLayout*)_contentLayout)->insertLayout(index+1, hLayout);
|
||||
delete layoutItem;
|
||||
Q_EMIT legendItemMoved(item->curve(), index+1);
|
||||
@@ -1694,7 +1724,7 @@ QString UPlotLegend::getAllCurveDataAsText() const
|
||||
xAxisMap.insert(iter.key(), iter.value());
|
||||
}
|
||||
}
|
||||
QList<qreal> xAxis = xAxisMap.uniqueKeys();
|
||||
QList<qreal> xAxis = xAxisMap.keys();
|
||||
|
||||
QVector<QVector<qreal> > axes;
|
||||
for(int i=0; i<items.size(); ++i)
|
||||
@@ -2585,7 +2615,11 @@ void UPlot::mouseMoveEvent(QMouseEvent * event)
|
||||
if((QApplication::mouseButtons() & Qt::LeftButton) ||
|
||||
(_aMouseTracking->isChecked() && xPos>=0 && yPos>=0 && xPos<_graphicsViewHolder->width() && yPos<_graphicsViewHolder->height()))
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QToolTip::showText(event->globalPosition().toPoint(), QString("%1,%2").arg(x).arg(y));
|
||||
#else
|
||||
QToolTip::showText(event->globalPos(), QString("%1,%2").arg(x).arg(y));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2831,8 +2865,8 @@ void UPlot::contextMenuEvent(QContextMenuEvent * event)
|
||||
|
||||
QPalette p(palette());
|
||||
// Set background color to white
|
||||
QColor c = p.color(QPalette::Background);
|
||||
p.setColor(QPalette::Background, Qt::white);
|
||||
QColor c = p.color(QPalette::Window);
|
||||
p.setColor(QPalette::Window, Qt::white);
|
||||
setPalette(p);
|
||||
|
||||
#ifdef QT_SVG_LIB
|
||||
@@ -2858,14 +2892,14 @@ void UPlot::contextMenuEvent(QContextMenuEvent * event)
|
||||
}
|
||||
else
|
||||
{
|
||||
QPixmap figure = QPixmap::grabWidget(this);
|
||||
QPixmap figure = this->grab();
|
||||
figure.save(text);
|
||||
}
|
||||
#ifdef QT_SVG_LIB
|
||||
}
|
||||
#endif
|
||||
// revert background color
|
||||
p.setColor(QPalette::Background, c);
|
||||
p.setColor(QPalette::Window, c);
|
||||
setPalette(p);
|
||||
|
||||
if(flatModified)
|
||||
@@ -2923,7 +2957,7 @@ void UPlot::captureScreen()
|
||||
}
|
||||
targetDir += "/";
|
||||
QString name = (QDateTime::currentDateTime().toString("yyMMddhhmmsszzz") + ".") + _autoScreenCaptureFormat;
|
||||
QPixmap figure = QPixmap::grabWidget(this);
|
||||
QPixmap figure = this->grab();
|
||||
figure.save(targetDir + name);
|
||||
}
|
||||
|
||||
@@ -3181,7 +3215,7 @@ void UPlot::removeCurves()
|
||||
|
||||
void UPlot::removeCurve(const UPlotCurve * curve)
|
||||
{
|
||||
QList<UPlotCurve *>::iterator iter = qFind(_curves.begin(), _curves.end(), curve);
|
||||
QList<UPlotCurve *>::iterator iter = std::find(_curves.begin(), _curves.end(), curve);
|
||||
#if PRINT_DEBUG
|
||||
ULOGGER_DEBUG("Plot=\"%s\" removing curve=\"%s\"", this->objectName().toStdString().c_str(), curve?curve->name().toStdString().c_str():"");
|
||||
#endif
|
||||
@@ -3215,7 +3249,7 @@ void UPlot::removeCurve(const UPlotCurve * curve)
|
||||
|
||||
void UPlot::showCurve(const UPlotCurve * curve, bool shown)
|
||||
{
|
||||
QList<UPlotCurve *>::iterator iter = qFind(_curves.begin(), _curves.end(), curve);
|
||||
QList<UPlotCurve *>::iterator iter = std::find(_curves.begin(), _curves.end(), curve);
|
||||
if(iter!=_curves.end())
|
||||
{
|
||||
UPlotCurve * value = *iter;
|
||||
|
||||
Reference in New Issue
Block a user