All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Member Functions | Static Public Member Functions
SciFigs::SciFigsGlobal Class Reference

Brief description of class still missing. More...

#include <SciFigsGlobal.h>

Inheritance diagram for SciFigs::SciFigsGlobal:
QGpCoreTools::GlobalObject

List of all members.

Public Member Functions

 SciFigsGlobal ()
 ~SciFigsGlobal ()

Static Public Member Functions

static void footprint (QPainter &p, double dotpercm, int w, int h)
static void initPlugins (QSettings *reg, bool debug)
static bool isInitialized ()
static QSettings * pluginSettings ()
static double screenResolution ()

Detailed Description

Brief description of class still missing.

Full description of class still missing


Constructor & Destructor Documentation

You must create this object to initialize the library. Application must be created before calling this function.

References QGpCoreTools::endl(), SciFigs::GraphContent::init(), initPlugins(), SciFigs::SciFigsPlugin::loadPlugins(), pluginSettings(), and TRACE.

{
  TRACE;
  // QApplication must exist
  ASSERT(QApplication::instance());
  if( !Application::instance()->hasGui()) {
    App::stream() << "SciFigs library requires a running X server" << endl;
    exit(2);
  }

  // Estimate the screen resolution
  QPaintDevice * p=qApp->desktop();
  _screenResolution=(double) p->height()/(double) p->heightMM() * 10.0;

  // Init statics used by GraphContent (coordinate tips, paint engine,...)
  GraphContent::init();

  // Load plugins
  QSettings * reg=pluginSettings();
  reg->beginGroup( "Plugins" );
  if( !reg->contains( "pluginList" )) {
    initPlugins(reg, false);
  } else {
    QStringList libs=reg->value( "pluginList" ).toStringList();
    if( ! SciFigsPlugin::loadPlugins(libs) ) {
      initPlugins(reg, false);
    }
  }
  delete reg;
}

References SciFigs::GraphContent::clear(), and TRACE.

{
  TRACE;
  GraphContent::clear();
  _screenResolution=0.0;
}

Member Function Documentation

void SciFigs::SciFigsGlobal::footprint ( QPainter &  p,
double  dotpercm,
int  w,
int  h 
) [static]

Draw a small footprint (for all produced images). w and h are the width and height of the print area. dotpercm is the resolution of the medium.

References MAX_INT, screenResolution(), and TRACE.

{
  TRACE;
  static const QString line1("SciFigs library");
  static const QString line2("by geopsy.org");
  QRect r;
  int spacing=(int) round(dotpercm*0.1);
  p.save();
  p.setOpacity(0.25);
  p.setRenderHints(QPainter::TextAntialiasing);
  QPainterPath tp;
  double factor=dotpercm/SciFigsGlobal::screenResolution();
  QFont f("Comic Sans MS", (int)round(factor*10), QFont::Black, true);
  p.setFont(f);
  r=p.boundingRect(0, 0, MAX_INT, MAX_INT, 0, line1);
  tp.addText(QPoint(w-r.width()-spacing, h-r.height()+spacing) , f, line1);
  r=p.boundingRect(0, 0, MAX_INT, MAX_INT, 0, line2);
  tp.addText(QPoint(w-r.width()-spacing, h-spacing) , f, line2);
  p.setPen(Qt::gray);
  p.setBrush(Qt::white);
  p.drawPath(tp);
  p.restore();
}
void SciFigs::SciFigsGlobal::initPlugins ( QSettings *  reg,
bool  debug 
) [static]

After first installion, make sure that the plugin path point to lib install directory so that all plugins provided with installation package are directly available.

Add current directory and install lib directory to search paths and search for plugins

References QGpCoreTools::PackageInfo::dllDir(), SciFigs::SciFigsPlugin::getPluginList(), SciFigs::SciFigsPlugin::loadPlugins(), and TRACE.

Referenced by SciFigsGlobal().

{
  TRACE;
  QStringList paths;
#ifdef Q_WS_MAC
  QString dll="/Library/Geopsy.org/plugins";
#else
  const PackageInfo * info=PackageInfo::package("SciFigs");
  ASSERT (info);
  QString dll=info->dllDir();
#endif
  QDir d(dll);
  if(d.exists()) paths << dll;
  reg->setValue( "Paths", paths);

  QStringList libs=File::getLibList(paths);
  bool ok;
  QStringList plugins=SciFigsPlugin::getPluginList(libs, ok, debug);
  reg->setValue( "pluginList", plugins);
  SciFigsPlugin::loadPlugins(plugins, debug);
}
static bool SciFigs::SciFigsGlobal::isInitialized ( ) [inline, static]
{return _screenResolution > 0.0;}
QSettings * SciFigs::SciFigsGlobal::pluginSettings ( ) [static]

Open a QSettings that point to SciFigs general settings.

Do not forget to delete the object when no longer necessary

References TRACE.

Referenced by SciFigs::SciFigsPreferences::savePluginList(), SciFigsGlobal(), and SciFigs::SciFigsPreferences::SciFigsPreferences().

{
  TRACE;
  QSettings * reg;
#ifdef Q_WS_MAC
  reg=new QSettings(qApp->organizationDomain(), "SciFigs");
#else
  reg=new QSettings(qApp->organizationName(), "SciFigs");
#endif
  reg->beginGroup("Plugins");
  reg->beginGroup(SCIFIGS_VERSION_TYPE);
  return reg;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines