From 69ec743346ebc51b216bb3065bfc1186e7170f3f Mon Sep 17 00:00:00 2001 From: Paolo Cignoni cignoni Date: Wed, 8 Nov 2006 01:04:48 +0000 Subject: [PATCH] First version with http communications --- src/meshlab/main.cpp | 9 ++++-- src/meshlab/mainwindow.h | 17 +++++++++-- src/meshlab/mainwindow_Init.cpp | 46 ++++++++++++++++++++++++++++-- src/meshlab/mainwindow_RunTime.cpp | 7 +++-- src/meshlab/meshlab.pro | 1 + 5 files changed, 71 insertions(+), 9 deletions(-) diff --git a/src/meshlab/main.cpp b/src/meshlab/main.cpp index db0aa2e84..2a00928a8 100644 --- a/src/meshlab/main.cpp +++ b/src/meshlab/main.cpp @@ -23,6 +23,9 @@ /**************************************************************************** History $Log$ +Revision 1.5 2006/11/08 01:04:48 cignoni +First version with http communications + Revision 1.4 2006/02/01 12:45:29 glvertex - Solved openig bug when running by command line @@ -40,8 +43,10 @@ Added copyright info int main(int argc, char *argv[]) { QApplication app(argc, argv); - MainWindow window; - window.showMaximized(); + QCoreApplication::setOrganizationName("VCG"); + QCoreApplication::setApplicationName("MeshLab"); + MainWindow window; + window.showMaximized(); if(argc>1) window.open(argv[1]); else window.open(); diff --git a/src/meshlab/mainwindow.h b/src/meshlab/mainwindow.h index e83d00c07..ad44a8346 100644 --- a/src/meshlab/mainwindow.h +++ b/src/meshlab/mainwindow.h @@ -23,6 +23,9 @@ /**************************************************************************** History $Log$ +Revision 1.70 2006/11/08 01:04:48 cignoni +First version with http communications + Revision 1.69 2006/10/26 12:07:12 corsini add lighting properties option @@ -91,6 +94,7 @@ class QMenu; class QScrollArea; class QSignalMapper; class QProgressDialog; +class QHttp; class MainWindow : public QMainWindow { @@ -99,7 +103,7 @@ class MainWindow : public QMainWindow public: MainWindow(); static bool QCallBack(const int pos, const char * str); - const QString appName() const {return tr("MeshLab v0.7"); } + const QString appName() const {return tr("MeshLab v0.8"); } // MaskObj maskobj; public slots: @@ -157,8 +161,11 @@ private slots: void about(); void aboutPlugins(); + ///////////Slot General Purpose //////////////////////// + void dropEvent ( QDropEvent * event ); void dragEnterEvent(QDragEnterEvent *); + void connectionFinished(int id, bool status); private: void createActions(); @@ -172,11 +179,15 @@ private: //void LoadKnownFilters(QStringList &filters, QHash &allKnownFormats, int type); - + QHttp *httpReq; + QBuffer *myLocalBuf; + int idHost; + int idGet; + static QProgressBar *qb; QWorkspace *workspace; QSignalMapper *windowMapper; - QDir pluginsDir; + QDir pluginsDir; QStringList pluginFileNames; std::vector meshIOPlugins; QByteArray toolbarState; //stato delle toolbar e dockwidgets diff --git a/src/meshlab/mainwindow_Init.cpp b/src/meshlab/mainwindow_Init.cpp index 1520098f5..21086d988 100644 --- a/src/meshlab/mainwindow_Init.cpp +++ b/src/meshlab/mainwindow_Init.cpp @@ -24,6 +24,9 @@ History $Log$ +Revision 1.60 2006/11/08 01:04:48 cignoni +First version with http communications + Revision 1.59 2006/10/26 12:07:30 corsini add lighting properties option @@ -80,7 +83,7 @@ Added short key lastFilter #include #include #include - +#include #include "meshmodel.h" #include "interfaces.h" @@ -103,6 +106,9 @@ MainWindow::MainWindow() connect(workspace, SIGNAL(windowActivated(QWidget *)),this, SLOT(updateMenus())); connect(workspace, SIGNAL(windowActivated(QWidget *)),this, SLOT(updateWindowMenu())); + httpReq=new QHttp(this); + connect(httpReq, SIGNAL(requestFinished(int,bool)), this, SLOT(connectionFinished(int,bool))); + createActions(); createMenus(); createToolBars(); @@ -526,9 +532,11 @@ void MainWindow::addToMenu(QList actionList, QMenu *menu, const char } } +// this function update the app settings with the current recent file list +// and update the loaded mesh counter void MainWindow::setCurrentFile(const QString &fileName) { - QSettings settings("Recent Files"); + QSettings settings; QStringList files = settings.value("recentFileList").toStringList(); files.removeAll(fileName); files.prepend(fileName); @@ -541,5 +549,39 @@ void MainWindow::setCurrentFile(const QString &fileName) MainWindow *mainWin = qobject_cast(widget); if (mainWin) mainWin->updateRecentFileActions(); } + + int loadedMeshCounter=settings.value("loadedMeshCounter",0).toInt(); + settings.setValue("loadedMeshCounter",loadedMeshCounter+1); + int lastComunicatedValue=settings.value("lastComunicatedValue",0).toInt(); + QString UID=settings.value("UID",QString("")).toString(); + if(UID.isEmpty()) + { + UID=QUuid::createUuid ().toString(); + settings.setValue("UID",UID); + } + if(loadedMeshCounter-lastComunicatedValue>20) + { + QString message= QString("/~cignoni/meshlab.php?code=%1&count=%2").arg(UID).arg(loadedMeshCounter); + idHost=httpReq->setHost("vcg.isti.cnr.it"); // id == 1 + myLocalBuf = new QBuffer(); + bool ret=myLocalBuf->open(QBuffer::WriteOnly); + if(!ret) QMessageBox::information(this,"Meshlab",QString("Failed opening of internal buffer")); + idGet=httpReq->get(message,myLocalBuf); // id == 2 + } } +void MainWindow::connectionFinished(int id, bool status) +{ + if(id==idGet && status == false) + { + httpReq->close(); + if(myLocalBuf->isOpen()) + { + myLocalBuf->close(); + QMessageBox::information(this,"Remote Counter",QString("Updated!")); + QSettings settings; + int loadedMeshCounter=settings.value("loadedMeshCounter",0).toInt(); + settings.setValue("lastComunicatedValue",loadedMeshCounter); + } + } +} diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index b17e77c1a..b0e2a8a80 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -24,6 +24,9 @@ History $Log$ +Revision 1.109 2006/11/08 01:04:48 cignoni +First version with http communications + Revision 1.108 2006/11/07 09:15:27 cignoni Added Drag n drog opening of files (thanks to Valentino Fiorin) @@ -100,7 +103,7 @@ Minor edits. #include #include #include - +#include #include "meshmodel.h" #include "interfaces.h" @@ -122,7 +125,7 @@ Minor edits. void MainWindow::updateRecentFileActions() { - QSettings settings("Recent Files"); + QSettings settings; QStringList files = settings.value("recentFileList").toStringList(); int numRecentFiles = qMin(files.size(), (int)MAXRECENTFILES); for (int i = 0; i < numRecentFiles; ++i) { diff --git a/src/meshlab/meshlab.pro b/src/meshlab/meshlab.pro index 43ec0a00f..f49bbaae5 100644 --- a/src/meshlab/meshlab.pro +++ b/src/meshlab/meshlab.pro @@ -53,6 +53,7 @@ RC_FILE = meshlab.rc QT += opengl QT += xml +QT += network # the following line is needed to avoid mismatch between # the awful min/max macros of windows and the limits max