예제 #1
0
/**
 * Calls the import method of the filter responsible for the format
 * of the given file.
 *
 * @param graphic The container to which we will add
 *        entities. Usually that's an RS_Graphic entity but
 *        it can also be a polyline, text, ...
 * @param file Path and name of the file to import.
 */
bool RS_FileIO::fileImport(RS_Graphic& graphic, const QString& file,
        RS2::FormatType type) {

    RS_DEBUG->print("Trying to import file '%s'...", file.toLatin1().data());

    RS2::FormatType t;
    if (type == RS2::FormatUnknown) {
        t = detectFormat(file);
    }
    else {
        t = type;
    }

    if (RS2::FormatUnknown != t) {
        std::unique_ptr<RS_FilterInterface> filter(getImportFilter(file, t));
        if (filter.get() != NULL ){
            return filter->fileImport(graphic, file, t);
        }
        RS_DEBUG->print(RS_Debug::D_WARNING,
                        "RS_FileIO::fileImport: failed to import file: %s",
                        file.toLatin1().data());
    }
    else {
        RS_DEBUG->print(RS_Debug::D_WARNING,
                        "RS_FileIO::fileImport: failed to detect file format: %s",
                        file.toLatin1().data());
    }

    return false;
}
예제 #2
0
/**
 * Calls the import method of the filter responsible for the format
 * of the given file.
 *
 * @param graphic The container to which we will add
 *        entities. Usually that's an RS_Graphic entity but
 *        it can also be a polyline, text, ...
 * @param file Path and name of the file to import.
 */
bool RS_FileIO::fileImport(RS_Graphic& graphic, const QString& file,
        RS2::FormatType type) {

    RS_DEBUG->print("Trying to import file '%s'...", file.toLatin1().data());

    RS2::FormatType t;
    if (type == RS2::FormatUnknown) {
        t = detectFormat(file);
    }
    else {
        t = type;
    }

    if (RS2::FormatUnknown != t) {
		std::unique_ptr<RS_FilterInterface>&& filter(getImportFilter(file, t));
		if (filter){
#ifdef DWGSUPPORT
            if (file.endsWith(".dwg",Qt::CaseInsensitive)){
                QMessageBox::StandardButton sel = QMessageBox::warning(qApp->activeWindow(), QObject::tr("Warning"),
                                                  QObject::tr("experimental, save your work first.\nContinue?"),
                                                  QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::NoButton);
                if (sel == QMessageBox::Cancel)
                    return false;
            }
#endif
            return filter->fileImport(graphic, file, t);
        }
        RS_DEBUG->print(RS_Debug::D_WARNING,
                        "RS_FileIO::fileImport: failed to import file: %s",
                        file.toLatin1().data());
    }
    else {
        RS_DEBUG->print(RS_Debug::D_WARNING,
                        "RS_FileIO::fileImport: failed to detect file format: %s",
                        file.toLatin1().data());
    }

    return false;
}