~ubuntu-branches/ubuntu/wily/ifrit/wily

« back to all changes in this revision

Viewing changes to shells/generic/iggframerangemapping.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2009-09-13 14:53:24 UTC
  • mfrom: (1.1.11 upstream) (2.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090913145324-084ivqvf29arkc1b
Tags: 3.3.2-1
* New upstream release.
* Bump Standards-Version to 3.8.3.  No changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*=========================================================================
2
 
 
3
 
  Program:   Ionization FRont Interactive Tool (IFRIT)
4
 
  Language:  C++
5
 
 
6
 
 
7
 
Copyright (c) 2002-2006 Nick Gnedin 
8
 
All rights reserved.
9
 
 
10
 
This file may be distributed and/or modified under the terms of the
11
 
GNU General Public License version 2 as published by the Free Software
12
 
Foundation and appearing in the file LICENSE.GPL included in the
13
 
packaging of this file.
14
 
 
15
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
16
 
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
 
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
19
 
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
 
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21
 
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22
 
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
 
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24
 
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
 
 
26
 
=========================================================================*/
 
1
/*=========================================================================
 
2
 
 
3
  Program:   Ionization FRont Interactive Tool (IFRIT)
 
4
  Language:  C++
 
5
 
 
6
 
 
7
Copyright (c) 2002-2006 Nick Gnedin 
 
8
All rights reserved.
 
9
 
 
10
This file may be distributed and/or modified under the terms of the
 
11
GNU General Public License version 2 as published by the Free Software
 
12
Foundation and appearing in the file LICENSE.GPL included in the
 
13
packaging of this file.
 
14
 
 
15
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 
16
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
17
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
18
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
 
19
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
20
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
21
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 
22
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 
23
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 
24
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
25
 
 
26
=========================================================================*/
27
27
 
28
28
 
29
29
#include "iconfigure.h"
51
51
#include "ibgwidgetentrysubject.h"
52
52
 
53
53
#include "iggsubjectfactory.h"
54
 
#include "iggparameter.h"
55
 
using namespace iggParameter;
56
54
 
57
55
//
58
56
//  Templates (needed for some compilers)
60
58
#include "iarraytemplate.h"
61
59
 
62
60
 
 
61
using namespace iParameter;
 
62
 
 
63
 
63
64
namespace iggFrameRangeMapping_Private
64
65
{
65
66
        //
124
125
 
125
126
                                float aMin, aMax;
126
127
                                int npic = rc->GetN();
127
 
                                float attMin = rc->GetGlobalMin();
128
 
                                float attMax = rc->GetGlobalMax();
 
128
                                float attMin = rc->GetStretchedGlobalMin();
 
129
                                float attMax = rc->GetStretchedGlobalMax();
129
130
 
130
131
                                dx = ixmax/(attMax-attMin);
131
132
 
139
140
                                        {
140
141
                                                i1 = i;
141
142
                                        }
142
 
                                        aMin = rc->GetMin(i1);
143
 
                                        aMax = rc->GetMax(i1);
 
143
                                        aMin = rc->GetStretchedMin(i1);
 
144
                                        aMax = rc->GetStretchedMax(i1);
144
145
                                        
145
146
                                        ix1 = round(dx*(aMin-attMin));
146
147
                                        if(ix1>=0 && ix1<lineWidth/2) ix1 = lineWidth/2;
171
172
                void OnAddRange()
172
173
                {
173
174
                        mParent->OnAddRange();
174
 
                        mSubject->RequestPainting(ibgWidgetDrawAreaSubject::_Foreground);
 
175
                        mSubject->RequestPainting(DrawMode::Foreground);
175
176
                }
176
177
 
177
178
                void OnRemoveRange();
375
376
 
376
377
                        float aMin, aMax, a;
377
378
                        int npic = rc->GetN();
378
 
                        float attMin = rc->GetGlobalMin();
379
 
                        float attMax = rc->GetGlobalMax();
 
379
                        float attMin = rc->GetStretchedGlobalMin();
 
380
                        float attMax = rc->GetStretchedGlobalMax();
380
381
 
381
382
                        int oldCurRange = mCurRange;
382
383
 
388
389
                                indmin = -1;
389
390
                                for(i=0; i<npic; i++)
390
391
                                {
391
 
                                        aMin = rc->GetMin(i);
392
 
                                        aMax = rc->GetMax(i);
 
392
                                        aMin = rc->GetStretchedMin(i);
 
393
                                        aMax = rc->GetStretchedMax(i);
393
394
 
394
395
                                        ix1 = round(dx*(aMin-attMin));
395
396
                                        if(ix1>=0 && ix1<lineWidth/2) ix1 = lineWidth/2;
419
420
                        }                                       
420
421
                        
421
422
                        a = x/dx + attMin;
422
 
                        aMin = rc->GetMin(mCurRange);
423
 
                        aMax = rc->GetMax(mCurRange);
 
423
                        aMin = rc->GetStretchedMin(mCurRange);
 
424
                        aMax = rc->GetStretchedMax(mCurRange);
424
425
                        if(isMax) aMax = a; else aMin = a;
425
 
                        rc->SetRange(mCurRange,aMin,aMax);
 
426
                        rc->SetRange(mCurRange,rc->ResetStretch(aMin),rc->ResetStretch(aMax));
426
427
                        
427
428
                        if(mCurRange != oldCurRange)
428
429
                        {
429
430
                                mParent->SetCurrentRange(mCurRange);
430
431
                        }
431
432
                        
432
 
                        mSubject->RequestPainting(ibgWidgetDrawAreaSubject::_Foreground);
433
 
 
434
 
                        if(b == _MouseRightButton) this->OnRender(); else if(!mRenderButton->IsEnabled()) mRenderButton->Enable(true);
 
433
                        if(mExtra != 0) mExtra->DisplayNumbers(rc->ResetStretch(aMin),rc->ResetStretch(aMax));
 
434
 
 
435
                        mSubject->RequestPainting(DrawMode::Foreground);
 
436
 
 
437
                        mParent->OnChange();
 
438
 
 
439
                        if(b == MouseButton::RightButton) this->OnRender(); else if(!mRenderButton->IsEnabled()) mRenderButton->Enable(true);
435
440
                }
436
441
        }
437
442
 
438
443
        void Area::OnRemoveRange()
439
444
        {
440
445
                mParent->OnRemoveRange();
441
 
                mSubject->RequestPainting(ibgWidgetDrawAreaSubject::_Foreground);
 
446
                mSubject->RequestPainting(DrawMode::Foreground);
442
447
                if(!mRenderButton->IsEnabled()) mRenderButton->Enable(true);
443
448
        }
444
449
        
445
450
        void Area::OnReset()
446
451
        {
447
452
                mParent->OnReset();
448
 
                mSubject->RequestPainting(ibgWidgetDrawAreaSubject::_Foreground);
 
453
                mSubject->RequestPainting(DrawMode::Foreground);
449
454
                if(!mRenderButton->IsEnabled()) mRenderButton->Enable(true);
450
455
        }
451
456
 
456
461
                {
457
462
                        rm->Modified();
458
463
                }
 
464
                if(mExtra != 0) mExtra->UpdateWidget();
459
465
                this->GetShell()->GetControlModule()->Render();
460
466
                mRenderButton->Enable(false);
461
467
        }