#include "sopnamsp.h" #include "machdefs.h" #include #include #include #include #include #include #include "piacmd.h" #include "timing.h" #include "srandgen.h" #include "nobjmgr.h" #include "pistdimgapp.h" // Exemple de module chargeable ds piapp // Classe Drawer de Test class TstSpeedDrw : public PIDrawer { public: TstSpeedDrw(int npt, int nblk); virtual ~TstSpeedDrw(); virtual void Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax); virtual void UpdateLimits(); protected: int _npt, _nblk; double * _mesx; double * _mesy; }; /* --Methode-- */ TstSpeedDrw::TstSpeedDrw(int npt, int nblk) : PIDrawer() { if (nblk > 1) { int q = npt / nblk; npt = q*nblk; } _npt = npt; _nblk = nblk; _mesx = new double[npt]; _mesy = new double[npt]; double dx = 3./npt; for(int i=0; iSelMarker(msz, mrk); */ PrtTim("TstSpeedDrw::Draw() START"); if (_nblk < 2) { for(int i=0; i<_npt; i++) g->DrawMarker(_mesx[i], _mesy[i]); PrtTim("TstSpeedDrw::Draw() Blk=1 done"); } else { int q = _npt/_nblk; PIGrCoord* grx = new PIGrCoord[_nblk]; PIGrCoord* gry = new PIGrCoord[_nblk]; for(int k=0; kDrawMarkers(grx, gry, _nblk); } PrtTim("TstSpeedDrw::Draw() Blk>1 done"); } } // Declaration de la fonction d'activation et de desactivation du module extern "C" { void exmoddrw_init(); void exmoddrw_end(); } // Une classe commande-executor, permettant d'enregistrer de // nouvelles commandes a piapp class exmoddrwExecutor : public CmdExecutor { public: exmoddrwExecutor(); virtual ~exmoddrwExecutor(); // Execute s'occupe de l'execution effective des commandes virtual int Execute(string& keyw, vector& args, string& toks); }; /* --Methode-- */ exmoddrwExecutor::exmoddrwExecutor() { PIACmd * mpiac; NamedObjMgr omg; mpiac = omg.GetImgApp()->CmdInterpreter(); // On enregistre deux nouvelles commandes string hgrp = "ExModDrw"; // commande excmd1 string kw = "tspeeddrw"; string usage = "tspeeddrw npt nblk gr_opt \n" ; mpiac->RegisterCommand(kw, usage, this, hgrp); } /* --Methode-- */ exmoddrwExecutor::~exmoddrwExecutor() { } /* --Methode-- */ int exmoddrwExecutor::Execute(string& kw, vector& tokens, string&) { NamedObjMgr omg; if (kw == "tspeeddrw") { if (tokens.size() < 2) { cout << "Usage: tspeeddrw npt nblk gr_opt" << endl; return(0); } int npt = atoi(tokens[0].c_str()); int nblk = atoi(tokens[1].c_str()); string opt = ""; if (tokens.size() > 2) opt = tokens[2]; TstSpeedDrw* drw = new TstSpeedDrw(npt, nblk); string name = "TstSpeedDrw"; omg.GetImgApp()->DispScDrawer(drw, name, opt); } return(0); } static exmoddrwExecutor * tdrwex = NULL; /* Nouvelle-Fonction */ void exmoddrw_init() { // Fonction d'initialisation du module // Appele par le gestionnaire de modules de piapp (PIACmd::LoadModule()) if (tdrwex) delete tdrwex; tdrwex = new exmoddrwExecutor; } /* Nouvelle-Fonction */ void exmoddrw_end() { // Desactivation du module if (tdrwex) delete tdrwex; tdrwex = NULL; }