/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ //TODO get initial state before newob to know if we have to destroy the compositor or not struct PlugCompositor = [ COMP_instance : PInstance, COMP_compositor : S, COMP_scheme : S, COMP_viewport : SO3_VIEWPORT, COMP_bEnable : I, COMP_bState : I ]mkPlugCompositor;; fun deleteOb(inst, compstr)= if compstr.COMP_bEnable && compstr.COMP_bState then nil else if !compstr.COMP_bEnable && compstr.COMP_bState then SO3ViewportRemoveCompositor compstr.COMP_viewport compstr.COMP_compositor else if compstr.COMP_bEnable && !compstr.COMP_bState then SO3ViewportAddCompositor compstr.COMP_viewport compstr.COMP_compositor compstr.COMP_scheme else nil; 0;; fun enableCompositor(inst, from, action, param, rep, compstr)= SO3ViewportAddCompositor compstr.COMP_viewport compstr.COMP_compositor compstr.COMP_scheme; set compstr.COMP_bState = 1; 0;; fun disableCompositor(inst, from, action, param, rep, compstr)= let c3dXsession -> sessionstr in SO3ViewportRemoveCompositor compstr.COMP_viewport compstr.COMP_compositor; set compstr.COMP_bState = 0; 0;; fun newOb(inst)= let (getPluginInstanceParam inst "compositor") -> compositor in let atoi (getPluginInstanceParam inst "init") -> init in let (V3DgetDefaultViewport (V3DgetSessionView c3dXsession)) -> viewportstr in let V3DgetCompositorScheme viewportstr compositor -> scheme in let isStringInList (SO3ViewportListEnabledCompositors viewportstr.V3D_viewport) compositor -> enable in let mkPlugCompositor [inst compositor scheme viewportstr.V3D_viewport enable init] -> compstr in ( if init && !enable then SO3ViewportAddCompositor compstr.COMP_viewport compstr.COMP_compositor compstr.COMP_scheme else if !init && enable then SO3ViewportRemoveCompositor compstr.COMP_viewport compstr.COMP_compositor else nil; PluginRegisterAction inst "Enable" mkfun6 @enableCompositor compstr; PluginRegisterAction inst "Disable" mkfun6 @disableCompositor compstr; setPluginInstanceCbDel inst mkfun2 @deleteOb compstr; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;