Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
2fa2cc39
Commit
2fa2cc39
authored
3 years ago
by
Matthias Puchner
Browse files
Options
Downloads
Patches
Plain Diff
rm remainings from net oriented sample editor
parent
6cd25f39
No related branches found
No related tags found
1 merge request
!513
Refactor sample model
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/View/Tool/DesignerHelper.cpp
+0
-239
0 additions, 239 deletions
GUI/View/Tool/DesignerHelper.cpp
GUI/View/Tool/DesignerHelper.h
+0
-48
0 additions, 48 deletions
GUI/View/Tool/DesignerHelper.h
with
0 additions
and
287 deletions
GUI/View/Tool/DesignerHelper.cpp
+
0
−
239
View file @
2fa2cc39
...
@@ -14,245 +14,6 @@
...
@@ -14,245 +14,6 @@
#include
"GUI/View/Tool/DesignerHelper.h"
#include
"GUI/View/Tool/DesignerHelper.h"
#include
"GUI/View/Tool/StyleUtils.h"
#include
"GUI/View/Tool/StyleUtils.h"
#include
<QPainter>
#include
<cmath>
#include
<iostream>
namespace
{
double
m_current_zoom_level
=
1.0
;
}
QGradient
DesignerHelper
::
getLayerGradient
(
const
QColor
&
color
,
const
QRectF
&
rect
)
{
QColor
c
=
color
;
c
.
setAlpha
(
160
);
QLinearGradient
result
(
rect
.
topLeft
(),
rect
.
bottomRight
());
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
result
.
setColorAt
(
0
,
c
.
darker
(
150
));
result
.
setColorAt
(
0.5
,
c
.
lighter
(
200
));
result
.
setColorAt
(
1
,
c
.
darker
(
150
));
#else
result
.
setColorAt
(
0
,
c
.
dark
(
150
));
result
.
setColorAt
(
0.5
,
c
.
light
(
200
));
result
.
setColorAt
(
1
,
c
.
dark
(
150
));
#endif
return
result
;
}
QGradient
DesignerHelper
::
getDecorationGradient
(
const
QColor
&
color
,
const
QRectF
&
rect
)
{
const
QColor
&
c
=
color
;
// c.setAlpha(200);
QLinearGradient
result
(
rect
.
x
()
+
rect
.
width
()
/
2
,
rect
.
y
(),
rect
.
x
()
+
rect
.
width
()
/
2
,
rect
.
y
()
+
rect
.
height
());
result
.
setColorAt
(
0
,
c
);
result
.
setColorAt
(
0.5
,
c
.
lighter
(
150
));
result
.
setColorAt
(
1
,
c
);
return
result
;
}
QPixmap
DesignerHelper
::
getSceneBackground
()
{
const
int
size
=
10
;
QPixmap
result
(
size
,
size
);
result
.
fill
(
QColor
(
250
,
250
,
250
));
QPainter
tilePainter
(
&
result
);
QColor
color
(
220
,
220
,
220
);
tilePainter
.
fillRect
(
0.0
,
0.0
,
2
,
2
,
color
);
tilePainter
.
end
();
return
result
;
}
QPixmap
DesignerHelper
::
getPixmapLayer
()
{
QRect
rect
(
0
,
0
,
layerWidth
(),
layerHeight
());
QPixmap
pixmap
(
rect
.
width
()
+
1
,
rect
.
height
()
+
1
);
pixmap
.
fill
(
Qt
::
transparent
);
QPainter
painter
(
&
pixmap
);
painter
.
setPen
(
Qt
::
black
);
painter
.
setBrush
(
getLayerGradient
(
Qt
::
green
,
rect
));
painter
.
drawRect
(
rect
);
return
pixmap
;
}
QPixmap
DesignerHelper
::
getPixmapMultiLayer
()
{
auto
rect
=
getDefaultMultiLayerRect
();
QPixmap
pixmap
(
rect
.
width
()
+
1
,
rect
.
height
()
+
1
);
pixmap
.
fill
(
Qt
::
transparent
);
QPainter
painter
(
&
pixmap
);
painter
.
setPen
(
Qt
::
black
);
painter
.
setBrush
(
getLayerGradient
(
QColor
(
75
,
157
,
249
),
rect
));
painter
.
drawRect
(
rect
);
painter
.
setPen
(
Qt
::
DashLine
);
painter
.
drawLine
(
0
,
layerHeight
()
*
0.3
,
rect
.
width
(),
layerHeight
()
*
0.3
);
painter
.
drawLine
(
0
,
layerHeight
()
*
0.6
,
rect
.
width
(),
layerHeight
()
*
0.6
);
return
pixmap
;
}
QPixmap
DesignerHelper
::
getPixmapParticleLayout
()
{
auto
rect
=
getParticleLayoutBoundingRect
();
QPixmap
pixmap
(
rect
.
width
()
+
1
,
rect
.
height
()
+
1
);
pixmap
.
fill
(
Qt
::
transparent
);
QPainter
painter
(
&
pixmap
);
painter
.
setPen
(
Qt
::
black
);
painter
.
setBrush
(
getDecorationGradient
(
QColor
(
135
,
206
,
50
),
rect
));
painter
.
drawRoundedRect
(
rect
,
3
,
3
);
return
pixmap
;
}
QPixmap
DesignerHelper
::
getPixmapInterference
()
{
auto
rect
=
getInterferenceBoundingRect
();
QPixmap
pixmap
(
rect
.
width
()
+
1
,
rect
.
height
()
+
1
);
pixmap
.
fill
(
Qt
::
transparent
);
QPainter
painter
(
&
pixmap
);
painter
.
setPen
(
Qt
::
black
);
painter
.
setBrush
(
getDecorationGradient
(
Qt
::
lightGray
,
rect
));
painter
.
drawRoundedRect
(
rect
,
3
,
3
);
return
pixmap
;
}
QPixmap
DesignerHelper
::
getPixmapParticle
()
{
auto
rect
=
getParticleBoundingRect
();
QPixmap
pixmap
(
rect
.
width
()
+
1
,
rect
.
height
()
+
1
);
pixmap
.
fill
(
Qt
::
transparent
);
QPainter
painter
(
&
pixmap
);
painter
.
setPen
(
Qt
::
black
);
painter
.
setBrush
(
getDecorationGradient
(
getDefaultParticleColor
(),
rect
));
painter
.
drawRoundedRect
(
rect
,
5
,
5
);
return
pixmap
;
}
bool
DesignerHelper
::
sort_layers
(
QGraphicsItem
*
left
,
QGraphicsItem
*
right
)
{
return
left
->
y
()
<
right
->
y
();
}
// non-linear conversion of layer's thickness in nanometers to screen size to have reasonable
// graphics representation
int
DesignerHelper
::
nanometerToScreen
(
double
nanometer
)
{
const
int
ymin
(
layerHeight
());
const
int
ymax
(
500
);
int
result
(
ymin
);
if
(
nanometer
>
0
)
result
=
qBound
(
ymin
,
ymin
+
(
int
)
std
::
pow
(
nanometer
,
0.9
),
ymax
);
return
result
;
}
QRectF
DesignerHelper
::
getDefaultBoundingRect
(
const
QString
&
name
)
{
if
(
name
==
"MultiLayer"
)
return
getDefaultMultiLayerRect
();
if
(
name
==
"Layer"
)
return
QRectF
(
0
,
0
,
layerWidth
(),
layerHeight
());
if
(
name
==
"ParticleLayout"
)
return
getParticleLayoutBoundingRect
();
if
(
name
==
"Rotation"
)
return
getTransformationBoundingRect
();
if
(
name
.
startsWith
(
"FormFactor"
)
||
name
==
"Particle"
||
name
==
"ParticleCoreShell"
)
return
getParticleBoundingRect
();
if
(
name
.
startsWith
(
"Interference"
))
return
getInterferenceBoundingRect
();
return
QRectF
(
0
,
0
,
50
,
50
);
}
QColor
DesignerHelper
::
getDefaultColor
(
const
QString
&
name
)
{
if
(
name
==
"MultiLayer"
)
// return QColor(Qt::blue);
return
QColor
(
51
,
116
,
255
);
if
(
name
==
"Layer"
)
// return QColor(Qt::green);
return
QColor
(
26
,
156
,
9
);
if
(
name
==
"ParticleLayout"
)
return
QColor
(
135
,
206
,
50
);
if
(
name
.
startsWith
(
"FormFactor"
)
||
name
==
"Particle"
||
name
==
"ParticleCoreShell"
)
return
QColor
(
210
,
223
,
237
);
if
(
name
.
startsWith
(
"Interference"
))
return
QColor
(
255
,
236
,
139
);
if
(
name
==
"Transparant red"
)
return
QColor
(
0xFF
,
0
,
0
,
0x80
);
if
(
name
==
"Transparant blue"
)
return
QColor
(
0
,
0
,
0xFF
,
0x80
);
return
QColor
(
Qt
::
lightGray
);
}
QPixmap
DesignerHelper
::
getMimePixmap
(
const
QString
&
name
)
{
QRectF
default_rect
=
getDefaultBoundingRect
(
name
);
QRectF
mime_rect
(
0
,
0
,
default_rect
.
width
()
*
m_current_zoom_level
,
default_rect
.
height
()
*
m_current_zoom_level
);
QPixmap
pixmap
(
mime_rect
.
width
()
+
1
,
mime_rect
.
height
()
+
1
);
pixmap
.
fill
(
Qt
::
transparent
);
QPainter
painter
(
&
pixmap
);
painter
.
setPen
(
Qt
::
black
);
painter
.
setBrush
(
getDecorationGradient
(
getDefaultColor
(
name
),
mime_rect
));
painter
.
drawRoundedRect
(
mime_rect
,
1
,
1
);
return
pixmap
;
}
int
DesignerHelper
::
getHeaderFontSize
()
{
return
GUI
::
Util
::
Style
::
SystemPointSize
()
*
1.5
;
}
int
DesignerHelper
::
layerWidth
()
{
return
GUI
::
Util
::
Style
::
SizeOfLetterM
().
width
()
*
18
;
}
int
DesignerHelper
::
layerHeight
()
{
return
GUI
::
Util
::
Style
::
SizeOfLetterM
().
height
()
*
2
;
}
QColor
DesignerHelper
::
getDefaultLayerColor
()
{
return
QColor
(
Qt
::
lightGray
);
}
QRectF
DesignerHelper
::
getDefaultMultiLayerRect
()
{
return
QRectF
(
0
,
0
,
layerWidth
()
*
1.15
,
layerHeight
());
}
QRectF
DesignerHelper
::
getParticleLayoutBoundingRect
()
{
return
QRectF
(
0
,
0
,
layerHeight
()
*
3.5
,
layerHeight
()
*
4.5
);
}
QRectF
DesignerHelper
::
getInterferenceBoundingRect
()
{
return
QRectF
(
0
,
0
,
layerHeight
()
*
4.5
,
layerHeight
()
*
4
);
}
QColor
DesignerHelper
::
getDefaultParticleColor
()
{
return
QColor
(
210
,
223
,
237
);
}
QRectF
DesignerHelper
::
getParticleBoundingRect
()
{
return
QRectF
(
0
,
0
,
layerHeight
()
*
3.5
,
layerHeight
()
*
4
);
}
QColor
DesignerHelper
::
getDefaultTransformationColor
()
{
return
QColor
(
145
,
50
,
220
);
}
QRectF
DesignerHelper
::
getTransformationBoundingRect
()
{
return
QRectF
(
0
,
0
,
layerHeight
()
*
4
,
layerHeight
()
*
2
);
}
int
DesignerHelper
::
getSectionFontSize
()
int
DesignerHelper
::
getSectionFontSize
()
{
{
...
...
This diff is collapsed.
Click to expand it.
GUI/View/Tool/DesignerHelper.h
+
0
−
48
View file @
2fa2cc39
...
@@ -15,58 +15,10 @@
...
@@ -15,58 +15,10 @@
#ifndef BORNAGAIN_GUI_VIEW_TOOL_DESIGNERHELPER_H
#ifndef BORNAGAIN_GUI_VIEW_TOOL_DESIGNERHELPER_H
#define BORNAGAIN_GUI_VIEW_TOOL_DESIGNERHELPER_H
#define BORNAGAIN_GUI_VIEW_TOOL_DESIGNERHELPER_H
#include
<QColor>
#include
<QGradient>
#include
<QGraphicsItem>
#include
<QRect>
//! collection of static methods with SampleDesigner geometry settings
//! collection of static methods with SampleDesigner geometry settings
class
DesignerHelper
{
class
DesignerHelper
{
public:
public:
static
int
layerWidth
();
static
int
layerHeight
();
static
QColor
getDefaultLayerColor
();
static
QRectF
getDefaultMultiLayerRect
();
static
QRectF
getParticleLayoutBoundingRect
();
static
QRectF
getInterferenceBoundingRect
();
static
QColor
getDefaultParticleColor
();
static
QRectF
getParticleBoundingRect
();
static
QColor
getDefaultTransformationColor
();
static
QRectF
getTransformationBoundingRect
();
static
QGradient
getLayerGradient
(
const
QColor
&
color
,
const
QRectF
&
rect
);
static
QGradient
getDecorationGradient
(
const
QColor
&
color
,
const
QRectF
&
rect
);
static
QPixmap
getSceneBackground
();
static
QPixmap
getPixmapLayer
();
static
QPixmap
getPixmapMultiLayer
();
static
QPixmap
getPixmapParticleLayout
();
static
QPixmap
getPixmapInterference
();
static
QPixmap
getPixmapParticle
();
//! sort graphics item according they y-coordinate
static
bool
sort_layers
(
QGraphicsItem
*
left
,
QGraphicsItem
*
right
);
//! non-linear conversion of layer's thickness in nanometers to screen size
//! to have reasonable graphics representation of layer in the form of QRect
static
int
nanometerToScreen
(
double
nanometer
);
//! returns default bounding rectangle for given IvView name
static
QRectF
getDefaultBoundingRect
(
const
QString
&
name
);
//! returns default color for IView with given name
static
QColor
getDefaultColor
(
const
QString
&
name
);
//! returns Mime pixmap for givew IView name
static
QPixmap
getMimePixmap
(
const
QString
&
name
);
//! returns system dependent font size
//! returns system dependent font size
static
int
getHeaderFontSize
();
static
int
getSectionFontSize
();
static
int
getSectionFontSize
();
static
int
getLabelFontSize
();
static
int
getLabelFontSize
();
static
int
getPortFontSize
();
static
int
getPortFontSize
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment