Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kumir2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kumir
kumir2
Commits
5a552228
Commit
5a552228
authored
Oct 08, 2020
by
Alexander A. Maly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaning warnings in Draw
parent
7d5e1cc2
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1482 additions
and
1515 deletions
+1482
-1515
src/actors/draw/drawmodule.cpp
src/actors/draw/drawmodule.cpp
+1222
-1256
src/actors/draw/drawmodule.h
src/actors/draw/drawmodule.h
+260
-259
No files found.
src/actors/draw/drawmodule.cpp
View file @
5a552228
This diff is collapsed.
Click to expand it.
src/actors/draw/drawmodule.h
View file @
5a552228
...
...
@@ -12,280 +12,281 @@ You should change it corresponding to functionality.
// Base class include
#include "drawmodulebase.h"
// Kumir includes
#include <kumir2-libs/extensionsystem/kplugin.h>
class
DrawNavigator
;
namespace
ActorDraw
{
class
DrawModule
;
class
DrawView
:
public
QGraphicsView
{
Q_OBJECT
public:
DrawView
(
QWidget
*
parent
=
0
)
:
QGraphicsView
(
parent
)
{
c_scale
=
1
;
pressed
=
false
;
press_pos
=
QPoint
();
firstResize
=
true
;
net
=
true
;
smallNetLabel
=
new
QLabel
(
this
);
smallNetLabel
->
hide
();
smallNetLabel
->
setText
(
trUtf8
(
"Слишком мелкая сетка"
));
};
void
setDraw
(
DrawModule
*
draw
,
QMutex
*
mutex
)
{
DRAW
=
draw
;
dr_mutex
=
mutex
;
};
double
zoom
()
const
{
return
c_scale
;
};
void
setZoom
(
double
zoom
);
void
setNet
();
//RESIZE NET
bool
isNet
()
const
{
return
net
;
// Qt includes
#if QT_VERSION >= 0x050000
#include <QtWidgets>
#else
#include <QtGui>
#endif
#include <QtCore>
}
void
forceRedraw
()
{
// horizontalScrollBar()->setValue(horizontalScrollBar()->value() +1);
// horizontalScrollBar()->setValue(horizontalScrollBar()->value()-1);
qDebug
()
<<
"ForceREDDR"
;
QGraphicsView
::
resetCachedContent
();
QGraphicsView
::
update
();
QGraphicsView
::
repaint
();
class
DrawNavigator
;
namespace
ActorDraw
{
class
DrawModule
;
// verticalScrollBar()->setValue(horizontalScrollBar()->value() +1);
// verticalScrollBar()->setValue(horizontalScrollBar()->value()-1);
}
class
DrawView
:
public
QGraphicsView
{
Q_OBJECT
public:
DrawView
(
QWidget
*
parent
=
0
)
:
QGraphicsView
(
parent
){
c_scale
=
1
;
pressed
=
false
;
press_pos
=
QPoint
();
firstResize
=
true
;
net
=
true
;
smallNetLabel
=
new
QLabel
(
this
);
smallNetLabel
->
hide
();
smallNetLabel
->
setText
(
trUtf8
(
"Слишком мелкая сетка"
));};
void
setDraw
(
DrawModule
*
draw
,
QMutex
*
mutex
){
DRAW
=
draw
;
dr_mutex
=
mutex
;};
double
zoom
()
const
{
return
c_scale
;};
void
setZoom
(
double
zoom
);
void
setNet
();
//RESIZE NET
bool
isNet
()
const
{
return
net
;
}
void
forceRedraw
()
{
// horizontalScrollBar()->setValue(horizontalScrollBar()->value() +1);
// horizontalScrollBar()->setValue(horizontalScrollBar()->value()-1);
qDebug
()
<<
"ForceREDDR"
;
QGraphicsView
::
resetCachedContent
();
QGraphicsView
::
update
();
QGraphicsView
::
repaint
();
// verticalScrollBar()->setValue(horizontalScrollBar()->value() +1);
// verticalScrollBar()->setValue(horizontalScrollBar()->value()-1);
}
protected:
// void scrollContentsBy ( int dx, int dy );
void
resizeEvent
(
QResizeEvent
*
event
);
void
wheelEvent
(
QWheelEvent
*
event
);
void
mousePressEvent
(
QMouseEvent
*
event
);
void
mouseReleaseEvent
(
QMouseEvent
*
event
);
void
mouseMoveEvent
(
QMouseEvent
*
event
);
// void paintEvent(QPaintEvent *event);
protected:
// void scrollContentsBy ( int dx, int dy );
void
resizeEvent
(
QResizeEvent
*
event
);
void
wheelEvent
(
QWheelEvent
*
event
);
void
mousePressEvent
(
QMouseEvent
*
event
);
void
mouseReleaseEvent
(
QMouseEvent
*
event
);
void
mouseMoveEvent
(
QMouseEvent
*
event
);
// void paintEvent(QPaintEvent *event);
private:
DrawModule
*
DRAW
;
double
c_scale
;
bool
pressed
;
bool
net
;
QPoint
press_pos
;
bool
firstResize
;
double
lastStep
;
QMutex
*
dr_mutex
;
QLabel
*
smallNetLabel
;
};
private:
DrawModule
*
DRAW
;
double
c_scale
;
bool
pressed
;
bool
net
;
QPoint
press_pos
;
bool
firstResize
;
double
lastStep
;
QMutex
*
dr_mutex
;
QLabel
*
smallNetLabel
;
};
class
DrawScene
:
public
QGraphicsScene
{
Q_OBJECT
public:
DrawScene
(
QObject
*
parent
=
0
)
:
QGraphicsScene
(
parent
){
/// installEventFilter(this);
};
void
drawNet
(
double
startx
,
double
endx
,
double
starty
,
double
endy
,
QColor
color
,
const
double
step
,
const
double
stepY
,
bool
net
,
qreal
nw
,
qreal
aw
);
void
setDraw
(
DrawModule
*
draw
,
QMutex
*
mutex
){
DRAW
=
draw
;
dr_mutex
=
mutex
;};
void
addDrawLine
(
QLineF
lineF
,
QColor
color
,
qreal
width
);
void
reset
()
{
for
(
int
i
=
0
;
i
<
lines
.
count
();
i
++
)
removeItem
(
lines
.
at
(
i
));
lines
.
clear
();
for
(
int
i
=
0
;
i
<
texts
.
count
();
i
++
)
removeItem
(
texts
.
at
(
i
));
texts
.
clear
();
clearBuffer
();
}
void
upd
()
{
QGraphicsScene
::
update
();
}
void
DestroyNet
();
void
drawOnlyAxis
(
double
startx
,
double
endx
,
double
starty
,
double
endy
,
qreal
aw
);
bool
isLineAt
(
const
QPointF
&
pos
,
qreal
radius
);
qreal
drawText
(
const
QString
&
Text
,
qreal
widthChar
,
QPointF
from
,
QColor
color
);
//Returns offset of pen.
QRectF
getRect
();
int
saveToFile
(
const
QString
&
p_FileName
);
int
loadFromFile
(
const
QString
&
p_FileName
);
void
fromBufferToScene
()
{
QGraphicsItemGroup
*
buff
=
createItemGroup
(
itemsBuffer
);
buff
->
setZValue
(
90
);
addItem
(
buff
);
clearBuffer
();
}
void
clearBuffer
()
{
itemsBuffer
.
clear
();
}
int
buffSize
()
{
return
itemsBuffer
.
count
();
}
protected:
// void resizeEvent ( QResizeEvent * event );
// bool eventFilter(QObject *object, QEvent *event);
// bool event(QEvent * event);
private:
bool
isUserLine
(
QGraphicsItem
*
);
//Return true if item is user item;
QList
<
QGraphicsLineItem
*>
lines
;
QList
<
QGraphicsLineItem
*>
Netlines
;
QList
<
QGraphicsLineItem
*>
linesDubl
;
//Базовый чертеж
QList
<
QGraphicsSimpleTextItem
*>
texts
;
DrawModule
*
DRAW
;
QList
<
QGraphicsItem
*>
itemsBuffer
;
QMutex
*
dr_mutex
;
};
class
DrawModule
:
public
DrawModuleBase
class
DrawScene
:
public
QGraphicsScene
{
Q_OBJECT
Q_OBJECT
public:
DrawScene
(
QObject
*
parent
=
0
)
:
QGraphicsScene
(
parent
)
{
/// installEventFilter(this);
};
void
drawNet
(
double
startx
,
double
endx
,
double
starty
,
double
endy
,
QColor
color
,
const
double
step
,
const
double
stepY
,
bool
net
,
qreal
nw
,
qreal
aw
);
void
setDraw
(
DrawModule
*
draw
,
QMutex
*
mutex
)
{
DRAW
=
draw
;
dr_mutex
=
mutex
;
};
void
addDrawLine
(
QLineF
lineF
,
QColor
color
,
qreal
width
);
void
reset
()
{
for
(
int
i
=
0
;
i
<
lines
.
count
();
i
++
)
{
removeItem
(
lines
.
at
(
i
));
}
lines
.
clear
();
for
(
int
i
=
0
;
i
<
texts
.
count
();
i
++
)
{
removeItem
(
texts
.
at
(
i
));
}
texts
.
clear
();
clearBuffer
();
}
void
upd
()
{
QGraphicsScene
::
update
();
}
void
DestroyNet
();
void
drawOnlyAxis
(
double
startx
,
double
endx
,
double
starty
,
double
endy
,
qreal
aw
);
bool
isLineAt
(
const
QPointF
&
pos
,
qreal
radius
);
qreal
drawText
(
const
QString
&
Text
,
qreal
widthChar
,
QPointF
from
,
QColor
color
);
//Returns offset of pen.
QRectF
getRect
();
int
saveToFile
(
const
QString
&
p_FileName
);
int
loadFromFile
(
const
QString
&
p_FileName
);
void
fromBufferToScene
()
{
QGraphicsItemGroup
*
buff
=
createItemGroup
(
itemsBuffer
);
buff
->
setZValue
(
90
);
addItem
(
buff
);
clearBuffer
();
}
void
clearBuffer
()
{
itemsBuffer
.
clear
();
}
int
buffSize
()
{
return
itemsBuffer
.
count
();
}
protected:
// void resizeEvent ( QResizeEvent * event );
// bool eventFilter(QObject *object, QEvent *event);
// bool event(QEvent * event);
private:
bool
isUserLine
(
QGraphicsItem
*
);
//Return true if item is user item;
QList
<
QGraphicsLineItem
*>
lines
;
QList
<
QGraphicsLineItem
*>
Netlines
;
QList
<
QGraphicsLineItem
*>
linesDubl
;
//Базовый чертеж
QList
<
QGraphicsSimpleTextItem
*>
texts
;
DrawModule
*
DRAW
;
QList
<
QGraphicsItem
*>
itemsBuffer
;
QMutex
*
dr_mutex
;
};
class
DrawModule
:
public
DrawModuleBase
{
Q_OBJECT
public
/* methods */
:
DrawModule
(
ExtensionSystem
::
KPlugin
*
parent
);
inline
void
terminateEvaluation
()
{}
static
QList
<
ExtensionSystem
::
CommandLineParameter
>
acceptableCommandLineParameters
();
QWidget
*
mainWidget
()
const
;
QWidget
*
pultWidget
()
const
;
void
handleGuiReady
();
DrawModule
(
ExtensionSystem
::
KPlugin
*
parent
);
inline
void
terminateEvaluation
()
{}
static
QList
<
ExtensionSystem
::
CommandLineParameter
>
acceptableCommandLineParameters
();
QWidget
*
mainWidget
()
const
;
QWidget
*
pultWidget
()
const
;
void
handleGuiReady
();
bool
isAutoNet
()
const
{
return
autoNet
;
}
void
setAutoNet
(
bool
state
)
{
autoNet
=
state
;
}
double
NetStepX
()
const
{
return
netStepX
;
}
void
setNetStepX
(
double
step
)
{
netStepX
=
step
;
}
double
NetStepY
()
const
{
return
netStepY
;
}
void
setNetStepY
(
double
step
)
{
netStepY
=
step
;
}
double
zoom
()
{
return
CurView
->
zoom
();
}
QGraphicsPolygonItem
*
Pen
()
const
{
return
mPen
;
}
void
scalePen
(
double
factor
)
{
mutex
.
lock
();
mPen
->
setScale
(
factor
);
qDebug
()
<<
"PenScale"
<<
factor
<<
"mPen->scale"
<<
mPen
->
scale
();
mutex
.
unlock
();
}
DrawView
*
getCurView
()
const
{
return
CurView
;
}
static
ExtensionSystem
::
SettingsPtr
DrawSettings
();
QColor
axisColor
()
const
{
return
QColor
(
DrawSettings
()
->
value
(
"AxisColor"
,
"#999900"
).
toString
());
}
void
redrawPicture
()
{
// CurScene->resetCashedContent();
CurScene
->
upd
();
CurView
->
setViewportUpdateMode
(
QGraphicsView
::
FullViewportUpdate
);
CurView
->
forceRedraw
();
CurScene
->
update
(
CurScene
->
sceneRect
());
bool
isAutoNet
()
const
{
return
autoNet
;
}
void
setAutoNet
(
bool
state
)
{
autoNet
=
state
;
}
double
NetStepX
()
const
{
return
netStepX
;
}
void
setNetStepX
(
double
step
)
{
netStepX
=
step
;
}
double
NetStepY
()
const
{
return
netStepY
;
}
void
setNetStepY
(
double
step
)
{
netStepY
=
step
;
}
double
zoom
()
{
return
CurView
->
zoom
();
}
QGraphicsPolygonItem
*
Pen
()
const
{
return
mPen
;
}
void
scalePen
(
double
factor
)
{
mutex
.
lock
();
mPen
->
setScale
(
factor
);
qDebug
()
<<
"PenScale"
<<
factor
<<
"mPen->scale"
<<
mPen
->
scale
();
mutex
.
unlock
();
}
DrawView
*
getCurView
()
const
{
return
CurView
;
}
static
ExtensionSystem
::
SettingsPtr
DrawSettings
();
QColor
axisColor
()
const
{
return
QColor
(
DrawSettings
()
->
value
(
"AxisColor"
,
"#999900"
).
toString
());
}
void
redrawPicture
()
{
// CurScene->resetCashedContent();
CurScene
->
upd
();
CurView
->
setViewportUpdateMode
(
QGraphicsView
::
FullViewportUpdate
);
CurView
->
forceRedraw
();
CurScene
->
update
(
CurScene
->
sceneRect
());
CurView
->
viewport
()
->
update
();
CurView
->
setZoom
(
CurView
->
zoom
()
*
2
);
CurView
->
setZoom
(
CurView
->
zoom
()
*
0.5
);
// CurView->setViewportUpdateMode (QGraphicsView::NoViewportUpdate);
}
QString
initialize
(
const
QStringList
&
configurationParameters
,
const
ExtensionSystem
::
CommandLine
&
runtimeParameters
);
QMutex
mutex
;
CurView
->
viewport
()
->
update
();
CurView
->
setZoom
(
CurView
->
zoom
()
*
2
);
CurView
->
setZoom
(
CurView
->
zoom
()
*
0.5
);
// CurView->setViewportUpdateMode (QGraphicsView::NoViewportUpdate);
}
QString
initialize
(
const
QStringList
&
configurationParameters
,
const
ExtensionSystem
::
CommandLine
&
runtimeParameters
);
QMutex
mutex
;
public
slots
:
void
changeGlobalState
(
ExtensionSystem
::
GlobalState
old
,
ExtensionSystem
::
GlobalState
current
);
void
loadActorData
(
QIODevice
*
source
);
void
reloadSettings
(
ExtensionSystem
::
SettingsPtr
settings
,
const
QStringList
&
keys
);
void
reset
();
void
setAnimationEnabled
(
bool
enabled
);
void
runSetupPen
();
void
runReleasePen
();
void
runSetPenColor
(
const
Color
&
color
);
void
runMoveTo
(
const
qreal
x
,
const
qreal
y
);
void
runMoveBy
(
const
qreal
dX
,
const
qreal
dY
);
void
runAddCaption
(
const
qreal
width
,
const
QString
&
text
);
bool
runIsLineAtCircle
(
const
qreal
x
,
const
qreal
y
,
const
qreal
radius
);
void
zoomFullDraw
();
void
drawNet
();
void
autoNetChange
(
bool
value
);
void
netStepChange
(
double
value
);
void
zoomIn
();
void
zoomOut
();
void
zoomNorm
();
void
showNavigator
(
bool
state
);
void
openFile
();
void
saveFile
();
void
redraw
();
void
updateDraw
();
void
changeGlobalState
(
ExtensionSystem
::
GlobalState
old
,
ExtensionSystem
::
GlobalState
current
);
void
loadActorData
(
QIODevice
*
source
);
void
reloadSettings
(
ExtensionSystem
::
SettingsPtr
settings
,
const
QStringList
&
keys
);
void
reset
();
void
setAnimationEnabled
(
bool
enabled
);
void
runSetupPen
();
void
runReleasePen
();
void
runSetPenColor
(
const
Color
&
color
);
void
runMoveTo
(
const
qreal
x
,
const
qreal
y
);
void
runMoveBy
(
const
qreal
dX
,
const
qreal
dY
);
void
runAddCaption
(
const
qreal
width
,
const
QString
&
text
);
bool
runIsLineAtCircle
(
const
qreal
x
,
const
qreal
y
,
const
qreal
radius
);
void
zoomFullDraw
();
void
drawNet
();
void
autoNetChange
(
bool
value
);
void
netStepChange
(
double
value
);
void
zoomIn
();
void
zoomOut
();
void
zoomNorm
();
/* ========= CLASS PRIVATE ========= */
void
showNavigator
(
bool
state
);
void
openFile
();
void
saveFile
();
void
redraw
();
void
updateDraw
();
/* ========= CLASS PRIVATE ========= */
private:
void
createGui
();
void
CreatePen
(
void
);
DrawScene
*
CurScene
;
DrawView
*
CurView
;
QGraphicsPolygonItem
*
mPen
;
double
netStepX
,
netStepY
;
QColor
netColor
;
bool
autoNet
;
bool
penIsDrawing
;
bool
firstShow
;
Color
penColor
;
ExtensionSystem
::
GlobalState
currentState
;
DrawNavigator
*
navigator
;
QToolButton
*
showToolsBut
;
QDir
curDir
;
bool
animate
;
QTimer
*
redrawTimer
;
qreal
curAngle
;
qreal
AncX
,
AncY
;
QPointF
curPos
;
void
createGui
();
void
CreatePen
(
void
);
DrawScene
*
CurScene
;
DrawView
*
CurView
;
QGraphicsPolygonItem
*
mPen
;
double
netStepX
,
netStepY
;
QColor
netColor
;
bool
autoNet
;
bool
penIsDrawing
;
bool
firstShow
;
Color
penColor
;
ExtensionSystem
::
GlobalState
currentState
;
DrawNavigator
*
navigator
;
QToolButton
*
showToolsBut
;
QDir
curDir
;
bool
animate
;
QTimer
*
redrawTimer
;
qreal
curAngle
;
qreal
AncX
,
AncY
;
QPointF
curPos
;
};
}
// namespace ActorDraw
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment