Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
berryStackPresentation.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "berryStackPresentation.h"
14 
15 #include "berryConstants.h"
16 
17 namespace berry
18 {
19 
20 const int StackPresentation::AS_INACTIVE = 0;
23 
24 
26  : site(stackSite)
27 {
28  poco_assert(stackSite.IsNotNull());
29 }
30 
32 {
33  // Do not remove empty destructor. Otherwise, the WeakPointer member "site"
34  // will be destroyed in a strange way and the destruction of a DefaultStackPresentationSite
35  // instance will notify the WeakPointer "site" (although it was destroyed, the
36  // DefaultStackPresentationSite somehow still has a MessageDelegate for the destroy
37  // event, pointing to the destroyed "site").
38 }
39 
41 {
42  return site.Lock();
43 }
44 
46 {
47  return QSize(0, 0);
48 }
49 
51 {
52  bool hasMaximumSize = this->GetSite()->GetState()
54 
55  return Constants::MIN | (hasMaximumSize ? Constants::MAX : 0);
56 }
57 
58 int StackPresentation::ComputePreferredSize(bool width, int /*availableParallel*/,
59  int /*availablePerpendicular*/, int preferredResult)
60 {
61  QSize s = this->ComputeMinimumSize();
62  int minSize = width ? s.width() : s.width();
63 
64  if (this->GetSite()->GetState() == IStackPresentationSite::STATE_MINIMIZED
65  || preferredResult < minSize)
66  {
67  return minSize;
68  }
69 
70  return preferredResult;
71 }
72 
74  Object::Pointer cookie)
75 {
76  this->RemovePart(toMove);
77  this->AddPart(toMove, cookie);
78 
79  if (this->GetSite()->GetSelectedPart() == toMove)
80  {
81  this->SelectPart(toMove);
82  toMove->SetFocus();
83  }
84 }
85 
87 {
88 
89 }
90 
92 {
93 
94 }
95 
97 {
98 
99 }
100 
101 }
IStackPresentationSite::Pointer GetSite()
virtual void MovePart(IPresentablePart::Pointer toMove, Object::Pointer cookie)
virtual void RestoreState(IPresentationSerializer *context, IMemento::Pointer memento)
StackPresentation(IStackPresentationSite::Pointer stackSite)
virtual void SaveState(IPresentationSerializer *context, IMemento::Pointer memento)
virtual void SelectPart(IPresentablePart::Pointer toSelect)=0
virtual void RemovePart(IPresentablePart::Pointer oldPart)=0
static const int MAX
static const int MIN
virtual void AddPart(IPresentablePart::Pointer newPart, Object::Pointer cookie)=0
int ComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredResult) override
int GetSizeFlags(bool width) override