OpenStructure
Loading...
Searching...
No Matches
build-2.11
stage
lib
python3.11
site-packages
ost
gui
scene
gradient_info_handler.py
Go to the documentation of this file.
1
#------------------------------------------------------------------------------
2
# This file is part of the OpenStructure project <www.openstructure.org>
3
#
4
# Copyright (C) 2008-2020 by the OpenStructure authors
5
#
6
# This library is free software; you can redistribute it and/or modify it under
7
# the terms of the GNU Lesser General Public License as published by the Free
8
# Software Foundation; either version 3.0 of the License, or (at your option)
9
# any later version.
10
# This library is distributed in the hope that it will be useful, but WITHOUT
11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13
# details.
14
#
15
# You should have received a copy of the GNU Lesser General Public License
16
# along with this library; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
#------------------------------------------------------------------------------
19
# -*- coding: utf-8 -*-
20
21
from
ost
import
gui
22
from
ost
import
gfx
23
from
ost
import
info
24
from
PyQt5
import
QtCore
25
from
.immutable_gradient_info_handler
import
ImmutableGradientInfoHandler
26
27
#Gradient Info Handler
28
class
GradientInfoHandler
(
ImmutableGradientInfoHandler
):
29
def
__init__
(self, fileName):
30
ImmutableGradientInfoHandler.__init__(self, fileName)
31
32
def
StoreQGradient
(self,gradient,name):
33
group = self.
gradients_
.CreateGroup(self.
GRADIENT_GROUP_NAME
)
34
group.SetAttribute(self.
NAME_ATTRIBUTE_NAME
NAME_ATTRIBUTE_NAME
, name)
35
gfx_gradient = self.
ConvertToGfxGradient
(gradient)
36
37
gfx_gradient.GradientToInfo(group)
38
self.
handle_
.Export(self.
FILE_NAME
FILE_NAME
)
39
40
def
RemoveGradient
(self, name):
41
group_list = self.
gradients_
.GetGroups(self.
GRADIENT_GROUP_NAME
)
42
for
group
in
group_list:
43
if
group.HasAttribute(self.
NAME_ATTRIBUTE_NAME
NAME_ATTRIBUTE_NAME
):
44
groupname = group.GetAttribute(self.
NAME_ATTRIBUTE_NAME
NAME_ATTRIBUTE_NAME
)
45
if
name == groupname:
46
groupToDel = group
47
break
48
49
if
groupToDel !=
None
:
50
self.
gradients_
.Remove(groupToDel)
51
self.
handle_
.Export(self.
FILE_NAME
FILE_NAME
)
52
53
def
RenameGradient
(self, old, new):
54
group_list = self.
gradients_
.GetGroups(self.
GRADIENT_GROUP_NAME
)
55
for
group
in
group_list:
56
if
group.HasAttribute(self.
NAME_ATTRIBUTE_NAME
NAME_ATTRIBUTE_NAME
):
57
groupname = group.GetAttribute(self.
NAME_ATTRIBUTE_NAME
NAME_ATTRIBUTE_NAME
)
58
if
old == groupname:
59
group.SetAttribute(self.
NAME_ATTRIBUTE_NAME
NAME_ATTRIBUTE_NAME
, new)
60
self.
handle_
.Export(self.
FILE_NAME
FILE_NAME
)
ost::gui.scene.gradient_info_handler.GradientInfoHandler
Definition
gradient_info_handler.py:28
ost::gui.scene.gradient_info_handler.GradientInfoHandler.RemoveGradient
RemoveGradient(self, name)
Definition
gradient_info_handler.py:40
ost::gui.scene.gradient_info_handler.GradientInfoHandler.__init__
__init__(self, fileName)
Definition
gradient_info_handler.py:29
ost::gui.scene.gradient_info_handler.GradientInfoHandler.FILE_NAME
FILE_NAME
Definition
gradient_info_handler.py:38
ost::gui.scene.gradient_info_handler.GradientInfoHandler.RenameGradient
RenameGradient(self, old, new)
Definition
gradient_info_handler.py:53
ost::gui.scene.gradient_info_handler.GradientInfoHandler.NAME_ATTRIBUTE_NAME
NAME_ATTRIBUTE_NAME
Definition
gradient_info_handler.py:34
ost::gui.scene.gradient_info_handler.GradientInfoHandler.StoreQGradient
StoreQGradient(self, gradient, name)
Definition
gradient_info_handler.py:32
ost::gui.scene.immutable_gradient_info_handler.ImmutableGradientInfoHandler
Definition
immutable_gradient_info_handler.py:27
ost::gui.scene.immutable_gradient_info_handler.ImmutableGradientInfoHandler.ConvertToGfxGradient
ConvertToGfxGradient(gradient)
Definition
immutable_gradient_info_handler.py:76
ost::gui.scene.immutable_gradient_info_handler.ImmutableGradientInfoHandler.handle_
handle_
Definition
immutable_gradient_info_handler.py:35
ost::gui.scene.immutable_gradient_info_handler.ImmutableGradientInfoHandler.FILE_NAME
FILE_NAME
Definition
immutable_gradient_info_handler.py:30
ost::gui.scene.immutable_gradient_info_handler.ImmutableGradientInfoHandler.gradients_
gradients_
Definition
immutable_gradient_info_handler.py:39
ost::gui.scene.immutable_gradient_info_handler.ImmutableGradientInfoHandler.NAME_ATTRIBUTE_NAME
NAME_ATTRIBUTE_NAME
Definition
immutable_gradient_info_handler.py:33
ost::gui.scene.immutable_gradient_info_handler.ImmutableGradientInfoHandler.GRADIENT_GROUP_NAME
GRADIENT_GROUP_NAME
Definition
immutable_gradient_info_handler.py:32
Generated by
1.9.8