ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
FileIOFilter Class Reference

Generic file I/O filter. More...

#include <FileIOFilter.h>

Inheritance diagram for FileIOFilter:

Classes

struct  FilterInfo
 
struct  LoadParameters
 Generic loading parameters. More...
 
struct  SaveParameters
 Generic saving parameters. More...
 

Public Types

enum  FilterFeature {
  NoFeatures = 0x0000 , Import = 0x00001 , Export = 0x0002 , BuiltIn = 0x0004 ,
  DynamicInfo = 0x0008
}
 
using Shared = QSharedPointer< FileIOFilter >
 Shared type. More...
 
using FilterContainer = std::vector< FileIOFilter::Shared >
 Type of a I/O filters container. More...
 

Public Member Functions

virtual ~FileIOFilter ()=default
 
bool importSupported () const
 Returns whether this I/O filter can import files. More...
 
bool exportSupported () const
 Returns whether this I/O filter can export files. More...
 
const QStringList & getFileFilters (bool onImport) const
 Returns the file filter(s) for this I/O filter. More...
 
QString getDefaultExtension () const
 Returns the default file extension. More...
 
virtual CC_FILE_ERROR loadFile (const QString &filename, ccHObject &container, LoadParameters &parameters)
 Loads one or more entities from a file. More...
 
virtual CC_FILE_ERROR saveToFile (ccHObject *entity, const QString &filename, const SaveParameters &parameters)
 Saves an entity (or a group of) to a file. More...
 
virtual bool canSave (CV_CLASS_ENUM type, bool &multiple, bool &exclusive) const
 Returns whether this I/O filter can save the specified type of entity. More...
 
virtual void unregister ()
 Called when the filter is unregistered. More...
 

Static Public Member Functions

static QStringList ImportFilterList ()
 
static ccHObjectLoadFromFile (const QString &filename, LoadParameters &parameters, Shared filter, CC_FILE_ERROR &result)
 Loads one or more entities from a file with a known filter. More...
 
static ccHObjectLoadFromFile (const QString &filename, LoadParameters &parameters, CC_FILE_ERROR &result, const QString &fileFilter=QString())
 Loads one or more entities from a file with known type. More...
 
static CC_FILE_ERROR SaveToFile (ccHObject *entities, const QString &filename, const SaveParameters &parameters, Shared filter)
 
static CC_FILE_ERROR SaveToFile (ccHObject *entities, const QString &filename, const SaveParameters &parameters, const QString &fileFilter)
 
static bool HandleGlobalShift (const CCVector3d &P, CCVector3d &Pshift, bool &preserveCoordinateShift, LoadParameters &loadParameters, bool useInputCoordinatesShiftIfPossible=false)
 Shortcut to the ecvGlobalShiftManager mechanism specific for files. More...
 
static void DisplayErrorMessage (CC_FILE_ERROR err, const QString &action, const QString &filename)
 Displays (to console) the message corresponding to a given error code. More...
 
static bool CheckForSpecialChars (const QString &filename)
 Returns whether special characters are present in the input string. More...
 
static void ResetSesionCounter ()
 
static unsigned IncreaseSesionCounter ()
 
static void Register (Shared filter)
 Registers a new filter. More...
 
static Shared GetFilter (const QString &fileFilter, bool onImport)
 Returns the filter corresponding to the given 'file filter'. More...
 
static Shared FindBestFilterForExtension (const QString &ext)
 Returns the best filter (presumably) to open a given file extension. More...
 
static const FilterContainerGetFilters ()
 Returns the set of all registered filters. More...
 
static void UnregisterAll ()
 Unregisters all filters. More...
 

Protected Member Functions

 FileIOFilter (const FilterInfo &info)
 
void setImportExtensions (const QStringList &extensions)
 
void setImportFileFilterStrings (const QStringList &filterStrings)
 
void setExportFileFilterStrings (const QStringList &filterStrings)
 

Static Protected Attributes

static constexpr float DEFAULT_PRIORITY = 25.0f
 

Detailed Description

Generic file I/O filter.

Gives static access to file loader. Must be implemented by any specific I/O filter.

Definition at line 46 of file FileIOFilter.h.

Member Typedef Documentation

◆ FilterContainer

Type of a I/O filters container.

Definition at line 284 of file FileIOFilter.h.

◆ Shared

using FileIOFilter::Shared = QSharedPointer<FileIOFilter>

Shared type.

Definition at line 97 of file FileIOFilter.h.

Member Enumeration Documentation

◆ FilterFeature

Enumerator
NoFeatures 
Import 
Export 
BuiltIn 
DynamicInfo 

Definition at line 299 of file FileIOFilter.h.

Constructor & Destructor Documentation

◆ ~FileIOFilter()

virtual FileIOFilter::~FileIOFilter ( )
virtualdefault

◆ FileIOFilter()

FileIOFilter::FileIOFilter ( const FilterInfo info)
explicitprotected

Definition at line 52 of file FileIOFilter.cpp.

References DynamicInfo, and FileIOFilter::FilterInfo::features.

Member Function Documentation

◆ canSave()

virtual bool FileIOFilter::canSave ( CV_CLASS_ENUM  type,
bool &  multiple,
bool &  exclusive 
) const
inlinevirtual

Returns whether this I/O filter can save the specified type of entity.

Parameters
typeentity type
multiplewhether the filter can save multiple instances of this entity at once
exclusivewhether the filter can only save this type of entity if selected or if it can be mixed with other types
Returns
whether the entity type can be saved

Reimplemented in RDBFilter, LASFilter, LasIOFilter, LASFWFFilter, FBXFilter, E57Filter, DRCFilter, SimpleBinFilter, MascaretFilter, MAFilter, HeightProfileFilter, SinusxFilter, SalomeHydroFilter, PVFilter, PovFilter, PNFilter, VTKFilter, STLFilter, PlyFilter, OFFFilter, ObjFilter, ImageFileFilter, DxfFilter, DepthMapFileFilter, BinFilter, AsciiFilter, PcdFilter, and IoAbstractLoader.

Definition at line 158 of file FileIOFilter.h.

References type.

◆ CheckForSpecialChars()

bool FileIOFilter::CheckForSpecialChars ( const QString &  filename)
static

Returns whether special characters are present in the input string.

Definition at line 505 of file FileIOFilter.cpp.

References filename.

Referenced by IcmFilter::LoadCalibratedImages(), DxfFilter::loadFile(), IcmFilter::loadFile(), FBXFilter::loadFile(), DxfFilter::saveToFile(), FBXFilter::saveToFile(), and DepthMapFileFilter::saveToFile().

◆ DisplayErrorMessage()

◆ exportSupported()

bool FileIOFilter::exportSupported ( ) const

Returns whether this I/O filter can export files.

Definition at line 65 of file FileIOFilter.cpp.

References Export, and FileIOFilter::FilterInfo::features.

◆ FindBestFilterForExtension()

FileIOFilter::Shared FileIOFilter::FindBestFilterForExtension ( const QString &  ext)
static

Returns the best filter (presumably) to open a given file extension.

Definition at line 228 of file FileIOFilter.cpp.

References s_ioFilters.

Referenced by cloudViewer::io::AutoReadEntity(), cloudViewer::io::AutoWriteEntity(), IcmFilter::loadFile(), PovFilter::loadFile(), and LoadFromFile().

◆ getDefaultExtension()

QString FileIOFilter::getDefaultExtension ( ) const

Returns the default file extension.

Definition at line 77 of file FileIOFilter.cpp.

References FileIOFilter::FilterInfo::defaultExtension.

◆ getFileFilters()

const QStringList & FileIOFilter::getFileFilters ( bool  onImport) const

Returns the file filter(s) for this I/O filter.

E.g. 'ASCII file (*.asc)'

Parameters
onImportwhether the requested filters are for import or export
Returns
list of filters

Definition at line 69 of file FileIOFilter.cpp.

References FileIOFilter::FilterInfo::exportFileFilterStrings, and FileIOFilter::FilterInfo::importFileFilterStrings.

◆ GetFilter()

FileIOFilter::Shared FileIOFilter::GetFilter ( const QString &  fileFilter,
bool  onImport 
)
static

Returns the filter corresponding to the given 'file filter'.

Definition at line 212 of file FileIOFilter.cpp.

References s_ioFilters.

Referenced by LoadFromFile(), CommandLoadLASFWF::process(), ccCommandLineParser::saveClouds(), ccCommandLineParser::saveMeshes(), and SaveToFile().

◆ GetFilters()

const FileIOFilter::FilterContainer & FileIOFilter::GetFilters ( )
static

◆ HandleGlobalShift()

bool FileIOFilter::HandleGlobalShift ( const CCVector3d P,
CCVector3d Pshift,
bool &  preserveCoordinateShift,
LoadParameters loadParameters,
bool  useInputCoordinatesShiftIfPossible = false 
)
static

Shortcut to the ecvGlobalShiftManager mechanism specific for files.

Parameters
[in]Psample point (typically the first loaded)
[out]Pshiftglobal shift
[out]preserveCoordinateShiftwhether shift sould be preserved on save
[in]loadParametersloading parameters
[in]useInputCoordinatesShiftIfPossiblewhether to use the input 'PShift' vector if possible
Returns
whether global shift has been defined/enabled

Definition at line 509 of file FileIOFilter.cpp.

References FileIOFilter::LoadParameters::coordinatesShift, FileIOFilter::LoadParameters::coordinatesShiftEnabled, ecvGlobalShiftManager::Handle(), FileIOFilter::LoadParameters::preserveShiftOnSave, and FileIOFilter::LoadParameters::shiftHandlingMode.

Referenced by FromFbxMesh(), GetGlobalShift(), STLFilter::loadASCIIFile(), STLFilter::loadBinaryFile(), LoadCloud(), AsciiFilter::loadCloudFromFormatedAsciiStream(), ObjFilter::loadFile(), OFFFilter::loadFile(), PTXFilter::loadFile(), VTKFilter::loadFile(), SalomeHydroFilter::loadFile(), SinusxFilter::loadFile(), SimpleBinFilter::loadFile(), LASFWFFilter::loadFile(), LASFilter::loadFile(), LoadScan(), and vertex_cb().

◆ ImportFilterList()

QStringList FileIOFilter::ImportFilterList ( )
static

Get a list of all the available importer filter strings for use in a drop down menu. Includes "All (*.)" as the first item in the list.

Definition at line 241 of file FileIOFilter.cpp.

References s_ioFilters.

◆ importSupported()

bool FileIOFilter::importSupported ( ) const

Returns whether this I/O filter can import files.

Definition at line 61 of file FileIOFilter.cpp.

References FileIOFilter::FilterInfo::features, and Import.

◆ IncreaseSesionCounter()

unsigned FileIOFilter::IncreaseSesionCounter ( )
static

Indicates to the I/O filters that a new loading/saving action has started

Returns
the updated session counter

Definition at line 142 of file FileIOFilter.cpp.

References s_sessionCounter.

Referenced by cloudViewer::io::AutoReadEntity(), and LoadFromFile().

◆ loadFile()

virtual CC_FILE_ERROR FileIOFilter::loadFile ( const QString &  filename,
ccHObject container,
LoadParameters parameters 
)
inlinevirtual

Loads one or more entities from a file.

This method must be implemented by children classes.

Parameters
filenamefile to load
containercontainer to store loaded entities
parametersgeneric loading parameters
Returns
error

Reimplemented in IoAbstractLoader, STEPFilter, RDBFilter, LASFilter, LasIOFilter, LASFWFFilter, FBXFilter, E57Filter, DRCFilter, SimpleBinFilter, PDMSFilter, SoiFilter, SinusxFilter, SalomeHydroFilter, PVFilter, PovFilter, PNFilter, IcmFilter, BundlerFilter, VTKFilter, STLFilter, PTXFilter, PlyFilter, OFFFilter, ObjFilter, ImageFileFilter, DxfFilter, BinFilter, AsciiFilter, PcdFilter, PhotoScanFilter, and CSVMatrixFilter.

Definition at line 124 of file FileIOFilter.h.

References CC_FERR_NOT_IMPLEMENTED, and filename.

◆ LoadFromFile() [1/2]

ccHObject * FileIOFilter::LoadFromFile ( const QString &  filename,
LoadParameters parameters,
CC_FILE_ERROR result,
const QString &  fileFilter = QString() 
)
static

Loads one or more entities from a file with known type.

Shortcut to the other version of FileIOFilter::LoadFromFile

Parameters
filenamefilename
parametersgeneric loading parameters
[out]resultfile error code
fileFilterinput filter 'file filter' (if empty, the best I/O filter will be guessed from the file extension)
Returns
loaded entities (or 0 if an error occurred)

Definition at line 334 of file FileIOFilter.cpp.

References CC_FERR_CONSOLE_ERROR, CVLog::Error(), filename, FindBestFilterForExtension(), GetFilter(), LoadFromFile(), and result.

◆ LoadFromFile() [2/2]

ccHObject * FileIOFilter::LoadFromFile ( const QString &  filename,
LoadParameters parameters,
Shared  filter,
CC_FILE_ERROR result 
)
static

◆ Register()

void FileIOFilter::Register ( Shared  filter)
static

Registers a new filter.

Definition at line 167 of file FileIOFilter.cpp.

References s_ioFilters, and CVLog::Warning().

Referenced by ccPluginManager::loadPlugins().

◆ ResetSesionCounter()

void FileIOFilter::ResetSesionCounter ( )
static

Indicates to the I/O filters that a new loading/saving session has started (for "Apply all" buttons for instance)

Definition at line 140 of file FileIOFilter.cpp.

References s_sessionCounter.

Referenced by MainWindow::addToDB(), cloudViewer::io::AutoReadEntity(), cloudViewer::io::AutoWriteEntity(), and masc::Tools::LoadFile().

◆ SaveToFile() [1/2]

CC_FILE_ERROR FileIOFilter::SaveToFile ( ccHObject entities,
const QString &  filename,
const SaveParameters parameters,
const QString &  fileFilter 
)
static

Saves an entity (or a group of) to a specific file thanks to a given filter Shortcut to the other version of FileIOFilter::SaveToFile

Parameters
entitiesentity to save (can be a group of other entities)
filenamefilename
parameterssaving parameters
fileFilteroutput filter 'file filter'
Returns
error type (if any)

Definition at line 408 of file FileIOFilter.cpp.

References CC_FERR_BAD_ARGUMENT, CC_FERR_UNKNOWN_FILE, CVLog::Error(), filename, GetFilter(), and SaveToFile().

◆ SaveToFile() [2/2]

CC_FILE_ERROR FileIOFilter::SaveToFile ( ccHObject entities,
const QString &  filename,
const SaveParameters parameters,
Shared  filter 
)
static

Saves an entity (or a group of) to a specific file thanks to a given filter Shortcut to FileIOFilter::saveFile

Parameters
entitiesentity to save (can be a group of other entities)
filenamefilename
parameterssaving parameters
filteroutput filter
Returns
error type (if any)

Definition at line 377 of file FileIOFilter.cpp.

References CC_FERR_BAD_ARGUMENT, CC_FERR_CONSOLE_ERROR, CC_FERR_NO_ERROR, DisplayErrorMessage(), filename, CVLog::Print(), result, and CVLog::Warning().

Referenced by define_qcc_io(), ccCommandLineParser::exportEntity(), cvSelectionExporter::saveObjectToFileWithDialog(), SaveToFile(), and PovFilter::saveToFile().

◆ saveToFile()

virtual CC_FILE_ERROR FileIOFilter::saveToFile ( ccHObject entity,
const QString &  filename,
const SaveParameters parameters 
)
inlinevirtual

Saves an entity (or a group of) to a file.

This method must be implemented by children classes.

Parameters
entityentity (or group of) to save
filenamefilename
parametersgeneric saving parameters
Returns
error

Reimplemented in LASFilter, LasIOFilter, LASFWFFilter, FBXFilter, E57Filter, DRCFilter, SimpleBinFilter, MascaretFilter, MAFilter, HeightProfileFilter, SinusxFilter, SalomeHydroFilter, PVFilter, PovFilter, PNFilter, VTKFilter, STLFilter, PlyFilter, OFFFilter, ObjFilter, ImageFileFilter, DxfFilter, DepthMapFileFilter, BinFilter, AsciiFilter, and PcdFilter.

Definition at line 141 of file FileIOFilter.h.

References CC_FERR_NOT_IMPLEMENTED, and filename.

◆ setExportFileFilterStrings()

void FileIOFilter::setExportFileFilterStrings ( const QStringList &  filterStrings)
protected

Allow export filter strings to be set after construction (e.g. for ImageFileFilter & QImageReader::supportedImageFormats())

Definition at line 90 of file FileIOFilter.cpp.

References FileIOFilter::FilterInfo::exportFileFilterStrings.

◆ setImportExtensions()

void FileIOFilter::setImportExtensions ( const QStringList &  extensions)
protected

Allow import extensions to be set after construction (e.g. for ImageFileFilter & QImageReader::supportedImageFormats())

Definition at line 81 of file FileIOFilter.cpp.

References FileIOFilter::FilterInfo::importExtensions.

◆ setImportFileFilterStrings()

void FileIOFilter::setImportFileFilterStrings ( const QStringList &  filterStrings)
protected

Allow import filter strings to be set after construction (e.g. for ImageFileFilter & QImageReader::supportedImageFormats())

Definition at line 85 of file FileIOFilter.cpp.

References FileIOFilter::FilterInfo::importFileFilterStrings.

◆ unregister()

virtual void FileIOFilter::unregister ( )
inlinevirtual

Called when the filter is unregistered.

Does nothing by default

Definition at line 296 of file FileIOFilter.h.

◆ UnregisterAll()

void FileIOFilter::UnregisterAll ( )
static

Unregisters all filters.

Should be called at the end of the application

Definition at line 204 of file FileIOFilter.cpp.

References s_ioFilters.

Referenced by main().

Member Data Documentation

◆ DEFAULT_PRIORITY


The documentation for this class was generated from the following files: