Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CellulutLO21
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LO21_Pin_Noir_Boucher_Bouri_Detree
CellulutLO21
Commits
e2f17afd
Commit
e2f17afd
authored
3 years ago
by
Yann Boucher
Browse files
Options
Downloads
Patches
Plain Diff
Support de la couleur pour les preview
parent
f537df3e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#79372
failed
3 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/structurelibraryview.hpp
+7
-1
7 additions, 1 deletion
include/structurelibraryview.hpp
src/interface.cpp
+1
-0
1 addition, 0 deletions
src/interface.cpp
src/structurelibraryview.cpp
+12
-5
12 additions, 5 deletions
src/structurelibraryview.cpp
with
20 additions
and
6 deletions
include/structurelibraryview.hpp
+
7
−
1
View file @
e2f17afd
...
@@ -16,6 +16,7 @@ Widget de la bibliothèque de structures.
...
@@ -16,6 +16,7 @@ Widget de la bibliothèque de structures.
#include
<QFileSystemWatcher>
#include
<QFileSystemWatcher>
#include
"structure.hpp"
#include
"structure.hpp"
#include
"alphabet.hpp"
namespace
Ui
{
namespace
Ui
{
class
StructureLibraryView
;
class
StructureLibraryView
;
...
@@ -32,6 +33,10 @@ public:
...
@@ -32,6 +33,10 @@ public:
explicit
StructureLibraryView
(
QWidget
*
parent
=
nullptr
);
explicit
StructureLibraryView
(
QWidget
*
parent
=
nullptr
);
~
StructureLibraryView
();
~
StructureLibraryView
();
//! \brief Spécifie l'alphabet à utiliser pour les couleurs de la preview
void
set_alphabet
(
const
Alphabet
&
alph
)
{
m_alph
=
alph
;
}
signals
:
signals
:
//! \brief Signal émis lorsqu'une structure de la bibliothèque est copiée.
//! \brief Signal émis lorsqu'une structure de la bibliothèque est copiée.
//! \param s La structure copiée.
//! \param s La structure copiée.
...
@@ -47,7 +52,7 @@ private:
...
@@ -47,7 +52,7 @@ private:
QTreeWidgetItem
*
add_directory_contents
(
const
QDir
&
dir
);
QTreeWidgetItem
*
add_directory_contents
(
const
QDir
&
dir
);
bool
try_load_structure
(
const
QString
&
filename
,
Structure
&
s
);
bool
try_load_structure
(
const
QString
&
filename
,
Structure
&
s
);
void
update_preview
(
const
Structure
&
s
);
void
update_preview
(
const
Structure
&
s
);
QImage
create_preview_image
(
const
Structure
&
s
,
QColor
background
);
QImage
create_preview_image
(
const
Structure
&
s
,
bool
transparent
);
void
create_drag
(
QTreeWidgetItem
*
item
,
int
column
);
void
create_drag
(
QTreeWidgetItem
*
item
,
int
column
);
private
slots
:
private
slots
:
...
@@ -58,6 +63,7 @@ private:
...
@@ -58,6 +63,7 @@ private:
Ui
::
StructureLibraryView
*
ui
;
Ui
::
StructureLibraryView
*
ui
;
QFileSystemWatcher
m_watcher
;
QFileSystemWatcher
m_watcher
;
unsigned
m_cell_pixel_size
;
unsigned
m_cell_pixel_size
;
Alphabet
m_alph
;
};
};
#endif // STRUCTURELIBRARYVIEW_HPP
#endif // STRUCTURELIBRARYVIEW_HPP
This diff is collapsed.
Click to expand it.
src/interface.cpp
+
1
−
0
View file @
e2f17afd
...
@@ -501,6 +501,7 @@ void MainWindow::load_from_image()
...
@@ -501,6 +501,7 @@ void MainWindow::load_from_image()
void
MainWindow
::
ui_update_alphabet
(
const
Alphabet
&
alpha
)
void
MainWindow
::
ui_update_alphabet
(
const
Alphabet
&
alpha
)
{
{
simulation
.
setAlphabet
(
alpha
);
simulation
.
setAlphabet
(
alpha
);
ui
->
struct_library
->
set_alphabet
(
alpha
);
ui
->
grid_view
->
set_alphabet
(
alpha
);
ui
->
grid_view
->
set_alphabet
(
alpha
);
ui
->
nbrStateComboBox
->
clear
();
ui
->
nbrStateComboBox
->
clear
();
for
(
unsigned
i
=
0
;
i
<
alpha
.
taille
();
++
i
)
for
(
unsigned
i
=
0
;
i
<
alpha
.
taille
();
++
i
)
...
...
This diff is collapsed.
Click to expand it.
src/structurelibraryview.cpp
+
12
−
5
View file @
e2f17afd
...
@@ -117,19 +117,26 @@ void StructureLibraryView::update_preview(const Structure &s)
...
@@ -117,19 +117,26 @@ void StructureLibraryView::update_preview(const Structure &s)
QPixmap
pix
;
QPixmap
pix
;
/** to check wether load ok */
/** to check wether load ok */
if
(
pix
.
convertFromImage
(
create_preview_image
(
s
,
Qt
::
whit
e
))){
if
(
pix
.
convertFromImage
(
create_preview_image
(
s
,
fals
e
))){
/** scale pixmap to fit in label'size and keep ratio of pixmap */
/** scale pixmap to fit in label'size and keep ratio of pixmap */
pix
=
pix
.
scaled
(
ui
->
preview
->
size
()
-
2
*
QSize
(
ui
->
preview
->
lineWidth
(),
ui
->
preview
->
lineWidth
()),
Qt
::
KeepAspectRatio
);
pix
=
pix
.
scaled
(
ui
->
preview
->
size
()
-
2
*
QSize
(
ui
->
preview
->
lineWidth
(),
ui
->
preview
->
lineWidth
()),
Qt
::
KeepAspectRatio
);
ui
->
preview
->
setPixmap
(
pix
);
ui
->
preview
->
setPixmap
(
pix
);
}
}
}
}
QImage
StructureLibraryView
::
create_preview_image
(
const
Structure
&
s
,
QColor
background
)
QImage
StructureLibraryView
::
create_preview_image
(
const
Structure
&
s
,
bool
transparent
)
{
{
stateColor
bg
=
m_alph
.
getState
(
0
).
getColor
();
QImage
img
(
s
.
width
(),
s
.
height
(),
QImage
::
Format_ARGB32
);
QImage
img
(
s
.
width
(),
s
.
height
(),
QImage
::
Format_ARGB32
);
img
.
fill
(
background
);
if
(
transparent
)
img
.
fill
(
Qt
::
transparent
);
else
img
.
fill
(
Qt
::
white
);
for
(
const
auto
&
cell
:
s
)
for
(
const
auto
&
cell
:
s
)
img
.
setPixelColor
(
cell
.
first
.
x
,
cell
.
first
.
y
,
QColor
(
Qt
::
black
));
{
stateColor
s_c
=
m_alph
.
getState
(
cell
.
second
%
m_alph
.
taille
()).
getColor
();
img
.
setPixelColor
(
cell
.
first
.
x
,
cell
.
first
.
y
,
QColor
(
s_c
.
getRed
(),
s_c
.
getGreen
(),
s_c
.
getBlue
()));
}
return
img
;
return
img
;
}
}
...
@@ -193,7 +200,7 @@ void StructureLibraryView::create_drag(QTreeWidgetItem *item, int column)
...
@@ -193,7 +200,7 @@ void StructureLibraryView::create_drag(QTreeWidgetItem *item, int column)
QString
filename
=
QFileInfo
(
item
->
data
(
0
,
Qt
::
UserRole
).
toString
()).
absoluteFilePath
();
QString
filename
=
QFileInfo
(
item
->
data
(
0
,
Qt
::
UserRole
).
toString
()).
absoluteFilePath
();
QPixmap
pix
;
QPixmap
pix
;
QImage
img
=
create_preview_image
(
s
,
Qt
::
transparent
);
QImage
img
=
create_preview_image
(
s
,
true
);
pix
.
convertFromImage
(
img
);
pix
.
convertFromImage
(
img
);
...
...
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