1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
//##########################################################################
//# #
//# CLOUDCOMPARE LIGHT VIEWER #
//# #
//# This project has been initiated under funding from ANR/CIFRE #
//# #
//# This program is free software; you can redistribute it and/or modify #
//# it under the terms of the GNU General Public License as published by #
//# the Free Software Foundation; version 2 or later of the License. #
//# #
//# This program is distributed in the hope that it will be useful, #
//# but WITHOUT ANY WARRANTY; without even the implied warranty of #
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
//# GNU General Public License for more details. #
//# #
//# +++ COPYRIGHT: EDF R&D + TELECOM ParisTech (ENST-TSI) +++ #
//# #
//##########################################################################
//Qt
#include <QDir>
#include <QGLFormat>
//Local
#include "ccviewerlog.h"
//qCC_db
#include <ccIncludeGL.h>
#include <ccNormalVectors.h>
#include <ccColorScalesManager.h>
#include <ccMaterial.h>
#include <ccPointCloud.h>
//qCC_io
#include <FileIOFilter.h>
#ifdef USE_VLD
//VLD
#include <vld.h>
#endif
#include "ccviewer.h"
#include "ccViewerApplication.h"
int main(int argc, char *argv[])
{
#ifdef Q_OS_WIN
//enables automatic scaling based on the monitor's pixel density
ccViewerApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
ccViewerApplication::InitOpenGL();
// Convert the input arguments to QString before the application is initialized
// (as it will force utf8, which might prevent from properly reading filenmaes from the command line)
QStringList argumentsLocal8Bit;
for (int i = 0; i < argc; ++i)
{
argumentsLocal8Bit << QString::fromLocal8Bit(argv[i]);
}
ccViewerApplication a(argc, argv, false);
#ifdef CC_GAMEPAD_SUPPORT
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
QGamepadManager::instance(); //potential workaround to bug https://bugreports.qt.io/browse/QTBUG-61553
#endif
#endif
#endif
#ifdef USE_VLD
VLDEnable();
#endif
QDir workingDir = QCoreApplication::applicationDirPath();
#ifdef Q_OS_MAC
// This makes sure that our "working directory" is not within the application bundle
if ( workingDir.dirName() == "MacOS" )
{
workingDir.cdUp();
workingDir.cdUp();
workingDir.cdUp();
}
#endif
QDir::setCurrent(workingDir.absolutePath());
if (!QGLFormat::hasOpenGL())
{
QMessageBox::critical(nullptr, "Error", "This application needs OpenGL to run!");
return EXIT_FAILURE;
}
if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) == 0)
{
QMessageBox::critical(nullptr, "Error", "This application needs OpenGL 2.1 at least to run!");
return EXIT_FAILURE;
}
//common data initialization
FileIOFilter::InitInternalFilters(); //load all known I/O filters (plugins will come later!)
ccNormalVectors::GetUniqueInstance(); //force pre-computed normals array initialization
ccColorScalesManager::GetUniqueInstance(); //force pre-computed color tables initialization
ccViewer w;
a.setViewer(&w);
//register minimal logger to display errors
ccViewerLog logger(&w);
ccLog::RegisterInstance(&logger);
w.show();
//files to open are passed as argument
if (argc > 1)
{
//parse arguments
QStringList filenames;
int i = 1;
while (i < argc)
{
QString argument = argumentsLocal8Bit[i++];
QString upperArgument = argument.toUpper();
//Argument '-WIN X Y W H' (to set window size and position)
if (upperArgument == "-WIN")
{
bool ok = true;
if (i + 3 < argc)
{
bool converionOk;
int x = argumentsLocal8Bit[i ].toInt(&converionOk); ok &= converionOk;
int y = argumentsLocal8Bit[i + 1].toInt(&converionOk); ok &= converionOk;
int width = argumentsLocal8Bit[i + 2].toInt(&converionOk); ok &= converionOk;
int height = argumentsLocal8Bit[i + 3].toInt(&converionOk); ok &= converionOk;
i += 4;
if (ok)
{
//change window position and size
w.move(x,y);
w.resize(width,height);
}
}
if (!ok)
{
ccLog::Warning("Invalid arguments! 4 integer values are expected after '-win' (X Y W H)");
break;
}
}
else if (upperArgument == "-MAX")
{
w.showMaximized();
}
else if (upperArgument == "-TOP")
{
w.setWindowFlags(w.windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
w.show();
}
else //any other argument is assumed to be a filename (that will we try to load)
{
filenames << argument;
}
}
if (!filenames.empty())
{
w.addToDB(filenames);
}
}
#ifdef Q_OS_MAC
// process events to load any files on the command line
QCoreApplication::processEvents();
#endif
w.checkForLoadedEntities();
int result = a.exec();
//release global structures
FileIOFilter::UnregisterAll();
ccPointCloud::ReleaseShaders();
return result;
}
|