33 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
34 #include <QSurfaceFormat>
38 #include <QMessageBox>
39 #include <QOffscreenSurface>
40 #include <QOpenGLContext>
41 #include <QOpenGLFunctions>
43 #include <QSplashScreen>
44 #include <QStorageInfo>
48 #include <QTranslator>
49 #include <QtWidgets/QApplication>
50 #ifdef CC_GAMEPAD_SUPPORT
51 #include <QGamepadManager>
87 double totalGB =
static_cast<double>(memInfo.
totalRam) /
88 (1024.0 * 1024.0 * 1024.0);
89 return QString(
"RAM: %1 GB").arg(totalGB, 0,
'f', 2);
92 return QString(
"RAM: Unable to detect");
97 QStorageInfo storage = QStorageInfo::root();
99 if (storage.isValid() && storage.isReady()) {
100 qint64 totalBytes = storage.bytesTotal();
101 qint64 availableBytes = storage.bytesAvailable();
103 double totalGB = totalBytes / (1024.0 * 1024.0 * 1024.0);
104 double availableGB = availableBytes / (1024.0 * 1024.0 * 1024.0);
105 double usedGB = totalGB - availableGB;
107 return QString(
"Storage: %1 GB total, %2 GB used, %3 GB available")
108 .arg(totalGB, 0,
'f', 2)
109 .arg(usedGB, 0,
'f', 2)
110 .arg(availableGB, 0,
'f', 2);
113 return QString(
"Storage: Unable to detect");
123 std::string modelName = cpuInfo.
ModelName();
125 if (numCores <= 0 && numThreads <= 0) {
126 return QString(
"CPU: Unable to detect");
130 if (!modelName.empty()) {
133 result = QString(
"CPU: %1 (%2 cores, %3 threads)")
134 .arg(QString::fromStdString(modelName))
138 result = QString(
"CPU: %1 (%2 threads)")
139 .arg(QString::fromStdString(modelName))
145 result = QString(
"CPU: %1 cores, %2 threads")
149 result = QString(
"CPU: %1 threads").arg(numThreads);
158 QString gpuInfo =
"GPU: ";
161 QOffscreenSurface surface;
166 QOpenGLFunctions* functions =
context.functions();
168 const GLubyte* vendor = functions->glGetString(GL_VENDOR);
169 const GLubyte* renderer = functions->glGetString(GL_RENDERER);
170 const GLubyte*
version = functions->glGetString(GL_VERSION);
172 if (vendor && renderer &&
version) {
173 gpuInfo += QString(
"%1 %2 (OpenGL %3)")
174 .arg(
reinterpret_cast<const char*
>(vendor))
175 .arg(
reinterpret_cast<const char*
>(renderer))
176 .arg(
reinterpret_cast<const char*
>(
version));
178 gpuInfo +=
"Unable to query details";
183 gpuInfo +=
"Unable to create OpenGL context";
192 "=================================================================="
196 "=================================================================="
201 .arg(QSysInfo::productType())
202 .arg(QSysInfo::productVersion())
203 .arg(QSysInfo::currentCpuArchitecture()));
206 CVLog::Print(QString(
"Kernel: %1").arg(QSysInfo::kernelVersion()));
221 "=================================================================="
229 char ompEnv[] =
"KMP_DUPLICATE_LIB_OK=True";
237 FileIOFilter::InitInternalFilters();
261 CVLog::Print(QObject::tr(
"Restore [Global Shift] Max abs. coord = %1 / "
262 "max abs. diag = %2")
263 .arg(maxAbsCoord, 0,
'e', 0)
264 .arg(maxAbsDiag, 0,
'e', 0));
271 int main(
int argc,
char* argv[]) {
274 DWORD stdout_type = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE));
275 if (AttachConsole(ATTACH_PARENT_PROCESS)) {
280 freopen(
"CONOUT$",
"w", stdout);
281 freopen(
"CONOUT$",
"w", stderr);
292 int numRealArgs = argc;
294 for (
int i = 1; i < argc; ++i) {
295 if (strncmp(argv[i],
"-psn_", 5) == 0) {
300 bool commandLine = (numRealArgs > 1) && (argv[1][0] ==
'-');
302 bool commandLine = (argc > 1) && (argv[1][0] ==
'-');
307 #ifdef CC_GAMEPAD_SUPPORT
308 QGamepadManager::instance();
316 setlocale(LC_NUMERIC,
"C");
319 QLocale::setDefault(QLocale::c());
322 int lastArgumentIndex = 1;
323 QTranslator translator;
326 if (QString(argv[lastArgumentIndex]).toUpper() ==
"-LANG") {
327 QString langFilename = QString::fromLocal8Bit(argv[2]);
331 lastArgumentIndex += 2;
336 QScopedPointer<QSplashScreen> splash(
nullptr);
340 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
346 QMessageBox::critical(
nullptr, QObject::tr(
"Error"),
347 QObject::tr(
"This application needs OpenGL "
348 "2.1 at least to run!"));
352 if ((QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_1) ==
354 QMessageBox::critical(
nullptr, QObject::tr(
"Error"),
355 QObject::tr(
"This application needs OpenGL "
356 "2.1 at least to run!"));
362 QPixmap pixmap(QString::fromUtf8(
364 splash.reset(
new QSplashScreen(pixmap, Qt::WindowStaysOnTopHint));
366 QApplication::processEvents();
386 QMessageBox::critical(
nullptr, QObject::tr(
"Error"),
387 QObject::tr(
"Failed to initialize the main "
388 "application window?!"));
411 qui->setSizeGripEnabled(
true);
448 QApplication::processEvents();
453 QObject::tr(
"Current [Global Shift] Max abs. coord = %1 / "
454 "max abs. diag = %2")
461 if (argc > lastArgumentIndex) {
468 QStringList filenames;
469 for (
int i = lastArgumentIndex; i < argc; ++i) {
470 QString arg(argv[i]);
472 if (arg.startsWith(
":start-plugin:")) {
473 QString pluginName = arg.mid(14);
474 QString pluginNameUpper = pluginName.toUpper();
479 if (plugin->getName().replace(
' ',
'_').toUpper() ==
482 bool success = plugin->start();
486 .arg(plugin->getName()));
494 QObject::tr(
"Couldn't find the plugin '%1'")
495 .arg(pluginName.replace(
'_',
' ')));
498 filenames << QString::fromLocal8Bit(argv[i]);
502 mainWindow->
addToDB(filenames);
506 QObject::connect(&splashTimer, &QTimer::timeout, [&]() {
507 if (splash) splash->close();
508 QCoreApplication::processEvents();
511 splashTimer.setInterval(1000);
517 QDir workingDir = QCoreApplication::applicationDirPath();
522 if (workingDir.dirName() ==
"MacOS") {
529 QDir::setCurrent(workingDir.absolutePath());
535 }
catch (
const std::exception& e) {
536 QMessageBox::warning(
537 nullptr, QObject::tr(
"ECV crashed!"),
538 QObject::tr(
"Hum, it seems that ECV has crashed... Sorry "
542 QMessageBox::warning(
nullptr, QObject::tr(
"ECV crashed!"),
543 QObject::tr(
"Hum, it seems that ECV has "
544 "crashed... Sorry about that :)"));
567 if (qui !=
nullptr) {
572 #ifdef CV_TRACK_ALIVE_SHARED_OBJECTS
574 unsigned alive = CCShareable::GetAliveCount();
576 printf(
"Error: some shared objects (%u) have not been released on "
filament::Texture::InternalFormat format
int main(int argc, char *argv[])
void PrintSystemHardwareInfo()
QString GetTotalMemoryInfo()
static bool Print(const char *format,...)
Prints out a formatted message in console.
static void EnableMessageBackup(bool state)
Enables the message backup system.
static bool Error(const char *format,...)
Display an error dialog with formatted message.
static void UnregisterAll()
Unregisters all filters.
static MainWindow * TheInstance()
Returns the unique instance of this object.
void setUiManager(QUIWidget *uiManager)
void addToDB(const QStringList &filenames, QString fileFilter=QString(), bool displayDialog=true)
static void ChangeStyle(const QString &qssFile)
void initPlugins()
Sets up the UI (menus and toolbars) based on loaded plugins.
static void DestroyInstance()
Deletes current main window instance.
static ccColorScalesManager * GetUniqueInstance()
Returns unique instance.
static int Parse(int nargs, char **args, ccPluginInterfaceList &plugins)
Parses the input command.
static ccNormalVectors * GetUniqueInstance()
Returns unique instance.
Standard ECV plugin interface.
static ccPluginManager & get()
static ccTranslationManager & get()
void loadTranslation(QString language)
static CPUInfo & GetInstance()
const std::string & ModelName() const
static double MaxCoordinateAbsValue()
Returns the max coordinate (absolute) value.
static void SetMaxCoordinateAbsValue(double value)
Sets the max coordinate (absolute) value.
static void SetMaxBoundgBoxDiagonal(double value)
Sets the max bounding-box diagonal.
static double MaxBoundgBoxDiagonal()
Returns max bounding-box diagonal.
static const QString CurrentTheme()
static const QString GlobalShift()
static const QString MaxAbsCoord()
static const QString MaxAbsDiag()
static const QString ThemeSettings()
static void ReleaseInstance()
Releases unique instance.
static QVariant getValue(const QString §ion, const QString &key, const QVariant &defaultValue=QVariant())
static void Init(const QString &path)
static const QString APP_START_LOGO
static const QString DEFAULT_STYLE
static const QString APP_TITLE
static QString CONFIG_PATH
static const QString APP_LOGO
MemoryInfo getMemoryInfo()