#######################################################################
#
# $Id: consts.py,v 1.11 2008-04-07 05:09:35 lorenz Exp $
# 
# Copyright (C) 2004-2008 Petr Lorenz
# All rights reserved.
# 
# ##### BEGIN LICENSE BLOCK #####
#
# Version: MPL 1.1 / GPL 2.0 / LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
# 
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
# 
# The Original Code is Petr Lorenz emGine Graphical User Interface (GUI).
# 
# The Initial Developer of the Original Code is Petr Lorenz.
# Portions created by the Initial Developer are Copyright (C) 2004-2008.
# All Rights Reserved.
# 
# Contributor(s): Bruno Biscontini, Rachid Khlifi.
# 
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the  "GPL"), or the
# GNU Lesser General Public License Version 2.1 or later (the "LGPL"), in which
# case the provisions of the GPL or the LGPL are applicable instead of those
# above.  If you wish to allow use of your version of this file only under the
# terms of either the GPL or the LGPL and not to allow others to use your
# version of this file under the MPL, indicate your decision by deleting the
# provisions above and replace them with the notice and other provisions
# required by the GPL or LGPL.  If you do not delete the provisions above, a
# recipient may use your version of this file under the terms of any one of the
# MPL License, the GPL or the LGPL.
#
# ##### END LICENSE BLOCK #####
#
#######################################################################
# 
# $Log: consts.py,v $
# Revision 1.11  2008-04-07 05:09:35  lorenz
# Smith diagram integration.
#
# Revision 1.10  2008-03-28 06:25:37  lorenz
# - Perspective/Orthogonal view
# - Top/Bottom/Front/Back/Left/Right views
# - Boundary conditions setup
# - Platform Info
#
# Revision 1.9  2008-02-28 05:05:01  lorenz
# Zero rounding for too small distances in dl calculation.
#
# Revision 1.8  2008-02-14 05:59:26  lorenz
# Simulation thread improvements - lock, better IPC, termination.
#
# Revision 1.7  2008-02-13 15:28:27  lorenz
# Windows simulation termination implemented.
#
# Revision 1.6  2008-02-08 05:04:57  lorenz
# Unix support for terminating a simulation.
#
# Revision 1.5  2008-02-07 05:45:25  lorenz
# * Fixed 'Simulation Boundary View' check problem
#   when closing a project.
#
# * Fixed Bounding Box problems when moving/editing a geometry.
#
# Revision 1.4  2008-02-03 16:34:34  lorenz
# Version information update.
#
# Revision 1.3  2008-01-30 05:29:04  lorenz
# Application Icon added
#
# Revision 1.2  2008-01-28 16:15:15  lorenz
# Windows related changes (e.g., refreshing).
#
# Revision 1.1.1.1  2008-01-28 06:15:35  lorenz
# Import emGine GUI v. 0.7.1
#
# Revision 1.6  2007-07-02 06:37:18  lorenz
# Clean up of old code.
#
# Revision 1.5  2007-06-28 05:34:28  lorenz
# Checkbutton in 'View->Simulation Boundary' added.
#
# Preliminary support for polygons added.
#
# Revision 1.4  2007-06-18 03:55:36  lorenz
# Status bar extended
#
# Revision 1.3  2007-05-18 16:37:01  lorenz
# Work on 'surrounding space' simbox and
#  'emgine_gui' tag
#
# Revision 1.2  2007-05-14 04:53:51  lorenz
# New code for multiport time-domain signals and S-parameters
#
# Revision 1.1.1.1  2007-05-08 06:22:35  lorenz
# Initial Import
#
#######################################################################

#--------------------------------------------------
# general information
#--------------------------------------------------
REVISION = "$Revision: 1.11 $"
LAST_UPDATE = "01.04.2008"
VERSION = "0.7.4" + " - " + LAST_UPDATE


#--------------------------------------------------
# The Main Window Status
#--------------------------------------------------
MW_TITLE = "%s %s" %("emGine GUI, v", VERSION)

#--------------------------------------------------
# Simulation related constants
#--------------------------------------------------
EMGINE_DEEMBEDDING_CELLS = 20
EMGINE_LARGE_NUMBER_OF_CELLS = 10e6

EMGINE_SIMULATION_RUNNING = 150

EMGINE_SIMULATION_FINISHED = 200
EMGINE_SIMULATION_FINISHED_OK = 201
EMGINE_SIMULATION_FINISHED_ERROR = 202
EMGINE_SIMULATION_EXIT_THREAD = 210

EMGINE_SIMULATION_TERMINATE = 300

#--------------------------------------------------
# Default material if no material chosen
#--------------------------------------------------
EMGINE_MATERIAL_FREE_SPACE = 'Air'
EMGINE_MATERIAL_PEC = 'PEC'
EMGINE_MATERIAL_PMC = 'PMC'
EMGINE_DEFAULT_MATERIAL = EMGINE_MATERIAL_FREE_SPACE

#--------------------------------------------------
# Rounding errors related constants
#--------------------------------------------------
EMGINE_ROUND_ZERO_MESH_THRESHOLD = 1e-10

#--------------------------------------------------
# STATEs of the program
#--------------------------------------------------
STATE_NONE = 0

STATE_INITIALIZED = 1

STATE_PROJECT_CHANGED = 10
#STATE_PROJECT_NEW = 2
#STATE_PROJECT_OPENED = 3
#STATE_PROJECT_CLOSED = 4
#STATE_PROJECT_SAVED = 5
#STATE_PROJECT_MODIFIED = 6

STATE_TREE_CLICKED_PROJECT = 100
STATE_TREE_CLICKED_FOLDER = 105
STATE_TREE_CLICKED_SFOLDER = 110
STATE_TREE_CLICKED_SIMULATION = 115
STATE_TREE_CLICKED_FILE = 120

STATE_TREE_CLICKED_GEOMETRY = 200
STATE_TREE_CLICKED_GEOMETRY_NODE = 201

STATE_TREE_CLICKED_EXCITATION = 300
STATE_TREE_CLICKED_EXCITATION_NODE = 301

STATE_TREE_CLICKED_MATERIAL = 400

STATE_TREE_CLICKED_RESULTS = 500
STATE_TREE_CLICKED_RESULTS2D = 510
STATE_TREE_CLICKED_PLOT_SMITH = 511
STATE_TREE_CLICKED_RESULTS2D_ALL_TDSIGNALS = 515
STATE_TREE_CLICKED_RESULTS2D_ALL_SPARAMETERS = 516
STATE_TREE_CLICKED_PLOT_ALL_SMITH = 517

#--------------------------------------------------
# MISC
#--------------------------------------------------
GUI_XML_NODE = "GUI__xml_node"

#--------------------------------------------------
# PROJECT STATUS
#--------------------------------------------------
PRJ_STATE_INITIALIZED = 1
PRJ_STATE_OPENED = 2
PRJ_STATE_NEW = 3
PRJ_STATE_CLOSED = 4
PRJ_STATE_SAVED = 5
PRJ_STATE_MODIFIED = 6

PRJ_DEFAULT_FNAME = "Noname.emm"
PRJ_TLMGUI_VERSION = "0.1"

PRJ_TAG_PROJECT = "project"
PRJ_TAG_FOLDER = "folder"
PRJ_TAG_SFOLDER = "sfolder"
PRJ_TAG_SIMULATION = "simulation"
PRJ_TAG_FILE = "file"

#--------------------------------------------------
# XML Tags
#--------------------------------------------------

# emGine specific
XML_TAG_EMGINE_GUI = "emgine_gui"
XML_TAG_SURROUNDING_SPACE = "surrounding_space"

#
XML_TAG_PROJECT = "project"

XML_TAG_MATERIALS = "materials"
XML_TAG_MATERIAL = "material"
XML_TAG_EPSR = "eps_r"
XML_TAG_MUR = "mu_r"
XML_TAG_CONDUCTIVITY = "conductivity"
XML_TAG_TAND = "tand"

XML_TAG_GEOMETRY = "geometry"
XML_TAG_EXCITATION = "excitation"

# Boundaries
XML_TAG_BOUNDARIES = "boundaries"
XML_TAG_BOUNDARY = "boundary"

XML_TAG_BOUNDARY_XMIN = "xmin"
XML_TAG_BOUNDARY_XMAX = "xmax"
XML_TAG_BOUNDARY_YMIN = "ymin"
XML_TAG_BOUNDARY_YMAX = "ymax"
XML_TAG_BOUNDARY_ZMIN = "zmin"
XML_TAG_BOUNDARY_ZMAX = "zmax"

# Boundary conditions
XML_TAG_BC = "boundary_condition"
XML_BC_ATTR_TYPE = "type"
XML_BC_TYPE_PEC = "PEC"
XML_BC_TYPE_PMC = "PMC"
XML_BC_TYPE_ABSORBING = "absorbing"

XML_TAG_X = "x"
XML_TAG_Y = "y"
XML_TAG_Z = "z"

XML_TAG_VECTOR2D_COMPONENTS = [XML_TAG_X, XML_TAG_Y]
XML_TAG_VECTOR3D_COMPONENTS = [XML_TAG_X, XML_TAG_Y, XML_TAG_Z]

XML_TAG_POINT2D_COMPONENTS = XML_TAG_VECTOR2D_COMPONENTS
XML_TAG_POINT3D_COMPONENTS = XML_TAG_VECTOR3D_COMPONENTS

XML_TAG_X1 = "x1"
XML_TAG_Y1 = "y1"
XML_TAG_Z1 = "z1"
XML_TAG_X2 = "x2"
XML_TAG_Y2 = "y2"
XML_TAG_Z2 = "z2"
XML_TAG_LENGTH_X = "length_x"
XML_TAG_LENGTH_Y = "length_y"
XML_TAG_LENGTH_Z = "length_z"


# Geomtry tags
XML_TAG_PATCH = "patch"

XML_TAG_CIRCLE = "circle"

XML_TAG_CUBE = "cube"

XML_TAG_CYLINDER = "cylinder"
XML_TAG_CYLINDER_ORIENTATION = "orientation"
XML_TAG_RADIUS = "radius"
XML_TAG_HEIGHT = "height"

XML_TAG_POINT2D = "p2d"
XML_TAG_POINT3D = "p3d"
XML_TAG_VECTOR2D = "v2d"
XML_TAG_VECTOR3D = "v3d"
XML_TAG_POLYGON2D = "polygon2d"

XML_TAG_NORMAL = "normal"
XML_TAG_LEVEL = "level"
XML_TAG_POINTS = "points"



XML_GEOMETRY_GROUP = [XML_TAG_PATCH,
                      XML_TAG_CIRCLE,
		      XML_TAG_POLYGON2D,
                      XML_TAG_CUBE,
                      XML_TAG_CYLINDER]



# Excitation tags
XML_TAG_VOLTAGE_PORT = "voltage_port"

XML_EXCITATION_GROUP = [XML_TAG_VOLTAGE_PORT]

# signals
XML_TAG_SIGNALS = "signals"
XML_TAG_SIGNAL_GAUSSIAN_DIFFERENTIATED = "gaussian_differentiated"
XML_TAG_SIGNAL_GAUSSIAN_MODULATED = "gaussian_modulated"
XML_TAG_FREQUENCY_MIN = "frequency_min"
XML_TAG_FREQUENCY_MAX = "frequency_max"
XML_TAG_TSHIFT = "tshift"

# simulation
XML_TAG_SIMULATION = "simulation"
XML_TAG_SIMULATION_TLM = "tlm"
XML_TAG_NUMBER_OF_TIME_STEPS = "number_of_time_steps"

# mesh
XML_TAG_MESH = "mesh"
XML_TAG_DX = "dx"
XML_TAG_DY = "dy"
XML_TAG_DZ = "dz"

# results
XML_TAG_RESULTS = "results"
XML_TAG_RESULT = "result"
XML_ATTR_RESULT_TYPE = "type"

XML_TAG_TDSIGNAL = "tdsignal"
XML_TAG_SPARAMETERS = "sparameters"
XML_TAG_ZPARAMETERS = "zparameters"

#XML_TAG_TDSIGNALS = "tdsignals"

RESULT_TYPE_SPARAMETERS = "SParameters"
RESULT_TYPE_IMPEDANCE = "Impedance"
RESULT_TYPE_TIME_DOMAIN_SIGNAL = "TimeDomainSignal"

# emgine_result
XML_TAG_EMGINE_RESULT = "emgine_result"
RESULT_TYPE_SIMULATION = "simulation"
RESULT_TYPE_REFERENCE = "reference"

# Files
XML_TAG_FILE = "file"
XML_ATTR_FILE_SRC = "src"
XML_ATTR_FILE_COLUMN = "column"
XML_ATTR_FILE_TYPE = "type"

FILE_TYPE_ASCII = "ascii"
FILE_TYPE_S1P = "s1p"
FILE_TYPE_S2P = "s2p"
FILE_TYPE_V5D = "v5d"
FILE_TYPE_HTML = "html"

# Parameters
XML_TAG_PARAMETERS = "parameters"
XML_TAG_PARAMETER = "parameter"

# Units
XML_TAG_UNITS = "units"
XML_TAG_UNITS_LENGTH = "length"
XML_TAG_UNITS_FREQUENCY = "frequency"
XML_TAG_UNITS_TIME = "time"

# Misc tags
XML_TAG_INFINITE = "INFINITE"
XML_TAG_ORIENTATION_X = "X"
XML_TAG_ORIENTATION_Y = "Y"
XML_TAG_ORIENTATION_Z = "Z"

# Attributes
XML_ATTR_NAME = "name"
XML_ATTR_GEOMETRY_MATERIAL = "material"
XML_ATTR_UNITS = "units"

XML_ATTR_PARAMETER = "parameter"

XML_ATTR_NORMAL = "normal"
XML_ATTR_LEVEL = "level"

# Groups
XML_RESULTS2D_GROUP = [XML_TAG_TDSIGNAL,
		       XML_TAG_SPARAMETERS,
		       XML_TAG_ZPARAMETERS]
                       
		       


### DEFAULT_MATERIALS = """
### <materials>
### <material name=\"Air\">
###   <eps_r>1.0</eps_r>
###   <mu_r>1.0</mu_r>
### </material>
### <material name=\"PEC\">
###   <eps_r>1.0</eps_r>
###   <mu_r>1.0</mu_r>
###   <conductivity><INFINITE/></conductivity>
### </material>
### <material name=\"Copper\">
###   <eps_r>1.0</eps_r>
###   <mu_r>1.0</mu_r>
###   <conductivity>5.8e7</conductivity>
### </material>
### </materials>
### """

DEFAULT_UNITS = """
<units>
  <length>1</length>
  <frequency>1</frequency>
  <time>1</time>
</units>
"""

DEFAULT_MATERIALS = """
<materials>
<material name=\"Air\">
  <eps_r>1.0</eps_r>
  <mu_r>1.0</mu_r>
</material>
<material name=\"PEC\">
  <eps_r>1.0</eps_r>
  <mu_r>1.0</mu_r>
  <conductivity><INFINITE/></conductivity>
</material>
</materials>
"""

DEFAULT_GEOMETRY = """
<geometry>
</geometry>
"""

DEFAULT_SIGNALS = """
<signals>
  <gaussian_differentiated>
    <frequency_min>1e9</frequency_min>
    <frequency_max>3e9</frequency_max>
  </gaussian_differentiated>
</signals>
"""

DEFAULT_EXCITATION = """
<excitation>
</excitation>
"""

#DEFAULT_BOUNDARY = """
#<boundaries>
#<boundary name=\"Magnetic wall\">
#  <ref>1.0</ref>
#</boundary>
#<boundary name=\"Electric wall\">
#  <ref>-1.0</ref>
#</boundary>
#<boundary name=\"Absorbing wall\">
#  <ref>0.0</ref>
#</boundary>
#</boundaries>
#"""

DEFAULT_BOUNDARY = """
<boundaries>
</boundaries>
"""

DEFAULT_SIMULATION = """
<simulation>
  <tlm>
    <number_of_time_steps>100</number_of_time_steps>
    <mesh type="cartesian" mode="regular">
      <x1>-14</x1>
      <y1>-10</y1>
      <z1>-4</z1>
      <x2>14</x2>
      <y2>10</y2>
      <z2>4</z2>
      <dx>.1</dx>
      <dy>.1</dy>
      <dz>.1</dz>
    </mesh>
  </tlm>
</simulation>
"""

DEFAULT_RESULTS = """
<results>
</results>
"""

DEFAULT_PROJECT = "%s %s %s %s %s %s %s %s" %(DEFAULT_UNITS, DEFAULT_MATERIALS, DEFAULT_GEOMETRY, DEFAULT_SIGNALS, DEFAULT_EXCITATION, DEFAULT_BOUNDARY, DEFAULT_SIMULATION, DEFAULT_RESULTS)
