void SetFilters(IFileDialogPtr pDialog, jobjectArray jFilters, jint defaultFilterIndex)
{
    JNIEnv *env = GetEnv();

    jsize size = env->GetArrayLength(jFilters);
    COMDLG_FILTERSPEC *filterSpec = new COMDLG_FILTERSPEC[size];

    for (int i = 0; i < size; i++) {
        JLObject jFilter(env, env->GetObjectArrayElement(jFilters, i));
        COMDLG_FILTERSPEC c = {GetDescription(env, jFilter),
                               GetExtensions(env, jFilter)};
        filterSpec[i] = c;
    }

    OLE_TRY
    OLE_HRT( pDialog->SetDefaultExtension(L"") );
    OLE_HRT( pDialog->SetFileTypes(size, filterSpec) );
    if (size > 0) {
        OLE_HRT( pDialog->SetFileTypeIndex(defaultFilterIndex + 1) ); // 1-based index required
    }
    OLE_CATCH

    for (int i = 0; i < size; i++) {
        if (filterSpec[i].pszName) {
            delete[] filterSpec[i].pszName;
        }
        if (filterSpec[i].pszSpec) {
            delete[] filterSpec[i].pszSpec;
        }
    }
    delete[] filterSpec;
}
Ejemplo n.º 2
0
int svlVideoCodecTCPStream::DialogCompression(const std::string &filename)
{
    if (filename.empty()) DialogCompression();

    if (Opened) return SVL_FAIL;

    std::string extensionlist(GetExtensions());
    std::string extension;
    svlVideoIO::GetExtension(filename, extension);
    extension.insert(0, ".");
    extension += ";";
    if (extensionlist.find(extension) == std::string::npos) {
        // Codec parameters do not match this codec
        return SVL_FAIL;
    }

    int min, max, defaultval;
    if (extension == ".njpg;") {
        min        = 0;
        max        = 100;
        defaultval = 75;
        std::cout << " # Enter quality level (min=" << min << "; max=" << max << "; default=" << defaultval << "): ";
    }
    else if (extension == ".ncvi;") {
        min        = 0;
        max        = 9;
        defaultval = 4;
        std::cout << " # Enter compression level (min=" << min << "; max=" << max << "; default=" << defaultval << "): ";
    }

    int level;
    char input[256];
    std::cin.getline(input, 256);
    if (std::cin.gcount() > 1) {
        level = atoi(input);
        if (level < min) level = min;
        if (level > max) level = max;
    }
    else level = defaultval;
    if (extension == ".njpg;") {
        std::cout << "    Quality level = " << level << std::endl;
    }
    else if (extension == ".ncvi;") {
        std::cout << "    Compression level = " << level << std::endl;
    }

    svlVideoIO::ReleaseCompression(Codec);
    Codec = reinterpret_cast<svlVideoIO::Compression*>(new unsigned char[sizeof(svlVideoIO::Compression)]);

    std::string name("CISST Video Stream over TCP/IP");
    memset(&(Codec->extension[0]), 0, 16);
    memcpy(&(Codec->extension[0]), extension.c_str(), std::min(static_cast<int>(extension.length()) - 1, 15));
    memset(&(Codec->name[0]), 0, 64);
    memcpy(&(Codec->name[0]), name.c_str(), std::min(static_cast<int>(name.length()), 63));
    Codec->size = sizeof(svlVideoIO::Compression);
    Codec->datasize = 1;
    Codec->data[0] = static_cast<unsigned char>(level);
    
    return SVL_OK;
}
Ejemplo n.º 3
0
OGLInspector::OGLInspector()
{
	char* str = 0;
	char* token = 0;

	m_extNames = GetExtensions();
	m_extNames.append(" ");
	m_extNames.append(GetGluExtensions());
}
Ejemplo n.º 4
0
bool BXObject::FromXML(const TiXmlNode *pNode) {
  if (!pNode || pNode->Type() != TiXmlNode::ELEMENT)
    return false;
  
  TiXmlElement *pElement = (TiXmlElement *)pNode;
  const char *szType = pElement->Attribute("type");
  const char *szId = pElement->Attribute("id");

	if (szType)
		SetType(szType);

	if (szId)
		SetID(szId);

	GetExtensions(pNode);
	return BXStringMap::FromXML(pNode);
}
Ejemplo n.º 5
0
int svlVideoCodecTCPStream::Open(const std::string &filename, unsigned int &width, unsigned int &height, double &framerate)
{
    if (Opened || ParseFilename(filename) != SVL_OK) return SVL_FAIL;

    std::string extensionlist(GetExtensions());
    std::string extension;
    svlVideoIO::GetExtension(filename, extension);
         if (extension == "ncvi") Compressor = CVI;
    else if (extension == "njpg") Compressor = JPEG;
    else return SVL_FAIL;

    while (1) {

        Opened = true;
        Writing = false;
        Width = Height = 0;

        // Releasing existing buffers
        delete [] yuvBuffer;
        yuvBuffer = 0;
        yuvBufferSize = 0;
        AccumulatedSize = 0;

        // Start data receiving thread
        ReceiveInitialized = false;
        KillReceiveThread = false;
        ReceiveThread = new osaThread;
        ReceiveInitEvent = new osaThreadSignal;
        ReceiveThread->Create<svlVideoCodecTCPStream, int>(this, &svlVideoCodecTCPStream::ReceiveProc, 0);
        ReceiveInitEvent->Wait();
        if (ReceiveInitialized == false) break;

        // Wait until header is received
        while (Width == 0 || Height == 0) osaSleep(0.1);

        Pos = BegPos = EndPos = 0;
        width = Width;
        height = Height;
        framerate = -1.0;

        return SVL_OK;
    }

    Close();
    return SVL_FAIL;
}
Ejemplo n.º 6
0
wxString ExportPlugin::GetMask()
{
   if (!mMask.IsEmpty()) {
      return mMask;
   }

   wxString mask = GetDescription() + wxT("|");

   // Build the mask, but cater to the Mac FileDialog and put the default
   // extension at the end of the mask.
   wxString ext = GetExtension();
   wxArrayString exts = GetExtensions();
   for (size_t i = 0; i < exts.GetCount(); i++) {
      if (ext != exts[i]) {
         mask += wxT("*.") + exts[i] + wxT(";");
      }
   }

   return mask + wxT("*.") + ext;
}
Ejemplo n.º 7
0
int svlVideoCodecTCPStream::SetCompression(const svlVideoIO::Compression *compression)
{
    if (Opened || !compression || compression->size < sizeof(svlVideoIO::Compression)) return SVL_FAIL;

    std::string extensionlist(GetExtensions());
    std::string extension(compression->extension);
    extension += ";";
    if (extensionlist.find(extension) == std::string::npos) {
        // Codec parameters do not match this codec
        return SVL_FAIL;
    }

    svlVideoIO::ReleaseCompression(Codec);
    Codec = reinterpret_cast<svlVideoIO::Compression*>(new unsigned char[sizeof(svlVideoIO::Compression)]);

    std::string name("CISST Video Stream over TCP/IP");
    memset(&(Codec->extension[0]), 0, 16);
    memcpy(&(Codec->extension[0]), extension.c_str(), std::min(static_cast<int>(extension.length()) - 1, 15));
    memset(&(Codec->name[0]), 0, 64);
    memcpy(&(Codec->name[0]), name.c_str(), std::min(static_cast<int>(name.length()), 63));
    Codec->size = sizeof(svlVideoIO::Compression);
    Codec->datasize = 1;

    unsigned char max, defaultval;
    if (extension == ".ncvi;") {
        max        = 9;
        defaultval = 4;
    }
    else if (extension == ".njpg;") {
        max        = 100;
        defaultval = 75;
    }
    if (compression->data[0] > max) Codec->data[0] = defaultval;
    else Codec->data[0] = compression->data[0];

    return SVL_OK;
}
const GLubyte * PACKSPU_APIENTRY packspu_GetString( GLenum name )
{
    GET_CONTEXT(ctx);

    switch(name)
    {
        case GL_EXTENSIONS:
            return GetExtensions();
        case GL_VERSION:
#if 0 && defined(WINDOWS)
            if (packspuRunningUnderWine())
            {
                GetString(GL_REAL_VERSION, ctx->pszRealVersion);
                return ctx->pszRealVersion;               
            }
            else
#endif
            {
                char *oldlocale;
                float version;

                oldlocale = setlocale(LC_NUMERIC, NULL);
                oldlocale = crStrdup(oldlocale);
                setlocale(LC_NUMERIC, "C");

                version = GetVersionString();
                sprintf((char*)ctx->glVersion, "%.1f Chromium %s", version, CR_VERSION_STRING);

                if (oldlocale)
                {
                    setlocale(LC_NUMERIC, oldlocale);
                    crFree(oldlocale);
                }

                return ctx->glVersion;
            }
        case GL_VENDOR:
#ifdef WINDOWS
            if (packspuRunningUnderWine())
            {
                GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
                return ctx->pszRealVendor;
            }
            else
#endif
            {
                return crStateGetString(name);
            }
        case GL_RENDERER:
#ifdef WINDOWS
            if (packspuRunningUnderWine())
            {
                GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
                return ctx->pszRealRenderer;
            }
            else
#endif
            {
                return crStateGetString(name);
            }

#ifdef CR_OPENGL_VERSION_2_0
        case GL_SHADING_LANGUAGE_VERSION:
        {
            static GLboolean fInitialized = GL_FALSE;
            if (!fInitialized)
            {
                GetString(GL_SHADING_LANGUAGE_VERSION, gpszShadingVersion);
                fInitialized = GL_TRUE;
            }
            return gpszShadingVersion;
        }
#endif
#ifdef GL_CR_real_vendor_strings
        case GL_REAL_VENDOR:
            GetString(GL_REAL_VENDOR, ctx->pszRealVendor);
            return ctx->pszRealVendor;
        case GL_REAL_VERSION:
            GetString(GL_REAL_VERSION, ctx->pszRealVersion);
            return ctx->pszRealVersion;
        case GL_REAL_RENDERER:
            GetString(GL_REAL_RENDERER, ctx->pszRealRenderer);
            return ctx->pszRealRenderer;
#endif
        default:
            return crStateGetString(name);
    }
}
char* VSIArchiveFilesystemHandler::SplitFilename(const char *pszFilename,
                                                 CPLString &osFileInArchive,
                                                 int bCheckMainFileExists)
{
    int i = 0;

    if (strcmp(pszFilename, GetPrefix()) == 0)
        return NULL;

    /* Allow natural chaining of VSI drivers without requiring double slash */
    
    CPLString osDoubleVsi(GetPrefix());
    osDoubleVsi += "/vsi";
    
    if (strncmp(pszFilename, osDoubleVsi.c_str(), osDoubleVsi.size()) == 0)
        pszFilename += strlen(GetPrefix());
    else
        pszFilename += strlen(GetPrefix()) + 1;

    while(pszFilename[i])
    {
        std::vector<CPLString> oExtensions = GetExtensions();
        std::vector<CPLString>::const_iterator iter;
        int nToSkip = 0;

        for( iter = oExtensions.begin(); iter != oExtensions.end(); ++iter )
        {
            const CPLString& osExtension = *iter;
            if (EQUALN(pszFilename + i, osExtension.c_str(), strlen(osExtension.c_str())))
            {
                nToSkip = strlen(osExtension.c_str());
                break;
            }
        }

        if (nToSkip != 0)
        {
            VSIStatBufL statBuf;
            char* archiveFilename = CPLStrdup(pszFilename);
            int bArchiveFileExists = FALSE;

            if (archiveFilename[i + nToSkip] == '/' ||
                archiveFilename[i + nToSkip] == '\\')
            {
                archiveFilename[i + nToSkip] = 0;
            }

            if (!bCheckMainFileExists)
            {
                bArchiveFileExists = TRUE;
            }
            else
            {
                CPLMutexHolder oHolder( &hMutex );

                if (oFileList.find(archiveFilename) != oFileList.end() )
                {
                    bArchiveFileExists = TRUE;
                }
            }

            if (!bArchiveFileExists)
            {
                VSIFilesystemHandler *poFSHandler = 
                    VSIFileManager::GetHandler( archiveFilename );
                if (poFSHandler->Stat(archiveFilename, &statBuf,
                                      VSI_STAT_EXISTS_FLAG | VSI_STAT_NATURE_FLAG) == 0 &&
                    !VSI_ISDIR(statBuf.st_mode))
                {
                    bArchiveFileExists = TRUE;
                }
            }

            if (bArchiveFileExists)
            {
                if (pszFilename[i + nToSkip] == '/' ||
                    pszFilename[i + nToSkip] == '\\')
                {
                    char* pszArchiveInFileName = CPLStrdup(pszFilename + i + nToSkip + 1);

                    /* Replace a/../b by b and foo/a/../b by foo/b */
                    while(TRUE)
                    {
                        char* pszPrevDir = strstr(pszArchiveInFileName, "/../");
                        if (pszPrevDir == NULL || pszPrevDir == pszArchiveInFileName)
                            break;

                        char* pszPrevSlash = pszPrevDir - 1;
                        while(pszPrevSlash != pszArchiveInFileName &&
                                *pszPrevSlash != '/')
                            pszPrevSlash --;
                        if (pszPrevSlash == pszArchiveInFileName)
                            memmove(pszArchiveInFileName, pszPrevDir + nToSkip, strlen(pszPrevDir + nToSkip) + 1);
                        else
                            memmove(pszPrevSlash + 1, pszPrevDir + nToSkip, strlen(pszPrevDir + nToSkip) + 1);
                    }

                    osFileInArchive = pszArchiveInFileName;
                    CPLFree(pszArchiveInFileName);
                }
                else
                    osFileInArchive = "";

                /* Remove trailing slash */
                if (osFileInArchive.size())
                {
                    char lastC = osFileInArchive[strlen(osFileInArchive) - 1];
                    if (lastC == '\\' || lastC == '/')
                        osFileInArchive.resize(strlen(osFileInArchive) - 1);
                }

                return archiveFilename;
            }
            CPLFree(archiveFilename);
        }
        i++;
    }
    return NULL;
}
Ejemplo n.º 10
0
bool ExportPlugin::IsExtension(wxString & ext)
{
   return GetExtension() == wxT("") ||
          GetExtensions().Index(ext, false) != wxNOT_FOUND;
}