- Added icons to the project file [meshlab.qrc]
- Enabled renderToolbar with icons
BIN
src/meshlab/images/backlines.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
src/meshlab/images/flat.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
src/meshlab/images/flatlines.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
src/meshlab/images/info.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
src/meshlab/images/points.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
src/meshlab/images/smooth.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
src/meshlab/images/wire.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
@ -21,9 +21,13 @@
|
||||
* *
|
||||
****************************************************************************/
|
||||
/****************************************************************************
|
||||
History
|
||||
History
|
||||
|
||||
$Log$
|
||||
Revision 1.8 2005/11/18 02:12:04 glvertex
|
||||
- Added icons to the project file [meshlab.qrc]
|
||||
- Enabled renderToolbar with icons
|
||||
|
||||
Revision 1.7 2005/11/18 00:36:50 davide_portelli
|
||||
Added View->Toolbar and Windows->Tile and Windows->Cascade
|
||||
|
||||
@ -59,211 +63,226 @@ First rough version. It simply load a mesh.
|
||||
|
||||
MainWindow::MainWindow()
|
||||
{
|
||||
workspace = new QWorkspace(this);
|
||||
workspace = new QWorkspace(this);
|
||||
|
||||
setCentralWidget(workspace);
|
||||
createActions();
|
||||
createMenus();
|
||||
createToolBars();
|
||||
|
||||
addToolBar(mainToolBar);
|
||||
//addToolBar(renderToolBar);
|
||||
|
||||
setCentralWidget(workspace);
|
||||
createActions();
|
||||
createMenus();
|
||||
createToolBars();
|
||||
|
||||
setWindowTitle(tr("MeshLab 1.0"));
|
||||
addToolBar(mainToolBar);
|
||||
addToolBar(renderToolBar);
|
||||
|
||||
//QTimer::singleShot(500, this, SLOT(aboutPlugins()));
|
||||
setWindowTitle(tr("MeshLab v0.1"));
|
||||
|
||||
if(QCoreApplication::instance ()->argc()>1)
|
||||
open(QCoreApplication::instance ()->argv()[1]);
|
||||
else
|
||||
QTimer::singleShot(500, this, SLOT(open()));
|
||||
//QTimer::singleShot(500, this, SLOT(aboutPlugins()));
|
||||
|
||||
loadPlugins();
|
||||
if(QCoreApplication::instance ()->argc()>1)
|
||||
open(QCoreApplication::instance ()->argv()[1]);
|
||||
else
|
||||
QTimer::singleShot(500, this, SLOT(open()));
|
||||
|
||||
loadPlugins();
|
||||
}
|
||||
|
||||
void MainWindow::open(QString fileName)
|
||||
{
|
||||
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
/*QStringList types <<
|
||||
<< "Text files (*.txt)"
|
||||
<< "Any files (*)";
|
||||
QFileDialog fd = new QFileDialog( this );
|
||||
fd->setFilters( types );
|
||||
fd->show();*/
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
/*QStringList types <<
|
||||
<< "Text files (*.txt)"
|
||||
<< "Any files (*)";
|
||||
QFileDialog fd = new QFileDialog( this );
|
||||
fd->setFilters( types );
|
||||
fd->show();*/
|
||||
|
||||
fileName = QFileDialog::getOpenFileName(this,tr("Open File"),"../sample","Mesh files (*.ply *.off *.stl)");
|
||||
}
|
||||
if (!fileName.isEmpty()) {
|
||||
MeshModel *nm= new MeshModel();
|
||||
if(!nm->Open(fileName.toAscii())){
|
||||
QMessageBox::information(this, tr("Plug & Paint"),
|
||||
tr("Cannot load %1.").arg(fileName));
|
||||
fileName = QFileDialog::getOpenFileName(this,tr("Open File"),"../sample","Mesh files (*.ply *.off *.stl)");
|
||||
}
|
||||
if (!fileName.isEmpty()) {
|
||||
MeshModel *nm= new MeshModel();
|
||||
if(!nm->Open(fileName.toAscii())){
|
||||
QMessageBox::information(this, tr("Plug & Paint"),
|
||||
tr("Cannot load %1.").arg(fileName));
|
||||
|
||||
delete nm;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//QMessageBox::information(this, tr("MeshLab"), tr("Opened Mesh of %1. triangles").arg(nm->cm.fn));
|
||||
VM.push_back(nm);
|
||||
GLArea *gla=new GLArea(workspace);
|
||||
gla->mm=nm;
|
||||
gla->setWindowTitle(fileName);
|
||||
workspace->addWindow(gla);
|
||||
gla->showMaximized();
|
||||
return;
|
||||
}
|
||||
}
|
||||
delete nm;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//QMessageBox::information(this, tr("MeshLab"), tr("Opened Mesh of %1. triangles").arg(nm->cm.fn));
|
||||
VM.push_back(nm);
|
||||
GLArea *gla=new GLArea(workspace);
|
||||
gla->mm=nm;
|
||||
gla->setWindowTitle(fileName);
|
||||
workspace->addWindow(gla);
|
||||
gla->showMaximized();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::saveAs()
|
||||
{
|
||||
QString initialPath = QDir::currentPath() + "/untitled.png";
|
||||
QString initialPath = QDir::currentPath() + "/untitled.png";
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), initialPath);
|
||||
if (fileName.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
// return paintArea->saveImage(fileName, "png");
|
||||
return true;
|
||||
}
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), initialPath);
|
||||
if (fileName.isEmpty()) {
|
||||
return false;
|
||||
} else {
|
||||
// return paintArea->saveImage(fileName, "png");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::about()
|
||||
{
|
||||
QMessageBox::about(this, tr("About Plug & Paint"),
|
||||
tr("The <b>Plug & Paint</b> example demonstrates how to write Qt "
|
||||
"applications that can be extended through plugins."));
|
||||
QMessageBox::about(this, tr("About Plug & Paint"),
|
||||
tr("The <b>Plug & Paint</b> example demonstrates how to write Qt "
|
||||
"applications that can be extended through plugins."));
|
||||
}
|
||||
|
||||
void MainWindow::aboutPlugins()
|
||||
{
|
||||
PluginDialog dialog(pluginsDir.path(), pluginFileNames, this);
|
||||
dialog.exec();
|
||||
PluginDialog dialog(pluginsDir.path(), pluginFileNames, this);
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
void MainWindow::createActions()
|
||||
{
|
||||
|
||||
openAct = new QAction(QIcon(":/images/open.png"),tr("&Open..."), this);
|
||||
openAct->setShortcut(tr("Ctrl+O"));
|
||||
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
|
||||
openAct = new QAction(QIcon(":/images/open.png"),tr("&Open..."), this);
|
||||
openAct->setShortcut(tr("Ctrl+O"));
|
||||
connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
|
||||
|
||||
saveAsAct = new QAction(QIcon(":/images/save.png"),tr("&Save As..."), this);
|
||||
saveAsAct->setShortcut(tr("Ctrl+S"));
|
||||
connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
|
||||
saveAsAct = new QAction(QIcon(":/images/save.png"),tr("&Save As..."), this);
|
||||
saveAsAct->setShortcut(tr("Ctrl+S"));
|
||||
connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
|
||||
|
||||
exitAct = new QAction(tr("E&xit"), this);
|
||||
exitAct->setShortcut(tr("Ctrl+Q"));
|
||||
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
|
||||
viewModePoints = new QAction(QIcon(":/images/points.png"),tr("&Points"), this);
|
||||
viewModeWire = new QAction(QIcon(":/images/wire.png"),tr("&Wireframe"), this);
|
||||
viewModeLines = new QAction(QIcon(":/images/backlines.png"),tr("&Hidden Lines"), this);
|
||||
viewModeFlatLines = new QAction(QIcon(":/images/flatlines.png"),tr("Flat &Lines"), this);
|
||||
viewModeFlat = new QAction(QIcon(":/images/flat.png"),tr("&Flat"), this);
|
||||
viewModeSmooth = new QAction(QIcon(":/images/smooth.png"),tr("&Smooth"), this);
|
||||
|
||||
aboutAct = new QAction(tr("&About"), this);
|
||||
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
||||
exitAct = new QAction(tr("E&xit"), this);
|
||||
exitAct->setShortcut(tr("Ctrl+Q"));
|
||||
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
|
||||
|
||||
aboutQtAct = new QAction(tr("About &Qt"), this);
|
||||
connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
||||
aboutAct = new QAction(tr("&About"), this);
|
||||
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
||||
|
||||
aboutQtAct = new QAction(tr("About &Qt"), this);
|
||||
connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
||||
|
||||
aboutPluginsAct = new QAction(tr("About &Plugins"), this);
|
||||
connect(aboutPluginsAct, SIGNAL(triggered()), this, SLOT(aboutPlugins()));
|
||||
connect(aboutPluginsAct, SIGNAL(triggered()), this, SLOT(aboutPlugins()));
|
||||
|
||||
viewToolbarAct = new QAction (tr("&Toolbar"), this);
|
||||
connect(viewToolbarAct, SIGNAL(triggered()), this, SLOT(viewToolbar()));
|
||||
|
||||
windowsTileAct = new QAction(tr("&Tile"), this);
|
||||
connect(windowsTileAct, SIGNAL(triggered()), this, SLOT(windowsTile()));
|
||||
connect(windowsTileAct, SIGNAL(triggered()), this, SLOT(windowsTile()));
|
||||
|
||||
windowsCascadeAct = new QAction(tr("&Cascade"), this);
|
||||
connect(windowsCascadeAct, SIGNAL(triggered()), this, SLOT(windowsCascade()));
|
||||
connect(windowsCascadeAct, SIGNAL(triggered()), this, SLOT(windowsCascade()));
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::createToolBars()
|
||||
{
|
||||
mainToolBar = new QToolBar(this);
|
||||
mainToolBar->addAction(openAct);
|
||||
mainToolBar->addAction(saveAsAct);
|
||||
mainToolBar = new QToolBar(this);
|
||||
mainToolBar->setIconSize(QSize(32,32));
|
||||
mainToolBar->addAction(openAct);
|
||||
mainToolBar->addAction(saveAsAct);
|
||||
|
||||
renderToolBar = new QToolBar(this);
|
||||
renderToolBar->setIconSize(QSize(32,32));
|
||||
renderToolBar->addAction(viewModePoints);
|
||||
renderToolBar->addAction(viewModeWire);
|
||||
renderToolBar->addAction(viewModeLines);
|
||||
renderToolBar->addAction(viewModeFlatLines);
|
||||
renderToolBar->addAction(viewModeFlat);
|
||||
renderToolBar->addAction(viewModeSmooth);
|
||||
}
|
||||
|
||||
void MainWindow::createMenus()
|
||||
{
|
||||
fileMenu = menuBar()->addMenu(tr("&File"));
|
||||
fileMenu->addAction(openAct);
|
||||
fileMenu->addAction(saveAsAct);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(exitAct);
|
||||
fileMenu = menuBar()->addMenu(tr("&File"));
|
||||
fileMenu->addAction(openAct);
|
||||
fileMenu->addAction(saveAsAct);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(exitAct);
|
||||
|
||||
filterMenu = menuBar()->addMenu(tr("&Filter"));
|
||||
filterMenu = menuBar()->addMenu(tr("&Filter"));
|
||||
|
||||
viewMenu = menuBar()->addMenu(tr("&View"));
|
||||
viewMenu->addAction(viewToolbarAct);
|
||||
|
||||
|
||||
windowsMenu = menuBar()->addMenu(tr("&Windows"));
|
||||
windowsMenu->addAction(windowsTileAct);
|
||||
windowsMenu->addAction(windowsCascadeAct);
|
||||
|
||||
menuBar()->addSeparator();
|
||||
menuBar()->addSeparator();
|
||||
|
||||
helpMenu = menuBar()->addMenu(tr("&Help"));
|
||||
helpMenu->addAction(aboutAct);
|
||||
helpMenu->addAction(aboutQtAct);
|
||||
helpMenu = menuBar()->addMenu(tr("&Help"));
|
||||
helpMenu->addAction(aboutAct);
|
||||
helpMenu->addAction(aboutQtAct);
|
||||
helpMenu->addAction(aboutPluginsAct);
|
||||
}
|
||||
|
||||
void MainWindow::loadPlugins()
|
||||
{
|
||||
pluginsDir = QDir(qApp->applicationDirPath());
|
||||
pluginsDir = QDir(qApp->applicationDirPath());
|
||||
#if defined(Q_OS_WIN)
|
||||
if (pluginsDir.dirName() == "debug" || pluginsDir.dirName() == "release")
|
||||
pluginsDir.cdUp();
|
||||
if (pluginsDir.dirName() == "debug" || pluginsDir.dirName() == "release")
|
||||
pluginsDir.cdUp();
|
||||
#elif defined(Q_OS_MAC)
|
||||
if (pluginsDir.dirName() == "MacOS") {
|
||||
pluginsDir.cdUp();
|
||||
pluginsDir.cdUp();
|
||||
pluginsDir.cdUp();
|
||||
}
|
||||
if (pluginsDir.dirName() == "MacOS") {
|
||||
pluginsDir.cdUp();
|
||||
pluginsDir.cdUp();
|
||||
pluginsDir.cdUp();
|
||||
}
|
||||
#endif
|
||||
pluginsDir.cd("plugins");
|
||||
pluginsDir.cd("plugins");
|
||||
|
||||
foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
|
||||
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
|
||||
QObject *plugin = loader.instance();
|
||||
if (plugin) {
|
||||
MeshFilterInterface *iFilter = qobject_cast<MeshFilterInterface *>(plugin);
|
||||
if (iFilter)
|
||||
addToMenu(plugin, iFilter->filters(), filterMenu, SLOT(applyFilter()));
|
||||
|
||||
pluginFileNames += fileName;
|
||||
}
|
||||
}
|
||||
foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
|
||||
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
|
||||
QObject *plugin = loader.instance();
|
||||
if (plugin) {
|
||||
MeshFilterInterface *iFilter = qobject_cast<MeshFilterInterface *>(plugin);
|
||||
if (iFilter)
|
||||
addToMenu(plugin, iFilter->filters(), filterMenu, SLOT(applyFilter()));
|
||||
|
||||
// brushMenu->setEnabled(!brushActionGroup->actions().isEmpty());
|
||||
// shapesMenu->setEnabled(!shapesMenu->actions().isEmpty());
|
||||
filterMenu->setEnabled(!filterMenu->actions().isEmpty());
|
||||
pluginFileNames += fileName;
|
||||
}
|
||||
}
|
||||
|
||||
// brushMenu->setEnabled(!brushActionGroup->actions().isEmpty());
|
||||
// shapesMenu->setEnabled(!shapesMenu->actions().isEmpty());
|
||||
filterMenu->setEnabled(!filterMenu->actions().isEmpty());
|
||||
}
|
||||
|
||||
void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,QMenu *menu, const char *member,
|
||||
QActionGroup *actionGroup)
|
||||
QActionGroup *actionGroup)
|
||||
{
|
||||
foreach (QString text, texts) {
|
||||
QAction *action = new QAction(text, plugin);
|
||||
connect(action, SIGNAL(triggered()), this, member);
|
||||
menu->addAction(action);
|
||||
foreach (QString text, texts) {
|
||||
QAction *action = new QAction(text, plugin);
|
||||
connect(action, SIGNAL(triggered()), this, member);
|
||||
menu->addAction(action);
|
||||
|
||||
if (actionGroup) {
|
||||
action->setCheckable(true);
|
||||
actionGroup->addAction(action);
|
||||
}
|
||||
}
|
||||
if (actionGroup) {
|
||||
action->setCheckable(true);
|
||||
actionGroup->addAction(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::applyFilter()
|
||||
{
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
MeshFilterInterface *iFilter = qobject_cast<MeshFilterInterface *>(action->parent());
|
||||
iFilter->applyFilter(action->text(), *(((GLArea *)(workspace->activeWindow()))->mm ), this);
|
||||
QAction *action = qobject_cast<QAction *>(sender());
|
||||
MeshFilterInterface *iFilter = qobject_cast<MeshFilterInterface *>(action->parent());
|
||||
iFilter->applyFilter(action->text(), *(((GLArea *)(workspace->activeWindow()))->mm ), this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -36,50 +36,59 @@ class GLArea;
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow();
|
||||
MainWindow();
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
void open(QString fileName=QString());
|
||||
bool saveAs();
|
||||
void about();
|
||||
void aboutPlugins();
|
||||
void applyFilter();
|
||||
bool saveAs();
|
||||
void about();
|
||||
void aboutPlugins();
|
||||
void applyFilter();
|
||||
void windowsTile();
|
||||
void windowsCascade();
|
||||
void viewToolbar();
|
||||
|
||||
private:
|
||||
void createActions();
|
||||
void createMenus();
|
||||
void createToolBars();
|
||||
void loadPlugins();
|
||||
void addToMenu(QObject *plugin, const QStringList &texts, QMenu *menu,
|
||||
const char *member, QActionGroup *actionGroup = 0);
|
||||
void createActions();
|
||||
void createMenus();
|
||||
void createToolBars();
|
||||
void loadPlugins();
|
||||
void addToMenu(QObject *plugin, const QStringList &texts, QMenu *menu,
|
||||
const char *member, QActionGroup *actionGroup = 0);
|
||||
|
||||
QWorkspace *workspace;
|
||||
QWorkspace *workspace;
|
||||
|
||||
vector<MeshModel *> VM;
|
||||
GLArea *paintArea;
|
||||
QScrollArea *scrollArea;
|
||||
QDir pluginsDir;
|
||||
QStringList pluginFileNames;
|
||||
QToolBar *mainToolBar;
|
||||
//QToolBar *renderToolBar;
|
||||
|
||||
QMenu *fileMenu;
|
||||
QMenu *filterMenu;
|
||||
vector<MeshModel *> VM;
|
||||
GLArea *paintArea;
|
||||
QScrollArea *scrollArea;
|
||||
QDir pluginsDir;
|
||||
QStringList pluginFileNames;
|
||||
QToolBar *mainToolBar;
|
||||
QToolBar *renderToolBar;
|
||||
|
||||
QMenu *fileMenu;
|
||||
QMenu *filterMenu;
|
||||
QMenu *viewMenu;
|
||||
QMenu *windowsMenu;
|
||||
QMenu *helpMenu;
|
||||
QAction *openAct;
|
||||
QAction *saveAsAct;
|
||||
QAction *exitAct;
|
||||
QAction *aboutAct;
|
||||
QAction *aboutQtAct;
|
||||
QMenu *helpMenu;
|
||||
|
||||
QAction *openAct;
|
||||
QAction *saveAsAct;
|
||||
|
||||
QAction *viewModePoints;
|
||||
QAction *viewModeWire;
|
||||
QAction *viewModeLines;
|
||||
QAction *viewModeFlatLines;
|
||||
QAction *viewModeFlat;
|
||||
QAction *viewModeSmooth;
|
||||
|
||||
QAction *exitAct;
|
||||
QAction *aboutAct;
|
||||
QAction *aboutQtAct;
|
||||
QAction *aboutPluginsAct;
|
||||
QAction *viewToolbarAct;
|
||||
QAction *windowsTileAct;
|
||||
|
||||
@ -1,6 +1,13 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="" >
|
||||
<file>images/open.png</file>
|
||||
<file>images/save.png</file>
|
||||
<RCC>
|
||||
<qresource prefix="/" >
|
||||
<file>images\backlines.png</file>
|
||||
<file>images\flat.png</file>
|
||||
<file>images\flatlines.png</file>
|
||||
<file>images\info.png</file>
|
||||
<file>images\open.png</file>
|
||||
<file>images\points.png</file>
|
||||
<file>images\save.png</file>
|
||||
<file>images\smooth.png</file>
|
||||
<file>images\wire.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||