Пример #1
0
void ViewProviderPoints::setDisplayMode(const char* ModeName)
{
    int numPoints = pcPointsCoord->point.getNum();

    if (strcmp("Color",ModeName) == 0) {
        std::map<std::string,App::Property*> Map;
        pcObject->getPropertyMap(Map);
        for (std::map<std::string,App::Property*>::iterator it = Map.begin(); it != Map.end(); ++it) {
            Base::Type type = it->second->getTypeId();
            if (type == App::PropertyColorList::getClassTypeId()) {
                App::PropertyColorList* colors = static_cast<App::PropertyColorList*>(it->second);
                if (numPoints != colors->getSize()) {
#ifdef FC_DEBUG
                    SoDebugError::postWarning("ViewProviderPoints::setDisplayMode",
                                              "The number of points (%d) doesn't match with the number of colors (%d).", numPoints, colors->getSize());
#endif
                    // fallback 
                    setDisplayMaskMode("Point");
                }
                else {
                    setVertexColorMode(colors);
                    setDisplayMaskMode("Color");
                }
                break;
            }
        }
    }
    else if (strcmp("Intensity",ModeName) == 0) {
        std::map<std::string,App::Property*> Map;
        pcObject->getPropertyMap(Map);
        for (std::map<std::string,App::Property*>::iterator it = Map.begin(); it != Map.end(); ++it) {
            Base::Type type = it->second->getTypeId();
            if (type == Points::PropertyGreyValueList::getClassTypeId()) {
                Points::PropertyGreyValueList* greyValues = static_cast<Points::PropertyGreyValueList*>(it->second);
                if (numPoints != greyValues->getSize()) {
#ifdef FC_DEBUG
                    SoDebugError::postWarning("ViewProviderPoints::setDisplayMode",
                                              "The number of points (%d) doesn't match with the number of grey values (%d).", numPoints, greyValues->getSize());
#endif
                    // Intensity mode is not possible then set the default () mode instead.
                    setDisplayMaskMode("Point");
                }
                else {
                    setVertexGreyvalueMode((Points::PropertyGreyValueList*)it->second);
                    setDisplayMaskMode("Color");
                }
                break;
            }
        }
    }
    else if (strcmp("Shaded",ModeName) == 0) {
        std::map<std::string,App::Property*> Map;
        pcObject->getPropertyMap(Map);
        for (std::map<std::string,App::Property*>::iterator it = Map.begin(); it != Map.end(); ++it) {
            Base::Type type = it->second->getTypeId();
            if (type == Points::PropertyNormalList::getClassTypeId()) {
                Points::PropertyNormalList* normals = static_cast<Points::PropertyNormalList*>(it->second);
                if (numPoints != normals->getSize()) {
#ifdef FC_DEBUG
                    SoDebugError::postWarning("ViewProviderPoints::setDisplayMode",
                                              "The number of points (%d) doesn't match with the number of normals (%d).", numPoints, normals->getSize());
#endif
                    // fallback 
                    setDisplayMaskMode("Point");
                }
                else {
                    setVertexNormalMode(normals);
                    setDisplayMaskMode("Shaded");
                }
                break;
            }
        }
    }
    else if (strcmp("Points",ModeName) == 0) {
        setDisplayMaskMode("Point");
    }

    ViewProviderGeometryObject::setDisplayMode(ModeName);
}