Showing
11 changed files
with
331 additions
and
16 deletions
PaperGraph/GraphicsView.cpp
0 → 100644
1 | +#include "GraphicsView.h" | ||
2 | +#include <qmath.h> | ||
3 | + | ||
4 | +//View | ||
5 | +View::View(const QString& name, QWidget *parent) | ||
6 | + : QFrame(parent) | ||
7 | +{ | ||
8 | + //GraphicsView settings | ||
9 | + graphicsView = new GraphicsView(this); | ||
10 | + graphicsView->setDragMode(QGraphicsView::RubberBandDrag); | ||
11 | + graphicsView->setOptimizationFlags(QGraphicsView::DontSavePainterState); | ||
12 | + graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); | ||
13 | + graphicsView->setTransformationAnchor(QGraphicsView::AnchorUnderMouse); | ||
14 | + | ||
15 | + //connect | ||
16 | + | ||
17 | + //layout | ||
18 | + QGridLayout *topLayout = new QGridLayout; | ||
19 | + topLayout->addWidget(graphicsView, 0, 0); | ||
20 | + setLayout(topLayout); | ||
21 | + | ||
22 | + setupMatrix(); | ||
23 | +} | ||
24 | + | ||
25 | +QGraphicsView* View::view() const | ||
26 | +{ | ||
27 | + return static_cast<QGraphicsView *>(graphicsView); | ||
28 | +} | ||
29 | + | ||
30 | +void View::setupMatrix() | ||
31 | +{ | ||
32 | + qreal scale = qPow(qreal(2), qreal(2)); | ||
33 | + | ||
34 | + QMatrix matrix; | ||
35 | + matrix.scale(scale, scale); | ||
36 | + matrix.rotate(qreal(0)); | ||
37 | + | ||
38 | + graphicsView->setMatrix(matrix); | ||
39 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
PaperGraph/GraphicsView.h
0 → 100644
1 | +#ifndef GRAPHICSVIEW_H | ||
2 | +#define GRAPHICSVIEW_H | ||
3 | + | ||
4 | +#include <QFrame> | ||
5 | +#include <QGraphicsView> | ||
6 | +#include <QGridLayout> | ||
7 | + | ||
8 | +//pre-declare | ||
9 | +class View; | ||
10 | + | ||
11 | + | ||
12 | +class GraphicsView | ||
13 | + : public QGraphicsView | ||
14 | +{ | ||
15 | + Q_OBJECT | ||
16 | +private: | ||
17 | + View* view; | ||
18 | + | ||
19 | +public: | ||
20 | + GraphicsView(View *v): QGraphicsView(), view(v) {}; | ||
21 | +}; | ||
22 | + | ||
23 | + | ||
24 | +class View | ||
25 | + : public QFrame | ||
26 | +{ | ||
27 | + Q_OBJECT | ||
28 | +private: | ||
29 | + GraphicsView *graphicsView; | ||
30 | + | ||
31 | +public: | ||
32 | + explicit View(const QString& name, QWidget *parent = 0); | ||
33 | + QGraphicsView *view() const; | ||
34 | + | ||
35 | +public slots: | ||
36 | + /*void zoomIn(int level = 1); | ||
37 | + void zoomOut(int level = 1);*/ | ||
38 | + void setupMatrix(); | ||
39 | +}; | ||
40 | + | ||
41 | +#endif // GRAPHICSVIEW_H |
PaperGraph/NodeItem.cpp
0 → 100644
1 | +#include "NodeItem.h" | ||
2 | +#include <QtWidgets> | ||
3 | + | ||
4 | +void NodeItem::mousePressEvent(QGraphicsSceneMouseEvent * event) | ||
5 | +{ | ||
6 | +} | ||
7 | + | ||
8 | +void NodeItem::mouseMoveEvent(QGraphicsSceneMouseEvent * event) | ||
9 | +{ | ||
10 | +} | ||
11 | + | ||
12 | +void NodeItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) | ||
13 | +{ | ||
14 | +} | ||
15 | + | ||
16 | +NodeItem::NodeItem(int x, int y) | ||
17 | +{ | ||
18 | + this->x = x; | ||
19 | + this->y = y; | ||
20 | + this->color = QColor(0, 0, 0); //R, G, B | ||
21 | + setZValue((x+y)%2); | ||
22 | + | ||
23 | + setFlags(ItemIsSelectable | ItemIsMovable); | ||
24 | + setAcceptHoverEvents(true); | ||
25 | +} | ||
26 | + | ||
27 | +QRectF NodeItem::boundingRect() const | ||
28 | +{ | ||
29 | + return QRectF(0, 0, 110, 70); | ||
30 | +} | ||
31 | + | ||
32 | +QPainterPath NodeItem::shape() const | ||
33 | +{ | ||
34 | + QPainterPath path; | ||
35 | + path.addRect(14, 14, 82, 42); | ||
36 | + return path; | ||
37 | +} | ||
38 | + | ||
39 | +void NodeItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) | ||
40 | +{ | ||
41 | + Q_UNUSED(widget); | ||
42 | + | ||
43 | + QColor fillColor = (option->state & QStyle::State_Selected) ? color.dark(150) : color; | ||
44 | + if (option->state & QStyle::State_MouseOver) | ||
45 | + fillColor = fillColor.light(125); | ||
46 | + | ||
47 | + const qreal& lod = option->levelOfDetailFromTransform(painter->worldTransform()); | ||
48 | + if (lod < 0.2) { | ||
49 | + if (lod < 0.125) { | ||
50 | + painter->fillRect(QRectF(0, 0, 110, 70), fillColor); | ||
51 | + return; | ||
52 | + } | ||
53 | + | ||
54 | + QBrush b = painter->brush(); | ||
55 | + painter->setBrush(fillColor); | ||
56 | + painter->drawRect(13, 13, 97, 57); | ||
57 | + painter->setBrush(b); | ||
58 | + return; | ||
59 | + } | ||
60 | + | ||
61 | + QPen oldPen = painter->pen(); | ||
62 | + QPen pen = oldPen; | ||
63 | + int width = 0; | ||
64 | + if (option->state & QStyle::State_Selected) | ||
65 | + width += 2; | ||
66 | + | ||
67 | + pen.setWidth(width); | ||
68 | + QBrush b = painter->brush(); | ||
69 | + painter->setBrush(QBrush(fillColor.dark(option->state & QStyle::State_Sunken ? 120 : 100))); | ||
70 | + | ||
71 | + painter->drawRect(QRect(14, 14, 79, 39)); | ||
72 | + painter->setBrush(b); | ||
73 | + | ||
74 | + if (lod >= 1) { | ||
75 | + painter->setPen(QPen(Qt::gray, 1)); | ||
76 | + painter->drawLine(15, 54, 94, 54); | ||
77 | + painter->drawLine(94, 53, 94, 15); | ||
78 | + painter->setPen(QPen(Qt::black, 0)); | ||
79 | + } | ||
80 | + | ||
81 | + // Draw text | ||
82 | + //if (lod >= 2) { | ||
83 | + // QFont font("Times", 10); | ||
84 | + // font.setStyleStrategy(QFont::ForceOutline); | ||
85 | + // painter->setFont(font); | ||
86 | + // painter->save(); | ||
87 | + // painter->scale(0.1, 0.1); | ||
88 | + // painter->drawText(170, 180, QString("Model: VSC-2000 (Very Small Chip) at %1x%2").arg(x).arg(y)); | ||
89 | + // painter->drawText(170, 200, QString("Serial number: DLWR-WEER-123L-ZZ33-SDSJ")); | ||
90 | + // painter->drawText(170, 220, QString("Manufacturer: Chip Manufacturer")); | ||
91 | + // painter->restore(); | ||
92 | + //} | ||
93 | + | ||
94 | + // Draw lines | ||
95 | + //QVarLengthArray<QLineF, 36> lines; | ||
96 | + //if (lod >= 0.5) { | ||
97 | + // for (int i = 0; i <= 10; i += (lod > 0.5 ? 1 : 2)) { | ||
98 | + // lines.append(QLineF(18 + 7 * i, 13, 18 + 7 * i, 5)); | ||
99 | + // lines.append(QLineF(18 + 7 * i, 54, 18 + 7 * i, 62)); | ||
100 | + // } | ||
101 | + // for (int i = 0; i <= 6; i += (lod > 0.5 ? 1 : 2)) { | ||
102 | + // lines.append(QLineF(5, 18 + i * 5, 13, 18 + i * 5)); | ||
103 | + // lines.append(QLineF(94, 18 + i * 5, 102, 18 + i * 5)); | ||
104 | + // } | ||
105 | + //} | ||
106 | + //if (lod >= 0.4) { | ||
107 | + // const QLineF lineData[] = { | ||
108 | + // QLineF(25, 35, 35, 35), | ||
109 | + // QLineF(35, 30, 35, 40), | ||
110 | + // QLineF(35, 30, 45, 35), | ||
111 | + // QLineF(35, 40, 45, 35), | ||
112 | + // QLineF(45, 30, 45, 40), | ||
113 | + // QLineF(45, 35, 55, 35) | ||
114 | + // }; | ||
115 | + // lines.append(lineData, 6); | ||
116 | + //} | ||
117 | + //painter->drawLines(lines.data(), lines.size()); | ||
118 | + | ||
119 | + // Draw red ink | ||
120 | + //if (stuff.size() > 1) { | ||
121 | + // QPen p = painter->pen(); | ||
122 | + // painter->setPen(QPen(Qt::red, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); | ||
123 | + // painter->setBrush(Qt::NoBrush); | ||
124 | + // QPainterPath path; | ||
125 | + // path.moveTo(stuff.first()); | ||
126 | + // for (int i = 1; i < stuff.size(); ++i) | ||
127 | + // path.lineTo(stuff.at(i)); | ||
128 | + // painter->drawPath(path); | ||
129 | + // painter->setPen(p); | ||
130 | + //} | ||
131 | +} |
PaperGraph/NodeItem.h
0 → 100644
1 | +#ifndef NODEITEM_H | ||
2 | +#define NODEITEM_H | ||
3 | + | ||
4 | +#include <QColor> | ||
5 | +#include <QGraphicsItem> | ||
6 | + | ||
7 | + | ||
8 | +const int NODE_SIZE = 4; | ||
9 | + | ||
10 | +class NodeItem | ||
11 | + : public QGraphicsItem | ||
12 | +{ | ||
13 | +private: | ||
14 | + int x; | ||
15 | + int y; | ||
16 | + QColor color; | ||
17 | + | ||
18 | +protected: | ||
19 | + void mousePressEvent(QGraphicsSceneMouseEvent *event) override; | ||
20 | + void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; | ||
21 | + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; | ||
22 | + | ||
23 | +public: | ||
24 | + NodeItem(int x, int y); | ||
25 | + | ||
26 | + QRectF boundingRect() const override; | ||
27 | + QPainterPath shape() const override; | ||
28 | + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; | ||
29 | +}; | ||
30 | + | ||
31 | +#endif // NODEITEM_H | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -66,9 +66,13 @@ | ... | @@ -66,9 +66,13 @@ |
66 | </PropertyGroup> | 66 | </PropertyGroup> |
67 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | 67 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
68 | <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> | 68 | <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> |
69 | + <IncludePath>C:\boost\boost_1_63_0;$(IncludePath)</IncludePath> | ||
70 | + <LibraryPath>C:\boost\boost_1_63_0\stage\lib;$(LibraryPath)</LibraryPath> | ||
69 | </PropertyGroup> | 71 | </PropertyGroup> |
70 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | 72 | <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
71 | <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> | 73 | <OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir> |
74 | + <IncludePath>C:\boost\boost_1_63_0;$(IncludePath)</IncludePath> | ||
75 | + <LibraryPath>C:\boost\boost_1_63_0\stage\lib;$(LibraryPath)</LibraryPath> | ||
72 | </PropertyGroup> | 76 | </PropertyGroup> |
73 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | 77 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
74 | <ClCompile> | 78 | <ClCompile> |
... | @@ -137,6 +141,10 @@ | ... | @@ -137,6 +141,10 @@ |
137 | </Link> | 141 | </Link> |
138 | </ItemDefinitionGroup> | 142 | </ItemDefinitionGroup> |
139 | <ItemGroup> | 143 | <ItemGroup> |
144 | + <ClCompile Include="GeneratedFiles\Debug\moc_GraphicsView.cpp"> | ||
145 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> | ||
146 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | ||
147 | + </ClCompile> | ||
140 | <ClCompile Include="GeneratedFiles\Debug\moc_PaperGraphWidget.cpp"> | 148 | <ClCompile Include="GeneratedFiles\Debug\moc_PaperGraphWidget.cpp"> |
141 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> | 149 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> |
142 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | 150 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> |
... | @@ -151,11 +159,17 @@ | ... | @@ -151,11 +159,17 @@ |
151 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | 159 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
152 | </PrecompiledHeader> | 160 | </PrecompiledHeader> |
153 | </ClCompile> | 161 | </ClCompile> |
162 | + <ClCompile Include="GeneratedFiles\Release\moc_GraphicsView.cpp"> | ||
163 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> | ||
164 | + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | ||
165 | + </ClCompile> | ||
154 | <ClCompile Include="GeneratedFiles\Release\moc_PaperGraphWidget.cpp"> | 166 | <ClCompile Include="GeneratedFiles\Release\moc_PaperGraphWidget.cpp"> |
155 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> | 167 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> |
156 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | 168 | <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> |
157 | </ClCompile> | 169 | </ClCompile> |
170 | + <ClCompile Include="GraphicsView.cpp" /> | ||
158 | <ClCompile Include="main.cpp" /> | 171 | <ClCompile Include="main.cpp" /> |
172 | + <ClCompile Include="NodeItem.cpp" /> | ||
159 | <ClCompile Include="PaperGraphWidget.cpp" /> | 173 | <ClCompile Include="PaperGraphWidget.cpp" /> |
160 | </ItemGroup> | 174 | </ItemGroup> |
161 | <ItemGroup> | 175 | <ItemGroup> |
... | @@ -200,6 +214,25 @@ | ... | @@ -200,6 +214,25 @@ |
200 | </ItemGroup> | 214 | </ItemGroup> |
201 | <ItemGroup> | 215 | <ItemGroup> |
202 | <ClInclude Include="GeneratedFiles\ui_PaperGraphWidget.h" /> | 216 | <ClInclude Include="GeneratedFiles\ui_PaperGraphWidget.h" /> |
217 | + <CustomBuild Include="GraphicsView.h"> | ||
218 | + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs> | ||
219 | + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Moc%27ing GraphicsView.h...</Message> | ||
220 | + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs> | ||
221 | + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets"</Command> | ||
222 | + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs> | ||
223 | + <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Moc%27ing GraphicsView.h...</Message> | ||
224 | + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs> | ||
225 | + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets"</Command> | ||
226 | + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs> | ||
227 | + <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Moc%27ing GraphicsView.h...</Message> | ||
228 | + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs> | ||
229 | + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets"</Command> | ||
230 | + <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs> | ||
231 | + <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Moc%27ing GraphicsView.h...</Message> | ||
232 | + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp</Outputs> | ||
233 | + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets"</Command> | ||
234 | + </CustomBuild> | ||
235 | + <ClInclude Include="NodeItem.h" /> | ||
203 | </ItemGroup> | 236 | </ItemGroup> |
204 | <ItemGroup> | 237 | <ItemGroup> |
205 | <CustomBuild Include="PaperGraphWidget.qrc"> | 238 | <CustomBuild Include="PaperGraphWidget.qrc"> | ... | ... |
... | @@ -50,6 +50,18 @@ | ... | @@ -50,6 +50,18 @@ |
50 | <ClCompile Include="GeneratedFiles\qrc_PaperGraphWidget.cpp"> | 50 | <ClCompile Include="GeneratedFiles\qrc_PaperGraphWidget.cpp"> |
51 | <Filter>Generated Files</Filter> | 51 | <Filter>Generated Files</Filter> |
52 | </ClCompile> | 52 | </ClCompile> |
53 | + <ClCompile Include="NodeItem.cpp"> | ||
54 | + <Filter>Source Files</Filter> | ||
55 | + </ClCompile> | ||
56 | + <ClCompile Include="GraphicsView.cpp"> | ||
57 | + <Filter>Source Files</Filter> | ||
58 | + </ClCompile> | ||
59 | + <ClCompile Include="GeneratedFiles\Debug\moc_GraphicsView.cpp"> | ||
60 | + <Filter>Generated Files\Debug</Filter> | ||
61 | + </ClCompile> | ||
62 | + <ClCompile Include="GeneratedFiles\Release\moc_GraphicsView.cpp"> | ||
63 | + <Filter>Generated Files\Release</Filter> | ||
64 | + </ClCompile> | ||
53 | </ItemGroup> | 65 | </ItemGroup> |
54 | <ItemGroup> | 66 | <ItemGroup> |
55 | <CustomBuild Include="PaperGraphWidget.h"> | 67 | <CustomBuild Include="PaperGraphWidget.h"> |
... | @@ -61,10 +73,16 @@ | ... | @@ -61,10 +73,16 @@ |
61 | <CustomBuild Include="PaperGraphWidget.qrc"> | 73 | <CustomBuild Include="PaperGraphWidget.qrc"> |
62 | <Filter>Resource Files</Filter> | 74 | <Filter>Resource Files</Filter> |
63 | </CustomBuild> | 75 | </CustomBuild> |
76 | + <CustomBuild Include="GraphicsView.h"> | ||
77 | + <Filter>Header Files</Filter> | ||
78 | + </CustomBuild> | ||
64 | </ItemGroup> | 79 | </ItemGroup> |
65 | <ItemGroup> | 80 | <ItemGroup> |
66 | <ClInclude Include="GeneratedFiles\ui_PaperGraphWidget.h"> | 81 | <ClInclude Include="GeneratedFiles\ui_PaperGraphWidget.h"> |
67 | <Filter>Generated Files</Filter> | 82 | <Filter>Generated Files</Filter> |
68 | </ClInclude> | 83 | </ClInclude> |
84 | + <ClInclude Include="NodeItem.h"> | ||
85 | + <Filter>Header Files</Filter> | ||
86 | + </ClInclude> | ||
69 | </ItemGroup> | 87 | </ItemGroup> |
70 | </Project> | 88 | </Project> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | #include "PaperGraphWidget.h" | 1 | #include "PaperGraphWidget.h" |
2 | +#include "NodeItem.h" | ||
3 | +#include "GraphicsView.h" | ||
2 | 4 | ||
3 | PaperGraphWidget::PaperGraphWidget(QWidget *parent) | 5 | PaperGraphWidget::PaperGraphWidget(QWidget *parent) |
4 | : QWidget(parent) | 6 | : QWidget(parent) |
5 | { | 7 | { |
6 | ui.setupUi(this); | 8 | ui.setupUi(this); |
9 | + initscene(); | ||
10 | + | ||
11 | + View *view = new View("temp view"); | ||
12 | + view->view()->setScene(scene); | ||
13 | + QHBoxLayout *layout = new QHBoxLayout; | ||
14 | + layout->addWidget(view); | ||
15 | + setLayout(layout); | ||
16 | + | ||
17 | + setWindowTitle(tr("Paper Graph Visualization")); | ||
7 | } | 18 | } |
8 | 19 | ||
9 | -PaperGraphWidget::~PaperGraphWidget() | 20 | +void PaperGraphWidget::initscene() |
10 | { | 21 | { |
22 | + scene = new QGraphicsScene(this); | ||
11 | 23 | ||
24 | + int x = 0, y; | ||
25 | + for (int i=-11000; i<11000; i+=110) { | ||
26 | + ++x; | ||
27 | + y = 0; | ||
28 | + for (int j=-7000; j<7000; j+=70) { | ||
29 | + ++y; | ||
30 | + QGraphicsItem *item = new NodeItem(x, y); | ||
31 | + item->setPos(QPointF(i, j)); | ||
32 | + scene->addItem(item); | ||
33 | + } | ||
34 | + } | ||
12 | } | 35 | } | ... | ... |
... | @@ -2,18 +2,23 @@ | ... | @@ -2,18 +2,23 @@ |
2 | #define PAPERGRAPHWIDGET_H | 2 | #define PAPERGRAPHWIDGET_H |
3 | 3 | ||
4 | #include <QtWidgets/QWidget> | 4 | #include <QtWidgets/QWidget> |
5 | +#include <QGraphicsScene> | ||
5 | #include "ui_PaperGraphWidget.h" | 6 | #include "ui_PaperGraphWidget.h" |
6 | 7 | ||
8 | +//class QGraphicsScene; | ||
9 | + | ||
7 | class PaperGraphWidget : public QWidget | 10 | class PaperGraphWidget : public QWidget |
8 | { | 11 | { |
9 | Q_OBJECT | 12 | Q_OBJECT |
10 | 13 | ||
11 | public: | 14 | public: |
12 | PaperGraphWidget(QWidget *parent = 0); | 15 | PaperGraphWidget(QWidget *parent = 0); |
13 | - ~PaperGraphWidget(); | ||
14 | 16 | ||
15 | private: | 17 | private: |
18 | + void initscene(); | ||
19 | + | ||
16 | Ui::PaperGraphWidgetClass ui; | 20 | Ui::PaperGraphWidgetClass ui; |
21 | + QGraphicsScene *scene; | ||
17 | }; | 22 | }; |
18 | 23 | ||
19 | #endif // PAPERGRAPHWIDGET_H | 24 | #endif // PAPERGRAPHWIDGET_H | ... | ... |
... | @@ -13,16 +13,6 @@ | ... | @@ -13,16 +13,6 @@ |
13 | <property name="windowTitle"> | 13 | <property name="windowTitle"> |
14 | <string>PaperGraphWidget</string> | 14 | <string>PaperGraphWidget</string> |
15 | </property> | 15 | </property> |
16 | - <widget class="QGraphicsView" name="graphicsView"> | ||
17 | - <property name="geometry"> | ||
18 | - <rect> | ||
19 | - <x>10</x> | ||
20 | - <y>10</y> | ||
21 | - <width>581</width> | ||
22 | - <height>381</height> | ||
23 | - </rect> | ||
24 | - </property> | ||
25 | - </widget> | ||
26 | </widget> | 16 | </widget> |
27 | <layoutdefault spacing="6" margin="11"/> | 17 | <layoutdefault spacing="6" margin="11"/> |
28 | <resources> | 18 | <resources> | ... | ... |
... | @@ -3,8 +3,11 @@ | ... | @@ -3,8 +3,11 @@ |
3 | 3 | ||
4 | int main(int argc, char *argv[]) | 4 | int main(int argc, char *argv[]) |
5 | { | 5 | { |
6 | - QApplication a(argc, argv); | 6 | + QApplication app(argc, argv); |
7 | + app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); | ||
8 | + | ||
7 | PaperGraphWidget w; | 9 | PaperGraphWidget w; |
8 | w.show(); | 10 | w.show(); |
9 | - return a.exec(); | 11 | + |
12 | + return app.exec(); | ||
10 | } | 13 | } | ... | ... |
-
Please register or login to post a comment