images/plugin_impl/render_result_impl.cpp

Go to the documentation of this file.
00001 /*
00002  * File Name: render_result_impl.cpp
00003  */
00004 
00005 /*
00006  * This file is part of uds-plugin-images.
00007  *
00008  * uds-plugin-images is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * uds-plugin-images is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 /**
00023  * Copyright (C) 2008 iRex Technologies B.V.
00024  * All rights reserved.
00025  */
00026 
00027 #include "render_result_impl.h"
00028 #include "render_settings_impl.h"
00029 #include "image_page.h"
00030 #include "log.h"
00031 
00032 namespace images
00033 {
00034 
00035 utils::ObjectTable<PluginRenderResultImpl> PluginRenderResultImpl::g_instances_table;
00036 
00037 PluginRenderResultImpl::PluginRenderResultImpl(void)
00038 : page(0)        
00039 {   
00040     LOGPRINTF("entry");
00041     
00042     // IPluginUnknown
00043     query_interface = query_interface_impl;
00044     release = release_impl;
00045 
00046     // IPluginRenderResult
00047     get_bitmap_attributes = get_bitmap_attributes_impl;
00048     get_anchor_from_coordinates = get_anchor_from_coordinates_impl;
00049     get_bounding_rectangles_from_range = get_bounding_rectangles_from_range_impl;
00050     get_rendered_range = get_rendered_range_impl;
00051 
00052     // IPluginRenderSettings, no method yet.
00053 
00054 
00055     // IPluginZoom
00056     set_zoom_factor = set_zoom_factor_impl;
00057     get_zoom_factor = get_zoom_factor_impl;
00058 
00059     // IPluginRotation
00060     set_rotation = set_rotation_impl;
00061     get_rotation = get_rotation_impl;
00062 
00063     // Initialize all supported interfaces. In render result, 
00064     // the render settings, zoom and rotation are read only.
00065     g_instances_table.add_interface<IPluginUnknown>(this);
00066     g_instances_table.add_interface<IPluginRenderResult>(this);
00067     g_instances_table.add_interface<IPluginRenderSettings>(this);
00068     g_instances_table.add_interface<IPluginZoom>(this);
00069     g_instances_table.add_interface<IPluginRotation>(this);
00070 }
00071 
00072 PluginRenderResultImpl::~PluginRenderResultImpl(void)
00073 {
00074     LOGPRINTF("entry");
00075     
00076     if (page)
00077     {
00078         page->set_in_use_flag(false);
00079     }
00080     g_instances_table.remove(this);
00081 }
00082     
00083 void PluginRenderResultImpl::set_page(ImagePage * p)
00084 {    
00085     LOGPRINTF("entry %p", p);
00086 
00087     page = p;
00088     if (page)
00089     {
00090         page->set_in_use_flag(true);
00091     }
00092 }
00093 
00094 PluginStatus
00095 PluginRenderResultImpl::query_interface_impl(IPluginUnknown    *thiz,
00096                                              const UDSString   *id, 
00097                                              void              **ptr )
00098 {
00099     LOGPRINTF("entry");
00100 
00101     PluginRenderResultImpl *instance = g_instances_table.get_object(thiz);
00102     if (g_instances_table.query_interface(instance, 
00103                                           id->get_buffer(id), 
00104                                           ptr))
00105     {
00106         return PLUGIN_OK;
00107     }
00108     return PLUGIN_FAIL;
00109 }
00110 
00111 int 
00112 PluginRenderResultImpl::release_impl(IPluginUnknown  *thiz )
00113 {
00114     LOGPRINTF("entry");
00115 
00116     PluginRenderResultImpl *instance = g_instances_table.get_object(thiz);
00117     instance->release_signal.safe_broadcast(instance);
00118     return 0;
00119 }
00120 
00121 PluginStatus 
00122 PluginRenderResultImpl::get_bitmap_attributes_impl(IPluginUnknown *thiz,
00123                                          PluginBitmapAttributes *attributes)
00124 {
00125     LOGPRINTF("entry");
00126 
00127     PluginRenderResultImpl *instance = g_instances_table.get_object(thiz);
00128  
00129     ImagePage *page = instance->page;
00130     if (page)
00131     {
00132         attributes->width = page->attributes().desired_width;
00133         attributes->height = page->attributes().desired_height;
00134         attributes->row_stride = page->attributes().row_stride;
00135         attributes->data = page->attributes().data;
00136         return PLUGIN_OK;
00137     }
00138     return PLUGIN_FAIL;
00139 }
00140 
00141 PluginStatus 
00142 PluginRenderResultImpl::get_anchor_from_coordinates_impl(IPluginUnknown *thiz,
00143                                                  const int      x,
00144                                                  const int      y,
00145                                                  UDSString      *anchor )
00146 {
00147     LOGPRINTF("entry");
00148 
00149     return PLUGIN_FAIL;
00150 }
00151 
00152 IPluginUnknown* 
00153 PluginRenderResultImpl::get_bounding_rectangles_from_range_impl(IPluginUnknown      *thiz,
00154                                                                 const PluginRange   *range)
00155 {
00156     LOGPRINTF("entry");
00157 
00158     return 0;
00159 }
00160 
00161 PluginStatus PluginRenderResultImpl::get_rendered_range_impl(IPluginUnknown *thiz,
00162                                                              PluginRange    *range)
00163 {
00164     LOGPRINTF("entry");
00165 
00166     return PLUGIN_FAIL;
00167 }
00168 
00169 PluginStatus PluginRenderResultImpl::set_zoom_factor_impl(IPluginUnknown* thiz,
00170                                                           const float zoom_factor )
00171 {
00172     LOGPRINTF("entry");
00173 
00174     return PLUGIN_FAIL;
00175 }
00176 
00177 float 
00178 PluginRenderResultImpl::get_zoom_factor_impl(IPluginUnknown* thiz )
00179 {
00180     LOGPRINTF("entry");
00181 
00182     PluginRenderResultImpl *instance = g_instances_table.get_object(thiz);
00183     if (instance->page)
00184     {
00185         return static_cast<float>(instance->page->attributes().zoom);
00186     }
00187     else
00188     {
00189         return 0;
00190     }
00191 }
00192 
00193 PluginStatus 
00194 PluginRenderResultImpl::set_rotation_impl(IPluginUnknown               *thiz,
00195                                           const PluginRotationDegree   rotation )
00196 {
00197     LOGPRINTF("entry");
00198 
00199     return PLUGIN_FAIL;
00200 }
00201 
00202 PluginRotationDegree 
00203 PluginRenderResultImpl::get_rotation_impl(IPluginUnknown  *thiz )
00204 {
00205     LOGPRINTF("entry");
00206 
00207     PluginRenderResultImpl *instance = g_instances_table.get_object(thiz);
00208     if (instance->page)
00209     {
00210         return static_cast<PluginRotationDegree>(
00211                 instance->page->attributes().rotation);
00212     }
00213     else
00214     {
00215         return Clockwise_Degrees_0;
00216     }
00217 
00218 }
00219 
00220 }
00221 
00222 
Generated by  doxygen 1.6.2-20100208