@@ -67,17 +67,20 @@ namespace
6767 numClassTypes = FFaTypeCheck ::getNewTypeID (NULL );
6868
6969 std ::string funcName (64 ,' ' );
70- const char * fName = funcName .c_str ()+ 4 ;
70+ char * fName = const_cast < char * > (funcName .c_str ()+ 4 );
71+ int funcIdx = USER_HEADING + 1 ;
7172 itsFuncInfoTable [USER_HEADING ] = "-- User-defined Functions --" ;
72- for (int i = 1 ; i <= nUserFuncs ; i ++ )
73- if (FFaUserFuncPlugin ::instance ()-> getFuncName (funcId [i - 1 ],60 ,const_cast < char * > (fName )) > 0 )
74- itsFuncInfoTable [USER_HEADING + i ] = FmFuncTypeInfo (funcName .c_str (),numClassTypes + funcId [i - 1 ]);
73+ for (int i = 0 ; i < nUserFuncs ; i ++ , funcIdx ++ )
74+ if (FFaUserFuncPlugin ::instance ()-> getFuncName (funcId [i ],60 ,fName ) > 0 )
75+ itsFuncInfoTable [funcIdx ] = FmFuncTypeInfo (funcName .c_str (),
76+ numClassTypes + funcId [i ]);
7577 }
7678
7779 for (std ::pair < const int ,FmFuncTypeInfo > & info : itsFuncInfoTable )
7880 info .second .funcMenuEnum = info .first ;
7981
80- itsFuncInfoTable [WAVE_SINUS ].funcMenuEnum = INTERNAL ; // Should not appear in Function type menu
82+ // Should not appear in the Function type menu
83+ itsFuncInfoTable [WAVE_SINUS ].funcMenuEnum = INTERNAL ;
8184 }
8285}
8386
@@ -140,36 +143,32 @@ bool FmFuncAdmin::hasSmartPoints(int type)
140143}
141144
142145
143- void FmFuncAdmin ::getCompatibleFunctionTypes (std ::vector < FmFuncTypeInfo > & toFill ,
144- FmMathFuncBase * compatibleFunc )
146+ void FmFuncAdmin ::getCompatibleFunctionTypes (std ::vector < FmFuncTypeInfo > & types ,
147+ FmMathFuncBase * func )
145148{
146- toFill .clear ();
147- if (!compatibleFunc )
148- return ;
149-
150149 if (itsFuncInfoTable .empty ())
151150 initFuncInfoTable ();
152151
153152 using FmFuncInfo = std ::pair < const int ,FmFuncTypeInfo > ;
154153
155- switch (compatibleFunc -> getFunctionUse ())
154+ switch (func ? func -> getFunctionUse () : FmMathFuncBase :: GENERAL )
156155 {
157156 case FmMathFuncBase ::GENERAL :
158157 // General function, allow all function types,
159158 // except for internal ones and wave spectrums
160- if (compatibleFunc -> getTypeID () == FmfWaveSinus ::getClassTypeID ())
159+ if (func && func -> getTypeID () == FmfWaveSinus ::getClassTypeID ())
161160 // Internal function with predefined type, don't allow type switching
162- toFill .push_back (itsFuncInfoTable [FmFuncAdmin ::WAVE_SINUS ]);
161+ types .push_back (itsFuncInfoTable [FmFuncAdmin ::WAVE_SINUS ]);
163162 else
164163 for (const FmFuncInfo & info : itsFuncInfoTable )
165164 if (info .second .funcMenuEnum > FmFuncAdmin ::UNDEFINED &&
166165 info .second .funcMenuEnum != FmFuncAdmin ::WAVE_SPECTRUM &&
167166 info .second .funcMenuEnum != FmFuncAdmin ::FILE_SPECTRUM )
168- toFill .push_back (info .second );
167+ types .push_back (info .second );
169168 return ;
170169
171170 case FmMathFuncBase ::DRIVE_FILE :
172- toFill .push_back (itsFuncInfoTable [FmFuncAdmin ::DEVICE ]);
171+ types .push_back (itsFuncInfoTable [FmFuncAdmin ::DEVICE ]);
173172 return ;
174173
175174 case FmMathFuncBase ::NONE :
@@ -180,20 +179,20 @@ void FmFuncAdmin::getCompatibleFunctionTypes(std::vector<FmFuncTypeInfo>& toFill
180179 info .second .funcMenuEnum != FmFuncAdmin ::WAVE_SPECTRUM &&
181180 info .second .funcMenuEnum != FmFuncAdmin ::FILE_SPECTRUM &&
182181 info .second .funcMenuEnum != FmFuncAdmin ::REFERENCE )
183- toFill .push_back (info .second );
182+ types .push_back (info .second );
184183 return ;
185184
186185 case FmMathFuncBase ::WAVE_FUNCTION :
187- toFill .push_back (itsFuncInfoTable [FmFuncAdmin ::SINUSOIDAL ]);
188- toFill .push_back (itsFuncInfoTable [FmFuncAdmin ::WAVE_SPECTRUM ]);
189- toFill .push_back (itsFuncInfoTable [FmFuncAdmin ::FILE_SPECTRUM ]);
186+ types .push_back (itsFuncInfoTable [FmFuncAdmin ::SINUSOIDAL ]);
187+ types .push_back (itsFuncInfoTable [FmFuncAdmin ::WAVE_SPECTRUM ]);
188+ types .push_back (itsFuncInfoTable [FmFuncAdmin ::FILE_SPECTRUM ]);
190189 // Check if we have user-defined wave functions
191190 for (const FmFuncInfo & info : itsFuncInfoTable )
192191 if (info .first > FmFuncAdmin ::USER_HEADING &&
193192 info .second .funcType > numClassTypes )
194193 if (int fId = info .second .funcType - numClassTypes ;
195194 FFaUserFuncPlugin ::instance ()-> getFlag (fId ) & 4 )
196- toFill .push_back (info .second );
195+ types .push_back (info .second );
197196 return ;
198197
199198 default : // Stiffness or Damper function
@@ -204,7 +203,7 @@ void FmFuncAdmin::getCompatibleFunctionTypes(std::vector<FmFuncTypeInfo>& toFill
204203 for (const FmFuncInfo & info : itsFuncInfoTable )
205204 if (std ::find (ftyp .begin (),ftyp .end (),info .second .funcType ) != ftyp .end ())
206205 if (info .first != FmFuncAdmin ::FILE_SPECTRUM )
207- toFill .push_back (info .second );
206+ types .push_back (info .second );
208207}
209208
210209
0 commit comments