0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / Expr / Expr_NamedConstant.cxx
1 // Created on: 1991-04-12
2 // Created by: Arnaud BOUZY
3 // Copyright (c) 1991-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Expr_GeneralExpression.hxx>
19 #include <Expr_NamedConstant.hxx>
20 #include <Expr_NamedUnknown.hxx>
21 #include <Expr_NumericValue.hxx>
22 #include <Standard_OutOfRange.hxx>
23 #include <Standard_Type.hxx>
24 #include <TCollection_AsciiString.hxx>
25
26 IMPLEMENT_STANDARD_RTTIEXT(Expr_NamedConstant,Expr_NamedExpression)
27
28 Expr_NamedConstant::Expr_NamedConstant(const TCollection_AsciiString& name, const Standard_Real value)
29 {
30   SetName(name);
31   myValue = value;
32 }
33
34 const Handle(Expr_GeneralExpression)& Expr_NamedConstant::SubExpression (const Standard_Integer ) const
35 {
36  throw Standard_OutOfRange();
37 }
38
39 Handle(Expr_GeneralExpression) Expr_NamedConstant::Simplified () const
40 {
41   Handle(Expr_GeneralExpression) res = new Expr_NumericValue(myValue);
42   return res;
43 }
44
45 Handle(Expr_GeneralExpression) Expr_NamedConstant::Copy () const
46 {
47   return new Expr_NamedConstant(GetName(),myValue);
48 }
49
50 Handle(Expr_GeneralExpression) Expr_NamedConstant::Derivative (const Handle(Expr_NamedUnknown)& ) const
51 {
52   Handle(Expr_GeneralExpression) aNumVal = new Expr_NumericValue(0.0);
53   return aNumVal;
54 }
55
56 Handle(Expr_GeneralExpression) Expr_NamedConstant::NDerivative (const Handle(Expr_NamedUnknown)& , const Standard_Integer ) const
57 {
58   return new Expr_NumericValue(0.0);
59 }
60
61 Handle(Expr_GeneralExpression) Expr_NamedConstant::ShallowSimplified () const
62 {
63   Handle(Expr_GeneralExpression) res = new Expr_NumericValue(myValue);
64   return res;
65 }
66
67 Standard_Real Expr_NamedConstant::Evaluate(const Expr_Array1OfNamedUnknown&, const TColStd_Array1OfReal&) const
68 {
69   return myValue;
70 }
71
72 Standard_Integer Expr_NamedConstant::NbSubExpressions () const
73 {
74   return 0;
75 }
76
77 Standard_Boolean Expr_NamedConstant::ContainsUnknowns () const
78 {
79   return Standard_False;
80 }
81
82 Standard_Boolean Expr_NamedConstant::Contains (const Handle(Expr_GeneralExpression)& ) const
83 {
84   return Standard_False;
85 }
86
87 Standard_Boolean Expr_NamedConstant::IsLinear () const
88 {
89   return Standard_True;
90 }
91
92 void Expr_NamedConstant::Replace (const Handle(Expr_NamedUnknown)& , const Handle(Expr_GeneralExpression)& )
93 {
94 }
95