PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PlatformPolygon Class Reference

#include <PlatformDrawObject.h>

Inheritance diagram for PlatformPolygon:
PlatformDrawObject PPolygon PlatformDrawObject PPolygon PlatformWidget PlatformWidget PDrawObject PlatformWidget PlatformWidget PDrawObject PWidget PWidget PWidget PWidget PWidget PWidget PWidget PWidget PWidget PWidget

Public Member Functions

 PlatformPolygon (int x, int y, Variant xpoints, Variant ypoints, Variant fg, bool filled)
 
virtual ~PlatformPolygon ()
 
virtual bool Draw ()
 This method initiates everything needed to display the main window

 
 PlatformPolygon (int x, int y, Variant xpoints, Variant ypoints, Variant fg, bool filled)
 
virtual ~PlatformPolygon ()
 
virtual bool Draw ()
 This method initiates everything needed to display the main window

 
virtual std::string ObjectName () const
 
virtual bool SetProperty (std::string name, Variant v)
 
virtual ObjectValidationError ValidateProperty (std::string name, Variant v) const
 
virtual ObjectValidationError ValidateProperty (std::string name) const
 
virtual void SetPosition (pInt x, pInt y)
 This sets the widget's position on its parent widget.
 
- Public Member Functions inherited from PlatformDrawObject
 PlatformDrawObject ()
 
 ~PlatformDrawObject ()
 
 PlatformDrawObject ()
 
 ~PlatformDrawObject ()
 
- Public Member Functions inherited from PlatformWidget
 PlatformWidget ()
 
virtual ~PlatformWidget ()
 
virtual SDL_Texture * GetSDL_Texture ()
 Used to extract an SDL surface from the widget. Used by children drawing themselves on their parent.
 
void SetParent (PlatformWidget *parent)
 
SDL_Surface * GetSurface ()
 
virtual bool SetRenderer (SDL_Renderer *renderer)
 
SDL_Renderer * GetRenderer ()
 
virtual bool AddToParentWidget (PlatformWidget *parent)
 
virtual bool AddSubWidget (PlatformWidget *widget)
 
virtual bool RemoveSubWidget (PlatformWidget *widget)
 
virtual bool RemoveSubWidgets ()
 
virtual bool RotoZoom (double angle, double zoomx, double zoomy, int smooth)
 This uses the SDL_gfx package to 'rotozoom'.
 
bool SetPoint (int x, int y, PColor col)
 
PColor GetPixel (int x, int y)
 
 PlatformWidget ()
 
 PlatformWidget (pInt x, pInt y, pInt width, pInt height, bool visible)
 
virtual ~PlatformWidget ()
 
virtual bool RotoZoom (pDouble angle, pDouble zoomx, pDouble zoomy, pInt smooth)
 
virtual bool SetPoint (pInt x, pInt y, PColor col)
 
virtual PColor GetPixel (pInt x, pInt y)
 
- Public Member Functions inherited from PWidget
 PWidget ()
 
 PWidget (const PWidget &pw)
 
 PWidget (pInt x, pInt y, pInt width, pInt height, bool visible)
 
virtual ~PWidget ()
 
virtual void SetParent (PWidget *widget)
 This unconditionally sets the parent widget.
 
virtual PWidgetGetParent ()
 
virtual bool IsParent (PWidget *parent)
 
virtual void SetZoomX (pDouble x)
 This sets the widget's position on its parent widget.
 
virtual void SetZoomY (pDouble x)
 This sets the widget's position on its parent widget.
 
virtual void SetRotation (pDouble x)
 This sets the widget's position on its parent widget.
 
virtual void SetWidth (pInt w)
 
virtual void SetHeight (pInt h)
 
virtual pInt GetX () const
 
virtual pInt GetY () const
 
virtual void SetBackgroundColor (const PColor &color)
 
virtual PColor GetBackgroundColor ()
 
virtual bool AddSubWidget (PWidget *widget)
 
virtual bool RemoveSubWidget (PWidget *widget)
 
virtual bool RemoveLastSubWidget ()
 This is probably pretty useless.
 
virtual void Show ()
 
virtual void Hide ()
 
virtual bool IsVisible () const
 
- Public Member Functions inherited from PEBLObjectBase
 PEBLObjectBase ()
 Standard Constructor.
 
 PEBLObjectBase (ComplexDataType cdt)
 Standard Constructor.
 
 PEBLObjectBase (const PEBLObjectBase &pob)
 
virtual ~PEBLObjectBase ()
 Standard Destructor.
 
virtual bool InitializeProperty (std::string name, Variant v)
 
Variant GetProperty (std::string) const
 
ComplexDataType GetType ()
 
virtual std::ostream & PrintProperties (std::ostream &out)
 
virtual Variant GetPropertyList ()
 
- Public Member Functions inherited from PPolygon
 PPolygon (pInt x, pInt y, Variant xpoints, Variant ypoints, Variant fg, bool filled)
 
virtual ~PPolygon ()
 
virtual pInt GetWidth () const
 
virtual pInt GetHeight () const
 
virtual bool SetXPoints (Variant v)
 
virtual bool SetYPoints (Variant v)
 
virtual std::ostream & SendToStream (std::ostream &out)
 
virtual Variant GetProperty (std::string) const
 
- Public Member Functions inherited from PDrawObject
 PDrawObject ()
 
virtual ~PDrawObject ()
 
virtual void SetFilled (bool filled)
 
virtual void SetColor (Variant col)
 
virtual void SetOutlineColor (Variant ocol)
 
virtual void SetAA (bool aa)
 

Protected Member Functions

virtual std::ostream & SendToStream (std::ostream &out) const
 An inheritable printing class used by PEBLObjectBase::operator<<.
 
virtual std::ostream & SendToStream (std::ostream &out) const
 An inheritable printing class used by PEBLObjectBase::operator<<.
 
- Protected Member Functions inherited from PlatformWidget
virtual void PrintSubWidgets (std::ostream &out) const
 
virtual bool LockSurface ()
 This needs to be used on some platforms/video cards.
 
virtual bool UnlockSurface ()
 This needs to be used on some platforms/video cards.
 
- Protected Member Functions inherited from PDrawObject
PColorGetColor () const
 
PColorGetOutlineColor () const
 

Additional Inherited Members

- Protected Attributes inherited from PlatformWidget
pInt mTextureWidth
 
pInt mTextureHeight
 
bool mNeedsTexture
 
SDL_Texture * mTexture
 
SDL_Surface * mSurface
 
SDL_Renderer * mRenderer
 
- Protected Attributes inherited from PWidget
pInt mX
 
pInt mY
 
pInt mDrawX
 
pInt mDrawY
 
pInt mWidth
 
pInt mHeight
 
pDouble mZoomX
 
pDouble mZoomY
 
pDouble mRotation
 
PColor mBackgroundColor
 The background color of the widget. if alpha = 0, will not be painted.
 
std::list< PWidget * > mSubWidgets
 
bool mIsVisible
 
PWidgetmParent
 
- Protected Attributes inherited from PEBLObjectBase
ComplexDataType mCDT
 
std::map< std::string, VariantmProperties
 
- Protected Attributes inherited from PPolygon
Variant mXPoints
 
Variant mYPoints
 
- Protected Attributes inherited from PDrawObject
bool mFilled
 
bool mAntiAliased
 

Detailed Description

Definition at line 161 of file sdl/PlatformDrawObject.h.

Constructor & Destructor Documentation

◆ PlatformPolygon() [1/2]

PlatformPolygon::PlatformPolygon ( int  x,
int  y,
Variant  xpoints,
Variant  ypoints,
Variant  fg,
bool  filled 
)

Definition at line 499 of file sdl/PlatformDrawObject.cpp.

499 :
500 PPolygon(x1,y1,xpoints,ypoints,fg,filled)
501
502{
503 mNeedsTexture=false;
505 mSurface =NULL;
506 mParent = NULL;
507 mIsVisible=true;
508
509}
#define NULL
Definition BinReloc.cpp:317
@ CDT_DRAWOBJECT
Definition PEBLObject.h:60
ComplexDataType mCDT
Definition PEBLObject.h:109
PWidget * mParent
Definition PWidget.h:154
bool mIsVisible
Definition PWidget.h:150
SDL_Surface * mSurface

References CDT_DRAWOBJECT, PEBLObjectBase::mCDT, PWidget::mIsVisible, PlatformWidget::mNeedsTexture, PWidget::mParent, PlatformWidget::mSurface, and NULL.

◆ ~PlatformPolygon() [1/2]

PlatformPolygon::~PlatformPolygon ( )
virtual

Definition at line 511 of file sdl/PlatformDrawObject.cpp.

512{
513
514}

◆ PlatformPolygon() [2/2]

PlatformPolygon::PlatformPolygon ( int  x,
int  y,
Variant  xpoints,
Variant  ypoints,
Variant  fg,
bool  filled 
)

◆ ~PlatformPolygon() [2/2]

virtual PlatformPolygon::~PlatformPolygon ( )
virtual

Member Function Documentation

◆ Draw() [1/2]

bool PlatformPolygon::Draw ( )
virtual

This method initiates everything needed to display the main window

Reimplemented from PlatformWidget.

Definition at line 522 of file sdl/PlatformDrawObject.cpp.

523{
524 int result = -1;
525 if(mParent && mRenderer)
526 {
527
528 result = SDL_SetRenderTarget(mRenderer, dynamic_cast<PlatformWidget*>(mParent)->GetSDL_Texture());
529
530 if(result < 0)
531 {
532
533 std::cerr << " SetRenderTarget failed in PlatformPolygon with error code: " << result << endl;
534 cerr << "SDL message: " << SDL_GetError() << endl;
535 cerr << *this << endl;
536
537 }
538
539
540 //We need to transform the double-list points into int vectors for
541 //the x and y points, plus the length.
542
543 PList * pxlist = mXPoints.GetComplexData()->GetList();
544 PList * pylist = mYPoints.GetComplexData()->GetList();
545
546 unsigned long int length = pxlist->Length();
547 Sint16 *x = new Sint16[length];
548 Sint16 *y = new Sint16[length];
549
550 vector<Variant>::iterator p1 = pxlist->Begin();
551 vector<Variant>::iterator p2 = pylist->Begin();
552
553 int i = 0;
554 while(p1 != pxlist->End())
555 {
556 x[i]= (Sint16)((int)(*p1)) + (Sint16)mX;
557 y[i]= (Sint16)((int)(*p2)) + (Sint16)mY;
558 p1++;
559 p2++;
560 i++;
561 }
562
563
564 if(mFilled)
565 {
566
567 if(mAntiAliased)
568 {
569 result = aapolygonRGBA(mRenderer,x,y,(int)length,
570 GetColor()->GetRed(), GetColor()->GetGreen(), GetColor()->GetBlue(), GetColor()->GetAlpha());
571
572
573
574 if(result < 0)
575 {
576
577 std::cerr << " rendering aapolygonRGBA failed in PlatformPolygon with error code: " << result << endl;
578 cerr << "SDL message: " << SDL_GetError() << endl;
579 cerr << *this << endl;
580
581
582 }
583
584
585 }
586 result = filledPolygonRGBA(mRenderer,x,y,(int)length,
587 GetColor()->GetRed(), GetColor()->GetGreen(), GetColor()->GetBlue(), GetColor()->GetAlpha());
588
589 if(result < 0)
590 {
591
592 std::cerr << " rendering filledPolygonRGBA failed in PlatformPolygon with error code: " << result << endl;
593 cerr << "SDL message: " << SDL_GetError() << endl;
594 cerr << *this << endl;
595
596
597 }
598
599 }
600 else
601 {
602 if(mAntiAliased)
603 {
604 result = aapolygonRGBA(mRenderer,x,y,(int)length,
605 GetColor()->GetRed(), GetColor()->GetGreen(), GetColor()->GetBlue(), GetColor()->GetAlpha());
606 }else
607 {
608 result =polygonRGBA(mRenderer,x,y,(int)length,
609 GetColor()->GetRed(), GetColor()->GetGreen(), GetColor()->GetBlue(), GetColor()->GetAlpha());
610 }
611 if(result < 0)
612 {
613
614 std::cerr << " rendering polygonRGBA failed in PlatformPolygon with error code: " << result << endl;
615 cerr << "SDL message: " << SDL_GetError() << endl;
616 cerr << *this << endl;
617
618
619 }
620
621 }
622 delete[] x;
623 delete[] y;
624 result = SDL_SetRenderTarget(mRenderer,NULL);
625
626 if(result < 0)
627 {
628
629 std::cerr << " Resetting rendertarget failed in PlatformPolygon with error code: " << result << endl;
630 cerr << "SDL message: " << SDL_GetError() << endl;
631 cerr << *this << endl;
632
633
634 }
635
636
637 }
638 //UnlockSurface();
639 return result;
640}
PList * GetList() const
bool mAntiAliased
Definition PDrawObject.h:69
PColor * GetColor() const
Definition PList.h:45
std::vector< Variant >::const_iterator End() const
Definition PList.cpp:132
std::vector< Variant >::const_iterator Begin() const
Definition PList.cpp:127
unsigned long Length() const
Definition PList.h:89
Variant mYPoints
Variant mXPoints
pInt mX
Definition PWidget.h:125
pInt mY
Definition PWidget.h:125
SDL_Renderer * mRenderer
virtual SDL_Texture * GetSDL_Texture()
Used to extract an SDL surface from the widget. Used by children drawing themselves on their parent.
PComplexData * GetComplexData() const
Definition Variant.cpp:1299

References PList::Begin(), PList::End(), PDrawObject::GetColor(), Variant::GetComplexData(), PComplexData::GetList(), PlatformWidget::GetSDL_Texture(), PList::Length(), PDrawObject::mAntiAliased, PDrawObject::mFilled, PWidget::mParent, PlatformWidget::mRenderer, PWidget::mX, PPolygon::mXPoints, PWidget::mY, PPolygon::mYPoints, and NULL.

◆ Draw() [2/2]

virtual bool PlatformPolygon::Draw ( )
virtual

This method initiates everything needed to display the main window

Reimplemented from PlatformWidget.

◆ ObjectName()

virtual std::string PlatformPolygon::ObjectName ( ) const
inlinevirtual

Reimplemented from PWidget.

Definition at line 128 of file validator/PlatformDrawObject.h.

128{ return "PlatformPolygon (validator)"; }

◆ SendToStream() [1/2]

std::ostream & PlatformPolygon::SendToStream ( std::ostream &  out) const
protectedvirtual

An inheritable printing class used by PEBLObjectBase::operator<<.

Reimplemented from PlatformWidget.

Definition at line 516 of file sdl/PlatformDrawObject.cpp.

517{
518 out << "<A Polygon :"<< mX << ", " << mY << ":" << std::endl;
519 return out;
520}

References PWidget::mX, and PWidget::mY.

◆ SendToStream() [2/2]

virtual std::ostream & PlatformPolygon::SendToStream ( std::ostream &  out) const
protectedvirtual

An inheritable printing class used by PEBLObjectBase::operator<<.

Reimplemented from PlatformWidget.

◆ SetPosition()

virtual void PlatformPolygon::SetPosition ( pInt  x,
pInt  y 
)
inlinevirtual

This sets the widget's position on its parent widget.

Sets the location of the upper left-hand corner of the image on the parent widget; unless overridden

Reimplemented from PWidget.

Definition at line 132 of file validator/PlatformDrawObject.h.

132{ PPolygon::SetPosition(x, y); }
virtual void SetPosition(pInt x, pInt y)
This sets the widget's position on its parent widget.
Definition PWidget.cpp:220

References PWidget::SetPosition().

◆ SetProperty()

virtual bool PlatformPolygon::SetProperty ( std::string  name,
Variant  v 
)
inlinevirtual

Reimplemented from PWidget.

Definition at line 129 of file validator/PlatformDrawObject.h.

129{ return PPolygon::SetProperty(name, v); }
virtual bool SetProperty(std::string, Variant v)

References PPolygon::SetProperty().

◆ ValidateProperty() [1/2]

virtual ObjectValidationError PlatformPolygon::ValidateProperty ( std::string  name) const
inlinevirtual

Reimplemented from PWidget.

Definition at line 131 of file validator/PlatformDrawObject.h.

131{ return PPolygon::ValidateProperty(name); }
virtual ObjectValidationError ValidateProperty(std::string, Variant v) const

References PPolygon::ValidateProperty().

◆ ValidateProperty() [2/2]

virtual ObjectValidationError PlatformPolygon::ValidateProperty ( std::string  name,
Variant  v 
) const
inlinevirtual

Reimplemented from PWidget.

Definition at line 130 of file validator/PlatformDrawObject.h.

130{ return PPolygon::ValidateProperty(name, v); }

References PPolygon::ValidateProperty().


The documentation for this class was generated from the following files: