Problem saving Ocaf Document

Greetings

I'm trying to save an ocaf document, the problems is that it dosen't display in the disk here is my code:

  statusBar()->showMessage(tr("Salvar archivo"));
    myOccView->clearCommand();
    QFileDialog dialog(this);
    dialog.setFileMode(QFileDialog::AnyFile);
    QStringList exportFormats;
    exportFormats << "*.xml" << "*.cbf";
    dialog.setNameFilters(exportFormats);
    dialog.setAcceptMode(QFileDialog::AcceptSave);
    dialog.setWindowTitle("Save As");
    QString file;
    if (dialog.exec())
        file = dialog.selectedFiles().at(0);
    else return;
    if(!file.endsWith(".xml",Qt::CaseInsensitive)&&!file.endsWith(".cbf",Qt::CaseInsensitive))
    {
        file.append(dialog.selectedNameFilter());
        file.remove("*");
    }
    char* wdf = file.toLatin1().data();
    std::string name8bit = wdf;
    Standard_CString dir=(Standard_CString)(name8bit.c_str());
    if(dialog.selectedNameFilter()=="*.xml")
        m_ocafDoc->ChangeStorageFormat("XmlOcaf");
    if(dialog.selectedNameFilter()=="*.cbf")
        m_ocafDoc->ChangeStorageFormat("BinOcaf");
    else{
        m_ocafDoc->ChangeStorageFormat("MDTV-Standard");
    }
    TCollection_ExtendedString s( (char *) dir );
    cout << "Salvado en: " << s << endl;
    try
    {
        m_ocafApp->SaveAs( m_ocafDoc,s );
    }
    catch(...)
    {
        cout << "El documento no se salvo";
        return;
    }
}

I create an application that inherits form tdocstd_application and i define this methods
 

void TOcaf_Application::Formats(TColStd_SequenceOfExtendedString& Formats)
{
    Formats.Append(TCollection_ExtendedString ("Ocaf-Sample"));
  Formats.Append(TCollection_ExtendedString ("MDTV-Standard"));
  Formats.Append(TCollection_ExtendedString("BinOcaf"));
  Formats.Append(TCollection_ExtendedString("XmlOcaf"));

}

Standard_CString TOcaf_Application::ResourcesName()
{
  return Standard_CString ("Resources");

}

is there something that I'm missing?

 m_ocafApp = new TOcaf_Application();
    m_ocafApp->NewDocument("XmlOcaf",m_ocafDoc);
    m_ocafDoc->SetUndoLimit(10); 

 tpr.New( aLabel, myOccView->getV3d_Viewer());
       tpr.SetInteractiveContext(myOccView->getContext());
       tpr.Find(aLabel,myOccView->getAisContext());

although if I use directly XCAFApp_Application instead of TOcaf_Application it save correctly, what is the direffence of using XCAFApp_Application versus an application the one that inherits from TDocStd_Application, I'm still lacking of experience in this topics why with the first one I could save correctly, could anyone answer this doubts, thanks very much...

Benjamin Bihler's picture

Hi,

just an idea: do you have a file named "Resources"? Is it in the path stored by the environment variable "CSF_PluginDefaults"? If not, then check the documentation of TOcaf_Application::ResourcesName() and the OCAF documentation.

Benjamin

Eduardo Castillo's picture

Problem solved, thanks very much, that was the problem, the file where I have the description of the format had the name of "Plugin" and not Resources thanks...

Benjamin Bihler's picture

You're welcome! :-)