Skip to content

Commit 053f78a

Browse files
committed
Merge pull request #794 from benjaminlarson/benSolveLinearSystem
Ben solve linear system.
2 parents 0dfbeee + 5cc6a78 commit 053f78a

File tree

6 files changed

+535
-101
lines changed

6 files changed

+535
-101
lines changed

src/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,16 @@ IF(NOT BUILD_HEADLESS)
492492
ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
493493
ENDIF()
494494

495+
SET(QWT_INCLUDE_DIR CACHE PATH "Qwt include directory")
496+
IF(NOT QWT_INCLUDE_DIR)
497+
MESSAGE(FATAL_ERROR "QWT_INCLUDE_DIR should be set to path like 'qwt-6.0.1/include'")
498+
ENDIF()
499+
INCLUDE_DIRECTORIES(${QWT_INCLUDE_DIR})
500+
SET(QWT_LIBRARY CACHE FILEPATH "Qwt library")
501+
IF(NOT QWT_LIBRARY)
502+
MESSAGE(FATAL_ERROR "QWT_LIBRARY should be set to a filepath like 'qwt-6.0.1/lib/libqwt.so'")
503+
ENDIF()
504+
SET(qwt_libraries ${QWT_LIBRARY} )
495505

496506
########################################################################
497507
# Find and configure dl library

src/Interface/Modules/Math/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ SET(Interface_Modules_Math_HEADERS
5252
SolveLinearSystemDialog.h
5353
ConvertMatrixTypeDialog.h
5454
BuildNoiseColumnMatrixDialog.h
55+
qwt_global.h
56+
qwt_plot.h
5557
)
5658

5759
SET(Interface_Modules_Math_SOURCES
@@ -81,8 +83,10 @@ TARGET_LINK_LIBRARIES(Interface_Modules_Math
8183
Algorithms_Math
8284
Modules_Math
8385
Interface_Modules_Base
86+
8487
${SCI_BOOST_LIBRARY}
85-
${QT_LIBRARIES})
88+
${QT_LIBRARIES}
89+
${qwt_libraries})
8690

8791
IF(BUILD_SHARED_LIBS)
8892
ADD_DEFINITIONS(-DBUILD_Interface_Modules_Math)

src/Interface/Modules/Math/SolveLinearSystem.ui

Lines changed: 133 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,14 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>389</width>
10-
<height>192</height>
9+
<width>350</width>
10+
<height>250</height>
1111
</rect>
1212
</property>
13-
<property name="sizePolicy">
14-
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
15-
<horstretch>0</horstretch>
16-
<verstretch>0</verstretch>
17-
</sizepolicy>
18-
</property>
1913
<property name="minimumSize">
2014
<size>
21-
<width>389</width>
22-
<height>192</height>
15+
<width>350</width>
16+
<height>250</height>
2317
</size>
2418
</property>
2519
<property name="windowTitle">
@@ -31,112 +25,151 @@
3125
<property name="title">
3226
<string/>
3327
</property>
34-
<layout class="QFormLayout" name="formLayout">
35-
<item row="0" column="0">
36-
<widget class="QLabel" name="label_3">
37-
<property name="text">
38-
<string>Method:</string>
39-
</property>
40-
</widget>
41-
</item>
42-
<item row="0" column="1">
43-
<widget class="QComboBox" name="methodComboBox_">
28+
<layout class="QVBoxLayout" name="verticalLayout_3">
29+
<item>
30+
<layout class="QVBoxLayout" name="verticalLayout_2">
4431
<item>
45-
<property name="text">
46-
<string>Conjugate Gradient (SCI)</string>
47-
</property>
32+
<layout class="QHBoxLayout" name="horizontalLayout_5">
33+
<item>
34+
<widget class="QLabel" name="label_3">
35+
<property name="text">
36+
<string>Method:</string>
37+
</property>
38+
</widget>
39+
</item>
40+
<item>
41+
<widget class="QComboBox" name="methodComboBox_">
42+
<item>
43+
<property name="text">
44+
<string>Conjugate Gradient (SCI)</string>
45+
</property>
46+
</item>
47+
<item>
48+
<property name="text">
49+
<string>BiConjugate Gradient (SCI)</string>
50+
</property>
51+
</item>
52+
<item>
53+
<property name="text">
54+
<string>Jacobi (SCI)</string>
55+
</property>
56+
</item>
57+
<item>
58+
<property name="text">
59+
<string>MINRES (SCI)</string>
60+
</property>
61+
</item>
62+
</widget>
63+
</item>
64+
</layout>
4865
</item>
4966
<item>
50-
<property name="text">
51-
<string>BiConjugate Gradient (SCI)</string>
52-
</property>
67+
<layout class="QHBoxLayout" name="horizontalLayout_4">
68+
<item>
69+
<widget class="QLabel" name="label_4">
70+
<property name="text">
71+
<string>Preconditioner:</string>
72+
</property>
73+
</widget>
74+
</item>
75+
<item>
76+
<widget class="QComboBox" name="preconditionerComboBox_">
77+
<item>
78+
<property name="text">
79+
<string>Jacobi</string>
80+
</property>
81+
</item>
82+
<item>
83+
<property name="text">
84+
<string>None</string>
85+
</property>
86+
</item>
87+
</widget>
88+
</item>
89+
</layout>
5390
</item>
5491
<item>
55-
<property name="text">
56-
<string>Jacobi (SCI)</string>
57-
</property>
92+
<layout class="QHBoxLayout" name="horizontalLayout_3">
93+
<item>
94+
<widget class="QLabel" name="label">
95+
<property name="text">
96+
<string>Target error:</string>
97+
</property>
98+
</widget>
99+
</item>
100+
<item>
101+
<widget class="QDoubleSpinBox" name="targetErrorSpinBox_">
102+
<property name="decimals">
103+
<number>20</number>
104+
</property>
105+
<property name="maximum">
106+
<double>999999999.000000000000000</double>
107+
</property>
108+
<property name="singleStep">
109+
<double>0.000100000000000</double>
110+
</property>
111+
<property name="value">
112+
<double>0.010000000000000</double>
113+
</property>
114+
</widget>
115+
</item>
116+
</layout>
58117
</item>
59118
<item>
60-
<property name="text">
61-
<string>MINRES (SCI)</string>
62-
</property>
63-
</item>
64-
</widget>
65-
</item>
66-
<item row="1" column="0">
67-
<widget class="QLabel" name="label_4">
68-
<property name="text">
69-
<string>Preconditioner:</string>
70-
</property>
71-
</widget>
72-
</item>
73-
<item row="1" column="1">
74-
<widget class="QComboBox" name="preconditionerComboBox_">
75-
<item>
76-
<property name="text">
77-
<string>Jacobi</string>
78-
</property>
119+
<layout class="QHBoxLayout" name="horizontalLayout_2">
120+
<item>
121+
<widget class="QLabel" name="label_2">
122+
<property name="text">
123+
<string>Maximum iterations:</string>
124+
</property>
125+
</widget>
126+
</item>
127+
<item>
128+
<widget class="QSpinBox" name="maxIterationsSpinBox_">
129+
<property name="minimum">
130+
<number>1</number>
131+
</property>
132+
<property name="maximum">
133+
<number>100000</number>
134+
</property>
135+
</widget>
136+
</item>
137+
</layout>
79138
</item>
80139
<item>
81-
<property name="text">
82-
<string>None</string>
83-
</property>
140+
<layout class="QHBoxLayout" name="horizontalLayout" stretch="10,0">
141+
<item>
142+
<widget class="QwtPlot" name="qwtPlot"/>
143+
</item>
144+
<item>
145+
<spacer name="horizontalSpacer">
146+
<property name="orientation">
147+
<enum>Qt::Horizontal</enum>
148+
</property>
149+
<property name="sizeHint" stdset="0">
150+
<size>
151+
<width>40</width>
152+
<height>20</height>
153+
</size>
154+
</property>
155+
</spacer>
156+
</item>
157+
</layout>
84158
</item>
85-
</widget>
86-
</item>
87-
<item row="4" column="0">
88-
<widget class="QLabel" name="label_2">
89-
<property name="text">
90-
<string>Maximum iterations:</string>
91-
</property>
92-
</widget>
93-
</item>
94-
<item row="4" column="1">
95-
<widget class="QSpinBox" name="maxIterationsSpinBox_">
96-
<property name="minimum">
97-
<number>1</number>
98-
</property>
99-
<property name="maximum">
100-
<number>100000</number>
101-
</property>
102-
</widget>
103-
</item>
104-
<item row="2" column="1">
105-
<widget class="QDoubleSpinBox" name="targetErrorSpinBox_">
106-
<property name="decimals">
107-
<number>20</number>
108-
</property>
109-
<property name="maximum">
110-
<double>999999999.000000000000000</double>
111-
</property>
112-
<property name="singleStep">
113-
<double>0.000100000000000</double>
114-
</property>
115-
<property name="value">
116-
<double>0.010000000000000</double>
117-
</property>
118-
</widget>
119-
</item>
120-
<item row="2" column="0">
121-
<widget class="QLabel" name="label">
122-
<property name="text">
123-
<string>Target error:</string>
124-
</property>
125-
</widget>
159+
</layout>
126160
</item>
127161
</layout>
128-
<zorder>label_2</zorder>
129-
<zorder>maxIterationsSpinBox_</zorder>
130-
<zorder>methodComboBox_</zorder>
131-
<zorder>label_3</zorder>
132-
<zorder>label_4</zorder>
133-
<zorder>preconditionerComboBox_</zorder>
134-
<zorder>targetErrorSpinBox_</zorder>
135-
<zorder>label</zorder>
136162
</widget>
137163
</item>
138164
</layout>
139165
</widget>
166+
<customwidgets>
167+
<customwidget>
168+
<class>QwtPlot</class>
169+
<extends>QFrame</extends>
170+
<header>qwt_plot.h</header>
171+
</customwidget>
172+
</customwidgets>
140173
<resources/>
141174
<connections/>
142175
</ui>

src/Interface/Modules/Math/SolveLinearSystemDialog.cc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@
3030
#include <Core/Algorithms/Base/AlgorithmVariableNames.h>
3131
#include <Core/Logging/Log.h>
3232
#include <Dataflow/Network/ModuleStateInterface.h> //TODO: extract into intermediate
33+
#include <qwt_plot.h>
34+
#include <qwt_plot_curve.h>
35+
#include <qwt_legend.h>
3336

3437
using namespace SCIRun::Gui;
3538
using namespace SCIRun::Dataflow::Networks;
3639
using namespace SCIRun::Core::Algorithms;
3740

41+
3842
namespace SCIRun {
3943
namespace Gui {
4044
class SolveLinearSystemDialogImpl
@@ -62,6 +66,36 @@ SolveLinearSystemDialog::SolveLinearSystemDialog(const std::string& name, Module
6266
addSpinBoxManager(maxIterationsSpinBox_, Variables::MaxIterations);
6367
addDoubleSpinBoxManager(targetErrorSpinBox_, Variables::TargetError);
6468

69+
QwtPlot *myPlot = this->qwtPlot;
70+
QwtLegend *myLegend = new QwtLegend;
71+
QwtPlotCurve *curve1 = new QwtPlotCurve("Current Target");
72+
QwtPlotCurve *curve2 = new QwtPlotCurve("Target Error");
73+
QwtPlotCurve *curve3 = new QwtPlotCurve("CurrentError");
74+
double x[5] = { 0, 10, 15, 20, 25 };
75+
double y[5] = { 0, 2, 4, 16, 64 };
76+
77+
curve1->setSamples(&x[0], &y[0], (size_t)5);
78+
curve1->setPen(Qt::blue);
79+
curve1->setLegendAttribute(QwtPlotCurve::LegendShowLine);
80+
curve1->setItemAttribute(QwtPlotItem::Legend, true);
81+
82+
curve2->setPen(Qt::darkRed);
83+
curve2->setLegendAttribute(QwtPlotCurve::LegendShowLine);
84+
curve2->setItemAttribute(QwtPlotItem::Legend, true);
85+
86+
curve3->setPen(Qt::darkGreen);
87+
curve3->setLegendAttribute(QwtPlotCurve::LegendShowLine);
88+
curve3->setItemAttribute(QwtPlotItem::Legend, true);
89+
90+
myPlot->setAxisTitle(2, QString("Iteration"));
91+
myPlot->setAxisTitle(0, QString("Error (RMS)"));
92+
myPlot->setTitle(QString("Convergence"));
93+
myPlot->insertLegend(myLegend, QwtPlot::RightLegend);
94+
95+
curve1->attach(myPlot);
96+
myPlot->replot();
97+
myPlot->show();
98+
6599
addComboBoxManager(preconditionerComboBox_, Variables::Preconditioner);
66100
addComboBoxManager(methodComboBox_, Variables::Method, impl_->solverNameLookup_);
67101
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2+
* Qwt Widget Library
3+
* Copyright (C) 1997 Josef Wilgen
4+
* Copyright (C) 2002 Uwe Rathmann
5+
*
6+
* This library is free software; you can redistribute it and/or
7+
* modify it under the terms of the Qwt License, Version 1.0
8+
*****************************************************************************/
9+
10+
#ifndef QWT_GLOBAL_H
11+
#define QWT_GLOBAL_H
12+
13+
#include <qglobal.h>
14+
15+
// QWT_VERSION is (major << 16) + (minor << 8) + patch.
16+
17+
#define QWT_VERSION 0x060102
18+
#define QWT_VERSION_STR "6.1.2"
19+
20+
#if defined(_MSC_VER) /* MSVC Compiler */
21+
/* template-class specialization 'identifier' is already instantiated */
22+
#pragma warning(disable: 4660)
23+
/* inherits via dominance */
24+
#pragma warning(disable: 4250)
25+
#endif // _MSC_VER
26+
27+
#ifdef QWT_DLL
28+
29+
#if defined(QWT_MAKEDLL) // create a Qwt DLL library
30+
#define QWT_EXPORT Q_DECL_EXPORT
31+
#else // use a Qwt DLL library
32+
#define QWT_EXPORT Q_DECL_IMPORT
33+
#endif
34+
35+
#endif // QWT_DLL
36+
37+
#ifndef QWT_EXPORT
38+
#define QWT_EXPORT
39+
#endif
40+
41+
#endif

0 commit comments

Comments
 (0)