@@ -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-
152136void 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-
169143void 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-
185154void 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-
202166void 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-
219178void 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-
236190void 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-
253202void 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-
270214void 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-
287226void 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-
361255bool GraphicsView::addComponent (QString className, QPointF position)
362256{
363257 MainWindow *pMainWindow = mpModelWidget->getModelWidgetContainer ()->getMainWindow ();
@@ -1488,30 +1382,34 @@ void GraphicsView::dropEvent(QDropEvent *event)
14881382
14891383void 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 ();
0 commit comments