Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 4f45e7bdfd4a5ff17f5f8eaab90d017f > files > 1399

albumshaper-2.1-6mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>AlbumShaper: panningPreviewInterface.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>panningPreviewInterface.cpp</h1><a href="panningPreviewInterface_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//==============================================</span>
<a name="l00002"></a>00002 <span class="comment">//  copyright            : (C) 2003-2005 by Will Stokes</span>
<a name="l00003"></a>00003 <span class="comment">//==============================================</span>
<a name="l00004"></a>00004 <span class="comment">//  This program is free software; you can redistribute it </span>
<a name="l00005"></a>00005 <span class="comment">//  and/or modify it under the terms of the GNU General </span>
<a name="l00006"></a>00006 <span class="comment">//  Public License as published by the Free Software </span>
<a name="l00007"></a>00007 <span class="comment">//  Foundation; either version 2 of the License, or  </span>
<a name="l00008"></a>00008 <span class="comment">//  (at your option) any later version.         </span>
<a name="l00009"></a>00009 <span class="comment">//==============================================</span>
<a name="l00010"></a>00010 
<a name="l00011"></a>00011 <span class="comment">//Projectwide includes</span>
<a name="l00012"></a>00012 <span class="preprocessor">#include "<a class="code" href="panningPreviewInterface_8h.html">panningPreviewInterface.h</a>"</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="comment">//==============================================</span>
<a name="l00015"></a><a class="code" href="classPanningPreviewInterface.html#774581c6fdb7939ed31f9d7cd9ddb4b3">00015</a> <a class="code" href="classPanningPreviewInterface.html#774581c6fdb7939ed31f9d7cd9ddb4b3" title="Creates layout.">PanningPreviewInterface::PanningPreviewInterface</a>( QString imageFilename, 
<a name="l00016"></a>00016                                                   <a class="code" href="classQWidget.html">QWidget</a> *parent, <span class="keyword">const</span> <span class="keywordtype">char</span>* name ) : 
<a name="l00017"></a>00017                                                   <a class="code" href="classSplitViewInterface.html" title="A split view interface provides a means to show before and after versions of an image...">SplitViewInterface</a> (parent, name )
<a name="l00018"></a>00018 {
<a name="l00019"></a>00019   <span class="comment">//load full size image</span>
<a name="l00020"></a>00020   <a class="code" href="classPanningPreviewInterface.html#e9d723a64dc61d1913635a135b538c00" title="Full size image.">fullSizeImage</a> = QImage( imageFilename );
<a name="l00021"></a>00021           
<a name="l00022"></a>00022   <span class="comment">//a 0-width selection is invalid and prevents </span>
<a name="l00023"></a>00023   <span class="comment">//resize events from triggering painting</span>
<a name="l00024"></a>00024   <span class="comment">//until the true selection region is set</span>
<a name="l00025"></a>00025   <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.setWidth( 0 );
<a name="l00026"></a>00026 }
<a name="l00027"></a>00027 <span class="comment">//==============================================</span>
<a name="l00028"></a><a class="code" href="classPanningPreviewInterface.html#181e8b15629fb913e41d7476df90745e">00028</a> QSize <a class="code" href="classPanningPreviewInterface.html#181e8b15629fb913e41d7476df90745e">PanningPreviewInterface::sizeHint</a>()<span class="keyword"> const</span>
<a name="l00029"></a>00029 <span class="keyword"></span>{
<a name="l00030"></a>00030   <span class="comment">//subjetively chosen default size :)</span>
<a name="l00031"></a>00031   <span class="keywordflow">return</span> QSize( 500, 400 );
<a name="l00032"></a>00032 }
<a name="l00033"></a>00033 <span class="comment">//==============================================</span>
<a name="l00034"></a><a class="code" href="classPanningPreviewInterface.html#8eca66ff583ebe33a194864a802f1dcd">00034</a> QSize <a class="code" href="classPanningPreviewInterface.html#8eca66ff583ebe33a194864a802f1dcd">PanningPreviewInterface::paintingSize</a>()
<a name="l00035"></a>00035 {
<a name="l00036"></a>00036   <span class="keywordflow">return</span> QSize( QMIN( <a class="code" href="classPanningPreviewInterface.html#e9d723a64dc61d1913635a135b538c00" title="Full size image.">fullSizeImage</a>.width(),  size().width()  ),
<a name="l00037"></a>00037                 QMIN( <a class="code" href="classPanningPreviewInterface.html#e9d723a64dc61d1913635a135b538c00" title="Full size image.">fullSizeImage</a>.height(), size().height() ) );
<a name="l00038"></a>00038 }
<a name="l00039"></a>00039 <span class="comment">//==============================================</span>
<a name="l00040"></a><a class="code" href="classPanningPreviewInterface.html#2895eb5c0614dfaebf3bc8d69ac3e989">00040</a> <span class="keywordtype">void</span> <a class="code" href="classPanningPreviewInterface.html#2895eb5c0614dfaebf3bc8d69ac3e989">PanningPreviewInterface::resizeEvent</a>( QResizeEvent * )
<a name="l00041"></a>00041 {
<a name="l00042"></a>00042   <span class="comment">//center of new selection...</span>
<a name="l00043"></a>00043   QPoint center;
<a name="l00044"></a>00044   
<a name="l00045"></a>00045   <span class="comment">//if selection not set then default to center of image</span>
<a name="l00046"></a>00046   <span class="keywordflow">if</span>( <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.width() == 0)
<a name="l00047"></a>00047   {
<a name="l00048"></a>00048     <span class="comment">//compute center selection center</span>
<a name="l00049"></a>00049     center = QPoint( <a class="code" href="classPanningPreviewInterface.html#e9d723a64dc61d1913635a135b538c00" title="Full size image.">fullSizeImage</a>.width() / 2,
<a name="l00050"></a>00050                      <a class="code" href="classPanningPreviewInterface.html#e9d723a64dc61d1913635a135b538c00" title="Full size image.">fullSizeImage</a>.height() / 2 );
<a name="l00051"></a>00051   }
<a name="l00052"></a>00052   <span class="comment">//else construct new selection that is centered over old selection</span>
<a name="l00053"></a>00053   <span class="keywordflow">else</span>
<a name="l00054"></a>00054   {
<a name="l00055"></a>00055     <span class="comment">//compute center selection center</span>
<a name="l00056"></a>00056     center = QPoint( <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.left() + <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.width()/2,
<a name="l00057"></a>00057                      <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.top() + <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.height()/2 );
<a name="l00058"></a>00058   }
<a name="l00059"></a>00059   
<a name="l00060"></a>00060   <span class="comment">//determine width/height that will be used for painting</span>
<a name="l00061"></a>00061   QSize actualSize = <a class="code" href="classPanningPreviewInterface.html#8eca66ff583ebe33a194864a802f1dcd">paintingSize</a>();
<a name="l00062"></a>00062 
<a name="l00063"></a>00063   <span class="comment">//compute new selection area centerd over old selection region</span>
<a name="l00064"></a>00064   QRect newSelection;
<a name="l00065"></a>00065   newSelection.setLeft( center.x() - actualSize.width() /2 );
<a name="l00066"></a>00066   newSelection.setTop ( center.y() - actualSize.height()/2 );
<a name="l00067"></a>00067   newSelection.setRight( newSelection.left() + actualSize.width()  - 1 );
<a name="l00068"></a>00068   newSelection.setBottom( newSelection.top() + actualSize.height() - 1 );
<a name="l00069"></a>00069   
<a name="l00070"></a>00070   <span class="comment">//set selection which will result in regenerating of orig and adjusted images</span>
<a name="l00071"></a>00071   <a class="code" href="classPanningPreviewInterface.html#8c4e6125ea261a0506441736224a9a96">setSelection</a>( newSelection ); 
<a name="l00072"></a>00072 }
<a name="l00073"></a>00073 <span class="comment">//==============================================</span>
<a name="l00074"></a><a class="code" href="classPanningPreviewInterface.html#8c4e6125ea261a0506441736224a9a96">00074</a> <span class="keywordtype">void</span> <a class="code" href="classPanningPreviewInterface.html#8c4e6125ea261a0506441736224a9a96">PanningPreviewInterface::setSelection</a>( QRect s )
<a name="l00075"></a>00075 {
<a name="l00076"></a>00076   <span class="comment">//set the selection</span>
<a name="l00077"></a>00077   <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a> = s; 
<a name="l00078"></a>00078 
<a name="l00079"></a>00079   <span class="comment">//get the available painting size</span>
<a name="l00080"></a>00080   QSize actualSize = <a class="code" href="classPanningPreviewInterface.html#8eca66ff583ebe33a194864a802f1dcd">paintingSize</a>();
<a name="l00081"></a>00081 
<a name="l00082"></a>00082   <span class="comment">//if too wide or tall shrink selection</span>
<a name="l00083"></a>00083   <span class="keywordflow">if</span>( <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.width() &gt; actualSize.width() )
<a name="l00084"></a>00084     <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.setRight( <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.left() + actualSize.width() - 1 );
<a name="l00085"></a>00085   <span class="keywordflow">if</span>( <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.height() &gt; actualSize.height() )
<a name="l00086"></a>00086     <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.setBottom( <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.top() + actualSize.height() - 1 );
<a name="l00087"></a>00087 
<a name="l00088"></a>00088  <span class="comment">//shift selection area if it extends beyond image boundary</span>
<a name="l00089"></a>00089   <span class="keywordflow">if</span>( <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.left() &lt; 0 )
<a name="l00090"></a>00090     <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.moveBy( -<a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.left(), 0 );
<a name="l00091"></a>00091   
<a name="l00092"></a>00092   <span class="keywordflow">if</span>( <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.top() &lt; 0 )
<a name="l00093"></a>00093     <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.moveBy( 0, -<a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.top() );
<a name="l00094"></a>00094   
<a name="l00095"></a>00095   <span class="keywordflow">if</span>( <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.right() &gt; <a class="code" href="classPanningPreviewInterface.html#e9d723a64dc61d1913635a135b538c00" title="Full size image.">fullSizeImage</a>.width()-1 )
<a name="l00096"></a>00096     <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.moveBy( (<a class="code" href="classPanningPreviewInterface.html#e9d723a64dc61d1913635a135b538c00" title="Full size image.">fullSizeImage</a>.width()-1) - <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.right(), 0 );
<a name="l00097"></a>00097 
<a name="l00098"></a>00098   <span class="keywordflow">if</span>( <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.bottom() &gt; <a class="code" href="classPanningPreviewInterface.html#e9d723a64dc61d1913635a135b538c00" title="Full size image.">fullSizeImage</a>.height()-1 )
<a name="l00099"></a>00099     <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.moveBy( 0, (<a class="code" href="classPanningPreviewInterface.html#e9d723a64dc61d1913635a135b538c00" title="Full size image.">fullSizeImage</a>.height()-1) - <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.bottom() );
<a name="l00100"></a>00100   
<a name="l00101"></a>00101   <span class="comment">//regenerate orig and adjusted images</span>
<a name="l00102"></a>00102   <a class="code" href="classPanningPreviewInterface.html#cf1d9fbd7cb9b61f3632dc5d93a9fbed">generateOrigImage</a>();
<a name="l00103"></a>00103 }
<a name="l00104"></a>00104 <span class="comment">//==============================================</span>
<a name="l00105"></a><a class="code" href="classPanningPreviewInterface.html#cf1d9fbd7cb9b61f3632dc5d93a9fbed">00105</a> <span class="keywordtype">void</span> <a class="code" href="classPanningPreviewInterface.html#cf1d9fbd7cb9b61f3632dc5d93a9fbed">PanningPreviewInterface::generateOrigImage</a>()
<a name="l00106"></a>00106 {
<a name="l00107"></a>00107   <span class="comment">//generate orig image</span>
<a name="l00108"></a>00108   <span class="comment">//set adjusted image to null so repain won't occur until it is reset</span>
<a name="l00109"></a>00109   <a class="code" href="classSplitViewInterface.html#7c60276f4afa1fa1fc3dfc201b6311aa">setImages</a>( <a class="code" href="classPanningPreviewInterface.html#e9d723a64dc61d1913635a135b538c00" title="Full size image.">fullSizeImage</a>.copy( <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.left(), <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.top(),
<a name="l00110"></a>00110                                  <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.width(), <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>.height() ),
<a name="l00111"></a>00111              QImage() );
<a name="l00112"></a>00112   
<a name="l00113"></a>00113   <span class="comment">//emit signal indicating adjusted image is out of date</span>
<a name="l00114"></a>00114   emit <a class="code" href="classPanningPreviewInterface.html#c0276e9177e6ff67c038659ceb63af9b">selectionChanged</a>();
<a name="l00115"></a>00115 }
<a name="l00116"></a>00116 <span class="comment">//==============================================</span>
<a name="l00117"></a><a class="code" href="classPanningPreviewInterface.html#4b3332b2006f61fab9a290bd3637db10">00117</a> QRect <a class="code" href="classPanningPreviewInterface.html#4b3332b2006f61fab9a290bd3637db10">PanningPreviewInterface::getSelection</a>()
<a name="l00118"></a>00118 { <span class="keywordflow">return</span> <a class="code" href="classPanningPreviewInterface.html#071ba54dffe1ed00e809510ebda6f19e" title="Current selection.">selection</a>; }
<a name="l00119"></a>00119 <span class="comment">//==============================================</span>
<a name="l00120"></a>00120 
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Aug 23 02:34:26 2009 for AlbumShaper by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>