Skip to content

Commit

Permalink
Merge branch 'Issue#14'
Browse files Browse the repository at this point in the history
* Issue#14:
  Some fix on coding style (issue #14)
  • Loading branch information
Alberto Losi committed Jan 24, 2013
2 parents 0a93e89 + da981d9 commit 3d2f600
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 219 deletions.
2 changes: 1 addition & 1 deletion Libs/Qt/Widgets/msvQVTKButtonsGroup.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void msvQVTKButtonsGroup::show(bool val)
{
if (val)
{
msvQVTKButtonsInterface::setShowButton(val);
Superclass::setShowButton(val);
this->update();
}
}
2 changes: 2 additions & 0 deletions Libs/Qt/Widgets/msvQVTKButtonsGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class MSV_QT_WIDGETS_EXPORT msvQVTKButtonsGroup : public msvQVTKButtonsInterface
Q_OBJECT

public:
typedef msvQVTKButtonsInterface Superclass;

/// Object constructor.
msvQVTKButtonsGroup(QObject *parent = 0);

Expand Down
94 changes: 46 additions & 48 deletions Libs/VTK/Widgets/msvVTKButtons.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,24 @@ class vtkButtonCallback : public vtkCommand
return new vtkButtonCallback;
}

vtkTypeMacro(vtkButtonCallback,vtkCommand);

virtual void Execute(vtkObject *caller, unsigned long, void*)
{
ToolButton->SetPreviousOpacity(0);
msvVTKAnimate* animateCamera = new msvVTKAnimate();
if (FlyTo)
{
{
animateCamera->Execute(Renderer, Bounds, 100);
}
}
else
{
{
Renderer->ResetCamera(Bounds);
}
}
if (animateCamera)
{
{
delete animateCamera;
}
}
//selection
}

Expand Down Expand Up @@ -115,12 +117,11 @@ msvVTKButtons::msvVTKButtons() : msvVTKButtonsInterface()
this->OnCenter=false;

this->ButtonCallback = vtkButtonCallback::New();
reinterpret_cast<vtkButtonCallback*>(this->ButtonCallback)->ToolButton = this;
vtkButtonCallback::SafeDownCast(
this->ButtonCallback)->ToolButton = this;

//this->RWICallback = vtkRWICallback::New();
//reinterpret_cast<vtkRWICallback*>(this->RWICallback)->ToolButton = this;

this->GetButton()->AddObserver(vtkCommand::StateChangedEvent,this->ButtonCallback);
this->GetButton()->AddObserver(
vtkCommand::StateChangedEvent,this->ButtonCallback);

this->OnCorner = false;
this->CornerIndex = -1;
Expand All @@ -138,33 +139,29 @@ msvVTKButtons::~msvVTKButtons()
void msvVTKButtons::SetBounds(double b[6])
{
Superclass::SetBounds(b);
reinterpret_cast<vtkButtonCallback*>(ButtonCallback)->SetBounds(b);
//reinterpret_cast<vtkRWICallback*>(RWICallback)->SetBounds(b);
//this->Update();
vtkButtonCallback::SafeDownCast(ButtonCallback)->SetBounds(b);
}

//----------------------------------------------------------------------
void msvVTKButtons::SetCurrentRenderer(vtkRenderer *renderer)
{
Superclass::SetCurrentRenderer(renderer);
if (renderer)
{
//renderer->GetActiveCamera()->AddObserver(vtkCommand::ModifiedEvent,RWICallback);
//reinterpret_cast<vtkRWICallback*>(RWICallback)->Renderer = renderer;
reinterpret_cast<vtkButtonCallback*>(ButtonCallback)->Renderer = renderer;
}
{
vtkButtonCallback::SafeDownCast(
ButtonCallback)->Renderer = renderer;
}
else
{
//reinterpret_cast<vtkRWICallback*>(RWICallback)->Renderer = NULL;
reinterpret_cast<vtkButtonCallback*>(ButtonCallback)->Renderer = NULL;
}
{
vtkButtonCallback::SafeDownCast(ButtonCallback)->Renderer = NULL;
}
}

//----------------------------------------------------------------------
vtkImageData* msvVTKButtons::GetPreview(int width, int height)
{
if (Data)
{
{
double bounds[6];
Data->GetBounds(bounds);

Expand Down Expand Up @@ -213,7 +210,7 @@ vtkImageData* msvVTKButtons::GetPreview(int width, int height)
//this->GetWindow()->Delete();

return vtkImage;
}
}
return NULL;
}

Expand All @@ -223,13 +220,13 @@ void msvVTKButtons::Update()
Superclass::Update();
this->CalculatePosition();
if (ButtonCallback)
{
reinterpret_cast<vtkButtonCallback*>(ButtonCallback)->FlyTo = FlyTo;
if (reinterpret_cast<vtkButtonCallback*>(ButtonCallback)->Renderer)
{
vtkButtonCallback::SafeDownCast(ButtonCallback)->FlyTo = FlyTo;
if (vtkButtonCallback::SafeDownCast(ButtonCallback)->Renderer)
{
Renderer->GetRenderWindow()->Render();
}
}
}
}

//------------------------------------------------------------------------------
Expand All @@ -244,7 +241,8 @@ void msvVTKButtons::CalculatePosition()
bds[3] = 16;
bds[4] = 0.0;
bds[5] = 0.0;
vtkTexturedButtonRepresentation2D *rep = vtkTexturedButtonRepresentation2D::SafeDownCast(this->GetButton()->GetRepresentation());
vtkTexturedButtonRepresentation2D *rep = vtkTexturedButtonRepresentation2D::SafeDownCast(
this->GetButton()->GetRepresentation());
rep->SetPlaceFactor(1.);
rep->PlaceWidget(bds);
rep->Modified();
Expand All @@ -258,34 +256,34 @@ void msvVTKButtons::CalculatePosition()
vtkRenderWindow* msvVTKButtons::GetWindow()
{
if (Window == NULL)
{
{
Window = vtkRenderWindow::New();
}
}
return Window;
}

//------------------------------------------------------------------------------
void msvVTKButtons::DeleteWindow()
{
if (this->Window)
{
{
this->Window->Delete();
this->Window = NULL;
}
}
}

//------------------------------------------------------------------------------
void msvVTKButtons::GetDisplayPosition(double pos[2])
{
if (!this->GetOnCorner())
{
{
this->GetRealDisplayPosition(pos);
}
}
else
{
{
pos[0] = 96;
pos[1] = (24 * (CornerIndex - 1)) + CornerIndex;
}
}
}

//------------------------------------------------------------------------------
Expand All @@ -296,18 +294,18 @@ void msvVTKButtons::GetRealDisplayPosition(double pos[2])
double coord[3];
this->GetBounds(bounds);
if (this->OnCenter)
{
{
coord[0] = (bounds[1] + bounds[0])*.5;
coord[1] = (bounds[3] + bounds[2])*.5;
coord[2] = (bounds[5] + bounds[4])*.5;
}
}
else
{
//on the corner of the bounding box of the VME.
coord[0] = bounds[0];
coord[1] = bounds[2];
coord[2] = bounds[4];
}
{
//on the corner of the bounding box of the VME.
coord[0] = bounds[0];
coord[1] = bounds[2];
coord[2] = bounds[4];
}

vtkCoordinate* anchor = vtkCoordinate::New();
anchor->SetCoordinateSystemToWorld();
Expand All @@ -317,9 +315,9 @@ void msvVTKButtons::GetRealDisplayPosition(double pos[2])
pos[0] = static_cast<double>(p[0]);
pos[1] = static_cast<double>(p[1]) + this->YOffset;
if (pos[0]<0 || pos[1]<0)
{
{
pos[0] = 0;
pos[1] = 0;
}
}
anchor->Delete();
}
Loading

0 comments on commit 3d2f600

Please sign in to comment.