Changeset 7aafc15 in OpenModelica


Ignore:
Timestamp:
2023-03-27T11:28:24+02:00 (13 months ago)
Author:
anotheruserofgithub <96748782+anotheruserofgithub@…>
Parents:
e757cda7
git-author:
anotheruserofgithub <96748782+anotheruserofgithub@…> (03/23/23 09:52:56)
git-committer:
anotheruserofgithub <96748782+anotheruserofgithub@…> (03/27/23 11:28:24)
Message:

Add helper functions for CAD type checks

Location:
OMEdit/OMEditLIB/Animation
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • OMEdit/OMEditLIB/Animation/AnimationUtil.h

    re757cda7 r7aafc15  
    165165}
    166166
     167inline bool isDXFType(const std::string& type)
     168{
     169  return type == "DXF";
     170}
     171
     172inline bool isSTLType(const std::string& type)
     173{
     174  return type == "STL";
     175}
     176
     177inline bool isOBJType(const std::string& type)
     178{
     179  return type == "OBJ";
     180}
     181
     182inline bool is3DSType(const std::string& type)
     183{
     184  return type == "3DS";
     185}
     186
     187inline bool isCADType(const std::string& type)
     188{
     189  return isDXFType(type) || isSTLType(type) || isOBJType(type) || is3DSType(type);
     190}
     191
     192inline bool isSimpleCADType(const std::string& type)
     193{
     194  return isDXFType(type) || isSTLType(type);
     195}
     196
     197inline bool isAdvancedCADType(const std::string& type)
     198{
     199  return isOBJType(type) || is3DSType(type);
     200}
     201
    167202inline const char* boolToString(bool b)
    168203{
  • OMEdit/OMEditLIB/Animation/ViewerWidget.cpp

    r740a8c7 r7aafc15  
    404404    if (mpSelectedVisualizer->isShape()) {
    405405      ShapeObject* shape = mpSelectedVisualizer->asShape();
    406       if (shape->_type.compare("dxf") == 0 or shape->_type.compare("stl") == 0) {
    407         QString msg = tr("Texture feature is not applicable for %1 files.").arg(shape->_type.compare("dxf") == 0 ? "DXF" : "STL");
     406      if (isSimpleCADType(shape->_type)) {
     407        QString msg = tr("Texture feature is not applicable for %1 files.").arg(shape->_type.c_str());
    408408        MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, msg,
    409409                                                              Helper::scriptingKind, Helper::notificationLevel));
     
    427427    if (mpSelectedVisualizer->isShape()) {
    428428      ShapeObject* shape = mpSelectedVisualizer->asShape();
    429       if (shape->_type.compare("dxf") == 0 or shape->_type.compare("stl") == 0) {
    430         QString msg = tr("Texture feature is not applicable for %1 files.").arg(shape->_type.compare("dxf") == 0 ? "DXF" : "STL");
     429      if (isSimpleCADType(shape->_type)) {
     430        QString msg = tr("Texture feature is not applicable for %1 files.").arg(shape->_type.c_str());
    431431        MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, msg,
    432432                                                              Helper::scriptingKind, Helper::notificationLevel));
     
    455455    if (mpSelectedVisualizer->isShape()) {
    456456      ShapeObject* shape = mpSelectedVisualizer->asShape();
    457       if (shape->_type.compare("dxf") == 0 or shape->_type.compare("stl") == 0) {
    458         QString msg = tr("Texture feature is not applicable for %1 files.").arg(shape->_type.compare("dxf") == 0 ? "DXF" : "STL");
     457      if (isSimpleCADType(shape->_type)) {
     458        QString msg = tr("Texture feature is not applicable for %1 files.").arg(shape->_type.c_str());
    459459        MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, msg,
    460460                                                              Helper::scriptingKind, Helper::notificationLevel));
  • OMEdit/OMEditLIB/Animation/ViewerWidget.h

    r740a8c7 r7aafc15  
    4848
    4949#include "AbstractAnimationWindow.h"
     50#include "AnimationUtil.h"
    5051#include "Util/Helper.h"
    5152
  • OMEdit/OMEditLIB/Animation/Visualization.cpp

    re757cda7 r7aafc15  
    330330
    331331      if (isDXFFile(shape._fileName)) {
    332         shape._type = "dxf";
     332        shape._type = "DXF";
    333333      } else if (isSTLFile(shape._fileName)) {
    334         shape._type = "stl";
     334        shape._type = "STL";
    335335      } else if (isOBJFile(shape._fileName)) {
    336         shape._type = "obj";
     336        shape._type = "OBJ";
    337337      } else if (is3DSFile(shape._fileName)) {
    338         shape._type = "3ds";
     338        shape._type = "3DS";
    339339      }
    340340    }
     
    796796        // Store the radius of relevant shapes
    797797        for (ShapeObject& shape : relevantShapes) {
    798           // Consider OpenSceneGraph shape drawables only
    799           if (shape._type.compare("dxf") == 0 || shape._type.compare("stl") == 0 ||
    800               shape._type.compare("obj") == 0 || shape._type.compare("3ds") == 0) {
     798          // Consider OSG shape drawables only
     799          if (isCADType(shape._type)) {
    801800            continue;
    802801          }
     
    12881287    transf->setName(shape._id);
    12891288
    1290     if (shape._type.compare("obj") == 0 or shape._type.compare("3ds") == 0)
     1289    if (isAdvancedCADType(shape._type))
    12911290    { //advanced cad node
    12921291      //std::cout<<"It's an advanced cad and the filename is "<<shape._fileName<<std::endl;
     
    12991298      }
    13001299    }
    1301     else if (shape._type.compare("stl") == 0)
     1300    else if (isSTLType(shape._type))
    13021301    { //stl node
    13031302      //std::cout<<"It's a stl and the filename is "<<shape._fileName<<std::endl;
     
    13121311      }
    13131312    }
    1314     else if (shape._type.compare("dxf") == 0)
     1313    else if (isDXFType(shape._type))
    13151314    { //geode with dxf drawable
    13161315      //std::cout<<"It's a dxf and the filename is "<<shape._fileName<<std::endl;
     
    14301429     {
    14311430      ShapeObject* shape = _visualizer->asShape();
    1432       if (shape->_type.compare("dxf") == 0 or shape->_type.compare("stl") == 0 or
    1433           shape->_type.compare("obj") == 0 or shape->_type.compare("3ds") == 0)
     1431      if (isCADType(shape->_type))
    14341432      {
    14351433        //it's a cad file so we have to rescale the underlying geometry vertices
     
    15681566    if (_visualizer->isShape()) {
    15691567      ShapeObject* shape = _visualizer->asShape();
    1570       if (shape->_type.compare("dxf") == 0 or shape->_type.compare("stl") == 0 or
    1571           shape->_type.compare("obj") == 0 or shape->_type.compare("3ds") == 0) {
     1568      if (isCADType(shape->_type)) {
    15721569        osg::ref_ptr<osg::Transform> transformNode = shape->getTransformNode();
    15731570        if (transformNode.valid() && transformNode->getNumChildren() > 0) {
     
    15761573            stateSet = cad->getOrCreateStateSet();
    15771574            geometryColors = !shape->getVisualProperties()->getColor().custom();
    1578             is3DSShape = shape->_type.compare("3ds") == 0;
     1575            is3DSShape = is3DSType(shape->_type);
    15791576          }
    15801577        }
     
    18911888
    18921889  osg::Matrix3 T0;
    1893   if (type == "dxf" || type == "stl" || type == "obj" || type == "3ds")
     1890  if (isCADType(type))
    18941891  {
    18951892    T0 = osg::Matrix3(dirs._lDir[0], dirs._lDir[1], dirs._lDir[2],
Note: See TracChangeset for help on using the changeset viewer.