Skip to content

Commit 3520e6d

Browse files
committed
Better background colors for views.
1 parent 8c65056 commit 3520e6d

File tree

2 files changed

+34
-141
lines changed

2 files changed

+34
-141
lines changed

OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp

Lines changed: 13 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ GraphicsView::GraphicsView(StringHandler::ViewType viewType, ModelWidget *parent
118118
setExtentRectangle(left, bottom, right, top);
119119
centerOn(sceneRect().center());
120120
scale(1.0, -1.0); // invert the drawing area.
121-
setStyleSheet(QString("QGraphicsView{background-color: lightGray;}"));
122121
setIsCustomScale(false);
123122
setAddClassAnnotationNeeded(false);
124123
setIsCreatingConnection(false);
@@ -134,38 +133,13 @@ GraphicsView::GraphicsView(StringHandler::ViewType viewType, ModelWidget *parent
134133
createActions();
135134
}
136135

137-
StringHandler::ViewType GraphicsView::getViewType()
138-
{
139-
return mViewType;
140-
}
141-
142-
ModelWidget* GraphicsView::getModelWidget()
143-
{
144-
return mpModelWidget;
145-
}
146-
147-
CoOrdinateSystem* GraphicsView::getCoOrdinateSystem()
148-
{
149-
return mpCoOrdinateSystem;
150-
}
151-
152136
void GraphicsView::setExtentRectangle(qreal left, qreal bottom, qreal right, qreal top)
153137
{
154138
mExtentRectangle = QRectF(left, bottom, fabs(left - right), fabs(bottom - top));
155139
QRectF sceneRectangle = mExtentRectangle.adjusted(left * 2, bottom * 2, right * 2, top * 2);
156140
setSceneRect(sceneRectangle);
157141
}
158142

159-
void GraphicsView::setIsCustomScale(bool enable)
160-
{
161-
mIsCustomScale = enable;
162-
}
163-
164-
bool GraphicsView::isCustomScale()
165-
{
166-
return mIsCustomScale;
167-
}
168-
169143
void GraphicsView::setIsCreatingConnection(bool enable)
170144
{
171145
mIsCreatingConnection = enable;
@@ -177,11 +151,6 @@ void GraphicsView::setIsCreatingConnection(bool enable)
177151
setItemsFlags(!enable);
178152
}
179153

180-
bool GraphicsView::isCreatingConnection()
181-
{
182-
return mIsCreatingConnection;
183-
}
184-
185154
void GraphicsView::setIsCreatingLineShape(bool enable)
186155
{
187156
mIsCreatingLineShape = enable;
@@ -194,11 +163,6 @@ void GraphicsView::setIsCreatingLineShape(bool enable)
194163
updateUndoRedoActions(enable);
195164
}
196165

197-
bool GraphicsView::isCreatingLineShape()
198-
{
199-
return mIsCreatingLineShape;
200-
}
201-
202166
void GraphicsView::setIsCreatingPolygonShape(bool enable)
203167
{
204168
mIsCreatingPolygonShape = enable;
@@ -211,11 +175,6 @@ void GraphicsView::setIsCreatingPolygonShape(bool enable)
211175
updateUndoRedoActions(enable);
212176
}
213177

214-
bool GraphicsView::isCreatingPolygonShape()
215-
{
216-
return mIsCreatingPolygonShape;
217-
}
218-
219178
void GraphicsView::setIsCreatingRectangleShape(bool enable)
220179
{
221180
mIsCreatingRectangleShape = enable;
@@ -228,11 +187,6 @@ void GraphicsView::setIsCreatingRectangleShape(bool enable)
228187
updateUndoRedoActions(enable);
229188
}
230189

231-
bool GraphicsView::isCreatingRectangleShape()
232-
{
233-
return mIsCreatingRectangleShape;
234-
}
235-
236190
void GraphicsView::setIsCreatingEllipseShape(bool enable)
237191
{
238192
mIsCreatingEllipseShape = enable;
@@ -245,11 +199,6 @@ void GraphicsView::setIsCreatingEllipseShape(bool enable)
245199
updateUndoRedoActions(enable);
246200
}
247201

248-
bool GraphicsView::isCreatingEllipseShape()
249-
{
250-
return mIsCreatingEllipseShape;
251-
}
252-
253202
void GraphicsView::setIsCreatingTextShape(bool enable)
254203
{
255204
mIsCreatingTextShape = enable;
@@ -262,11 +211,6 @@ void GraphicsView::setIsCreatingTextShape(bool enable)
262211
updateUndoRedoActions(enable);
263212
}
264213

265-
bool GraphicsView::isCreatingTextShape()
266-
{
267-
return mIsCreatingTextShape;
268-
}
269-
270214
void GraphicsView::setIsCreatingBitmapShape(bool enable)
271215
{
272216
mIsCreatingBitmapShape = enable;
@@ -279,11 +223,6 @@ void GraphicsView::setIsCreatingBitmapShape(bool enable)
279223
updateUndoRedoActions(enable);
280224
}
281225

282-
bool GraphicsView::isCreatingBitmapShape()
283-
{
284-
return mIsCreatingBitmapShape;
285-
}
286-
287226
void GraphicsView::setItemsFlags(bool enable)
288227
{
289228
// set components, shapes and connection flags accordingly
@@ -313,51 +252,6 @@ void GraphicsView::updateUndoRedoActions(bool enable)
313252
}
314253
}
315254

316-
void GraphicsView::setIsMovingComponentsAndShapes(bool enable)
317-
{
318-
mIsMovingComponentsAndShapes = enable;
319-
}
320-
321-
bool GraphicsView::isMovingComponentsAndShapes()
322-
{
323-
return mIsMovingComponentsAndShapes;
324-
}
325-
326-
QAction* GraphicsView::getDeleteConnectionAction()
327-
{
328-
return mpDeleteConnectionAction;
329-
}
330-
331-
QAction* GraphicsView::getDeleteAction()
332-
{
333-
return mpDeleteAction;
334-
}
335-
336-
QAction* GraphicsView::getDuplicateAction()
337-
{
338-
return mpDuplicateAction;
339-
}
340-
341-
QAction* GraphicsView::getRotateClockwiseAction()
342-
{
343-
return mpRotateClockwiseAction;
344-
}
345-
346-
QAction* GraphicsView::getRotateAntiClockwiseAction()
347-
{
348-
return mpRotateAntiClockwiseAction;
349-
}
350-
351-
QAction* GraphicsView::getFlipHorizontalAction()
352-
{
353-
return mpFlipHorizontalAction;
354-
}
355-
356-
QAction* GraphicsView::getFlipVerticalAction()
357-
{
358-
return mpFlipVerticalAction;
359-
}
360-
361255
bool GraphicsView::addComponent(QString className, QPointF position)
362256
{
363257
MainWindow *pMainWindow = mpModelWidget->getModelWidgetContainer()->getMainWindow();
@@ -1488,30 +1382,34 @@ void GraphicsView::dropEvent(QDropEvent *event)
14881382

14891383
void GraphicsView::drawBackground(QPainter *painter, const QRectF &rect)
14901384
{
1491-
if (mSkipBackground)
1385+
if (mSkipBackground || mpModelWidget->getLibraryTreeItem()->isSystemLibrary()) {
14921386
return;
1387+
}
14931388
// draw scene rectangle white background
14941389
painter->setPen(Qt::NoPen);
1390+
if (mViewType == StringHandler::Icon) {
1391+
painter->setBrush(QBrush(QColor(229, 244, 255), Qt::SolidPattern));
1392+
} else {
1393+
painter->setBrush(QBrush(QColor(242, 242, 242), Qt::SolidPattern));
1394+
}
1395+
painter->drawRect(rect);
14951396
painter->setBrush(QBrush(Qt::white, Qt::SolidPattern));
14961397
painter->drawRect(getExtentRectangle());
1497-
if (mpModelWidget->getModelWidgetContainer()->isShowGridLines())
1498-
{
1398+
if (mpModelWidget->getModelWidgetContainer()->isShowGridLines()) {
14991399
painter->setBrush(Qt::NoBrush);
15001400
painter->setPen(QColor(229, 229, 229));
15011401
/* Draw left half vertical lines */
15021402
int horizontalGridStep = mpCoOrdinateSystem->getHorizontalGridStep() * 10;
15031403
qreal xAxisStep = 0;
15041404
qreal yAxisStep = rect.y();
15051405
xAxisStep -= horizontalGridStep;
1506-
while (xAxisStep > rect.left())
1507-
{
1406+
while (xAxisStep > rect.left()) {
15081407
painter->drawLine(QPointF(xAxisStep, yAxisStep), QPointF(xAxisStep, rect.bottom()));
15091408
xAxisStep -= horizontalGridStep;
15101409
}
15111410
/* Draw right half vertical lines */
15121411
xAxisStep = 0;
1513-
while (xAxisStep < rect.right())
1514-
{
1412+
while (xAxisStep < rect.right()) {
15151413
painter->drawLine(QPointF(xAxisStep, yAxisStep), QPointF(xAxisStep, rect.bottom()));
15161414
xAxisStep += horizontalGridStep;
15171415
}
@@ -1520,15 +1418,13 @@ void GraphicsView::drawBackground(QPainter *painter, const QRectF &rect)
15201418
xAxisStep = rect.x();
15211419
yAxisStep = 0;
15221420
yAxisStep += verticalGridStep;
1523-
while (yAxisStep < rect.bottom())
1524-
{
1421+
while (yAxisStep < rect.bottom()) {
15251422
painter->drawLine(QPointF(xAxisStep, yAxisStep), QPointF(rect.right(), yAxisStep));
15261423
yAxisStep += verticalGridStep;
15271424
}
15281425
/* Draw right half horizontal lines */
15291426
yAxisStep = 0;
1530-
while (yAxisStep > rect.top())
1531-
{
1427+
while (yAxisStep > rect.top()) {
15321428
painter->drawLine(QPointF(xAxisStep, yAxisStep), QPointF(rect.right(), yAxisStep));
15331429
yAxisStep -= verticalGridStep;
15341430
}
@@ -2285,9 +2181,6 @@ void ModelWidget::loadModelWidget()
22852181
mpDiagramGraphicsView->removeAllComponents();
22862182
mpDiagramGraphicsView->removeAllConnections();
22872183
mpDiagramGraphicsView->scene()->clear();
2288-
if (mpLibraryTreeItem->getNameStructure().compare("Modelica.Electrical.Analog.Basic.Resistor") == 0) {
2289-
qDebug() << mpLibraryTreeItem->getNameStructure();
2290-
}
22912184
getModelInheritedClasses(mpLibraryTreeItem);
22922185
drawModelInheritedClasses();
22932186
getModelIconDiagramShapes();

OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -142,47 +142,47 @@ class GraphicsView : public QGraphicsView
142142
public:
143143
GraphicsView(StringHandler::ViewType viewType, ModelWidget *parent);
144144
bool mSkipBackground; /* Do not draw the background rectangle */
145-
StringHandler::ViewType getViewType();
146-
ModelWidget* getModelWidget();
147-
CoOrdinateSystem* getCoOrdinateSystem();
145+
StringHandler::ViewType getViewType() {return mViewType;}
146+
ModelWidget* getModelWidget() {return mpModelWidget;}
147+
CoOrdinateSystem* getCoOrdinateSystem() {return mpCoOrdinateSystem;}
148148
void setExtentRectangle(qreal x1, qreal y1, qreal x2, qreal y2);
149149
QRectF getExtentRectangle() {return mExtentRectangle;}
150-
void setIsCustomScale(bool enable);
151-
bool isCustomScale();
150+
void setIsCustomScale(bool enable) {mIsCustomScale = enable;}
151+
bool isCustomScale() {return mIsCustomScale;}
152152
void setAddClassAnnotationNeeded(bool needed) {mAddClassAnnotationNeeded = needed;}
153153
bool isAddClassAnnotationNeeded() {return mAddClassAnnotationNeeded;}
154154
void setIsCreatingConnection(bool enable);
155-
bool isCreatingConnection();
155+
bool isCreatingConnection() {return mIsCreatingConnection;}
156156
void setIsCreatingLineShape(bool enable);
157-
bool isCreatingLineShape();
157+
bool isCreatingLineShape() {return mIsCreatingLineShape;}
158158
void setIsCreatingPolygonShape(bool enable);
159-
bool isCreatingPolygonShape();
159+
bool isCreatingPolygonShape() {return mIsCreatingPolygonShape;}
160160
void setIsCreatingRectangleShape(bool enable);
161-
bool isCreatingRectangleShape();
161+
bool isCreatingRectangleShape() {return mIsCreatingRectangleShape;}
162162
void setIsCreatingEllipseShape(bool enable);
163-
bool isCreatingEllipseShape();
163+
bool isCreatingEllipseShape() {return mIsCreatingEllipseShape;}
164164
void setIsCreatingTextShape(bool enable);
165-
bool isCreatingTextShape();
165+
bool isCreatingTextShape() {return mIsCreatingTextShape;}
166166
void setIsCreatingBitmapShape(bool enable);
167-
bool isCreatingBitmapShape();
167+
bool isCreatingBitmapShape() {return mIsCreatingBitmapShape;}
168168
void setItemsFlags(bool enable);
169169
void updateUndoRedoActions(bool enable);
170-
void setIsMovingComponentsAndShapes(bool enable);
171-
bool isMovingComponentsAndShapes();
170+
void setIsMovingComponentsAndShapes(bool enable) {mIsMovingComponentsAndShapes = enable;}
171+
bool isMovingComponentsAndShapes() {return mIsMovingComponentsAndShapes;}
172172
void setRenderingLibraryPixmap(bool renderingLibraryPixmap) {mRenderingLibraryPixmap = renderingLibraryPixmap;}
173173
bool isRenderingLibraryPixmap() {return mRenderingLibraryPixmap;}
174174
QList<ShapeAnnotation*> getShapesList() {return mShapesList;}
175-
QAction* getDeleteConnectionAction();
176-
QAction* getDeleteAction();
177-
QAction* getDuplicateAction();
175+
QAction* getDeleteConnectionAction() {return mpDeleteConnectionAction;}
176+
QAction* getDeleteAction() {return mpDeleteAction;}
177+
QAction* getDuplicateAction() {return mpDuplicateAction;}
178178
QAction* getBringToFrontAction() {return mpBringToFrontAction;}
179179
QAction* getBringForwardAction() {return mpBringForwardAction;}
180180
QAction* getSendToBackAction() {return mpSendToBackAction;}
181181
QAction* getSendBackwardAction() {return mpSendBackwardAction;}
182-
QAction* getRotateClockwiseAction();
183-
QAction* getRotateAntiClockwiseAction();
184-
QAction* getFlipHorizontalAction();
185-
QAction* getFlipVerticalAction();
182+
QAction* getRotateClockwiseAction() {return mpRotateClockwiseAction;}
183+
QAction* getRotateAntiClockwiseAction() {return mpRotateAntiClockwiseAction;}
184+
QAction* getFlipHorizontalAction() {return mpFlipHorizontalAction;}
185+
QAction* getFlipVerticalAction() {return mpFlipVerticalAction;}
186186
bool addComponent(QString className, QPointF position);
187187
void addComponentToView(QString name, LibraryTreeItem *pLibraryTreeItem, QString transformationString, QPointF position,
188188
ComponentInfo *pComponentInfo, bool addObject = true, bool openingClass = false);

0 commit comments

Comments
 (0)