# -*- coding: iso-8859-1 -*-
#
#-------------------------------------------------------------------------------
#                    Code_Saturne version 1.3
#                    ------------------------
#
#
#     This file is part of the Code_Saturne User Interface, element of the
#     Code_Saturne CFD tool.
#
#     Copyright (C) 1998-2007 EDF S.A., France
#
#     contact: saturne-support@edf.fr
#
#     The Code_Saturne User Interface is free software; you can redistribute it
#     and/or modify it under the terms of the GNU General Public License
#     as published by the Free Software Foundation; either version 2 of
#     the License, or (at your option) any later version.
#
#     The Code_Saturne User Interface is distributed in the hope that it will be
#     useful, but WITHOUT ANY WARRANTY; without even the implied warranty
#     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
#
#     You should have received a copy of the GNU General Public License
#     along with the Code_Saturne Kernel; if not, write to the
#     Free Software Foundation, Inc.,
#     51 Franklin St, Fifth Floor,
#     Boston, MA  02110-1301  USA
#
#-------------------------------------------------------------------------------


"""
"""


#-------------------------------------------------------------------------------
# Library modules import
#-------------------------------------------------------------------------------


import Tix
from Tkconstants import *
import sys, unittest



#-------------------------------------------------------------------------------
# Application modules import
#-------------------------------------------------------------------------------

from Base.Common import *
import Base.Dialog as Dialog

class InitZoneModel :
    """
    Manage initialization zones
    """

    def __init__(self, case):
        """
        Constructor.
        """
        self.case                        = case
        self.node_thermophysical_models  = self.case.root().xmlGetNode('thermophysical_models')
        self.node_initialization         = self.node_thermophysical_models.xmlInitChildNode('initialization')
        self.zone_nodes                  = self.node_initialization.xmlGetNodeList('zone','name')

        
    def SetZone(self, num, name, cellColor):
        """
        Add to the XML doc the new values.
        """
        self.zone_nodes[num]['name'] = name
        if cellColor: self.zone_nodes[num].xmlSetTextNode(cellColor)

        
    def NewZone(self, name, cellColor):
        """
        Add to the XML doc the new values.
        """
        node = self.node_initialization.xmlInitChildNode('zone', name=name)
	node.xmlSetTextNode(cellColor)

        self.zone_nodes.append(node)

                
    def GetZone(self, num):
        """
        Get area Values.
        """
        name = self.zone_nodes[num]['name']
        cellColor = self.zone_nodes[num].getxmlTextNode()
        
        return name, cellColor


    def GetZones(self, areatype):
        """
        Get areas Values.
        """
        lname=[]
        lcellColor=[]

        for num in range(self.zone_nodes):
            name, cellColor = GetZone(num)
            lname.append(name)
            lcellColor.append(cellColor)

        return lname, lcellColor 


    def EraseZone(self, num):
        """
        Remove Zone.
        """
        node = self.zone_nodes.pop(num)
        node.xmlRemoveNode()

    


syntax highlighted by Code2HTML, v. 0.9.1