mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-20 03:16:10 +00:00
- added new interrupt system (it must be refined!)
- removed the old one
This commit is contained in:
parent
a72997a543
commit
ea2a277354
@ -369,7 +369,7 @@ void GLArea::paintEvent(QPaintEvent */*event*/)
|
||||
} ///end if busy
|
||||
|
||||
glPopMatrix(); // We restore the state to immediately after the trackball (and before the bbox scaling/translating)
|
||||
|
||||
|
||||
if(trackBallVisible && !takeSnapTile && !(iEdit && !suspendedEditor))
|
||||
trackball.DrawPostApply();
|
||||
|
||||
|
||||
@ -159,10 +159,6 @@ private slots:
|
||||
void viewFromCurrentRasterShot();
|
||||
void copyViewToClipBoard();
|
||||
void pasteViewFromClipboard();
|
||||
void filterUpdateRequest(const bool&,bool*);
|
||||
void interruptFilterExecution();
|
||||
void interruptButtonVisibility();
|
||||
void showInterruptButton(const bool& visible);
|
||||
|
||||
///////////Slot PopUp Menu Handles /////////////////////
|
||||
void splitFromHandle(QAction * qa);
|
||||
@ -217,7 +213,6 @@ private:
|
||||
MeshlabStdDialog *stddialog;
|
||||
MeshLabXMLStdDialog* xmldialog;
|
||||
static QProgressBar *qb;
|
||||
QPushButton* interruptbut;
|
||||
|
||||
QMdiArea *mdiarea;
|
||||
LayerDialog *layerDialog;
|
||||
|
||||
@ -61,7 +61,6 @@ MainWindow::MainWindow()
|
||||
connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)),this, SLOT(updateStdDialog()));
|
||||
connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)),this, SLOT(updateXMLStdDialog()));
|
||||
connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)),this, SLOT(updateDocumentScriptBindings()));
|
||||
connect(mdiarea, SIGNAL(subWindowActivated(QMdiSubWindow *)),this, SLOT(interruptButtonVisibility()));
|
||||
httpReq=new QHttp(this);
|
||||
//connect(httpReq, SIGNAL(requestFinished(int,bool)), this, SLOT(connectionFinished(int,bool)));
|
||||
connect(httpReq, SIGNAL(done(bool)), this, SLOT(connectionDone(bool)));
|
||||
@ -87,12 +86,7 @@ MainWindow::MainWindow()
|
||||
qb->setMaximum(100);
|
||||
qb->setMinimum(0);
|
||||
//qb->reset();
|
||||
QCommonStyle st;
|
||||
interruptbut = new QPushButton(st.standardIcon(QStyle::SP_MediaPause),"",this);
|
||||
interruptbut->setVisible(false);
|
||||
connect(interruptbut,SIGNAL(clicked()),this,SLOT(interruptFilterExecution()));
|
||||
statusBar()->addPermanentWidget(qb,0);
|
||||
statusBar()->addPermanentWidget(interruptbut,0);
|
||||
updateMenus();
|
||||
newProject();
|
||||
//PM should be initialized before passing it to PluginGeneratorGUI
|
||||
|
||||
@ -928,6 +928,8 @@ void MainWindow::startFilter()
|
||||
from the automatic dialog
|
||||
from the user defined dialog
|
||||
*/
|
||||
|
||||
|
||||
void MainWindow::executeFilter(QAction *action, RichParameterSet ¶ms, bool isPreview)
|
||||
{
|
||||
|
||||
@ -1028,8 +1030,6 @@ void MainWindow::executeFilter(QAction *action, RichParameterSet ¶ms, bool i
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MainWindow::executeFilter(MeshLabXMLFilterContainer* mfc, EnvWrap& env, bool /*isPreview*/)
|
||||
{
|
||||
if (mfc == NULL)
|
||||
@ -1039,7 +1039,6 @@ void MainWindow::executeFilter(MeshLabXMLFilterContainer* mfc, EnvWrap& env, boo
|
||||
bool filtercpp = (iFilter != NULL) && (!jscode);
|
||||
QString fname = mfc->act->text();
|
||||
QString ar = mfc->xmlInfo->filterAttribute(fname,MLXMLElNames::filterArity);
|
||||
MeshDocument* mmmmd = meshDoc();
|
||||
if (ar == MLXMLElNames::singleMeshArity)
|
||||
meshDoc()->renderState().addMesh(meshDoc()->mm()->id(),meshDoc()->mm()->cm);
|
||||
|
||||
@ -1146,6 +1145,7 @@ void MainWindow::executeFilter(MeshLabXMLFilterContainer* mfc, EnvWrap& env, boo
|
||||
FilterThread* ft = new FilterThread(fname,&PM.stringXMLFilterMap[fname],*(meshDoc()),env,this);
|
||||
connect(ft,SIGNAL(finished()),this,SLOT(postFilterExecution()));
|
||||
connect(ft,SIGNAL(ThreadCB(const int, const QString&)),this,SLOT(updateProgressBar(const int,const QString&)));
|
||||
connect(xmldialog,SIGNAL(filterInterrupt(const bool)),PM.stringXMLFilterMap[fname].filterInterface,SLOT(setInterrupt(const bool)));
|
||||
ft->start();
|
||||
//ret = iFilter->applyFilter(fname, *(meshDoc()), env, QCallBack);
|
||||
}
|
||||
@ -1184,6 +1184,8 @@ void MainWindow::postFilterExecution()
|
||||
MeshLabXMLFilterContainer* mfc = obj->_mfc;
|
||||
if (mfc == NULL)
|
||||
return;
|
||||
|
||||
mfc->filterInterface->setInterrupt(false);
|
||||
|
||||
QString fname = mfc->act->text();
|
||||
//meshDoc()->setBusy(false);
|
||||
@ -1248,46 +1250,6 @@ void MainWindow::postFilterExecution()
|
||||
delete obj;
|
||||
}
|
||||
|
||||
void MainWindow::filterUpdateRequest(const bool& redraw,bool* interrupted)
|
||||
{
|
||||
GLArea* ar = GLA();
|
||||
//if (ar != NULL && redraw)
|
||||
// ar->singleRedraw();
|
||||
if (ar != NULL)
|
||||
*interrupted = !(ar->showInterruptButton());
|
||||
}
|
||||
|
||||
void MainWindow::interruptFilterExecution()
|
||||
{
|
||||
GLArea* ar = GLA();
|
||||
if (ar != NULL)
|
||||
{
|
||||
showInterruptButton(false);
|
||||
if (meshDoc()->isBusy())
|
||||
meshDoc()->setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::interruptButtonVisibility()
|
||||
{
|
||||
GLArea* ar = GLA();
|
||||
if (ar != NULL)
|
||||
interruptbut->setVisible(ar->showInterruptButton());
|
||||
else
|
||||
interruptbut->setVisible(false);
|
||||
}
|
||||
|
||||
void MainWindow::showInterruptButton(const bool& visible)
|
||||
{
|
||||
GLArea* ar = GLA();
|
||||
if (ar != NULL)
|
||||
{
|
||||
ar->showInterruptButton(visible);
|
||||
interruptbut->setVisible(ar->showInterruptButton());
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
|
||||
void MainWindow::scriptCodeExecuted( const QScriptValue& val,const int time,const QString& output )
|
||||
{
|
||||
if (val.isError())
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#include <QtGui>
|
||||
|
||||
MeshLabXMLStdDialog::MeshLabXMLStdDialog(QWidget *p )
|
||||
:QDockWidget(QString("Plugin"), p),showHelp(false),env()
|
||||
:QDockWidget(QString("Plugin"), p),showHelp(false),env(),isfilterexecuting(false)
|
||||
{
|
||||
curmask = 0;
|
||||
qf = NULL;
|
||||
@ -59,17 +59,17 @@ void MeshLabXMLStdDialog::loadFrameContent( )
|
||||
|
||||
//int buttonRow = 2; // the row where the line of buttons start
|
||||
|
||||
QPushButton *helpButton = new QPushButton("Help", qf);
|
||||
helpButton = new QPushButton("Help", qf);
|
||||
//helpButton->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum);
|
||||
QPushButton *closeButton = new QPushButton("Close", qf);
|
||||
closeButton = new QPushButton("Close", qf);
|
||||
//closeButton->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum);
|
||||
QPushButton *applyButton = new QPushButton("Apply", qf);
|
||||
applyButton = new QPushButton("Apply", qf);
|
||||
//applyButton->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum);
|
||||
QPushButton *defaultButton = new QPushButton("Default", qf);
|
||||
defaultButton = new QPushButton("Default", qf);
|
||||
//defaultButton->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum);
|
||||
ExpandButtonWidget* exp = new ExpandButtonWidget(qf);
|
||||
connect(exp,SIGNAL(expandView(bool)),this,SLOT(extendedView(bool)));
|
||||
|
||||
connect(this->parentWidget(),SIGNAL(filterExecuted()),this,SLOT(postFilterExecution()));
|
||||
#ifdef Q_WS_MAC
|
||||
// Hack needed on mac for correct sizes of button in the bottom of the dialog.
|
||||
helpButton->setMinimumSize(100, 25);
|
||||
@ -89,6 +89,11 @@ void MeshLabXMLStdDialog::loadFrameContent( )
|
||||
//buttonRow++;
|
||||
}
|
||||
|
||||
connect(helpButton,SIGNAL(clicked()),this,SLOT(toggleHelp()));
|
||||
connect(closeButton,SIGNAL(clicked()),this,SLOT(closeClick()));
|
||||
connect(defaultButton,SIGNAL(clicked()),this,SLOT(resetExpressions()));
|
||||
connect(applyButton,SIGNAL(clicked()),this,SLOT(applyClick()));
|
||||
|
||||
gridLayout->addWidget(exp,gridLayout->rowCount(),0,1,2,Qt::AlignJustify);
|
||||
int firstButLine = gridLayout->rowCount();
|
||||
gridLayout->addWidget(helpButton, firstButLine,1,Qt::AlignBottom);
|
||||
@ -98,11 +103,6 @@ void MeshLabXMLStdDialog::loadFrameContent( )
|
||||
gridLayout->addWidget(applyButton, secButLine,1,Qt::AlignBottom);
|
||||
|
||||
|
||||
connect(helpButton,SIGNAL(clicked()),this,SLOT(toggleHelp()));
|
||||
connect(applyButton,SIGNAL(clicked()),this,SLOT(applyClick()));
|
||||
connect(closeButton,SIGNAL(clicked()),this,SLOT(closeClick()));
|
||||
connect(defaultButton,SIGNAL(clicked()),this,SLOT(resetExpressions()));
|
||||
|
||||
qf->showNormal();
|
||||
qf->adjustSize();
|
||||
|
||||
@ -161,6 +161,12 @@ bool MeshLabXMLStdDialog::showAutoDialog(MeshLabXMLFilterContainer& mfc,PluginMa
|
||||
void MeshLabXMLStdDialog::applyClick()
|
||||
{
|
||||
//env.pushContext();
|
||||
if ((isfilterexecuting) && (curmfc->xmlInfo->filterAttribute(curmfc->act->text(),MLXMLElNames::filterIsInterruptible) == "true"))
|
||||
{
|
||||
emit filterInterrupt(true);
|
||||
return;
|
||||
}
|
||||
|
||||
assert(curParMap.size() == stdParFrame->xmlfieldwidgets.size());
|
||||
for(int ii = 0;ii < curParMap.size();++ii)
|
||||
{
|
||||
@ -171,7 +177,6 @@ void MeshLabXMLStdDialog::applyClick()
|
||||
////int mask = 0;//curParSet.getDynamicFloatMask();
|
||||
if(curmask)
|
||||
meshState.apply(curModel);
|
||||
|
||||
//applyContext = env.currentContext()->toString();
|
||||
////PreView Caching: if the apply parameters are the same to those used in the preview mode
|
||||
////we don't need to reapply the filter to the mesh
|
||||
@ -182,6 +187,7 @@ void MeshLabXMLStdDialog::applyClick()
|
||||
//{
|
||||
QString nm = curmfc->act->text();
|
||||
EnvWrap* wrap = new EnvWrap(env);
|
||||
startFilterExecution();
|
||||
curmwi->executeFilter(curmfc,*wrap,false);
|
||||
/*}*/
|
||||
//env.popContext();
|
||||
@ -303,6 +309,46 @@ void MeshLabXMLStdDialog::resetPointers()
|
||||
curModel = NULL;
|
||||
}
|
||||
|
||||
void MeshLabXMLStdDialog::postFilterExecution()
|
||||
{
|
||||
setDialogStateRelativeToFilterExecution(false);
|
||||
}
|
||||
|
||||
void MeshLabXMLStdDialog::startFilterExecution()
|
||||
{
|
||||
setDialogStateRelativeToFilterExecution(true);
|
||||
}
|
||||
|
||||
void MeshLabXMLStdDialog::setDialogStateRelativeToFilterExecution( const bool isfilterinexecution )
|
||||
{
|
||||
isfilterexecuting = isfilterinexecution;
|
||||
if (curmfc == NULL)
|
||||
return;
|
||||
QString inter = curmfc->xmlInfo->filterAttribute(curmfc->act->text(),MLXMLElNames::filterIsInterruptible);
|
||||
|
||||
if (inter == "true")
|
||||
{
|
||||
applyButton->setEnabled(true);
|
||||
//during filter execution Stop label should appear, otherwise the apply button is in the usual apply state
|
||||
applyButton->setText(MeshLabXMLStdDialog::applyButtonLabel(!isfilterinexecution));
|
||||
}
|
||||
else
|
||||
{
|
||||
applyButton->setText(MeshLabXMLStdDialog::applyButtonLabel(true));
|
||||
applyButton->setEnabled(!isfilterexecuting);
|
||||
}
|
||||
stdParFrame->setEnabled(!isfilterexecuting);
|
||||
}
|
||||
|
||||
QString MeshLabXMLStdDialog::applyButtonLabel( const bool applystate )
|
||||
{
|
||||
if (applystate)
|
||||
return QString("Apply");
|
||||
else
|
||||
return QString("Stop");
|
||||
return QString();
|
||||
}
|
||||
|
||||
XMLStdParFrame::XMLStdParFrame( QWidget *p,QWidget *gla/*=0*/ )
|
||||
:QFrame(p),extended(false)
|
||||
{
|
||||
|
||||
@ -449,7 +449,6 @@ public:
|
||||
void closeEvent ( QCloseEvent * event );
|
||||
void resetPointers();
|
||||
MeshModel *curModel;
|
||||
//signals:
|
||||
//void dialogEvaluateExpression(const Expression& exp,Value** res);
|
||||
//void expandView(bool exp);
|
||||
|
||||
@ -463,8 +462,14 @@ private slots:
|
||||
void applyDynamic();
|
||||
void changeCurrentMesh(int meshInd);
|
||||
void extendedView(bool ext);
|
||||
void postFilterExecution();
|
||||
|
||||
private:
|
||||
void startFilterExecution();
|
||||
void setDialogStateRelativeToFilterExecution(const bool isfilterinexecution);
|
||||
static QString applyButtonLabel(const bool applystate);
|
||||
bool isfilterexecuting;
|
||||
|
||||
Env env;
|
||||
QFrame *qf;
|
||||
XMLStdParFrame *stdParFrame;
|
||||
@ -482,6 +487,15 @@ private:
|
||||
QString previewContext;
|
||||
bool validcache;
|
||||
bool showHelp;
|
||||
|
||||
//we have to change the button caption when the filter has been launched for execution
|
||||
QPushButton *applyButton;
|
||||
QPushButton *helpButton;
|
||||
QPushButton *closeButton;
|
||||
QPushButton *defaultButton;
|
||||
|
||||
signals:
|
||||
void filterInterrupt(const bool isinterruptrequested);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user