File: CGAL_Lab_io_plugin_interface.h

package info (click to toggle)
cgal 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 144,912 kB
  • sloc: cpp: 810,858; ansic: 208,477; sh: 493; python: 411; makefile: 286; javascript: 174
file content (92 lines) | stat: -rw-r--r-- 3,859 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright (c) 2009,2010,2012  GeometryFactory Sarl (France)
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
//
// $URL: https://github.com/CGAL/cgal/blob/v6.1/Three/include/CGAL/Three/CGAL_Lab_io_plugin_interface.h $
// $Id: include/CGAL/Three/CGAL_Lab_io_plugin_interface.h b26b07a1242 $
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
//
//
// Author(s)     : Laurent RINEAU
//! \file CGAL_Lab_io_plugin_interface.h
#ifndef LAB_DEMO_IO_PLUGIN_INTERFACE_H
#define LAB_DEMO_IO_PLUGIN_INTERFACE_H

#include <CGAL/license/Three.h>


#include <QFileInfo>
#include <QStringList>
#include <QtPlugin>
class QMainWindow;
class Messages_interface;
namespace CGAL{
namespace Three {
class Scene_item;
class Scene_interface;
  /*!
   * This class provides a base for creating a new IO plugin.
   */
class CGAL_Lab_io_plugin_interface
{
public:
  //! \brief initializes the plugin
  //! This function is called in the constructor of the MainWindow.
  //! Whatever initialization the plugin needs can be done here. Default
  //! behavior is to do nothing.
  virtual void init(){}
  //!Returns the name of the plugin
  //!It is used by the loading system.
  virtual QString name() const = 0;
  virtual ~CGAL_Lab_io_plugin_interface() {}
  /*! The filters for the names of the files that can be used
   * by the plugin.
   * Example : to filter OFF files : return "OFF files (*.off)"
*/
  virtual QString nameFilters() const = 0;
  //!Returns only the filters used for saving. The default is `nameFilters()`.
  //! You must override this function to change its behavior.
  virtual QString saveNameFilters() const {return nameFilters();}
  //!Returns only the filters used for loading. The default is `nameFilters()`.
  //! You must override this function to change its behavior.
  //! If multiple plugins have the same load filters, only once will be kept,
  //! so be careful not to use one that already exists.
  virtual QString loadNameFilters() const {return nameFilters();}

  //! Specifies if the io_plugin is able to load an item or not.
  //! This must be overridden.
  virtual bool canLoad(QFileInfo fileinfo) const = 0;
  //! Loads one or more item(s) from a file. `ok` is `true` if the loading
  //! was successful, `false` otherwise.
  //! New items will be added to the scene if `add_to_scene` is `true`.
  //! You don't want that when you reload an item, for example,
  //! as it will be added at some other point of the process.
  //! This must be overridden.
  virtual QList<Scene_item*> load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) = 0;
  //!Specifies if the io_plugin can save the item or not.
  //!This must be overridden.
  virtual bool canSave(const Scene_item*) = 0;
  //!Saves one or more items in the file corresponding to the path
  //!contained in fileinfo. Returns false if error.
  //! This must be overridden.
  //! @attention When a file is successfully saved, it must be removed from the
  //! list.
  virtual bool save(QFileInfo fileinfo,QList<CGAL::Three::Scene_item*>& ) = 0;

  //! If this returns `true`, then the loader will be chosen as default in the
  //! list of available loaders when saving a file, which means it will be the
  //! first in the list.
  virtual bool isDefaultLoader(const Scene_item*) const { return false; }
  //! If this returns `true`, then the loader will be chosen as default in the
  //! list of available loaders when loading a file, which means it will be the
  //! first in the list.
  //! @param name is the extension without the dot (e.g. "off" for a .off file)
  virtual bool isDefaultLoader(const QString& name) const { Q_UNUSED(name); return false; }
};
}
}
Q_DECLARE_INTERFACE(CGAL::Three::CGAL_Lab_io_plugin_interface,
                    "com.geometryfactory.CGALLab.IOPluginInterface/1.90")

#endif // LAB_DEMO_IO_PLUGIN_INTERFACE_H