Moved progress display to status bar. Disabled by default but can be enabled in .pro file with CONFIG += progresswidget. Please test and enable as default if it looks good on all platforms.

git-svn-id: http://svn.clifford.at/openscad/trunk@432 b57f626f-c46c-0410-a088-ec61d464b74c
stl_dim
kintel 2010-02-10 15:13:12 +00:00
parent c021720bfd
commit 8038ee0406
8 changed files with 190 additions and 31 deletions

View File

@ -22,6 +22,7 @@ o Preferences
- OpenGL params
- Default language feature settings
- Auto-view CSG/thrown together on load
- Make the library search path configurable?
o Export etc.: automatically add missing extension as in SaveAs
o MDI
- Think about how to do MDI the right way
@ -61,8 +62,6 @@ o Editor
o Computation
- Run CGAL rendering in a backgroud thread
- Progress
- Move progress bar to status bar (as in Eclipse)
- Enable viewing/editing while rendering
o Misc
- Reload and compile: Ask for confirmation if file is locally edited
@ -94,7 +93,6 @@ o Language Frontend
- Add "use" statement to load modules. Like include but read a module only once,
ignore all top level objects (they are used as module testcase) and search in
a module search path.
- Add a default search path for included files to allow bundling libs
- allow 0/1 f/t FALSE/TRUE as boolean values
o DXF Import
- Support for POLYLINE entity
@ -137,7 +135,6 @@ o Make the interfaces from OpenSCAD and OpenCSG and CGAL cleaner to facilitate
INFRASTRUCTURE
--------------
o Think about making external libraries easier available. Probably mostly convenience.
o Use a logging framework to get debugging/info output more under control?
(check log4j, google project)

BIN
icons/stopbutton.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -34,12 +34,20 @@ QT += opengl
macx:CONFIG += mdi
CONFIG += cgal
CONFIG += opencsg
#CONFIG += progresswidget
mdi {
# MDI needs an OpenCSG library that is compiled with OpenCSG-Reset-Hack.patch applied
DEFINES += ENABLE_MDI
}
progresswidget {
DEFINES += USE_PROGRESSWIDGET
FORMS += src/ProgressWidget.ui
HEADERS += src/ProgressWidget.h
SOURCES += src/ProgressWidget.cc
}
include(cgal.pri)
include(opencsg.pri)

View File

@ -1,7 +1,8 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
<file>icons/prefsAdvanced.png</file>
<file>icons/prefs3DView.png</file>
<file>icons/prefsEditor.png</file>
</qresource>
</RCC>
<RCC>
<qresource prefix="/">
<file>icons/stopbutton.png</file>
<file>icons/prefsAdvanced.png</file>
<file>icons/prefs3DView.png</file>
<file>icons/prefsEditor.png</file>
</qresource>
</RCC>

29
src/ProgressWidget.cc Normal file
View File

@ -0,0 +1,29 @@
#include "ProgressWidget.h"
ProgressWidget::ProgressWidget(QWidget *parent)
:QWidget(parent)
{
setupUi(this);
this->wascanceled = false;
connect(this->stopButton, SIGNAL(clicked()), this, SLOT(cancel()));
}
bool ProgressWidget::wasCanceled() const
{
return this->wascanceled;
}
void ProgressWidget::cancel()
{
this->wascanceled = true;
}
void ProgressWidget::setRange(int minimum, int maximum)
{
this->progressBar->setRange(minimum, maximum);
}
void ProgressWidget::setValue(int progress)
{
this->progressBar->setValue(progress);
}

25
src/ProgressWidget.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef PROGRESSWIDGET_H_
#define PROGRESSWIDGET_H_
#include "ui_ProgressWidget.h"
class ProgressWidget : public QWidget, public Ui::ProgressWidget
{
Q_OBJECT;
Q_PROPERTY(bool wasCanceled READ wasCanceled);
public:
ProgressWidget(QWidget *parent = NULL);
bool wasCanceled() const;
public slots:
void setRange(int minimum, int maximum);
void setValue(int progress);
void cancel();
private:
bool wascanceled;
};
#endif

74
src/ProgressWidget.ui Normal file
View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProgressWidget</class>
<widget class="QWidget" name="ProgressWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>121</width>
<height>20</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>5</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
</property>
<property name="format">
<string>%v / %m</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="stopButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>12</width>
<height>12</height>
</size>
</property>
<property name="baseSize">
<size>
<width>12</width>
<height>12</height>
</size>
</property>
<property name="icon">
<iconset resource="../openscad.qrc">
<normaloff>:/icons/stopbutton.png</normaloff>:/icons/stopbutton.png</iconset>
</property>
<property name="iconSize">
<size>
<width>12</width>
<height>12</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../openscad.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -38,6 +38,9 @@
#include "builtin.h"
#include "dxftess.h"
#include "progress.h"
#ifdef USE_PROGRESSWIDGET
#include "ProgressWidget.h"
#endif
#include <QMenu>
#include <QTime>
@ -338,18 +341,24 @@ MainWindow::~MainWindow()
#endif
}
typedef QPair<QProgressBar*, QProgressDialog*> ProgressData;
static void report_func(const class AbstractNode*, void *vp, int mark)
{
ProgressData *progpair = static_cast<ProgressData*>(vp);
#ifdef USE_PROGRESSWIDGET
ProgressWidget *pw = static_cast<ProgressWidget*>(vp);
int v = (int)((mark*100.0) / progress_report_count);
progpair->first->setValue(v < 100 ? v : 99);
pw->setValue(v < 100 ? v : 99);
QApplication::processEvents();
if (pw->wasCanceled()) throw ProgressCancelException();
#else
QProgressDialog *pd = static_cast<QProgressDialog*>(vp);
int v = (int)((mark*100.0) / progress_report_count);
pd->setValue(v < 100 ? v : 99);
QString label;
label.sprintf("Rendering Polygon Mesh (%d/%d)", mark, progress_report_count);
progpair->second->setLabelText(label);
pd->setLabelText(label);
QApplication::processEvents();
if (progpair->second->wasCanceled()) throw ProgressCancelException();
if (pd->wasCanceled()) throw ProgressCancelException();
#endif
}
/*!
@ -635,17 +644,21 @@ void MainWindow::compileCSG(bool procevents)
QTime t;
t.start();
#ifdef USE_PROGRESSWIDGET
ProgressWidget *pd = new ProgressWidget(this);
pd->setRange(0, 100);
pd->setValue(0);
this->statusBar()->addPermanentWidget(pd);
#else
QProgressDialog *pd = new QProgressDialog("Rendering CSG products...", "Cancel", 0, 100);
QProgressBar *bar = new QProgressBar(pd);
bar->setRange(0, 100);
bar->setValue(0);
pd->setBar(bar);
pd->setRange(0, 100);
pd->setValue(0);
pd->setAutoClose(false);
pd->show();
ProgressData progpair(bar, pd);
#endif
QApplication::processEvents();
progress_report_prep(root_node, report_func, &progpair);
progress_report_prep(root_node, report_func, pd);
try {
root_raw_term = root_node->render_csg_term(m, &highlight_terms, &background_terms);
if (!root_raw_term) {
@ -655,8 +668,12 @@ void MainWindow::compileCSG(bool procevents)
}
}
catch (ProgressCancelException e) {
PRINT("CSG generation cancelled.");
}
progress_report_fin();
#ifdef USE_PROGRESSWIDGET
this->statusBar()->removeWidget(pd);
#endif
delete pd;
if (root_raw_term) {
@ -1032,25 +1049,30 @@ void MainWindow::actionRenderCGAL()
QTime t;
t.start();
#ifdef USE_PROGRESSWIDGET
ProgressWidget *pd = new ProgressWidget(this);
pd->setRange(0, 100);
pd->setValue(0);
this->statusBar()->addPermanentWidget(pd);
#else
QProgressDialog *pd = new QProgressDialog("Rendering Polygon Mesh using CGAL...", "Cancel", 0, 100);
QProgressBar *bar = new QProgressBar(pd);
bar->setRange(0, 100);
bar->setValue(0);
pd->setBar(bar);
pd->setRange(0, 100);
pd->setValue(0);
pd->setAutoClose(false);
pd->show();
// this->statusBar()->addPermanentWidget(bar);
ProgressData progpair(bar, pd);
#endif
QApplication::processEvents();
progress_report_prep(root_node, report_func, &progpair);
progress_report_prep(root_node, report_func, pd);
try {
this->root_N = new CGAL_Nef_polyhedron(root_node->render_cgal_nef_polyhedron());
}
catch (ProgressCancelException e) {
PRINT("Rendering cancelled.");
}
progress_report_fin();
// this->statusBar()->removeWidget(bar);
if (this->root_N)
{
@ -1111,6 +1133,9 @@ void MainWindow::actionRenderCGAL()
PRINT("Rendering finished.");
}
#ifdef USE_PROGRESSWIDGET
this->statusBar()->removeWidget(pd);
#endif
delete pd;
current_win = NULL;
}