From 3d9223a37e2ff3036af68b70da613ce54d447d08 Mon Sep 17 00:00:00 2001 From: Guido Ranzuglia granzuglia Date: Thu, 13 Oct 2016 07:12:30 +0000 Subject: [PATCH] - added FUCKING color button for User Defined colors --- src/meshlab/mainwindow_RunTime.cpp | 2 +- src/meshlab/ml_render_gui.cpp | 97 +++++++++++++++++------------- src/meshlab/ml_render_gui.h | 11 ++-- 3 files changed, 61 insertions(+), 49 deletions(-) diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index 571b0a1d9..48b7cbae0 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -2596,7 +2596,7 @@ bool MainWindow::loadMesh(const QString& fileName, MeshIOInterface *pCurrentIOPl meshDoc()->setBusy(false); return false; } - // After opening the mesh lets ask to the io plugin if this format + // After opening the mesh lets ask to the io plugin if this format // requires some optional, or userdriven post-opening processing. // and in that case ask for the required parameters and then // ask to the plugin to perform that processing diff --git a/src/meshlab/ml_render_gui.cpp b/src/meshlab/ml_render_gui.cpp index aa42bf14c..6eafc5f81 100644 --- a/src/meshlab/ml_render_gui.cpp +++ b/src/meshlab/ml_render_gui.cpp @@ -48,7 +48,6 @@ bool MLRenderingToolbar::updateVisibility(MeshModel* mm) return isvis; } - void MLRenderingToolbar::addRenderingAction( MLRenderingAction* act ) { if (act == NULL) @@ -122,30 +121,24 @@ QList MLRenderingToolbar::getTopLevelActions() void MLRenderingToolbar::addColorPicker( MLRenderingColorPicker* pick ) { - MLRenderingUserDefinedColorAction* colact = qobject_cast(pick->defaultAction()); - if (colact != NULL) - { - _actgroup->addAction(colact); - _acts.push_back(colact); - colact->setCheckable(true); - colact->setVisible(true); - } - addWidget(pick); + if (pick == NULL) + return; + MLRenderingUserDefinedColorAction* colact = qobject_cast(pick->_act); + addRenderingAction(colact); + pick->_cbutton->setFixedSize(widgetForAction(colact)->height() / 2, widgetForAction(colact)->height() /2); + addWidget(pick); connect(pick,SIGNAL(triggered(QAction*)),this,SLOT(toggle(QAction*))); connect(pick,SIGNAL(userDefinedColorAction(int,MLRenderingAction*)),this,SLOT(extraUpdateRequired(int,MLRenderingAction*))); } void MLRenderingToolbar::addColorPicker( MLRenderingBBoxColorPicker* pick ) { - MLRenderingBBoxUserDefinedColorAction* colact = qobject_cast(pick->defaultAction()); - if (colact != NULL) - { - _actgroup->addAction(colact); - _acts.push_back(colact); - colact->setCheckable(true); - colact->setVisible(true); - } - addWidget(pick); + if (pick == NULL) + return; + MLRenderingBBoxUserDefinedColorAction* colact = qobject_cast(pick->_act); + addRenderingAction(colact); + pick->_cbutton->setFixedSize(widgetForAction(colact)->height() / 2, widgetForAction(colact)->height() / 2); + addWidget(pick); connect(pick,SIGNAL(triggered(QAction*)),this,SLOT(toggle(QAction*))); connect(pick,SIGNAL(userDefinedColorAction(int,MLRenderingAction*)),this,SLOT(extraUpdateRequired(int,MLRenderingAction*))); } @@ -332,9 +325,9 @@ void MLRenderingSolidParametersFrame::initGui() MLPerViewGLOptions tmp; MLPoliciesStandAloneFunctions::suggestedDefaultPerViewGLOptions(tmp); colbut->setColor(vcg::ColorConverter::ToQColor(tmp._persolid_fixed_color)); - _colortool->addColorPicker(colbut); layout->addWidget(_colortool,1,1,Qt::AlignLeft); - connect(_colortool,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&)),this,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&))); + _colortool->addColorPicker(colbut); + connect(_colortool,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&)),this,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&))); connect(_colortool, SIGNAL(updateRenderingDataAccordingToActions(int, MLRenderingAction*, QList&)), this, SIGNAL(updateRenderingDataAccordingToActions(int, MLRenderingAction*, QList&))); _backfacelab = new QLabel("Back-Face", this); @@ -790,8 +783,8 @@ void MLRenderingBBoxParametersFrame::initGui() MLPoliciesStandAloneFunctions::suggestedDefaultPerViewGLOptions(tmp); //tmp._perbbox_fixed_color = vcg::Color4b(255,85,0,255); colbut->setColor(vcg::ColorConverter::ToQColor(tmp._perbbox_fixed_color)); - _colortool->addColorPicker(colbut); layout->addWidget(_colortool,0,1,Qt::AlignLeft); + _colortool->addColorPicker(colbut); connect(_colortool,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&)),this,SIGNAL(updateRenderingDataAccordingToActions(int,const QList&))); connect(_colortool, SIGNAL(updateRenderingDataAccordingToActions(int, MLRenderingAction*,QList&)), this, SIGNAL(updateRenderingDataAccordingToActions(int, MLRenderingAction*,QList&))); @@ -1197,17 +1190,26 @@ void MLRenderingColorPicker::initGui() { if (_act == NULL) return; - setDefaultAction(_act); - //setText(_act->text()); - QMenu* colmenu = new QMenu(); - QWidgetAction* wa = new QWidgetAction(colmenu); - _cbutton = new QPushButton(colmenu); - _cbutton->setAutoFillBackground(true); - _cbutton->setFlat(true); - _cbutton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); - wa->setDefaultWidget(_cbutton); - colmenu->addAction(wa); - setMenu(colmenu); + //setDefaultAction(_act); + ////setText(_act->text()); + //QMenu* colmenu = new QMenu(); + //QWidgetAction* wa = new QWidgetAction(colmenu); + //_cbutton = new QPushButton(colmenu); + //_cbutton->setAutoFillBackground(true); + //_cbutton->setFlat(true); + //_cbutton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); + //wa->setDefaultWidget(_cbutton); + //colmenu->addAction(wa); + //setMenu(colmenu); + QVBoxLayout* lay = new QVBoxLayout(); + _cbutton = new QPushButton(this); + _cbutton->setAutoFillBackground(true); + _cbutton->setFlat(true); + _cbutton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + lay->addWidget(_cbutton); + lay->setMargin(2); + lay->setSizeConstraint(QLayout::SetFixedSize); + setLayout(lay); updateColorInfo(); connect(_cbutton,SIGNAL(clicked()),this,SLOT(pickColor())); } @@ -1267,17 +1269,26 @@ void MLRenderingBBoxColorPicker::initGui() { if (_act == NULL) return; - setDefaultAction(_act); + //setDefaultAction(_act); //setText(_act->text()); - QMenu* colmenu = new QMenu(); - QWidgetAction* wa = new QWidgetAction(colmenu); - _cbutton = new QPushButton(colmenu); - _cbutton->setAutoFillBackground(true); - _cbutton->setFlat(true); - _cbutton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); - wa->setDefaultWidget(_cbutton); - colmenu->addAction(wa); - setMenu(colmenu); + /*QMenu* colmenu = new QMenu(); + QWidgetAction* wa = new QWidgetAction(colmenu); + _cbutton = new QPushButton(colmenu); + _cbutton->setAutoFillBackground(true); + _cbutton->setFlat(true); + _cbutton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed); + wa->setDefaultWidget(_cbutton); + colmenu->addAction(wa); + setMenu(colmenu);*/ + QVBoxLayout* lay = new QVBoxLayout(); + _cbutton = new QPushButton(this); + _cbutton->setAutoFillBackground(true); + _cbutton->setFlat(true); + _cbutton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + lay->addWidget(_cbutton); + lay->setMargin(2); + lay->setSizeConstraint(QLayout::SetFixedSize); + setLayout(lay); updateColorInfo(); connect(_cbutton,SIGNAL(clicked()),this,SLOT(pickColor())); } diff --git a/src/meshlab/ml_render_gui.h b/src/meshlab/ml_render_gui.h index 8b9a2254f..0d78c119c 100644 --- a/src/meshlab/ml_render_gui.h +++ b/src/meshlab/ml_render_gui.h @@ -67,10 +67,10 @@ public: protected: void initGui(); void updateColorInfo(); - QPushButton* _cbutton; public: MLRenderingUserDefinedColorAction* _act; + QPushButton* _cbutton; signals: void userDefinedColorAction(int,MLRenderingAction*); @@ -89,8 +89,9 @@ public: protected: void initGui(); void updateColorInfo(); - QPushButton* _cbutton; - MLRenderingBBoxUserDefinedColorAction* _act; +public: + MLRenderingBBoxUserDefinedColorAction* _act; + QPushButton* _cbutton; signals: void userDefinedColorAction(int,MLRenderingAction*); @@ -199,8 +200,8 @@ protected slots: virtual void toggle(QAction* act); void extraUpdateRequired(int,MLRenderingAction*); -//private: -// void initGui(); +private: + void initGui(); signals: void updateRenderingDataAccordingToActions(int,const QList&);