added xml editor gui

This commit is contained in:
Guido Ranzuglia granzuglia 2011-10-24 07:42:30 +00:00
parent 44a0a0e132
commit 96b5fc3df0
14 changed files with 2204 additions and 137 deletions

View File

@ -1,7 +1,15 @@
#include "additionalgui.h"
CheckBoxList::CheckBoxList(const QString& defaultValue,QWidget *widget )
:QComboBox(widget),highli(0),default(defaultValue)
:QComboBox(widget),highli(0),defaultval(defaultValue)
{
view()->viewport()->installEventFilter(this);
view()->setAlternatingRowColors(true);
connect(this,SIGNAL(highlighted(int)),this,SLOT(currentHighlighted(int)));
}
CheckBoxList::CheckBoxList( QWidget *widget /*= 0*/ )
:QComboBox(widget),highli(0),defaultval()
{
view()->viewport()->installEventFilter(this);
view()->setAlternatingRowColors(true);
@ -20,7 +28,7 @@ void CheckBoxList::paintEvent(QPaintEvent *)
QStyleOptionComboBox opt;
initStyleOption(&opt);
if (selectedItemsNames().empty())
opt.currentText = default;
opt.currentText = defaultval;
else
opt.currentText = selectedItemsString(QString(" | "));
for (int ii=0;ii<count();++ii)
@ -91,5 +99,188 @@ QStringList CheckBoxList::selectedItemsNames() const
QString CheckBoxList::selectedItemsString(const QString& sep) const
{
QStringList ll = selectedItemsNames();
if (ll.isEmpty())
return defaultval;
return ll.join(sep);
}
}
void CheckBoxList::setDefaultValue( const QString& defaultValue )
{
defaultval = defaultValue;
}
void CheckBoxList::setCurrentValue( const QStringList& st )
{
sel = st;
}
QPixmap UsefulGUIFunctions::pixmapGeneratorFromQtPrimitiveElement(const QSize& pixmapsize,const QStyle::PrimitiveElement primitive, QStyle *style,const QStyleOption& opt)
{
QPixmap pix(pixmapsize);
pix.fill(Qt::transparent);
QPainter p;
p.begin(&pix);
style->drawPrimitive(primitive, &opt, &p);
p.end();
return pix;
}
QString UsefulGUIFunctions::generateUniqueDefaultName( const QString& basename,const QStringList& namelist)
{
int max = INT_MIN;
QString regexp(basename + "_(\\d)+");
QStringList items = namelist.filter(QRegExp(regexp));
for(int ii = 0;ii < items.size();++ii)
{
QRegExp reg("(\\d)+");
items[ii].indexOf(reg);
int index = reg.cap().toInt();
if (index > max)
max = index;
}
QString tmpname = basename + "_";
if (items.size() == 0)
tmpname += QString::number(namelist.size());
else
tmpname += QString::number(max + 1);
return tmpname;
}
QString UsefulGUIFunctions::generateFunctionName(const QString& originaltext)
{
QString newname;
if (originaltext.isEmpty())
return newname;
QRegExp nonchar("\\W+");
int index = 0;
do
{
originaltext.indexOf(nonchar,index);
QRegExp validchar("\\w+");
int validcharind = originaltext.indexOf(validchar,index);
if (validcharind != -1)
{
QString captured = validchar.cap();
if (captured.size() > 0)
captured[0] = captured[0].toUpper();
newname.push_back(captured);
}
index = index + validchar.cap().size() + nonchar.cap().size();
} while (index < originaltext.size());
if (originaltext[0].isLetter() && (newname.size() > 0))
newname[0] = originaltext[0].toLower();
return newname;
}
QString UsefulGUIFunctions::changeNameIfAlreadyInList( const QString& name,const QStringList& allnames )
{
QStringList ls;
QString tmpname = name;
do
{
ls = allnames.filter(tmpname);
if (ls.size() > 1)
tmpname = tmpname + "_" + QString::number(ls.size() - 1);
} while(ls.size() > 1);
return tmpname;
}
QString UsefulGUIFunctions::generateBackupName( const QFileInfo& finfo )
{
QDir dir = finfo.absoluteDir();
QFileInfoList list = dir.entryInfoList(QDir::Files);
QRegExp oldexp(finfo.fileName() + "\\.old(\\d+)");
int max = 0;
for (int ii = 0;ii < list.size();++ii)
{
if (list[ii].fileName().contains(oldexp))
{
QRegExp num("\\d+");
list[ii].suffix().indexOf(num);
int ver = num.cap().toInt();
if (ver > max)
max = ver;
}
}
return QString(finfo.absolutePath() + "/" + finfo.completeBaseName() + ".old" + QString::number(max));
}
ExpandButtonWidget::ExpandButtonWidget( QWidget* parent )
:QWidget(parent),isExpanded(false)
{
exp = new PrimitiveButton(QStyle::PE_IndicatorArrowDown,this);
exp->setMaximumSize(16,16);
QHBoxLayout *hlay = new QHBoxLayout(this);
hlay->addWidget(exp,0,Qt::AlignHCenter);
connect(exp,SIGNAL(clicked(bool)),this,SLOT(changeIcon()));
}
ExpandButtonWidget::~ExpandButtonWidget()
{
}
void ExpandButtonWidget::changeIcon()
{
isExpanded = !isExpanded;
if (isExpanded)
exp->setPrimitiveElement(QStyle::PE_IndicatorArrowUp);
else
exp->setPrimitiveElement(QStyle::PE_IndicatorArrowDown);
emit expandView(isExpanded);
}
PrimitiveButton::PrimitiveButton(const QStyle::PrimitiveElement el,QWidget* parent )
:QPushButton(parent),elem(el)
{
}
PrimitiveButton::PrimitiveButton( QWidget* parent )
:QPushButton(parent),elem(QStyle::PE_CustomBase)
{
}
PrimitiveButton::~PrimitiveButton()
{
}
void PrimitiveButton::paintEvent( QPaintEvent * event )
{
QStylePainter painter(this);
QStyleOptionButton option;
option.initFrom(this);
//painter.drawControl(QStyle::CE_PushButton,option);
painter.drawPrimitive (elem,option);
}
void PrimitiveButton::setPrimitiveElement( const QStyle::PrimitiveElement el)
{
elem = el;
}
TreeWidgetWithMenu::TreeWidgetWithMenu( QWidget* parent /*= NULL*/ )
:QTreeWidget(parent)
{
menu = new QMenu(this);
connect(menu,SIGNAL(triggered(QAction*)),this,SIGNAL(selectedAction(QAction*)));
}
TreeWidgetWithMenu::~TreeWidgetWithMenu()
{
}
void TreeWidgetWithMenu::contextMenuEvent( QContextMenuEvent * event )
{
menu->popup(event->globalPos());
}
void TreeWidgetWithMenu::insertInMenu(const QString& st,const QVariant& data)
{
QAction* act = menu->addAction(st);
act->setData(data);
}

View File

@ -4,11 +4,13 @@
#include <QtGui>
#include <QString>
//WARNING!!!!DON'T USE QComboBox currentText() to get selected elements! Instead use selectedItemsString.
class CheckBoxList: public QComboBox
{
Q_OBJECT;
public:
CheckBoxList(QWidget *widget = 0);
CheckBoxList(const QString& defaultValue,QWidget *widget = 0);
~CheckBoxList();
void paintEvent(QPaintEvent *);
@ -17,15 +19,79 @@ public:
void insertCheckableItem(const int pos,const QString& lab,const bool checked);
void insertCheckableItem(const QString& lab,const bool checked );
void updateSelected(int ind);
QString selectedItemsString(const QString& sep) const;
QString selectedItemsString(const QString& sep = QString(" | ")) const;
QStringList selectedItemsNames() const;
void setDefaultValue(const QString& defaultValue);
private slots:
void currentHighlighted(int high);
public slots:
void setCurrentValue(const QStringList& st);
private:
QStringList sel;
int highli;
QString default;
QString defaultval;
};
#endif // CHECKBOXLIST_H
class PrimitiveButton : public QPushButton
{
Q_OBJECT
public:
PrimitiveButton(QWidget* parent);
PrimitiveButton(const QStyle::PrimitiveElement el,QWidget* parent);
~PrimitiveButton();
void setPrimitiveElement(const QStyle::PrimitiveElement el);
protected:
void paintEvent(QPaintEvent * event);
private:
QStyle::PrimitiveElement elem;
};
class ExpandButtonWidget : public QWidget
{
Q_OBJECT
public:
ExpandButtonWidget(QWidget* parent);
~ExpandButtonWidget();
private slots:
void changeIcon();
signals:
void expandView(bool exp);
private:
PrimitiveButton* exp;
bool isExpanded;
};
class TreeWidgetWithMenu : public QTreeWidget
{
Q_OBJECT
public:
TreeWidgetWithMenu(QWidget* parent = NULL);
~TreeWidgetWithMenu();
void insertInMenu(const QString& st,const QVariant& data);
protected:
void contextMenuEvent( QContextMenuEvent * event );
private:
QMenu* menu;
signals:
void selectedAction(QAction* act);
};
class UsefulGUIFunctions
{
public:
static QPixmap pixmapGeneratorFromQtPrimitiveElement(const QSize& pixmapsize,const QStyle::PrimitiveElement primitive, QStyle *style,const QStyleOption& opt);
//result will be something like basename_number
static QString generateUniqueDefaultName(const QString& basename,const QStringList& namelist);
//called by an editingText event on a QLineEdit. Typically used when we need that the text in a QLineEdit is depending on the content of another widget.
//Originaltext is the text contained in the pattern widget we are currently editing.
//Example if original text is "Random vertex Displacement (really random)" we will obtain like result randomVertexDisplacementReallyRandom
static QString generateFunctionName(const QString& originaltext);
static QString changeNameIfAlreadyInList(const QString& name,const QStringList& allnames);
static QString generateBackupName(const QFileInfo& finfo);
};
#endif // CHECKBOXLIST_H

View File

@ -40,6 +40,7 @@
#include "layerDialog.h"
#include "stdpardialog.h"
#include "xmlstdpardialog.h"
#include "xmlgeneratorgui.h"
#define MAXRECENTFILES 4
@ -110,6 +111,7 @@ private slots:
void runFilterScript();
void showFilterScript();
void showScriptEditor();
void showXMLPluginEditorGui();
void showTooltip(QAction*);
/////////// Slot Menu Render /////////////////////
void renderBbox();
@ -206,6 +208,7 @@ private:
static QProgressBar *qb;
QMdiArea *mdiarea;
LayerDialog *layerDialog;
PluginGeneratorGUI* plugingui;
QSignalMapper *windowMapper;
@ -350,6 +353,7 @@ private:
QAction *runFilterScriptAct;
QAction *showFilterScriptAct;
QAction* showScriptEditAct;
QAction* showFilterEditAct;
/////////// Actions Menu Edit /////////////////////
QAction *suspendEditModeAct;
/////////// Actions Menu Render /////////////////////
@ -438,6 +442,7 @@ private:
////////////////////////////////////////////////////
};
/// Event filter that is installed to intercept the open events sent directly by the Operative System
class FileOpenEater : public QObject
{

View File

@ -48,6 +48,10 @@ MainWindow::MainWindow()
layerDialog = new LayerDialog(this);
layerDialog->setAllowedAreas ( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
addDockWidget(Qt::RightDockWidgetArea,layerDialog);
plugingui = new PluginGeneratorGUI(this);
plugingui->setAllowedAreas ( Qt::LeftDockWidgetArea | Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea);
addDockWidget(Qt::LeftDockWidgetArea,plugingui);
//setCentralWidget(workspace);
setCentralWidget(mdiarea);
windowMapper = new QSignalMapper(this);
@ -350,6 +354,10 @@ void MainWindow::createActions()
showScriptEditAct->setEnabled(false);
connect(showScriptEditAct, SIGNAL(triggered()), this, SLOT(showScriptEditor()));
showFilterEditAct = new QAction(tr("XML Plugin Editor GUI"),this);
showFilterEditAct->setEnabled(false);
connect(showFilterEditAct, SIGNAL(triggered()), this, SLOT(showXMLPluginEditorGui()));
//////////////Action Menu Preferences /////////////////////////////////////////////////////////////////////
setCustomizeAct = new QAction(tr("&Options..."),this);
connect(setCustomizeAct, SIGNAL(triggered()), this, SLOT(setCustomize()));
@ -473,6 +481,7 @@ void MainWindow::createMenus()
filterMenu->addAction(lastFilterAct);
filterMenu->addAction(showFilterScriptAct);
filterMenu->addAction(showScriptEditAct);
filterMenu->addAction(showFilterEditAct);
filterMenu->addSeparator();
@ -625,7 +634,7 @@ void MainWindow::fillFilterMenu()
{
//MeshLabFilterInterface * iFilter= xmlit.value().filterInterface;
QAction *filterAction = xmlit.value().act;
XMLFilterInfo* info = xmlit.value().xmlInfo;
MLXMLPluginInfo* info = xmlit.value().xmlInfo;
QString filterName = xmlit.key();
try
{

View File

@ -37,6 +37,7 @@
#include "savemaskexporter.h"
#include "alnParser.h"
#include <exception>
#include "xmlgeneratorgui.h"
#include "../common/scriptinterface.h"
@ -869,7 +870,7 @@ void MainWindow::startFilter()
// "minExpr" - "minExpr"
// "maxExpr" - "maxExpr"
XMLFilterInfo::XMLMapList params = filt.xmlInfo->filterParametersExtendedInfo(fname);
MLXMLPluginInfo::XMLMapList params = filt.xmlInfo->filterParametersExtendedInfo(fname);
/*****IMPORTANT NOTE******/
@ -881,9 +882,9 @@ void MainWindow::startFilter()
try
{
//each map inside the list contains info (type,name,def_expr) on each parameter inside the filter
for(XMLFilterInfo::XMLMapList::const_iterator it = params.constBegin();it != params.constEnd();++it)
for(MLXMLPluginInfo::XMLMapList::const_iterator it = params.constBegin();it != params.constEnd();++it)
{
XMLFilterInfo::XMLMap mp = *(it);
MLXMLPluginInfo::XMLMap mp = *(it);
//Initilize the parameters inside the environment
//Expression* exp = ExpressionFactory::create(mp[MLXMLElNames::paramType],mp[MLXMLElNames::paramDefExpr]);
@ -1933,6 +1934,8 @@ void MainWindow::showInfoPane() {if(GLA() != 0) GLA()->infoAreaVisible =!GLA()-
void MainWindow::showTrackBall() {if(GLA() != 0) GLA()->showTrackBall(!GLA()->isTrackBallVisible());}
void MainWindow::resetTrackBall(){if(GLA() != 0) GLA()->resetTrackBall();}
void MainWindow::showLayerDlg() {if(GLA() != 0) layerDialog->setVisible( !layerDialog->isVisible() );}
void MainWindow::showXMLPluginEditorGui(){if(GLA() != 0) plugingui->setVisible( !plugingui->isVisible() );}
void MainWindow::setCustomize()
{

View File

@ -22,6 +22,8 @@ HEADERS = ../common/interfaces.h \
layerDialog.h \
stdpardialog.h \
xmlstdpardialog.h \
additionalgui.h \
xmlgeneratorgui.h \
$$VCGDIR/wrap/gui/trackball.h \
$$VCGDIR/wrap/gui/trackmode.h \
$$VCGDIR/wrap/gl/trimesh.h
@ -39,6 +41,8 @@ SOURCES = main.cpp \
changetexturename.cpp \
stdpardialog.cpp \
xmlstdpardialog.cpp \
additionalgui.cpp \
xmlgeneratorgui.cpp \
$$VCGDIR/wrap/gui/trackball.cpp \
$$VCGDIR/wrap/gui/trackmode.cpp \
glarea_setting.cpp
@ -51,7 +55,11 @@ FORMS = ui/layerDialog.ui \
ui/renametexture.ui \
ui/savemaskexporter.ui \
ui/congratsDialog.ui \
ui/scriptEditor.ui
ui/scriptEditor.ui \
ui/filtergui.ui \
ui/paramgui.ui \
ui/filtercreatortab.ui
win32-msvc2005: RCC_DIR = $(ConfigurationName)

View File

@ -134,7 +134,7 @@ void PluginDialog::populateTreeWidget(const QString &path,const QStringList &fil
QString xmlFile = dir.absoluteFilePath(tmp);
XMLMessageHandler xmlErr;
MeshLabXMLFilterContainer fc;
fc.xmlInfo = XMLFilterInfo::createXMLFileInfo(xmlFile,ScriptAdapterGenerator::xmlSchemaFile(),xmlErr);
fc.xmlInfo = MLXMLPluginInfo::createXMLPluginInfo(xmlFile,MLXMLUtilityFunctions::xmlSchemaFile(),xmlErr);
if (fc.xmlInfo != NULL)
{
QStringList fn = fc.xmlInfo->filterNames();
@ -216,7 +216,7 @@ void PluginDialog::displayInfo(QTreeWidgetItem* item,int /* ncolumn*/)
QString xmlFile = dir.absoluteFilePath(tmp);
XMLMessageHandler xmlErr;
MeshLabXMLFilterContainer fc;
fc.xmlInfo = XMLFilterInfo::createXMLFileInfo(xmlFile,ScriptAdapterGenerator::xmlSchemaFile(),xmlErr);
fc.xmlInfo = MLXMLPluginInfo::createXMLPluginInfo(xmlFile,MLXMLUtilityFunctions::xmlSchemaFile(),xmlErr);
if (fc.xmlInfo != NULL)
{
QStringList ls = fc.xmlInfo->filterNames();

View File

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FilterCreatorTab</class>
<widget class="QFrame" name="FilterCreatorTab">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>785</width>
<height>700</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="mainlayout">
<item row="0" column="0">
<widget class="PrimitiveButton" name="jsbut">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>JavaScript Code Area</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QFrame" name="jsframe">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTextEdit" name="jscode">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="PrimitiveButton" name="guibut">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label_2">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string>Filter Generator GUI</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="FilterGeneratorGUI" name="guiframe">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>PrimitiveButton</class>
<extends>QPushButton</extends>
<header>additionalgui.h</header>
</customwidget>
<customwidget>
<class>FilterGeneratorGUI</class>
<extends>QFrame</extends>
<header>xmlgeneratorgui.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

521
src/meshlab/ui/filtergui.ui Normal file
View File

@ -0,0 +1,521 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FilterCreatorGUI</class>
<widget class="QFrame" name="FilterCreatorGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>567</width>
<height>325</height>
</rect>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>240</red>
<green>240</green>
<blue>240</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>247</red>
<green>247</green>
<blue>247</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>160</red>
<green>160</green>
<blue>160</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>247</red>
<green>247</green>
<blue>247</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>240</red>
<green>240</green>
<blue>240</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>247</red>
<green>247</green>
<blue>247</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>160</red>
<green>160</green>
<blue>160</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>247</red>
<green>247</green>
<blue>247</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>240</red>
<green>240</green>
<blue>240</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>247</red>
<green>247</green>
<blue>247</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>160</red>
<green>160</green>
<blue>160</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>240</red>
<green>32</green>
<blue>122</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>240</red>
<green>240</green>
<blue>240</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="windowTitle">
<string>Filter Editor</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Filter Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameLine">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2" rowspan="7">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Parameters Viewer</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="TreeWidgetWithMenu" name="paramviewer">
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Filter JS Function </string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="functionLine"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Category</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="CheckBoxList" name="category"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Arity</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="arity"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Pre-Conditions</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="CheckBoxList" name="precond"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Post-Conditions</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="CheckBoxList" name="postcond"/>
</item>
<item row="6" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Filter Help</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPlainTextEdit" name="helpedit"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>CheckBoxList</class>
<extends>QComboBox</extends>
<header>additionalgui.h</header>
</customwidget>
<customwidget>
<class>TreeWidgetWithMenu</class>
<extends>QTreeWidget</extends>
<header>additionalgui.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

204
src/meshlab/ui/paramgui.ui Normal file
View File

@ -0,0 +1,204 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ParamCreatorGUI</class>
<widget class="QFrame" name="ParamCreatorGUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>411</width>
<height>494</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="nameline"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Type</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="typesel"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default Value</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="defvalline"/>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="isimportant">
<property name="text">
<string>Is Important</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Help</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>GUI Widget</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="guisel"/>
</item>
<item row="6" column="1">
<widget class="QFrame" name="labelframe">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>label</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="labelline"/>
</item>
</layout>
</widget>
</item>
<item row="7" column="1">
<widget class="QFrame" name="frame">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>min</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="minline">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>max</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="maxline">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,821 @@
#include "ui_filtergui.h"
#include "ui_paramgui.h"
#include "ui_filtercreatortab.h"
//#include "ui_filtereditorframe.h"
#include "xmlgeneratorgui.h"
#include "../common/meshmodel.h"
#include "../common/interfaces.h"
#include "../common/mlexception.h"
#include <QSplitter>
ParamGeneratorGUI::ParamGeneratorGUI(QWidget* parent /*= NULL*/ )
:QFrame(parent),currentname(),parentitem(NULL)
{
initUI();
initConnections();
}
ParamGeneratorGUI::ParamGeneratorGUI( const QString& name,QTreeWidgetItem* pitem,QWidget* parent /*= NULL*/ )
:QFrame(parent),parentitem(pitem),currentname(name)
{
initUI();
initConnections();
setParamName(name);
}
ParamGeneratorGUI::~ParamGeneratorGUI()
{
}
void ParamGeneratorGUI::collectInfo( MLXMLParamSubTree& param )
{
param.paraminfo[MLXMLElNames::paramType] = ptype->currentText();
param.paraminfo[MLXMLElNames::paramName] = pname->text();
param.paraminfo[MLXMLElNames::paramDefExpr] = pdefault->text();
QString isimp("false");
if (pisimp->isChecked())
isimp = "true";
param.paraminfo[MLXMLElNames::paramIsImportant] = isimp;
param.paraminfo[MLXMLElNames::paramHelpTag] = phel->toPlainText();
param.gui.guiinfo[MLXMLElNames::guiType] = pguitype->currentText();
param.gui.guiinfo[MLXMLElNames::guiLabel] = pguilab->text();
param.gui.guiinfo[MLXMLElNames::guiMinExpr] = pguimin->text();
param.gui.guiinfo[MLXMLElNames::guiMaxExpr] = pguimax->text();
}
void ParamGeneratorGUI::initConnections()
{
connect(ptype,SIGNAL(currentIndexChanged(const QString&)),this,SLOT(updateGUIType(const QString&)));
connect(pguitype,SIGNAL(currentIndexChanged(const QString&)),this,SLOT(updateGUIWidgetInterface(const QString&)));
connect(pname,SIGNAL(textChanged(const QString&)),this,SLOT(updateItemLabel(const QString&)));
connect(pname,SIGNAL(editingFinished()),this,SLOT(validateName()));
}
void ParamGeneratorGUI::initUI()
{
QLabel* tlab = new QLabel("Type",this);
ptype = new QComboBox(this);
ptype->view()->setAlternatingRowColors(true);
QStringList ptypelist;
MLXMLElNames::initMLXMLTypeList(ptypelist);
ptype->addItems(ptypelist);
QLabel* nlab = new QLabel("Name",this);
pname = new QLineEdit(this);
QLabel* dlab = new QLabel("Default Value",this);
pdefault = new QLineEdit(this);
pisimp = new QCheckBox("isImportant",this);
pisimp->setCheckState(Qt::Checked);
QLabel* hlab = new QLabel("Help",this);
phel = new QPlainTextEdit(this);
/*QLabel* glab = new QLabel("GUI",this);*/
pguitree = new QTreeWidget(this);
pguitree->header()->hide();
QGridLayout* layout = new QGridLayout(this);
layout->addWidget(tlab,0,0);
layout->addWidget(ptype,0,1);
layout->addWidget(nlab,1,0);
layout->addWidget(pname,1,1);
layout->addWidget(dlab,2,0);
layout->addWidget(pdefault,2,1);
layout->addWidget(pisimp,3,0);
layout->addWidget(hlab,4,0);
layout->addWidget(phel,4,1);
layout->addWidget(pguitree,5,1);
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0,"GUI");
pguitree->setColumnCount(2);
QTreeWidgetItem* ptChildItem = new QTreeWidgetItem();
item->addChild(ptChildItem);
QLabel* wlab = new QLabel("Widget",this);
pguitree->setItemWidget(ptChildItem,0,wlab);
pguitype = new QComboBox(this);
pguitype->view()->setAlternatingRowColors(true);
pguitree->setItemWidget(ptChildItem,1,pguitype);
QTreeWidgetItem* childItem = new QTreeWidgetItem();
item->addChild(childItem);
QLabel* llab = new QLabel("Label",this);
pguitree->setItemWidget(childItem,0,llab);
pguilab = new QLineEdit(this);
pguitree->setItemWidget(childItem,1,pguilab);
pguiminitem = new QTreeWidgetItem();
item->addChild(pguiminitem);
pguiminlab = new QLabel("Min",this);
pguitree->setItemWidget(pguiminitem,0,pguiminlab);
pguimin = new QLineEdit(this);
pguitree->setItemWidget(pguiminitem,1,pguimin);
pguimaxitem = new QTreeWidgetItem();
item->addChild(pguimaxitem);
pguimaxlab = new QLabel("Max",this);
pguitree->setItemWidget(pguimaxitem,0,pguimaxlab);
pguimax = new QLineEdit(this);
pguitree->setItemWidget(pguimaxitem,1,pguimax);
pguitree->setVerticalScrollMode(QTreeWidget::ScrollPerPixel);
pguitree->insertTopLevelItem(0,item);
updateGUIType(ptype->currentText());
//updateGUIWidgetInterface(pguitype->currentText());
}
void ParamGeneratorGUI::updateGUIType( const QString& paramtype )
{
pguitype->clear();
QStringList ls;
MLXMLElNames::initMLXMLGUIListForType(paramtype,ls);
pguitype->addItems(ls);
}
void ParamGeneratorGUI::updateGUIWidgetInterface( const QString& guitype )
{
bool show = ((guitype == MLXMLElNames::absPercTag) || (guitype == MLXMLElNames::sliderWidgetTag));
pguiminitem->setHidden(!show);
pguimaxitem->setHidden(!show);
}
void ParamGeneratorGUI::setParamName( const QString& name )
{
currentname = name;
pname->setText(currentname);
//emit paramNameChanged(tmp,pname->text());
}
void ParamGeneratorGUI::validateName()
{
emit paramNameValidationRequest(parentitem,pname->text());
}
void ParamGeneratorGUI::updateItemLabel( const QString& text)
{
emit itemLabelUpdateRequest(parentitem,text);
}
void ParamGeneratorGUI::importInfo( const MLXMLParamSubTree& tree )
{
QString typ = tree.paraminfo[MLXMLElNames::paramType];
ptype->setCurrentIndex(ptype->findText(tree.paraminfo[MLXMLElNames::paramType]));
pname->setText(tree.paraminfo[MLXMLElNames::paramName]);
pdefault->setText(tree.paraminfo[MLXMLElNames::paramDefExpr]);
phel->setPlainText(tree.paraminfo[MLXMLElNames::paramHelpTag]);
bool check = true;
if (tree.paraminfo[MLXMLElNames::paramIsImportant].trimmed() == QString("false"))
check = false;
pisimp->setChecked(check);
QString guity = tree.gui.guiinfo[MLXMLElNames::guiType];
pguitype->setCurrentIndex(pguitype->findText(guity));
pguilab->setText(tree.gui.guiinfo[MLXMLElNames::guiLabel]);
if ((guity == MLXMLElNames::absPercTag) || (guity == MLXMLElNames::sliderWidgetTag))
{
pguimin->setText(tree.gui.guiinfo[MLXMLElNames::guiMinExpr]);
pguimax->setText(tree.gui.guiinfo[MLXMLElNames::guiMaxExpr]);
}
}
FilterGeneratorGUI::FilterGeneratorGUI( QWidget* parent /*= NULL*/ )
:QFrame(parent)
{
ui = new Ui::FilterCreatorGUI();
ui->setupUi(this);
//(49,149,255)
this->setStyleSheet("QFrame { background-color:rgb(189,215,255); border-radius: 4px; } QPlainTextEdit{ background-color: white;} QTreeWidget { background-color: white;}");
fillComboBoxes();
createContextMenu();
ui->paramviewer->setVerticalScrollMode(QTreeWidget::ScrollPerPixel);
ui->arity->view()->setAlternatingRowColors(true);
ui->paramviewer->header()->hide();
connect(ui->nameLine,SIGNAL(textChanged(const QString&)),this,SLOT(updateFunctionName(const QString&)));
connect(ui->nameLine,SIGNAL(textEdited(const QString&)),this,SLOT(filterNameUpdated(const QString&)));
connect(ui->nameLine,SIGNAL(editingFinished()),this,SLOT(filterNameValidationRequest()));
}
FilterGeneratorGUI::~FilterGeneratorGUI()
{
}
void FilterGeneratorGUI::collectInfo( MLXMLFilterSubTree& filter )
{
filter.filterinfo[MLXMLElNames::filterName] = ui->nameLine->text();
filter.filterinfo[MLXMLElNames::filterScriptFunctName] = ui->functionLine->text();
filter.filterinfo[MLXMLElNames::filterArity] = ui->arity->currentText();
filter.filterinfo[MLXMLElNames::filterPreCond] = ui->precond->selectedItemsString();
filter.filterinfo[MLXMLElNames::filterPostCond] = ui->postcond->selectedItemsString();
filter.filterinfo[MLXMLElNames::filterClass] = ui->category->selectedItemsString();
filter.filterinfo[MLXMLElNames::filterHelpTag] = ui->helpedit->toPlainText();
QList<QTreeWidgetItem*> items = ui->paramviewer->findItems(QString(".*"),Qt::MatchRegExp);
for(int ii = 0;ii < items.size();++ii)
{
if (items.at(ii)->child(0) != NULL)
{
QWidget* wid = ui->paramviewer->itemWidget(items.at(ii)->child(0),0);
if (wid)
{
ParamGeneratorGUI* pgui = qobject_cast<ParamGeneratorGUI*>(wid);
if (pgui)
{
MLXMLParamSubTree subtree;
pgui->collectInfo(subtree);
filter.params.push_back(subtree);
}
}
}
}
}
void FilterGeneratorGUI::fillComboBoxes()
{
QString gen("Generic");
QMap<QString,MeshFilterInterface::FilterClass> category;
MeshLabFilterInterface::initConvertingCategoryMap(category);
for(QMap<QString,MeshFilterInterface::FilterClass>::iterator it = category.begin();it != category.end();++it)
{
if (it.key() != gen)
ui->category->addItem(it.key());
else
ui->category->setDefaultValue(gen);
}
QString none("MM_NONE");
QMap<QString,MeshModel::MeshElement> element;
MeshLabFilterInterface::initConvertingMap(element);
for(QMap<QString,MeshModel::MeshElement>::iterator it = element.begin();it != element.end();++it)
{
if (it.key() != none)
{
ui->precond->addItem(it.key());
ui->postcond->addItem(it.key());
}
else
{
ui->precond->setDefaultValue(none);
ui->postcond->setDefaultValue(none);
}
}
ui->arity->addItem(MLXMLElNames::singleMeshArity);
ui->arity->addItem(MLXMLElNames::fixedArity);
ui->arity->addItem(MLXMLElNames::variableArity);
}
void FilterGeneratorGUI::createContextMenu()
{
ui->paramviewer->insertInMenu("Add New Parameter",QVariant(MN_ADDPARAM));
ui->paramviewer->insertInMenu("Remove Current Parameter",QVariant(MN_REMOVECURRENTPARAM));
connect(ui->paramviewer,SIGNAL(selectedAction(QAction*)),this,SLOT(menuSelection(QAction*)));
}
void FilterGeneratorGUI::menuSelection( QAction* act)
{
if (act != NULL)
{
int indact = act->data().toInt();
switch(indact)
{
case MN_ADDPARAM:
{
addParam();
break;
}
case MN_REMOVECURRENTPARAM:
{
removeCurrentParam();
break;
}
}
}
}
void FilterGeneratorGUI::removeCurrentParam()
{
QList<QTreeWidgetItem*> sel = ui->paramviewer->selectedItems();
if (sel.size() == 1)
ui->paramviewer->takeTopLevelItem(ui->paramviewer->indexOfTopLevelItem(sel[0]));
}
void FilterGeneratorGUI::addParam()
{
QStringList namelist;
QList<QTreeWidgetItem*> totitems = ui->paramviewer->findItems(QString(".*"),Qt::MatchRegExp);
for(int ii = 0;ii < totitems.size();++ii)
namelist.push_back(totitems[ii]->text(0));
QString tmpname = UsefulGUIFunctions::generateUniqueDefaultName("Param",namelist);
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0,tmpname);
QTreeWidgetItem* childItem = new QTreeWidgetItem();
item->addChild(childItem);
ParamGeneratorGUI* pgui = new ParamGeneratorGUI(tmpname,item,this);
connect(pgui,SIGNAL(paramNameValidationRequest(QTreeWidgetItem*,const QString&)),this,SLOT(validateAndSetItemName(QTreeWidgetItem*,const QString&)));
connect(pgui,SIGNAL(itemLabelUpdateRequest(QTreeWidgetItem*,const QString&)),this,SLOT(updateItemText(QTreeWidgetItem*,const QString&)));
ui->paramviewer->setItemWidget(childItem,0,pgui);
ui->paramviewer->addTopLevelItem(item);
}
void FilterGeneratorGUI::addParam(const MLXMLParamSubTree& param)
{
QStringList namelist;
QList<QTreeWidgetItem*> totitems = ui->paramviewer->findItems(QString(".*"),Qt::MatchRegExp);
for(int ii = 0;ii < totitems.size();++ii)
namelist.push_back(totitems[ii]->text(0));
QString tmpname = param.paraminfo[MLXMLElNames::paramName];
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText(0,tmpname);
QTreeWidgetItem* childItem = new QTreeWidgetItem();
item->addChild(childItem);
ParamGeneratorGUI* pgui = new ParamGeneratorGUI(tmpname,item,this);
pgui->importInfo(param);
connect(pgui,SIGNAL(paramNameValidationRequest(QTreeWidgetItem*,const QString&)),this,SLOT(validateAndSetItemName(QTreeWidgetItem*,const QString&)));
connect(pgui,SIGNAL(itemLabelUpdateRequest(QTreeWidgetItem*,const QString&)),this,SLOT(updateItemText(QTreeWidgetItem*,const QString&)));
ui->paramviewer->setItemWidget(childItem,0,pgui);
ui->paramviewer->addTopLevelItem(item);
}
void FilterGeneratorGUI::validateAndSetItemName( QTreeWidgetItem* parentitem,const QString& newname )
{
QStringList allnames;
QList<QTreeWidgetItem*> allwid = ui->paramviewer->findItems(QString(".*"),Qt::MatchRegExp);
for(int ii = 0;ii < allwid.size();++ii)
allnames.push_back(allwid[ii]->text(0));
QString tmpname = UsefulGUIFunctions::changeNameIfAlreadyInList(newname,allnames);
parentitem->setText(0,tmpname);
ParamGeneratorGUI* gui = qobject_cast<ParamGeneratorGUI*>(ui->paramviewer->itemWidget(parentitem->child(0),0));
if (gui != NULL)
gui->setParamName(tmpname);
}
void FilterGeneratorGUI::updateItemText( QTreeWidgetItem* parent,const QString& text)
{
parent->setText(0,text);
}
void FilterGeneratorGUI::updateFunctionName( const QString& fun )
{
QString nm = UsefulGUIFunctions::generateFunctionName(ui->nameLine->text());
ui->functionLine->setText(nm);
}
void FilterGeneratorGUI::setFilterName( const QString& newname )
{
ui->nameLine->setText(newname);
}
void FilterGeneratorGUI::filterNameValidationRequest()
{
emit validateFilterName(ui->nameLine->text(),this);
}
void FilterGeneratorGUI::filterNameUpdated( const QString& name )
{
emit filterNameUpdated(name,this);
}
void FilterGeneratorGUI::importInfo( const MLXMLFilterSubTree& tree )
{
ui->nameLine->setText(tree.filterinfo[MLXMLElNames::filterName]);
ui->functionLine->setText(tree.filterinfo[MLXMLElNames::filterScriptFunctName]);
QString arval = tree.filterinfo[MLXMLElNames::filterArity];
ui->arity->setCurrentIndex(ui->arity->findText(arval));
ui->category->setCurrentValue(tree.filterinfo[MLXMLElNames::filterClass].split(" | "));
ui->precond->setCurrentValue(tree.filterinfo[MLXMLElNames::filterPreCond].split(" | "));
ui->postcond->setCurrentValue(tree.filterinfo[MLXMLElNames::filterPostCond].split(" | "));
ui->helpedit->setPlainText(tree.filterinfo[MLXMLElNames::filterHelpTag]);
for(int ii = 0;ii < tree.params.size();++ii)
addParam(tree.params[ii]);
}
FilterGeneratorTab::FilterGeneratorTab(const QString& filtername,QWidget* parent /*= NULL*/ )
:QFrame(parent),jsexp(true),guiexp(false)
{
//filtereditor = new FilterEditorFrame(this);
ui = new Ui::FilterCreatorTab();
ui->setupUi(this);
ui->guibut->setPrimitiveElement(QStyle::PE_IndicatorArrowRight);
ui->guibut->setMaximumSize(16,16);
ui->jsbut->setPrimitiveElement(QStyle::PE_IndicatorArrowDown);
ui->jsbut->setMaximumSize(16,16);
ui->guiframe->setVisible(false);
ui->guiframe->setFilterName(filtername);
ui->jsframe->setVisible(true);
QGridLayout* lay = new QGridLayout(this);
setLayout(lay);
connect(ui->guibut,SIGNAL(released()),this,SLOT(guiButtonClicked()));
connect(ui->jsbut,SIGNAL(released()),this,SLOT(jsButtonClicked()));
connect(ui->guiframe,SIGNAL(filterNameUpdated(const QString&,QWidget*)),this,SIGNAL(filterNameUpdated(const QString&,QWidget*)));
connect(ui->guiframe,SIGNAL(validateFilterName(const QString&,FilterGeneratorGUI*)),this,SIGNAL(validateFilterName(const QString&,FilterGeneratorGUI*)));
//disconnect(this,SIGNAL(itemExpanded(QTreeWidgetItem*)),this,SLOT(expandItem(QTreeWidgetItem*)));
}
FilterGeneratorTab::~FilterGeneratorTab()
{
}
//void FilterGeneratorTab::addRemoveVerticalSpacer()
//{
// if (!jsexp && !guiexp)
// ui->mainlayout
//}
void FilterGeneratorTab::jsButtonClicked()
{
//expandCollapse(jsexp,ui->jsbut,ui->jsframe);
jsexp = !jsexp;
}
void FilterGeneratorTab::guiButtonClicked()
{
guiexp = !guiexp;
//expandCollapse(guiexp,ui->guibut,ui->guiframe);
}
void FilterGeneratorTab::expandCollapse(const bool exp,PrimitiveButton* pb,QFrame* fr )
{
fr->setVisible(exp);
if (exp)
pb->setPrimitiveElement(QStyle::PE_IndicatorArrowDown);
else
pb->setPrimitiveElement(QStyle::PE_IndicatorArrowRight);
}
void FilterGeneratorTab::paintEvent( QPaintEvent* p )
{
ui->jsbut->show();
ui->label->show();
expandCollapse(jsexp,ui->jsbut,ui->jsframe);
ui->guibut->show();
ui->label_2->show();
expandCollapse(guiexp,ui->guibut,ui->guiframe);
if (!jsexp && !guiexp)
ui->mainlayout->addItem(ui->verticalSpacer, 4, 0, 1, 1);
else
ui->mainlayout->removeItem(ui->verticalSpacer);
}
void FilterGeneratorTab::collectInfo( MLXMLFilterSubTree& filter )
{
filter.filterinfo[MLXMLElNames::filterJSCodeTag] = ui->jscode->toPlainText ();
ui->guiframe->collectInfo(filter);
}
void FilterGeneratorTab::importInfo( const MLXMLFilterSubTree& tree )
{
ui->jscode->setText(tree.filterinfo[MLXMLElNames::filterJSCodeTag]);
ui->guiframe->importInfo(tree);
}
PluginGeneratorGUI::PluginGeneratorGUI(QWidget* parent )
:QDockWidget(parent),init(false),plugname(),author(),mail()
{
QFileInfo fi(QApplication::applicationFilePath());
directory.setCurrent(fi.absolutePath());
QSplitter* f = new QSplitter(this);
QGridLayout* lay = new QGridLayout(this);
tabs = new QTabWidget(this);
tabs->setUsesScrollButtons(true);
//setWidget(tabs);
int openedtabs = tabs->count();
if (openedtabs == 0)
addNewFilter();
else
{
if (openedtabs > 1)
for (int ii = 1;ii < openedtabs;++ii)
tabs->removeTab(ii);
addNewFilter();
}
lay->addWidget(tabs);
lay->setAlignment(Qt::AlignVCenter);
f->setLayout(lay);
setWidget(f);
createContextMenu();
this->setVisible(false);
//this->setScroll
}
void PluginGeneratorGUI::addNewFilter( const MLXMLPluginInfo::XMLMap& filter )
{
}
PluginGeneratorGUI::~PluginGeneratorGUI()
{
}
void PluginGeneratorGUI::paintEvent( QPaintEvent *event )
{
if (!init)
{
setMinimumSize(this->parentWidget()->size().width() * 0.5,0);
init = true;
}
tabs->show();
}
void PluginGeneratorGUI::contextMenuEvent( QContextMenuEvent * event )
{
menu->popup(event->globalPos());
}
void PluginGeneratorGUI::menuSelection( QAction* act)
{
if (act != NULL)
{
int indact = act->data().toInt();
switch(indact)
{
case MN_EXECUTECODE:
{
executeCurrentCode();
break;
}
case MN_ADDFILTER:
{
addNewFilter();
break;
}
case MN_REMOVEFILTER:
{
removeFilter();
break;
}
case MN_EXPORTFILTERINPLUGIN:
{
exportFilterInPlugin();
break;
}
case MN_NEWXMLPLUGIN:
{
newXMLPlugin();
break;
}
case MN_SAVEXMLPLUGIN:
{
saveXMLPlugin();
break;
}
case MN_SAVEASXMLPLUGIN:
{
saveAsXMLPlugin();
break;
}
case MN_LOADXMLPLUGIN:
{
loadXMLPlugin();
break;
}
case MN_INSERTPLUGINMESHLAB:
{
insertPluginInMeshLab();
break;
}
}
}
}
void PluginGeneratorGUI::createContextMenu()
{
menu = new QMenu(this);
QAction* runfilt = menu->addAction("Run Current Code");
runfilt->setData(QVariant(MN_EXECUTECODE));
menu->addSeparator();
QAction* actnewfilt = menu->addAction("New Filter");
actnewfilt->setData(QVariant(MN_ADDFILTER));
QAction* actremfilt = menu->addAction("Remove Current Filter");
actremfilt->setData(QVariant(MN_REMOVEFILTER));
menu->addSeparator();
QAction* actexpfilt = menu->addAction("Export Filter Inside Existing Plugin...");
actexpfilt->setData(QVariant(MN_EXPORTFILTERINPLUGIN));
menu->addSeparator();
QAction* actnewplug = menu->addAction("New XML Plugin");
actnewplug->setData(QVariant(MN_NEWXMLPLUGIN));
QAction* actloadplug = menu->addAction("Load XML Plugin...");
actloadplug->setData(QVariant(MN_LOADXMLPLUGIN));
QAction* actsaveplug = menu->addAction("Save XML Plugin");
actsaveplug->setData(QVariant(MN_SAVEXMLPLUGIN));
QAction* actsaveasplug = menu->addAction("Save XML Plugin As...");
actsaveasplug->setData(QVariant(MN_SAVEASXMLPLUGIN));
menu->addSeparator();
QAction* actloadmeshlabsplug = menu->addAction("Load Plugin In MeshLab");
actloadmeshlabsplug->setData(QVariant(MN_INSERTPLUGINMESHLAB));
connect(menu,SIGNAL(triggered(QAction*)),this,SLOT(menuSelection(QAction*)));
}
void PluginGeneratorGUI::executeCurrentCode()
{
//throw std::exception("The method or operation is not implemented.");
}
void PluginGeneratorGUI::addNewFilter()
{
QStringList namelist;
for(int ii = 0;ii < tabs->count();++ii)
namelist.push_back(tabs->tabText(ii));
QString tmpname = UsefulGUIFunctions::generateUniqueDefaultName("Filter",namelist);
FilterGeneratorTab* tb = new FilterGeneratorTab(tmpname,this);
tabs->addTab(tb,tmpname);
connect(tb,SIGNAL(filterNameUpdated(const QString&,QWidget*)),this,SLOT(updateTabTitle(const QString&,QWidget*)));
connect(tb,SIGNAL(validateFilterName(const QString&,FilterGeneratorGUI*)),this,SLOT(validateFilterName(const QString&,FilterGeneratorGUI*)));
}
void PluginGeneratorGUI::removeFilter()
{
tabs->removeTab(tabs->currentIndex());
}
void PluginGeneratorGUI::exportFilterInPlugin()
{
//throw std::exception("The method or operation is not implemented.");
}
void PluginGeneratorGUI::newXMLPlugin()
{
//throw std::exception("The method or operation is not implemented.");
}
void PluginGeneratorGUI::saveXMLPlugin()
{
//throw std::exception("The method or operation is not implemented.");
}
void PluginGeneratorGUI::saveAsXMLPlugin()
{
QFileDialog* saveDiag = new QFileDialog(this,tr("Save XML Plugin File"),directory.absolutePath(), tr("MeshLab XML Plugin (*.xml)"));
#if defined(Q_OS_MAC)
saveDiag->setOption(QFileDialog::DontUseNativeDialog,true);
#endif
QLabel* namelab = new QLabel(tr("JScript Plugin Name"),saveDiag);
QLineEdit* jsline= new QLineEdit(saveDiag);
QLabel* authlab = new QLabel(tr("Author Name"),saveDiag);
QLineEdit* authline= new QLineEdit(saveDiag);
QLabel* maillab = new QLabel(tr("Author e-Mail"),saveDiag);
QLineEdit* mailline= new QLineEdit(saveDiag);
QCheckBox* cpp = new QCheckBox(tr("Generate *.cpp,*.h"),saveDiag);
cpp->setChecked(false);
QGridLayout* layout = (QGridLayout*) saveDiag->layout();
layout->addWidget(namelab,4,0);
layout->addWidget(jsline,4,1);
layout->addWidget(authlab,5,0);
layout->addWidget(authline,5,1);
layout->addWidget(maillab,6,0);
layout->addWidget(mailline,6,1);
layout->addWidget(cpp,7,1);
saveDiag->setAcceptMode(QFileDialog::AcceptSave);
saveDiag->exec();
QStringList files = saveDiag->selectedFiles();
if (files.size() != 1)
return;
QString fileName = files[0];
QFileInfo finfo(files[0]);
MLXMLPluginInfo::XMLMapList ls;
/*for(int ii = 0;ii < tabs->count();++ii)
{
XMLFilterInfo::XMLMap mp;
collectFilterInfo(mp);
ls.push_back(mp);
}*/
MLXMLTree tree;
collectInfo(tree);
QString xml = generateXML(tree);
if (cpp->isChecked())
{
QDir dir(finfo.absolutePath());
QString cppcode = MLXMLUtilityFunctions::generateCPP(finfo.baseName(),tree);
QFileInfo cppinfo(finfo.absolutePath() + "/" +finfo.baseName() + ".cpp");
QString cppoldfilename = UsefulGUIFunctions::generateBackupName(cppinfo);
dir.rename(cppinfo.fileName(),cppoldfilename);
QFile cppfile(cppinfo.absoluteFilePath());
if (!cppfile.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream outcpp(&cppfile);
outcpp << cppcode;
cppfile.close();
QString hcode = MLXMLUtilityFunctions::generateH(finfo.baseName(),tree);
QFileInfo hinfo(finfo.absolutePath() + "/" +finfo.baseName() + ".h");
QString holdfilename = UsefulGUIFunctions::generateBackupName(hinfo);
dir.rename(cppinfo.fileName(),holdfilename);
QFile hfile(hinfo.absoluteFilePath());
if (!hfile.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream outh(&hfile);
outh << hcode;
hfile.close();
}
//QDomDocument has been introduced only in order to indent the xml code
QDomDocument doc;
bool ret = doc.setContent(xml,false);
xml = doc.toString();
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream out(&file);
out << xml;
file.close();
}
void PluginGeneratorGUI::loadXMLPlugin()
{
QString file = QFileDialog::getOpenFileName(this,"Load XML Plugin",directory.absolutePath(),QString("*.xml"));
if (!file.isEmpty())
{
MLXMLTree tree;
XMLMessageHandler msg;
MLXMLPluginInfo* plug = MLXMLPluginInfo::createXMLPluginInfo(file,MLXMLUtilityFunctions::xmlSchemaFile(),msg);
if (plug != NULL)
{
MLXMLUtilityFunctions::loadMeshLabXML(tree,*plug);
importInfo(tree);
}
}
}
void PluginGeneratorGUI::insertPluginInMeshLab()
{
//throw std::exception("The method or operation is not implemented.");
}
void PluginGeneratorGUI::collectInfo(MLXMLTree& tree )
{
tree.interfaceinfo[MLXMLElNames::mfiVersion] = MLXMLElNames::mfiCurrentVersion;
tree.plugin.pluginfo[MLXMLElNames::pluginScriptName] = plugname;
tree.plugin.pluginfo[MLXMLElNames::pluginAuthor] = author;
tree.plugin.pluginfo[MLXMLElNames::pluginEmail] = mail;
for(int ii = 0;ii < tabs->count();++ii)
{
MLXMLFilterSubTree filtertree;
FilterGeneratorTab* ftab = qobject_cast<FilterGeneratorTab*>(tabs->widget(ii));
if (ftab != NULL)
{
ftab->collectInfo(filtertree);
tree.plugin.filters.push_back(filtertree);
}
}
}
QString PluginGeneratorGUI::generateXML(const MLXMLTree& tree)
{
return MLXMLUtilityFunctions::generateMeshLabXML(tree);
}
void PluginGeneratorGUI::updateTabTitle( const QString& name,QWidget* wid)
{
int widind = getPageIndexOfWidget(wid);
if (widind != -1)
tabs->setTabText(widind,name);
}
void PluginGeneratorGUI::validateFilterName( const QString& name,FilterGeneratorGUI* wid )
{
QStringList ls;
int widind = getPageIndexOfWidget(wid);
for(int ii = 0;ii < tabs->count();++ii)
ls.push_back(tabs->tabText(ii));
QString res = UsefulGUIFunctions::changeNameIfAlreadyInList(name,ls);
if (res != name)
{
updateTabTitle(res,wid);
wid->setFilterName(res);
}
}
int PluginGeneratorGUI::getPageIndexOfWidget( QWidget* wid )
{
int widind = -1;
for(int ii = 0;ii < tabs->count();++ii)
{
if (wid && tabs->widget(ii)->isAncestorOf(wid))
widind = ii;
}
return widind;
}
void PluginGeneratorGUI::importInfo( const MLXMLTree& tree )
{
plugname = tree.plugin.pluginfo[MLXMLElNames::pluginScriptName];
author = tree.plugin.pluginfo[MLXMLElNames::pluginAuthor];
mail = tree.plugin.pluginfo[MLXMLElNames::pluginEmail];
int nwtab = tree.plugin.filters.size() - tabs->count();
for(int ii = 0;ii < nwtab;++ii)
addNewFilter();
for(int ii = 0;ii < tree.plugin.filters.size();++ii)
{
tabs->setTabText(ii,tree.plugin.filters[ii].filterinfo[MLXMLElNames::filterName]);
FilterGeneratorTab* gentab = qobject_cast<FilterGeneratorTab*>(tabs->widget(ii));
gentab->importInfo(tree.plugin.filters[ii]);
}
}

View File

@ -0,0 +1,181 @@
#ifndef XMLGENERATORGUI_H
#define XMLGENERATORGUI_H
#include "../common/xmlfilterinfo.h"
#include "additionalgui.h"
#include <QTabWidget>
#include <QFrame>
#include <QTreeWidget>
#include <QDockWidget>
#include <QCheckBox>
#include <QLineEdit>
#include <QComboBox>
#include <QLabel>
#include <QPlainTextEdit>
namespace Ui
{
class FilterCreatorGUI;
class ParamCreatorGUI;
class FilterCreatorTab;
}
class ParamGeneratorGUI : public QFrame
{
Q_OBJECT
public:
ParamGeneratorGUI(QWidget* parent = NULL);
ParamGeneratorGUI(const QString& name,QTreeWidgetItem* pitem,QWidget* parent = NULL);
~ParamGeneratorGUI();
/*this is the external function for setting the name. It's invoked by the caller of ParamGeneratorGUI constructor.*/
void setParamName(const QString& name);
private slots:
void updateGUIType(const QString& paramtype);
void updateGUIWidgetInterface(const QString& guitype);
void validateName();
void updateItemLabel(const QString&);
public slots:
void collectInfo(MLXMLParamSubTree& param);
void importInfo(const MLXMLParamSubTree& tree);
private:
void initUI();
void initConnections();
QTreeWidgetItem* parentitem;
QComboBox* ptype;
QLineEdit* pname;
QLineEdit* pdefault;
QCheckBox* pisimp;
QPlainTextEdit* phel;
QTreeWidget* pguitree;
QLineEdit* pguilab;
QTreeWidgetItem* pguiminitem;
QTreeWidgetItem* pguimaxitem;
QLabel* pguiminlab;
QLabel* pguimaxlab;
QLineEdit* pguimin;
QLineEdit* pguimax;
QComboBox* pguitype;
QString currentname;
signals:
void paramNameValidationRequest(QTreeWidgetItem* parent,const QString& newname);
void itemLabelUpdateRequest(QTreeWidgetItem* parent,const QString& text);
};
class FilterGeneratorTab;
class FilterGeneratorGUI : public QFrame
{
Q_OBJECT
friend class FilterGeneratorTab;
public:
FilterGeneratorGUI(QWidget* parent = NULL);
~FilterGeneratorGUI();
public slots:
void collectInfo(MLXMLFilterSubTree& filter);
void importInfo(const MLXMLFilterSubTree& tree);
void setFilterName(const QString& newname);
private slots:
void menuSelection( QAction* act);
void validateAndSetItemName(QTreeWidgetItem* parent,const QString& newname);
void updateItemText(QTreeWidgetItem* parent,const QString& text);
void filterNameValidationRequest();
void updateFunctionName(const QString& fun);
void filterNameUpdated(const QString& name);
/*void validateAndSetFilterName(const int tabindex,)*/
private:
enum MenuOption {MN_ADDPARAM,MN_REMOVECURRENTPARAM};
void fillComboBoxes();
void createContextMenu();
void addParam();
void addParam(const MLXMLParamSubTree& param);
void removeCurrentParam();
Ui::FilterCreatorGUI* ui;
signals:
void validateFunctionName(const QString& name);
void filterNameUpdated(const QString& name,QWidget* wid);
void validateFilterName(const QString& name,FilterGeneratorGUI* thiswid);
// void invalidExistingNameChangedWith(QTreeWidgetItem* item,const QString& corrected);
};
class FilterGeneratorTab : public QFrame
{
Q_OBJECT
public:
FilterGeneratorTab(const QString& filtername,QWidget* parent = NULL);
~FilterGeneratorTab();
void collectInfo(MLXMLFilterSubTree& filter);
void importInfo(const MLXMLFilterSubTree& tree);
protected:
void paintEvent(QPaintEvent* p);
private slots:
void jsButtonClicked();
void guiButtonClicked();
//void filterNameValidationRequest(const QString& name);
//void parentDocked( Qt::DockWidgetArea area);
signals:
void filterNameUpdated(const QString& fname,QWidget* wid);
void validateFilterName(const QString& fname,FilterGeneratorGUI* wid);
private:
//void expandCollapse(bool& exp,PrimitiveButton* pb,QFrame* fr );
void expandCollapse(const bool exp,PrimitiveButton* pb,QFrame* fr );
bool jsexp;
bool guiexp;
Ui::FilterCreatorTab* ui;
};
class PluginGeneratorGUI : public QDockWidget
{
Q_OBJECT
public:
PluginGeneratorGUI(QWidget* parent = NULL);
~PluginGeneratorGUI();
protected:
void paintEvent(QPaintEvent *event);
void contextMenuEvent ( QContextMenuEvent * event );
private slots:
void menuSelection(QAction*);
void addNewFilter(const MLXMLPluginInfo::XMLMap& filter);
void updateTabTitle(const QString& name,QWidget* wid);
void validateFilterName(const QString& name,FilterGeneratorGUI* wid);
private:
enum MenuOption {MN_ADDFILTER,MN_REMOVEFILTER,MN_EXPORTFILTERINPLUGIN,MN_EXECUTECODE,MN_NEWXMLPLUGIN,MN_SAVEXMLPLUGIN,MN_SAVEASXMLPLUGIN,MN_LOADXMLPLUGIN,MN_INSERTPLUGINMESHLAB};
void createContextMenu();
void executeCurrentCode();
void addNewFilter();
void removeFilter();
void exportFilterInPlugin();
void newXMLPlugin();
void saveXMLPlugin();
void saveAsXMLPlugin();
void loadXMLPlugin();
void insertPluginInMeshLab();
int getPageIndexOfWidget(QWidget* wid);
QString generateXML(const MLXMLTree& tree);
void collectInfo(MLXMLTree& tree);
void importInfo(const MLXMLTree& tree);
QString plugname;
QString author;
QString mail;
QMenu* menu;
QTabWidget* tabs;
bool init;
QDir directory;
};
#endif

View File

@ -52,7 +52,7 @@ void MeshLabXMLStdDialog::loadFrameContent( )
stdParFrame = new XMLStdParFrame(this,curgla);
//connect(stdParFrame,SIGNAL(frameEvaluateExpression(const Expression&,Value**)),this,SIGNAL(dialogEvaluateExpression(const Expression&,Value**)),Qt::DirectConnection);
XMLFilterInfo::XMLMapList mplist = curmfc->xmlInfo->filterParametersExtendedInfo(fname);
MLXMLPluginInfo::XMLMapList mplist = curmfc->xmlInfo->filterParametersExtendedInfo(fname);
EnvWrap wrap(env);
stdParFrame->loadFrameContent(mplist,wrap);
gridLayout->addWidget(stdParFrame,1,0,1,2);
@ -134,7 +134,7 @@ bool MeshLabXMLStdDialog::showAutoDialog(MeshLabXMLFilterContainer& mfc,MeshDocu
QString fname = mfc.act->text();
//mfi->initParameterSet(action, *mdp, curParSet);
XMLFilterInfo::XMLMapList mplist = mfc.xmlInfo->filterParametersExtendedInfo(fname);
MLXMLPluginInfo::XMLMapList mplist = mfc.xmlInfo->filterParametersExtendedInfo(fname);
curParMap = mplist;
//curmask = mfc->xmlInfo->filterAttribute(mfc->act->text(),QString("postCond"));
if(curParMap.isEmpty() && !isPreviewable())
@ -284,7 +284,7 @@ bool MeshLabXMLStdDialog::isPreviewable() const
void MeshLabXMLStdDialog::resetExpressions()
{
QString fname(curmfc->act->text());
XMLFilterInfo::XMLMapList mplist = curmfc->xmlInfo->filterParametersExtendedInfo(fname);
MLXMLPluginInfo::XMLMapList mplist = curmfc->xmlInfo->filterParametersExtendedInfo(fname);
EnvWrap envir(env);
stdParFrame->resetExpressions(mplist);
}
@ -314,12 +314,12 @@ XMLStdParFrame::~XMLStdParFrame()
}
void XMLStdParFrame::loadFrameContent(const XMLFilterInfo::XMLMapList& parMap,EnvWrap& envir)
void XMLStdParFrame::loadFrameContent(const MLXMLPluginInfo::XMLMapList& parMap,EnvWrap& envir)
{
MeshLabXMLStdDialog* dialog = qobject_cast<MeshLabXMLStdDialog*>(parent());
if (dialog == NULL)
throw MeshLabException("An XMLStdParFrame has not a MeshLabXMLStdDialog's parent");
for(XMLFilterInfo::XMLMapList::const_iterator it = parMap.constBegin();it != parMap.constEnd();++it)
for(MLXMLPluginInfo::XMLMapList::const_iterator it = parMap.constBegin();it != parMap.constEnd();++it)
{
XMLMeshLabWidget* widg = XMLMeshLabWidgetFactory::create(*it,envir,dialog->curMeshDoc,this);
if (widg == NULL)
@ -350,13 +350,13 @@ void XMLStdParFrame::extendedView(bool ext,bool help)
adjustSize();
}
void XMLStdParFrame::resetExpressions(const XMLFilterInfo::XMLMapList& mplist)
void XMLStdParFrame::resetExpressions(const MLXMLPluginInfo::XMLMapList& mplist)
{
for(int i = 0; i < xmlfieldwidgets.count(); i++)
xmlfieldwidgets[i]->set(mplist[i][MLXMLElNames::paramDefExpr]);
}
XMLMeshLabWidget::XMLMeshLabWidget(const XMLFilterInfo::XMLMap& mp,EnvWrap& envir,QWidget* parent )
XMLMeshLabWidget::XMLMeshLabWidget(const MLXMLPluginInfo::XMLMap& mp,EnvWrap& envir,QWidget* parent )
:QWidget(parent),env(envir)
{
//WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@ -403,7 +403,7 @@ void XMLMeshLabWidget::setVisibility( const bool vis )
// this->set(map[MLXMLElNames::paramDefExpr]);
//}
XMLCheckBoxWidget::XMLCheckBoxWidget( const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* parent )
XMLCheckBoxWidget::XMLCheckBoxWidget( const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* parent )
:XMLMeshLabWidget(xmlWidgetTag,envir,parent)
{
cb = new QCheckBox(xmlWidgetTag[MLXMLElNames::guiLabel],this);
@ -457,7 +457,7 @@ void XMLCheckBoxWidget::setVisibility( const bool vis )
cb->setVisible(vis);
}
XMLMeshLabWidget* XMLMeshLabWidgetFactory::create(const XMLFilterInfo::XMLMap& widgetTable,EnvWrap& env,MeshDocument* md,QWidget* parent)
XMLMeshLabWidget* XMLMeshLabWidgetFactory::create(const MLXMLPluginInfo::XMLMap& widgetTable,EnvWrap& env,MeshDocument* md,QWidget* parent)
{
QString guiType = widgetTable[MLXMLElNames::guiType];
if (guiType == MLXMLElNames::editTag)
@ -486,7 +486,7 @@ XMLMeshLabWidget* XMLMeshLabWidgetFactory::create(const XMLFilterInfo::XMLMap& w
return NULL;
}
XMLEditWidget::XMLEditWidget(const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* parent)
XMLEditWidget::XMLEditWidget(const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* parent)
:XMLMeshLabWidget(xmlWidgetTag,envir,parent)
{
fieldDesc = new QLabel(xmlWidgetTag[MLXMLElNames::guiLabel],this);
@ -549,7 +549,7 @@ void XMLEditWidget::setVisibility( const bool vis )
this->lineEdit->setVisible(vis);
}
XMLAbsWidget::XMLAbsWidget(const XMLFilterInfo::XMLMap& xmlWidgetTag, EnvWrap& envir,QWidget* parent )
XMLAbsWidget::XMLAbsWidget(const MLXMLPluginInfo::XMLMap& xmlWidgetTag, EnvWrap& envir,QWidget* parent )
:XMLMeshLabWidget(xmlWidgetTag,envir,parent)
{
m_min = env.evalFloat(xmlWidgetTag[MLXMLElNames::guiMinExpr]);
@ -636,70 +636,8 @@ void XMLAbsWidget::setVisibility( const bool vis )
this->percSB->setVisible(vis);
}
ExpandButtonWidget::ExpandButtonWidget( QWidget* parent )
:QWidget(parent),isExpanded(false)
{
QIcon arrow = QCommonStyle().standardIcon(QStyle::SP_ArrowDown);
QHBoxLayout *hlay = new QHBoxLayout(this);
//QChar ch(0x0036);
exp = new PrimitiveButton(QStyle::PE_IndicatorArrowDown,this);
//exp->setFlat(true);
//connect(exp,SIGNAL(clicked(bool)),this,SLOT(expandFrame(bool)));
/*QFontMetrics mt(exp->font(),exp);
QSize sz = mt.size(Qt::TextSingleLine,arrow);*/
/*QList<QSize> sizes = arrow.availableSizes();
int min = INT_MAX;
for(int ii = 0;ii < sizes.size();++ii)
if (sizes[ii].width() < min)
min = sizes[ii].width();
QSize sz;
sz.setWidth(min + 10);*/
hlay->addWidget(exp,0,Qt::AlignHCenter);
connect(exp,SIGNAL(clicked(bool)),this,SLOT(changeIcon()));
}
ExpandButtonWidget::~ExpandButtonWidget()
{
}
void ExpandButtonWidget::changeIcon()
{
isExpanded = !isExpanded;
if (isExpanded)
exp->setPrimitiveElement(QStyle::PE_IndicatorArrowUp);
else
exp->setPrimitiveElement(QStyle::PE_IndicatorArrowDown);
exp->repaint();
emit expandView(isExpanded);
}
PrimitiveButton::PrimitiveButton(const QStyle::PrimitiveElement el,QWidget* parent )
:QPushButton(parent),elem(el)
{
}
PrimitiveButton::~PrimitiveButton()
{
}
void PrimitiveButton::paintEvent( QPaintEvent * event )
{
QStylePainter painter(this);
QStyleOptionButton option;
option.initFrom(this);
//painter.drawControl(QStyle::CE_PushButton,option);
painter.drawPrimitive (elem,option);
}
void PrimitiveButton::setPrimitiveElement( const QStyle::PrimitiveElement el)
{
elem = el;
}
XMLVec3Widget::XMLVec3Widget(const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p)
XMLVec3Widget::XMLVec3Widget(const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p)
:XMLMeshLabWidget(xmlWidgetTag,envir,p)
{
XMLStdParFrame* par = qobject_cast<XMLStdParFrame*>(p);
@ -839,7 +777,7 @@ void XMLVec3Widget::setVisibility( const bool vis )
descLab->setVisible(vis);
}
XMLColorWidget::XMLColorWidget( const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p )
XMLColorWidget::XMLColorWidget( const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p )
:XMLMeshLabWidget(xmlWidgetTag,envir,p)
{
colorLabel = new QLabel(p);
@ -909,7 +847,7 @@ void XMLColorWidget::setVisibility( const bool vis )
colorButton->setVisible(vis);
}
XMLSliderWidget::XMLSliderWidget( const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p )
XMLSliderWidget::XMLSliderWidget( const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p )
:XMLMeshLabWidget(xmlWidgetTag,envir,p)
{
minVal = env.evalFloat(xmlWidgetTag[MLXMLElNames::guiMinExpr]);
@ -999,7 +937,7 @@ void XMLSliderWidget::setVisibility( const bool vis )
fieldDesc->setVisible(vis);
}
XMLComboWidget::XMLComboWidget( const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p )
XMLComboWidget::XMLComboWidget( const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p )
:XMLMeshLabWidget(xmlWidgetTag,envir,p)
{
enumLabel = new QLabel(p);
@ -1035,7 +973,7 @@ XMLComboWidget::~XMLComboWidget()
}
XMLEnumWidget::XMLEnumWidget( const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p )
XMLEnumWidget::XMLEnumWidget( const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p )
:XMLComboWidget(xmlWidgetTag,envir,p)
{
QString typ = xmlWidgetTag[MLXMLElNames::paramType];
@ -1054,7 +992,7 @@ QString XMLEnumWidget::getWidgetExpression()
return enumCombo->itemData(enumCombo->currentIndex()).toString();
}
XMLMeshWidget::XMLMeshWidget( MeshDocument* mdoc,const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p )
XMLMeshWidget::XMLMeshWidget( MeshDocument* mdoc,const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p )
:XMLEnumWidget(xmlWidgetTag,envir,p)
{
foreach(MeshModel* mm,mdoc->meshList)

View File

@ -17,7 +17,7 @@
#include<QTextEdit>
#include<QLabel>
#include "qstyleoption.h"
#include "additionalgui.h"
class XMLWidgetException : public MeshLabException
{
@ -34,7 +34,7 @@ class XMLMeshLabWidget : public QWidget
Q_OBJECT
public:
//WARNING! This constructor could rise up a set of MeshLabExceptions! this does it mean that the object COULD BE NOT correctly constructed!
XMLMeshLabWidget(const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* parent);
XMLMeshLabWidget(const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* parent);
// bring the values from the Qt widgets to the parameter (e.g. from the checkBox to the parameter).
//virtual void collectWidgetValue() = 0;
//void reset();
@ -74,7 +74,7 @@ class XMLMeshLabWidgetFactory
public:
//WARNING! this function call constructors that could rise up a set of MeshLabExceptions but it is not able to manage it, so let the exceptions floating up!
//IN ANY CASE the callee MUST check if the returned value is not NULL.
static XMLMeshLabWidget* create(const XMLFilterInfo::XMLMap& widgetTable,EnvWrap& env,MeshDocument* md,QWidget* parent);
static XMLMeshLabWidget* create(const MLXMLPluginInfo::XMLMap& widgetTable,EnvWrap& env,MeshDocument* md,QWidget* parent);
};
//
@ -82,7 +82,7 @@ class XMLCheckBoxWidget : public XMLMeshLabWidget
{
Q_OBJECT
public:
XMLCheckBoxWidget(const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* parent);
XMLCheckBoxWidget(const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* parent);
~XMLCheckBoxWidget();
// bring the values from the Qt widgets to the parameter (e.g. from the checkBox to the parameter).
@ -110,7 +110,7 @@ class XMLEditWidget : public XMLMeshLabWidget
{
Q_OBJECT
public:
XMLEditWidget(const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* parent);
XMLEditWidget(const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* parent);
~XMLEditWidget();
void set(const QString& nwExpStr);
@ -136,7 +136,7 @@ class XMLAbsWidget : public XMLMeshLabWidget
{
Q_OBJECT
public:
XMLAbsWidget(const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* parent);
XMLAbsWidget(const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* parent);
~XMLAbsWidget();
void set(const QString& nwExpStr);
@ -174,7 +174,7 @@ class XMLVec3Widget : public XMLMeshLabWidget
{
Q_OBJECT
public:
XMLVec3Widget(const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p);
XMLVec3Widget(const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p);
~XMLVec3Widget();
QString paramName;
@ -220,7 +220,7 @@ class XMLColorWidget : public XMLMeshLabWidget
QColor pickcol;
public:
XMLColorWidget(const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p);
XMLColorWidget(const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p);
~XMLColorWidget();
void set(const QString& nwExpStr);
@ -250,7 +250,7 @@ class XMLSliderWidget : public XMLMeshLabWidget
signals:
void dialogParamChanged();
public:
XMLSliderWidget(const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p);
XMLSliderWidget(const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p);
~XMLSliderWidget();
void set(const QString& nwExpStr);
void updateVisibility(const bool vis);
@ -286,7 +286,7 @@ protected:
QComboBox *enumCombo;
QLabel *enumLabel;
public:
XMLComboWidget(const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p);
XMLComboWidget(const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p);
~XMLComboWidget();
void updateVisibility(const bool vis);
void Init(QWidget *p,QString lab,int newEnum, QStringList values);
@ -312,7 +312,7 @@ class XMLEnumWidget : public XMLComboWidget
Q_OBJECT
public:
XMLEnumWidget(const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p);
XMLEnumWidget(const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p);
~XMLEnumWidget(){};
QString getWidgetExpression();
@ -323,7 +323,7 @@ class XMLMeshWidget : public XMLEnumWidget
Q_OBJECT
public:
XMLMeshWidget(MeshDocument* mdoc,const XMLFilterInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p);
XMLMeshWidget(MeshDocument* mdoc,const MLXMLPluginInfo::XMLMap& xmlWidgetTag,EnvWrap& envir,QWidget* p);
~XMLMeshWidget(){};
private:
@ -365,14 +365,14 @@ class XMLStdParFrame : public QFrame
Q_OBJECT
public:
XMLStdParFrame(QWidget *p,QWidget *gla=0);
void loadFrameContent(const XMLFilterInfo::XMLMapList& parMap,EnvWrap& envir);
void loadFrameContent(const MLXMLPluginInfo::XMLMapList& parMap,EnvWrap& envir);
void extendedView(bool ext,bool help);
//void loadFrameContent(RichParameter* par,MeshDocument *mdPt = 0);
//// The curParSet that is passed must be 'compatible' with the RichParameterSet that have been used to create the frame.
//// This function updates the RichParameterSet used to create the frame AND fill also the passed <curParSet>
//void readValues(RichParameterSet &curParSet);
void resetExpressions(const XMLFilterInfo::XMLMapList& mplist);
void resetExpressions(const MLXMLPluginInfo::XMLMapList& mplist);
void toggleHelp(bool help);
@ -393,35 +393,6 @@ private:
void parameterChanged();*/
};
class PrimitiveButton : public QPushButton
{
Q_OBJECT
public:
PrimitiveButton(const QStyle::PrimitiveElement el,QWidget* parent);
~PrimitiveButton();
void setPrimitiveElement(const QStyle::PrimitiveElement el);
protected:
void paintEvent(QPaintEvent * event);
private:
QStyle::PrimitiveElement elem;
};
class ExpandButtonWidget : public QWidget
{
Q_OBJECT
public:
ExpandButtonWidget(QWidget* parent);
~ExpandButtonWidget();
private slots:
void changeIcon();
signals:
void expandView(bool exp);
private:
PrimitiveButton* exp;
bool isExpanded;
};
class MeshLabXMLStdDialog : public QDockWidget
{
Q_OBJECT
@ -465,7 +436,7 @@ private:
MeshModel *curModel;
MeshLabXMLFilterContainer* curmfc;
MainWindowInterface *curmwi;
XMLFilterInfo::XMLMapList curParMap;
MLXMLPluginInfo::XMLMapList curParMap;
//XMLFilterInfo::XMLMapList prevParMap;
QString applyContext;
QString previewContext;