Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Radical.h

Go to the documentation of this file.
00001 
00002 // MathCore = a WYSIWYG equation editor + a powerful math engine     //
00003 // Copyright (C) 2003 by Francesco Montorsi                          //
00004 //                                                                   //
00005 // This library is free software; you can redistribute it and/or     //
00006 // modify it under the terms of the GNU Lesser General Public        //
00007 // License as published by the Free Software Foundation; either      //
00008 // version 2.1 of the License, or (at your option) any later         //
00009 // version.                                                          //
00010 //                                                                   //
00011 // This library is distributed in the hope that it will be useful,   //
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of    //
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      //
00014 // GNU Lesser General Public License for more details.               //
00015 //                                                                   //
00016 // You should have received a copy of the GNU Lesser General Public  //
00017 // License along with this program; if not, write to the Free        //
00018 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,   //
00019 // MA 02111-1307, USA.                                               //
00020 //                                                                   //
00021 // For any comment, suggestion or feature request, please contact    //
00022 // the administrator of the project at frm@users.sourceforge.net     //
00023 //                                                                   //
00031 
00032 
00033 
00034 #ifndef RADICAL_H
00035 #define RADICAL_H
00036 
00037 // optimization for GCC compiler
00038 #ifdef __GNUG__
00039 #pragma interface "Radical.h"
00040 #endif
00041 
00042 // required includes
00043 #include "mc/ExpContainer.h"
00044 #include "mc/Polynomial.h"
00045 #include "mc/Function.h"
00046 
00047 
00048 
00049 
00050 mcDEFINE_HELPER_CLASSES(mcRadical)
00051 
00052 
00053 
00054 
00055 
00056 class mcRadicalHelpers : public mcExpContainerHelpers
00057 {
00058  mcDEFINE_REFERENCE_DATA(mcRadical, mcET_RADICAL);
00059 
00060 #ifdef mcENABLE_GUI
00061 public:    // customizable variables
00062 
00064  static mcKey *sgui_pNewRadical;
00065 
00066  static int sgui_nSpaceAboveBelow;
00067  static int sgui_nSpaceLeftRight;
00068 
00069  virtual int gui_GetSpaceAboveBelow() const  { return sgui_nSpaceAboveBelow; }
00070  virtual int gui_GetSpaceLeftRight() const  { return sgui_nSpaceLeftRight; }
00071 #endif
00072 
00073 
00074 #ifdef mcENABLE_IO
00075 public:  // customizable variables
00076 
00077  static wxString sio_strSquareRoot;
00078  static wxString sio_strGenericRoot;
00079 #endif
00080 
00081 
00082 
00083 public:
00084 
00085  mcRadicalHelpers() {
00086 
00087   // mcRadicals uses the mcExpElement's exponent as
00088   // an index, placed on the left.
00089   mgui_bExpRight = FALSE;
00090   data_Init();
00091  }
00092 
00093  virtual ~mcRadicalHelpers() {}
00094  
00095 
00096 
00097 #ifdef mcENABLE_DATA
00098 public:
00099 
00100 #ifdef __MCDEBUG__
00101 
00102  wxString data_BaseDebug(long flags) const {
00103   return wxT("mcRadical:\n") + data_GetContent().data_GetDebug(
00104       mcMathCore::Get()->m_nIndentationStep, flags);
00105  }
00106 
00107 #endif
00108 #endif  // mcENABLE_DATA
00109 
00110 
00111 
00112 #ifdef mcENABLE_GUI
00113 public:
00114 
00116  int gui_GetVWidth() const;
00117 
00118 
00124 
00125  bool gui_isBeginKey(const mcKey &key) const;
00126  void gui_DrawContainer(wxDC &, int x, int y, long flags, const wxPoint &) const;
00127  //int gui_DrawBase(wxDC &, int x, int y, const wxPoint &);
00128  //int gui_GetRelCursorPos(wxDC &dc, wxPoint *);
00129  //int gui_GetYAnchor() const;
00130 
00133  bool gui_isLeftPosEnabled() const;
00134 
00137  bool gui_isRightPosEnabled() const   { return TRUE; }
00138 
00139  //mcMoveCursorRes gui_BaseMoveCursor(mcMoveCursorFlag flag, long modifiers);
00140  //int gui_BaseMoveCursorUsingPoint(wxDC &, const wxPoint &);
00141  void gui_DoRecalcBaseSize();
00142 
00143  int gui_GetExpOffsetx() const;
00144  int gui_GetContentOffsetX() const;
00145  int gui_GetContentOffsetY() const;
00146 
00149  int gui_GetBaseOffsety() const { return 0; }
00150 
00152 
00153 #endif  // mcENABLE_GUI
00154 
00155 
00156 
00157 #ifdef mcENABLE_MATH
00158 public:
00159 
00160  // the exp of a mcRadicalMath is called index
00161  bool math_hasIdx() const       { return math_hasExp(); }
00162  mcPolynomial &math_GetIdx()       { return math_GetExp(); }
00163  const mcPolynomial &math_GetIdx() const    { return math_GetExp(); }
00164 
00165  mcRealValue math_Evaluate() const;
00166  mcMathType math_GetBaseMathType() const;
00167  //mcBasicOpRes math_MakeReciprocal(mcElement *);
00168 
00169  mcExpSimRes math_SimplifyContents(long flags, mcElement *newelem);
00170  mcExpSimRes math_ExpandContents(long flags, mcElement *newelem);
00171  
00174  //mcRealValue math_GetBaseLenght() const { return mcExpContainer::math_GetBaseLenght()+1; }
00175 
00176  int math_GetOrderPos() const  { return 3; }
00177 
00178 #endif  // mcENABLE_MATH
00179 
00180 
00181 
00182 #ifdef mcENABLE_IO
00183 public:
00184 
00185  bool io_isBeginTag(const wxXml2Node &tag) const {
00186   if (tag.GetName() == sio_strSquareRoot || 
00187    tag.GetName() == sio_strGenericRoot)
00188    return TRUE;
00189   return FALSE;
00190  }
00191 
00192  static bool io_isRadicalBeginChar(const wxString &str) {
00193   if (str.StartsWith(sio_strSquareRoot) ||
00194    str.StartsWith(sio_strGenericRoot))
00195    return TRUE;
00196   return FALSE;
00197  }
00198 
00199  bool io_isBeginChar(const wxString &str) const 
00200   { return io_isRadicalBeginChar(str); }
00201  
00202  // MATH ML functions
00203  wxXml2Node io_GetMathML(bool bGetPresentation) const;
00204  wxXml2Node io_GetBaseMathML(bool bGetPresentation) const;
00205  bool io_ImportPresentationMathML(wxXml2Node tag, wxString &pErr);
00206 
00207  wxString io_GetInlinedExpr() const;
00208  wxString io_GetBaseInlinedExpr() const { return wxEmptyString; }
00209  bool io_ImportBaseInlinedExpr(const wxString &, int *, wxString &);
00210 
00211 #endif  // mcENABLE_IO
00212 };
00213 
00214 
00219 class mcRadical : public mcExpContainer
00220 {
00221  mcDEFINE_MAIN_CLASS(Radical, mcExpContainer);
00222 
00223 public:
00224 
00225  mcRadical(const mcPolynomial &contents)
00226  { data_SetRefData(new mcRadicalHelpers()); data_SetContent(contents); }
00227 
00228  bool data_isValidContainerFor(mcElementType t) const
00229   { return t == mcET_RADICAL; }
00230 };
00231 
00232 #endif // RADICAL_H
00233 


Documentation generated with Doxygen on Sun Feb 6 17:10:48 2005
Visit MathStudio home page for more info

[ Top ]