Changeset 292 in PSPA


Ignore:
Timestamp:
Jan 29, 2013, 3:04:19 PM (11 years ago)
Author:
garnier
Message:

Refactoring part 3

Location:
Interface_Web/trunk/pspaWT
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/History

    r291 r292  
    77
    8829 Janvier 2012  Laurent Garnier
    9 - Ajout de GWt_abstractElementFactory
     9- Ajout de la classe GWt_abstractElementFactory
     10- GWt_bend, GWt_drift, GWt_beam
     11  GWt_soleno, GWt_fit, GWt_rfgun
     12  GWt_cell,  GWt_pspaApplication,
     13  GWt_dropZoneLigneFaisceau : Déplacement des mimeTypes et imagesUrl directement
     14  dans les élements
     15
     16- GWt_abstractElement : Déplacement de methode createDragImage()
     17
     18- GWt_elementLigneFaisceau : passage d'une référence vers "pspaApplication"
     19
     20- GWt_pspaApplication : ajout d'une abstractElementFactory
    1021
    112228 Janvier 2012  Laurent Garnier
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_abstractElement.h

    r290 r292  
    4747   
    4848    virtual void dialogDone() = 0;
    49     virtual WImage* getImage() = 0;
    5049    virtual WString print() = 0;
    5150    virtual string getMimeType()= 0;
     
    5352    virtual string getBigImageURL()= 0;
    5453    virtual string getName()= 0;
     54
     55    void createDragImage(WContainerWidget*);
     56    WImage* getImage();
    5557   
    56     //    virtual void createDragImage() = 0;
    57    
     58protected:
     59    WImage* image_;
    5860private:
    5961    GWt_elementLigneFaisceau* elementLigneFaiseauContainer_;
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_beam.h

    r290 r292  
    2323    virtual void dialogDone();
    2424   
    25     WImage* getImage();
    2625    WString print();
    2726
     
    3130    inline string getName() {return "beam"; }
    3231
    33 private:
    34     WImage* image_;
    3532};
    3633
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_bend.h

    r290 r292  
    3030    inline string getName() {return "bend"; }
    3131
    32 private:
    33     WImage* image_;
    3432};
    3533#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_cell.h

    r290 r292  
    4141    inline string getName() {return "cell"; }
    4242
    43 private:
    44     WImage* image_;
    4543};
    4644#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_drift.h

    r290 r292  
    3232    inline string getName() {return "drift"; }
    3333
    34 private:
    35     WImage* image_;
    3634};
    3735#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_dropZoneLigneFaisceau.h

    r273 r292  
    33
    44#include "GWt_dropZoneLigneFaisceau.h"
     5#include "GWt_pspaApplication.h"
    56
    67#include <Wt/WContainerWidget>
     
    1314    public :
    1415   
    15     GWt_dropZoneLigneFaisceau();
     16    GWt_dropZoneLigneFaisceau(PspaApplication* pspa_);
    1617    ~GWt_dropZoneLigneFaisceau();
    1718   
    1819private:
    19     void initialise();
     20    void initialise( PspaApplication* pspa);
    2021    void mouseOver(const WMouseEvent &e );
    2122    void mouseOut(const WMouseEvent &e );
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_elementLigneFaisceau.h

    r287 r292  
    66#include "GWt_abstractElement.h"
    77#include "GWt_dropZoneLigneFaisceau.h"
     8#include "GWt_pspaApplication.h"
    89
    910#include <Wt/WContainerWidget>
     
    3233     */
    3334   
    34     GWt_elementLigneFaisceau();
    35     GWt_elementLigneFaisceau(abstractElement*);
     35    GWt_elementLigneFaisceau(PspaApplication*);
     36    GWt_elementLigneFaisceau(abstractElement*,PspaApplication*);
    3637   
    3738    ~GWt_elementLigneFaisceau();
     
    6970    GWt_dropZoneLigneFaisceau* dropZoneRight_;
    7071    WText* elementName_;
    71    
     72    PspaApplication* pspa_;
    7273    GWt_abstractElement* abstractElement_;
    7374};
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_fit.h

    r290 r292  
    2727    inline string getName() {return "fit"; }
    2828
    29 private:
    30     WImage* image_;
    3129};
    3230#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h

    r289 r292  
    115115    void updateSelections();
    116116    string getSelection();
     117    inline GWt_abstractElementFactory* getAbstractElementFactory() {
     118        return abstractElementFactory_;
     119    }
    117120};
    118121#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_rfgun.h

    r290 r292  
    3838    inline string getName() {return "rfgun"; }
    3939
    40 private:
    41     WImage* image_;
    42    
    4340};
    4441#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_soleno.h

    r290 r292  
    3939    inline string getName() {return "soleno"; }
    4040
    41 private:
    42     WImage* image_;
    4341};
    4442#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElement.cc

    r289 r292  
    1212#include "GWt_beam.h"
    1313#include "GWt_fit.h"
     14#include "GWt_draggableImage.h"
    1415
    1516#include "mixedTools.h"
     
    114115}
    115116
     117
     118void GWt_abstractElement::createDragImage(WContainerWidget* w){
     119
     120    GWt_draggableImage *result = new GWt_draggableImage(getBigImageURL(),w);
     121
     122    /*
     123     * Set the image to be draggable, showing the other image (dragImage)
     124     * to be used as the widget that is visually dragged.
     125     */
     126    result->setDraggable(getMimeType(),new WImage(getSmallImageURL(),w),true);
     127}
     128
     129WImage* GWt_abstractElement::getImage() {
     130    return image_;
     131}
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_beam.cc

    r290 r292  
    4646   
    4747    // make image
    48     image_ = new WImage("htdocs/beam.jpg",this);
     48    image_ = new WImage(getBigImageURL(),this);
    4949   
    5050    // activate slots
     
    7676}
    7777
    78 WImage* GWt_beam::getImage() {
    79     return image_;
    80 }
    81 
    8278
    8379WString GWt_beam::print(){
    8480    return WString(abstractElement_->print());
    8581}
     82
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_bend.cc

    r289 r292  
    4747   
    4848    // make image
    49     image_ = new WImage("htdocs/bend.jpg",this);
     49    image_ = new WImage(getBigImageURL(),this);
    5050   
    5151    // activate slots
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_cell.cc

    r289 r292  
    6969   
    7070    // make image
    71     image_ = new WImage("htdocs/cell.jpg",this);
     71    image_ = new WImage(getBigImageURL(),this);
    7272   
    7373    // activate slots
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_drift.cc

    r289 r292  
    2525   
    2626    // make image
    27     image_ = new WImage("htdocs/drift.jpg",this);
     27    image_ = new WImage(getBigImageURL(),this);
    2828   
    2929    // activate slots
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_dropZoneLigneFaisceau.cc

    r287 r292  
    1212//#define PSPA_DEBUG 1
    1313
    14 GWt_dropZoneLigneFaisceau::GWt_dropZoneLigneFaisceau()
     14GWt_dropZoneLigneFaisceau::GWt_dropZoneLigneFaisceau( PspaApplication* pspa)
    1515: WContainerWidget(){
    16     initialise();
     16    initialise(pspa);
    1717}
    1818
     
    2323
    2424
    25 void GWt_dropZoneLigneFaisceau::initialise()
     25void GWt_dropZoneLigneFaisceau::initialise( PspaApplication* pspa)
    2626{
    2727   
     
    3737   
    3838    // accept drops
    39     acceptDrops("htdocs/beam.jpg");
    40     acceptDrops("htdocs/rfgun.jpg");
    41     acceptDrops("htdocs/drift.jpg");
    42     acceptDrops("htdocs/cell.jpg");
    43     acceptDrops("htdocs/bend.jpg");
    44     acceptDrops("htdocs/soleno.jpg");
    45     acceptDrops("htdocs/fit.jpg");
    4639
     40        vector <GWt_abstractElement*> elems = pspa->getAbstractElementFactory()->getAllElements();
     41    for (int a = 0; a< elems.size(); a++) {
     42        acceptDrops(elems[a]->getMimeType());
     43    }
    4744    setMinimumSize(10,32);
    4845}
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc

    r289 r292  
    2626#define PSPA_DEBUG 1
    2727
    28 GWt_elementLigneFaisceau::GWt_elementLigneFaisceau()
    29 : WContainerWidget(),
    30 firstTimeInsertMessage_(NULL),
    31 dropZoneLeft_(NULL),
    32 dropZoneRight_(NULL),
    33 abstractElement_(NULL)
    34 {
    35     // set the css name
    36     setObjectName("elementLigneFaisceau");
    37    
    38     initialize_ligneFaisceau(NULL);
    39 }
    40 
    41 
    42 GWt_elementLigneFaisceau::GWt_elementLigneFaisceau(abstractElement* abstractElement)
     28
     29GWt_elementLigneFaisceau::GWt_elementLigneFaisceau(PspaApplication* pspa)
    4330: WContainerWidget(),
    4431firstTimeInsertMessage_(NULL),
     
    4633dropZoneRight_(NULL),
    4734abstractElement_(NULL),
    48 elementName_(NULL)
    49 {
     35elementName_(NULL),
     36pspa_(pspa)
     37{
     38   
     39    initialize_ligneFaisceau(NULL);
     40}
     41
     42GWt_elementLigneFaisceau::GWt_elementLigneFaisceau(abstractElement* abstractElement, PspaApplication* pspa)
     43: WContainerWidget(),
     44firstTimeInsertMessage_(NULL),
     45dropZoneLeft_(NULL),
     46dropZoneRight_(NULL),
     47abstractElement_(NULL),
     48elementName_(NULL),
     49pspa_(pspa)
     50{
     51    // set the css name
     52    setObjectName("elementLigneFaisceau");
     53
    5054    initialize_ligneFaisceau(abstractElement);
    5155}
     
    7276   
    7377    // add first line :  initialize arrow and link images
    74     dropZoneLeft_ = new GWt_dropZoneLigneFaisceau();
     78    dropZoneLeft_ = new GWt_dropZoneLigneFaisceau(pspa_);
    7579    dragElementZone_ = new WContainerWidget();
    76     dropZoneRight_ = new GWt_dropZoneLigneFaisceau();
     80    dropZoneRight_ = new GWt_dropZoneLigneFaisceau(pspa_);
    7781   
    7882    // change object name in order to manage css :
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_fit.cc

    r289 r292  
    4848   
    4949    // make image
    50     image_ = new WImage("htdocs/fit.jpg",this);
     50    image_ = new WImage(getBigImageURL(),this);
    5151   
    5252    // activate slots
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc

    r289 r292  
    3838    // add the first drop zone
    3939    decorationStyle().setBorder (WBorder (WBorder::Dotted));
    40     GWt_dropZoneLigneFaisceau* allDropZone= new GWt_dropZoneLigneFaisceau();
     40    GWt_dropZoneLigneFaisceau* allDropZone= new GWt_dropZoneLigneFaisceau(pspa_);
    4141    WVBoxLayout* fit = new WVBoxLayout();
    4242    allDropZone->setLayout(fit);
     
    6868        nObjets_[ptr->getNomdElement().getElementType()].incr();
    6969
    70         ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaisceau(ptr),1);
     70        ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaisceau(ptr,pspa_),1);
    7171       
    7272    }
     
    104104            ligneFaisceauLayout_->clear();
    105105            // add first element
    106             ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaisceau(ptr),1);
     106            ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaisceau(ptr,pspa_),1);
    107107            // remove arrow from begin and end
    108108           
     
    129129        if (index != -1) {
    130130            nObjets_[ptr->getNomdElement().getElementType()].incr();
    131             ligneFaisceauLayout_->insertWidget(index,new GWt_elementLigneFaisceau(ptr),1);
     131            ligneFaisceauLayout_->insertWidget(index,new GWt_elementLigneFaisceau(ptr,pspa_),1);
    132132        }
    133133    }
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc

    r289 r292  
    189189    //  nomdElements bidon;
    190190   
    191     // FIXME a reprendre avec un patern
    192     createDragImage("htdocs/beam.jpg","htdocs/beam.jpg","htdocs/beam.jpg",palette,"beam");
    193     new WBreak(palette);
    194     createDragImage("htdocs/rfgun.jpg","htdocs/rfgun.jpg","htdocs/rfgun.jpg",palette,"rfgun");
    195     new WBreak(palette);
    196     createDragImage("htdocs/drift.jpg","htdocs/drift.jpg","htdocs/drift.jpg",palette,"drift");
    197     new WBreak(palette);
    198     createDragImage("htdocs/cell.jpg","htdocs/cell.jpg","htdocs/cell.jpg",palette,"cell");
    199     new WBreak(palette);
    200     createDragImage("htdocs/bend.jpg","htdocs/bend.jpg","htdocs/bend.jpg",palette,"bend");
    201     new WBreak(palette);
    202     createDragImage("htdocs/soleno.jpg","htdocs/soleno.jpg","htdocs/soleno.jpg",palette,"soleno");
    203     new WBreak(palette);
    204     createDragImage("htdocs/fit.jpg","htdocs/fit.jpg","htdocs/fit.jpg",palette,"fit");
    205     new WBreak(palette);
    206    
     191    vector <GWt_abstractElement*> elems = abstractElementFactory_->getAllElements();
     192    for (int a = 0; a< elems.size(); a++) {
     193        elems[a]->createDragImage(palette);
     194        new WBreak(palette);
     195    }
    207196   
    208197    //  palette->setMinimumSize(100,300);
     
    214203{
    215204    GWt_draggableImage *result = new GWt_draggableImage(url,p);
    216     WImage *dragImage = new WImage(smallurl,p);
    217205   
    218206    /*
     
    220208     * to be used as the widget that is visually dragged.
    221209     */
    222     result->setDraggable(mimeType,dragImage,true);
     210    result->setDraggable(mimeType,new WImage(smallurl,p),true);
    223211}
    224212
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_rfgun.cc

    r289 r292  
    4343   
    4444    // make image
    45     image_ = new WImage("htdocs/rfgun.jpg",this);
     45    image_ = new WImage(getBigImageURL(),this);
    4646   
    4747    // activate slots
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_soleno.cc

    r289 r292  
    2929   
    3030    // make image
    31     image_ = new WImage("htdocs/soleno.jpg",this);
     31    image_ = new WImage(getBigImageURL(),this);
    3232   
    3333    // activate slots
Note: See TracChangeset for help on using the changeset viewer.