Changeset e757cda7 in OpenModelica
- Timestamp:
- 2023-03-27T11:28:24+02:00 (13 months ago)
- Children:
- 7aafc15
- Parents:
- ee088cb
- git-author:
- anotheruserofgithub <96748782+anotheruserofgithub@…> (03/23/23 09:18:12)
- git-committer:
- anotheruserofgithub <96748782+anotheruserofgithub@…> (03/27/23 11:28:24)
- Location:
- OMEdit/OMEditLIB/Animation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
OMEdit/OMEditLIB/Animation/AnimationUtil.h
ree088cb re757cda7 36 36 #define ANIMATIONUTIL_H 37 37 38 #include <QFileInfo> 38 39 #include <QString> 39 #include <QRegExp>40 #include <QFileInfo>41 40 42 #include <QOpenGLContext> // must be included before OSG headers43 44 #include <sys/stat.h>45 41 #include <string> 46 #include <osg/Vec3>47 42 48 43 #include "MainWindow.h" … … 126 121 } 127 122 128 /*! \brief Checks if the type is a cad file 123 /*! 124 * \brief Gets the filename of the CAD file 129 125 */ 130 inline bool isCADType(const std::string& typeName)126 inline std::string extractCADFilename(const std::string& typeName) 131 127 { 132 return ((typeName.size() >= 12 && std::string(typeName.begin(), typeName.begin() + 11) == "modelica://") 133 || (typeName.size() >= 8 && std::string(typeName.begin(), typeName.begin() + 7) == "file://")); 134 } 135 136 137 inline bool dxfFileType(const std::string& typeName) 138 { 139 return typeName.substr(typeName.size()-3) == std::string("dxf"); 140 } 141 142 inline bool stlFileType(const std::string& typeName) 143 { 144 return typeName.substr(typeName.size()-3) == std::string("stl"); 145 } 146 147 inline bool objFileType(const std::string& typeName) 148 { 149 return typeName.substr(typeName.size()-3) == std::string("obj"); 150 } 151 152 inline bool tdsFileType(const std::string& typeName) 153 { 154 return typeName.substr(typeName.size()-3) == std::string("3ds"); 155 } 156 157 158 /*! \brief Get file name of the cad file 159 */ 160 inline std::string extractCADFilename(const std::string& s) 161 { 162 QString str(s.c_str()); 128 QString str(typeName.c_str()); 163 129 if (str.startsWith("modelica://")) { 164 130 const QString absoluteFileName = MainWindow::instance()->getOMCProxy()->uriToFilename(str); 165 131 return absoluteFileName.toStdString(); 166 132 } else { 167 std::string fileKey = "file://"; 168 std::string s2 = s.substr(fileKey.length(), s.length()); 169 return s2; 133 const std::string fileKey = "file://"; 134 return typeName.substr(fileKey.length(), typeName.length()); 170 135 } 136 } 137 138 /*! 139 * \brief Checks if the type is a CAD file 140 */ 141 inline bool isCADFile(const std::string& typeName) 142 { 143 return ((typeName.size() >= 12 && std::string(typeName.begin(), typeName.begin() + 11) == "modelica://") || 144 (typeName.size() >= 8 && std::string(typeName.begin(), typeName.begin() + 7) == "file://")); 145 } 146 147 inline bool isDXFFile(const std::string& fileName) 148 { 149 return fileName.substr(fileName.size() - 3) == "dxf"; 150 } 151 152 inline bool isSTLFile(const std::string& fileName) 153 { 154 return fileName.substr(fileName.size() - 3) == "stl"; 155 } 156 157 inline bool isOBJFile(const std::string& fileName) 158 { 159 return fileName.substr(fileName.size() - 3) == "obj"; 160 } 161 162 inline bool is3DSFile(const std::string& fileName) 163 { 164 return fileName.substr(fileName.size() - 3) == "3ds"; 171 165 } 172 166 … … 176 170 } 177 171 178 179 172 #endif //ANIMATIONUTIL_H -
OMEdit/OMEditLIB/Animation/Visualization.cpp
ree088cb re757cda7 318 318 shape._type = std::string(expNode->value()); 319 319 320 if (isCAD Type(shape._type))320 if (isCADFile(shape._type)) 321 321 { 322 322 shape._fileName = extractCADFilename(shape._type); … … 329 329 } 330 330 331 if ( dxfFileType(shape._fileName)) {331 if (isDXFFile(shape._fileName)) { 332 332 shape._type = "dxf"; 333 } else if ( stlFileType(shape._fileName)) {333 } else if (isSTLFile(shape._fileName)) { 334 334 shape._type = "stl"; 335 } else if ( objFileType(shape._fileName)) {335 } else if (isOBJFile(shape._fileName)) { 336 336 shape._type = "obj"; 337 } else if ( tdsFileType(shape._fileName)) {337 } else if (is3DSFile(shape._fileName)) { 338 338 shape._type = "3ds"; 339 339 }
Note: See TracChangeset
for help on using the changeset viewer.