Changeset 442

Show
Ignore:
Timestamp:
12/13/11 11:31:01 (5 months ago)
Author:
Carsten
Message:

CaWE: The horizontal and vertical subdivisions of Bezier Patches can now be set in the Properties dialog.

The same functionality used to be available in the "New Bezier Patch" tool options bar, where it however was ill-placed and has been removed.

Location:
cafu/trunk/CaWE
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • cafu/trunk/CaWE/DialogInsp-PrimitiveProps.cpp

    r414 r442  
    3333#include "MapCommands/ChangePlantDescr.hpp" 
    3434#include "MapCommands/ModifyModel.hpp" 
     35#include "MapCommands/SetBPSubdivs.hpp" 
    3536 
    3637#include "wx/notebook.h" 
     
    5051                      const wxString& label=wxPG_LABEL, 
    5152                      const wxString& value=wxEmptyString, 
    52                       MapDocumentT* MapDoc_=NULL, 
    53                       wxString Filter_="All files (*.*)|*.*", 
    54                       wxString SubDir_=wxEmptyString) 
     53                      MapDocumentT* MapDoc=NULL, 
     54                      wxString Filter="All files (*.*)|*.*", 
     55                      wxString SubDir=wxEmptyString) 
    5556        : wxLongStringProperty(name, label, value), 
    56           MapDoc(MapDoc_), 
    57           Filter(Filter_), 
    58           SubDir(SubDir_) 
     57          m_MapDoc(MapDoc), 
     58          m_Filter(Filter), 
     59          m_SubDir(SubDir) 
    5960    { 
    6061    } 
     
    6364    virtual bool OnButtonClick(wxPropertyGrid* propGrid, wxString& value) 
    6465    { 
    65         wxString InitialDir =MapDoc->GetGameConfig()->ModDir+SubDir; 
    66         wxString FileNameStr=wxFileSelector("Please select a file", InitialDir, "", "", Filter, wxFD_OPEN | wxFD_FILE_MUST_EXIST); 
     66        wxString InitialDir =m_MapDoc->GetGameConfig()->ModDir+m_SubDir; 
     67        wxString FileNameStr=wxFileSelector("Please select a file", InitialDir, "", "", m_Filter, wxFD_OPEN | wxFD_FILE_MUST_EXIST); 
    6768 
    6869        if (FileNameStr=="") return false; 
    6970 
    7071        wxFileName FileName(FileNameStr); 
    71         FileName.MakeRelativeTo(MapDoc->GetGameConfig()->ModDir); 
     72        FileName.MakeRelativeTo(m_MapDoc->GetGameConfig()->ModDir); 
    7273        value=FileName.GetFullPath(wxPATH_UNIX); 
    7374        return true; 
     
    7778    private: 
    7879 
    79     MapDocumentT* MapDoc; 
    80     wxString      Filter; 
    81     wxString      SubDir; 
     80    MapDocumentT* m_MapDoc; 
     81    wxString      m_Filter; 
     82    wxString      m_SubDir; 
    8283}; 
    8384 
    8485 
    85 BEGIN_EVENT_TABLE(InspDlgPrimitivePropsT, wxPanel) 
    86     EVT_PG_CHANGED(ID_PROPERTY_GRID_MAN, InspDlgPrimitivePropsT::OnPropertyGridChanged) 
    87 END_EVENT_TABLE() 
    88  
    89  
    9086wxSizer* InspDlgPrimitivePropsT::InspectorPrimitivePropsInit(wxWindow* parent, bool call_fit, bool set_sizer) 
    9187{ 
    9288    wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); 
    9389 
    94     SelectionText=new wxStaticText(parent, -1, wxT("No map primitve is selected."), wxDefaultPosition, wxDefaultSize, 0); 
    95     item0->Add(SelectionText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2); 
     90    m_SelectionText=new wxStaticText(parent, -1, wxT("No map primitve is selected."), wxDefaultPosition, wxDefaultSize, 0); 
     91    item0->Add(m_SelectionText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2); 
    9692 
    9793    // BEGIN CUSTOM code, not generated by wxDesigner. 
    9894 
    99     PropMan=new wxPropertyGridManager(this, ID_PROPERTY_GRID_MAN, wxDefaultPosition, wxDefaultSize, wxPG_BOLD_MODIFIED | wxPG_SPLITTER_AUTO_CENTER | wxPG_TOOLBAR | wxPG_DESCRIPTION); 
    100     PropMan->SetExtraStyle(wxPG_EX_HELP_AS_TOOLTIPS | wxPG_EX_MODE_BUTTONS); 
    101  
    102     PropMan->AddPage("Properties"); 
     95    m_PropMan=new wxPropertyGridManager(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxPG_BOLD_MODIFIED | wxPG_SPLITTER_AUTO_CENTER | wxPG_TOOLBAR | wxPG_DESCRIPTION); 
     96    m_PropMan->SetExtraStyle(wxPG_EX_HELP_AS_TOOLTIPS | wxPG_EX_MODE_BUTTONS); 
     97 
     98    m_PropMan->AddPage("Properties"); 
    10399 
    104100    // END CUSTOM code, not generated by wxDesigner. 
    105101 
    106     item0->Add( PropMan, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 2 ); 
     102    item0->Add( m_PropMan, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 2 ); 
    107103 
    108104    if (set_sizer) 
     
    117113 
    118114 
    119 InspDlgPrimitivePropsT::InspDlgPrimitivePropsT(wxWindow* Parent_, MapDocumentT* MapDoc_) 
    120     : wxPanel(Parent_), 
    121       MapDoc(MapDoc_), 
    122       SelectionText(NULL), 
    123       IsRecursiveSelfNotify(false) 
    124 { 
     115InspDlgPrimitivePropsT::InspDlgPrimitivePropsT(wxWindow* Parent, MapDocumentT* MapDoc) 
     116    : wxPanel(Parent), 
     117      m_MapDoc(MapDoc), 
     118      m_PropMan(NULL), 
     119      m_SelectionText(NULL), 
     120      m_IsRecursiveSelfNotify(false) 
     121{ 
     122    wxPropertyGridInterface::RegisterAdditionalEditors(); 
     123 
    125124    InspectorPrimitivePropsInit(this); 
    126     MapDoc->RegisterObserver(this); 
     125    Bind(wxEVT_PG_CHANGED, &InspDlgPrimitivePropsT::OnPropertyGridChanged, this); 
     126    m_MapDoc->RegisterObserver(this); 
    127127} 
    128128 
     
    130130InspDlgPrimitivePropsT::~InspDlgPrimitivePropsT() 
    131131{ 
    132     PropMan->Clear(); 
    133     if (MapDoc) MapDoc->UnregisterObserver(this); 
     132    m_PropMan->Clear(); 
     133    if (m_MapDoc) m_MapDoc->UnregisterObserver(this); 
    134134} 
    135135 
     
    137137void InspDlgPrimitivePropsT::NotifySubjectChanged_Selection(SubjectT* Subject, const ArrayT<MapElementT*>& OldSelection, const ArrayT<MapElementT*>& NewSelection) 
    138138{ 
    139     if (IsRecursiveSelfNotify) return; 
     139    if (m_IsRecursiveSelfNotify) return; 
    140140 
    141141    UpdateGrid(); 
     
    145145void InspDlgPrimitivePropsT::NotifySubjectChanged_Deleted(SubjectT* Subject, const ArrayT<MapElementT*>& MapElements) 
    146146{ 
    147     // No need to react on deleted objects. 
     147    // No need to act on deleted objects. 
    148148    // If the deletion of an object changes the current selection the inspector is notified in the NotifySubjectChanged_Selection method. 
    149149} 
     
    152152void InspDlgPrimitivePropsT::NotifySubjectChanged_Modified(SubjectT* Subject, const ArrayT<MapElementT*>& MapElements, MapElemModDetailE Detail) 
    153153{ 
    154     if (IsRecursiveSelfNotify) return; 
     154    if (m_IsRecursiveSelfNotify) return; 
    155155 
    156156    if (Detail!=MEMD_PRIMITIVE_PROPS_CHANGED && Detail!=MEMD_GENERIC) return; 
     
    169169void InspDlgPrimitivePropsT::NotifySubjectChanged_Modified(SubjectT* Subject, const ArrayT<MapElementT*>& MapElements, MapElemModDetailE Detail, const ArrayT<BoundingBox3fT>& OldBounds) 
    170170{ 
    171     if (IsRecursiveSelfNotify) return; 
     171    if (m_IsRecursiveSelfNotify) return; 
    172172 
    173173    if (Detail!=MEMD_PRIMITIVE_PROPS_CHANGED) return; 
     
    186186void InspDlgPrimitivePropsT::NotifySubjectDies(SubjectT* dyingSubject) 
    187187{ 
    188     wxASSERT(dyingSubject==MapDoc); 
    189     MapDoc=NULL; 
     188    wxASSERT(dyingSubject==m_MapDoc); 
     189    m_MapDoc=NULL; 
    190190} 
    191191 
     
    195195    ArrayT<MapPrimitiveT*> SelectedPrimitives; 
    196196 
    197     // Loop over the map selection in order to determine the list of selected map primitves. 
    198     for (unsigned long i=0; i<MapDoc->GetSelection().Size(); i++) 
    199     { 
    200         MapPrimitiveT* Prim=dynamic_cast<MapPrimitiveT*>(MapDoc->GetSelection()[i]); 
     197    // Find the map primitives in the selection (ignore all entities). 
     198    // There is no need to bother with the entities, as it's up to the selection tool 
     199    // to explicitly add their items/children to the selection - or not. 
     200    for (unsigned long i=0; i<m_MapDoc->GetSelection().Size(); i++) 
     201    { 
     202        MapPrimitiveT* Prim=dynamic_cast<MapPrimitiveT*>(m_MapDoc->GetSelection()[i]); 
    201203 
    202204        if (Prim) 
    203         { 
    204205            SelectedPrimitives.PushBack(Prim); 
    205             continue; 
    206         } 
    207  
    208         MapEntityBaseT* Ent=dynamic_cast<MapEntityBaseT*>(MapDoc->GetSelection()[i]); 
    209  
    210         if (Ent) 
    211         { 
    212             SelectedPrimitives.PushBack(Ent->GetPrimitives()); 
    213             continue; 
    214         } 
    215206    } 
    216207 
    217208    // Update the selection description text. 
    218209    if (SelectedPrimitives.Size()==0) 
    219         SelectionText->SetLabel("No map primitive selected."); 
     210        m_SelectionText->SetLabel("No map primitive selected."); 
    220211    else if (SelectedPrimitives.Size()==1) 
    221         SelectionText->SetLabel("1 map primitive selected."); 
     212        m_SelectionText->SetLabel("1 map primitive selected."); 
    222213    else 
    223         SelectionText->SetLabel(wxString::Format("%lu map primitives selected.", SelectedPrimitives.Size())); 
    224  
    225     PropMan->ClearSelection();              // Clear the property grid. 
    226     PropMan->ClearPage(0);                  // At the moment we only got one page, so we only need to delete this page. 
    227  
    228     unsigned int BrushCount  =0; 
    229     unsigned int BPCount     =0; 
    230     unsigned int TerrainCount=0; 
    231     unsigned int PlantCount  =0; 
    232     unsigned int ModelCount  =0; 
     214        m_SelectionText->SetLabel(wxString::Format("%lu map primitives selected.", SelectedPrimitives.Size())); 
     215 
     216    m_PropMan->ClearSelection();    // Clear the property grid. 
     217    m_PropMan->ClearPage(0);        // At the moment we only got one page, so we only need to delete this page. 
     218 
     219    static const wxColour HEADING_COLOR("#CCCCCC"); 
    233220 
    234221    // Create a category for every selected map primitve and fill it with the primitves properties. 
    235222    for (unsigned long i=0; i<SelectedPrimitives.Size(); i++) 
    236223    { 
     224        const int      EntityNr=m_MapDoc->GetEntities().Find(SelectedPrimitives[i]->GetParent()); 
     225        const int      ItemNr  =EntityNr>=0 ? m_MapDoc->GetEntities()[EntityNr]->GetPrimitives().Find(SelectedPrimitives[i]) : -1; 
     226        const wxString ItemStr =wxString::Format(" (item %i in entity %i)", ItemNr, EntityNr); 
     227 
    237228        if (dynamic_cast<MapBrushT*>(SelectedPrimitives[i])!=NULL) 
    238229        { 
    239             wxPGProperty* Cat=PropMan->Append(new wxStringProperty(SelectedPrimitives[i]->GetType()->ClassName+wxString::Format("%i", ++BrushCount), wxPG_LABEL, "<composed>")); 
    240             PropMan->DisableProperty(Cat); 
     230            wxPGProperty* Cat=m_PropMan->Append(new wxStringProperty("Brush" + ItemStr, wxPG_LABEL, "<composed>")); 
     231 
     232            // Must do this last, as new children pick up the color of their parent. 
     233            m_PropMan->SetPropertyBackgroundColour(Cat, HEADING_COLOR, 0 /*don't recurse*/); 
    241234        } 
    242235 
    243236        if (dynamic_cast<MapBezierPatchT*>(SelectedPrimitives[i])!=NULL) 
    244237        { 
    245             wxPGProperty* Cat=PropMan->Append(new wxStringProperty(SelectedPrimitives[i]->GetType()->ClassName+wxString::Format("%i", ++BPCount), wxPG_LABEL, "<composed>")); 
    246             PropMan->DisableProperty(Cat); 
     238            wxPGProperty* Cat=m_PropMan->Append(new wxStringProperty("Bezier Patch" + ItemStr, wxPG_LABEL, "<composed>")); 
     239            MapBezierPatchT* BP=(MapBezierPatchT*)SelectedPrimitives[i]; 
     240 
     241            wxPGProperty* SdHorzIntProp=new wxIntProperty("Subdivs horz", wxPG_LABEL, BP->GetSubdivsHorz()); 
     242            m_PropMan->AppendIn(Cat, SdHorzIntProp)->SetClientData(BP); 
     243            m_PropMan->SetPropertyEditor(SdHorzIntProp, wxPGEditor_SpinCtrl); 
     244 
     245            wxPGProperty* SdVertIntProp=new wxIntProperty("Subdivs vert", wxPG_LABEL, BP->GetSubdivsVert()); 
     246            m_PropMan->AppendIn(Cat, SdVertIntProp)->SetClientData(BP); 
     247            m_PropMan->SetPropertyEditor(SdVertIntProp, wxPGEditor_SpinCtrl); 
     248 
     249            // Must do this last, as new children pick up the color of their parent. 
     250            m_PropMan->SetPropertyBackgroundColour(Cat, HEADING_COLOR, 0 /*don't recurse*/); 
    247251        } 
    248252 
    249253        if (dynamic_cast<MapTerrainT*>(SelectedPrimitives[i])!=NULL) 
    250254        { 
    251             wxPGProperty* Cat=PropMan->Append(new wxStringProperty(SelectedPrimitives[i]->GetType()->ClassName+wxString::Format("%i", ++TerrainCount), wxPG_LABEL, "<composed>")); 
    252             PropMan->DisableProperty(Cat); 
     255            wxPGProperty* Cat=m_PropMan->Append(new wxStringProperty("Terrain" + ItemStr, wxPG_LABEL, "<composed>")); 
     256 
     257            // Must do this last, as new children pick up the color of their parent. 
     258            m_PropMan->SetPropertyBackgroundColour(Cat, HEADING_COLOR, 0 /*don't recurse*/); 
    253259        } 
    254260 
    255261        if (dynamic_cast<MapPlantT*>(SelectedPrimitives[i])!=NULL) 
    256262        { 
    257             wxPGProperty* Cat=PropMan->Append(new wxStringProperty(SelectedPrimitives[i]->GetType()->ClassName+wxString::Format("%i", ++PlantCount), wxPG_LABEL, "<composed>")); 
    258             PropMan->DisableProperty(Cat); 
    259  
     263            wxPGProperty* Cat=m_PropMan->Append(new wxStringProperty("Plant" + ItemStr, wxPG_LABEL, "<composed>")); 
    260264            MapPlantT* Plant=(MapPlantT*)SelectedPrimitives[i]; 
    261265 
    262             PropMan->AppendIn(Cat, new GameFilePropertyT("Plant Description", wxPG_LABEL, Plant->m_DescrFileName, MapDoc, "Plant Description Files (*.cpd)|*.cpd|All Files (*.*)|*.*", "/Plants/"))->SetClientData(Plant); 
    263             PropMan->AppendIn(Cat, new wxIntProperty("Random Seed", wxPG_LABEL, Plant->m_RandomSeed))->SetClientData(Plant); 
     266            m_PropMan->AppendIn(Cat, new GameFilePropertyT("Plant Description", wxPG_LABEL, Plant->m_DescrFileName, m_MapDoc, "Plant Description Files (*.cpd)|*.cpd|All Files (*.*)|*.*", "/Plants/"))->SetClientData(Plant); 
     267            m_PropMan->AppendIn(Cat, new wxIntProperty("Random Seed", wxPG_LABEL, Plant->m_RandomSeed))->SetClientData(Plant); 
     268 
     269            // Must do this last, as new children pick up the color of their parent. 
     270            m_PropMan->SetPropertyBackgroundColour(Cat, HEADING_COLOR, 0 /*don't recurse*/); 
    264271        } 
    265272 
    266273        if (dynamic_cast<MapModelT*>(SelectedPrimitives[i])!=NULL) 
    267274        { 
    268             wxPGProperty* Cat=PropMan->Append(new wxStringProperty(SelectedPrimitives[i]->GetType()->ClassName+wxString::Format("%i", ++ModelCount), wxPG_LABEL, "<composed>")); 
    269             PropMan->DisableProperty(Cat); 
    270  
     275            wxPGProperty* Cat=m_PropMan->Append(new wxStringProperty("Model" + ItemStr, wxPG_LABEL, "<composed>")); 
    271276            MapModelT* Model=(MapModelT*)SelectedPrimitives[i]; 
    272277 
    273             PropMan->AppendIn(Cat, new GameFilePropertyT("Model",           wxPG_LABEL, Model->m_Model->GetFileName(), MapDoc, "All Files (*.*)|*.*|Model files (*.mdl)|*.mdl|Model Files (*.ase)|*.ase|Model Files (*.dlod)|*.dlod", "/Models/"))->SetClientData(Model); 
    274             PropMan->AppendIn(Cat, new GameFilePropertyT("Collision Model", wxPG_LABEL, Model->m_CollModelFileName, MapDoc, "Collision Model (*.cmap)|*.cmap|All Files (*.*)|*.*", "/Models/"))->SetClientData(Model); 
    275             PropMan->AppendIn(Cat, new wxStringProperty ("Label",           wxPG_LABEL, Model->m_Label))->SetClientData(Model); 
    276             PropMan->AppendIn(Cat, new wxFloatProperty  ("Scale",           wxPG_LABEL, Model->m_Scale))->SetClientData(Model); 
    277             PropMan->AppendIn(Cat, new wxIntProperty    ("Sequence Number", wxPG_LABEL, Model->m_SeqNumber))->SetClientData(Model); 
    278             PropMan->AppendIn(Cat, new wxFloatProperty  ("Frame Offset",    wxPG_LABEL, Model->m_FrameOffset))->SetClientData(Model); 
    279             PropMan->AppendIn(Cat, new wxFloatProperty  ("Frame Scale",     wxPG_LABEL, Model->m_FrameTimeScale))->SetClientData(Model); 
    280  
    281             wxPGProperty* AnimateProp=PropMan->AppendIn(Cat, new wxBoolProperty("Animated", wxPG_LABEL, Model->m_Animated)); 
     278            m_PropMan->AppendIn(Cat, new GameFilePropertyT("Model",           wxPG_LABEL, Model->m_Model->GetFileName(), m_MapDoc, "All Files (*.*)|*.*|Model files (*.mdl)|*.mdl|Model Files (*.ase)|*.ase|Model Files (*.dlod)|*.dlod", "/Models/"))->SetClientData(Model); 
     279            m_PropMan->AppendIn(Cat, new GameFilePropertyT("Collision Model", wxPG_LABEL, Model->m_CollModelFileName, m_MapDoc, "Collision Model (*.cmap)|*.cmap|All Files (*.*)|*.*", "/Models/"))->SetClientData(Model); 
     280            m_PropMan->AppendIn(Cat, new wxStringProperty ("Label",           wxPG_LABEL, Model->m_Label))->SetClientData(Model); 
     281            m_PropMan->AppendIn(Cat, new wxFloatProperty  ("Scale",           wxPG_LABEL, Model->m_Scale))->SetClientData(Model); 
     282            m_PropMan->AppendIn(Cat, new wxIntProperty    ("Sequence Number", wxPG_LABEL, Model->m_SeqNumber))->SetClientData(Model); 
     283            m_PropMan->AppendIn(Cat, new wxFloatProperty  ("Frame Offset",    wxPG_LABEL, Model->m_FrameOffset))->SetClientData(Model); 
     284            m_PropMan->AppendIn(Cat, new wxFloatProperty  ("Frame Scale",     wxPG_LABEL, Model->m_FrameTimeScale))->SetClientData(Model); 
     285 
     286            wxPGProperty* AnimateProp=m_PropMan->AppendIn(Cat, new wxBoolProperty("Animated", wxPG_LABEL, Model->m_Animated)); 
    282287            AnimateProp->SetClientData(Model); 
    283             PropMan->SetPropertyAttributeAll(wxPG_BOOL_USE_CHECKBOX, true); // Use checkbox instead of choice. 
    284         } 
    285     } 
    286  
    287     PropMan->RefreshGrid(); 
     288            m_PropMan->SetPropertyAttributeAll(wxPG_BOOL_USE_CHECKBOX, true); // Use checkbox instead of choice. 
     289 
     290            // Must do this last, as new children pick up the color of their parent. 
     291            m_PropMan->SetPropertyBackgroundColour(Cat, HEADING_COLOR, 0 /*don't recurse*/); 
     292        } 
     293    } 
     294 
     295    m_PropMan->RefreshGrid(); 
    288296} 
    289297 
     
    297305    if (Object->GetType()==&MapBrushT::TypeInfo) 
    298306    { 
    299         // Nothing yet. 
     307        // TODO. 
    300308    } 
    301309    else if (Object->GetType()==&MapBezierPatchT::TypeInfo) 
    302310    { 
    303         // Nothing yet. 
     311        MapBezierPatchT*    BP      =(MapBezierPatchT*)Object; 
     312        const wxPGProperty* Prop    =Event.GetProperty(); 
     313        const wxString      PropName=Prop->GetName().AfterLast('.'); 
     314        CommandT*           Command =NULL; 
     315 
     316        if (PropName=="Subdivs horz") 
     317            Command=new CommandSetBPSubdivsT(m_MapDoc, BP, Prop->GetValue().GetLong(), HORIZONTAL); 
     318        else if (PropName=="Subdivs vert") 
     319            Command=new CommandSetBPSubdivsT(m_MapDoc, BP, Prop->GetValue().GetLong(), VERTICAL); 
     320 
     321        if (Command) 
     322        { 
     323            m_IsRecursiveSelfNotify=true; 
     324            m_MapDoc->GetHistory().SubmitCommand(Command); 
     325            m_IsRecursiveSelfNotify=false; 
     326        } 
    304327    } 
    305328    else if (Object->GetType()==&MapTerrainT::TypeInfo) 
    306329    { 
    307         // Nothing yet. 
     330        // TODO. 
    308331    } 
    309332    else if (Object->GetType()==&MapPlantT::TypeInfo) 
     
    317340        { 
    318341            // Command to change the random seed. 
    319             CommandT* Command=new CommandChangePlantSeedT(*MapDoc, Plant, Event.GetProperty()->GetValue().GetLong()); 
    320  
    321             IsRecursiveSelfNotify=true; 
    322             MapDoc->GetHistory().SubmitCommand(Command); 
    323             IsRecursiveSelfNotify=false; 
     342            CommandT* Command=new CommandChangePlantSeedT(*m_MapDoc, Plant, Event.GetProperty()->GetValue().GetLong()); 
     343 
     344            m_IsRecursiveSelfNotify=true; 
     345            m_MapDoc->GetHistory().SubmitCommand(Command); 
     346            m_IsRecursiveSelfNotify=false; 
    324347        } 
    325348 
     
    327350        { 
    328351            // Command to change the plant description. 
    329             CommandT* Command=new CommandChangePlantDescrT(*MapDoc, Plant, Event.GetProperty()->GetValueAsString()); 
    330  
    331             IsRecursiveSelfNotify=true; 
    332             MapDoc->GetHistory().SubmitCommand(Command); 
    333             IsRecursiveSelfNotify=false; 
     352            CommandT* Command=new CommandChangePlantDescrT(*m_MapDoc, Plant, Event.GetProperty()->GetValueAsString()); 
     353 
     354            m_IsRecursiveSelfNotify=true; 
     355            m_MapDoc->GetHistory().SubmitCommand(Command); 
     356            m_IsRecursiveSelfNotify=false; 
    334357        } 
    335358    } 
     
    345368 
    346369        if (PropName=="Model") 
    347             Command=new CommandModifyModelT(*MapDoc, Model, Prop->GetValueAsString(), Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 
     370            Command=new CommandModifyModelT(*m_MapDoc, Model, Prop->GetValueAsString(), Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 
    348371        else if (PropName=="Collision Model") 
    349             Command=new CommandModifyModelT(*MapDoc, Model, Model->m_ModelFileName, Prop->GetValueAsString(), Model->m_Label, Model->m_Scale, Model->m_SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 
     372            Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Prop->GetValueAsString(), Model->m_Label, Model->m_Scale, Model->m_SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 
    350373        else if (PropName=="Label") 
    351             Command=new CommandModifyModelT(*MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Prop->GetValueAsString(), Model->m_Scale, Model->m_SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 
     374            Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Prop->GetValueAsString(), Model->m_Scale, Model->m_SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 
    352375        else if (PropName=="Scale") 
    353             Command=new CommandModifyModelT(*MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, PropValueF, Model->m_SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 
     376            Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, PropValueF, Model->m_SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 
    354377        else if (PropName=="Sequence Number") 
    355             Command=new CommandModifyModelT(*MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Prop->GetValue().GetLong(), Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 
     378            Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Prop->GetValue().GetLong(), Model->m_FrameOffset, Model->m_FrameTimeScale, Model->m_Animated); 
    356379        else if (PropName=="Frame Offset") 
    357             Command=new CommandModifyModelT(*MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_SeqNumber, PropValueF, Model->m_FrameTimeScale, Model->m_Animated); 
     380            Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_SeqNumber, PropValueF, Model->m_FrameTimeScale, Model->m_Animated); 
    358381        else if (PropName=="Frame Scale") 
    359             Command=new CommandModifyModelT(*MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_SeqNumber, Model->m_FrameOffset, PropValueF, Model->m_Animated); 
     382            Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_SeqNumber, Model->m_FrameOffset, PropValueF, Model->m_Animated); 
    360383        else if (PropName=="Animated") 
    361             Command=new CommandModifyModelT(*MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Prop->GetValue().GetBool()); 
     384            Command=new CommandModifyModelT(*m_MapDoc, Model, Model->m_ModelFileName, Model->m_CollModelFileName, Model->m_Label, Model->m_Scale, Model->m_SeqNumber, Model->m_FrameOffset, Model->m_FrameTimeScale, Prop->GetValue().GetBool()); 
    362385 
    363386        if (Command) 
    364387        { 
    365             IsRecursiveSelfNotify=true; 
    366             MapDoc->GetHistory().SubmitCommand(Command); 
    367             IsRecursiveSelfNotify=false; 
     388            m_IsRecursiveSelfNotify=true; 
     389            m_MapDoc->GetHistory().SubmitCommand(Command); 
     390            m_IsRecursiveSelfNotify=false; 
    368391        } 
    369392    } 
  • cafu/trunk/CaWE/DialogInsp-PrimitiveProps.hpp

    r285 r442  
    3838    public: 
    3939 
    40     InspDlgPrimitivePropsT(wxWindow* Parent_, MapDocumentT* MapDoc_); 
     40    InspDlgPrimitivePropsT(wxWindow* Parent, MapDocumentT* MapDoc); 
    4141    ~InspDlgPrimitivePropsT(); 
    4242 
     
    5252 
    5353    wxSizer* InspectorPrimitivePropsInit(wxWindow* parent, bool call_fit=true, bool set_sizer=true); 
    54  
    55     void UpdateGrid(); 
     54    void     UpdateGrid(); 
    5655 
    5756    // Event handler methods. 
    5857    void OnPropertyGridChanged(wxPropertyGridEvent& Event); 
    5958 
    60     MapDocumentT*          MapDoc; 
    61     wxPropertyGridManager* PropMan; 
    62     wxStaticText*          SelectionText;  ///< Text that is displayed above the property grid. It shows the number of selected primitives. 
    63  
    64     bool IsRecursiveSelfNotify; 
    65  
    66  
    67     // IDs for the controls whose events we are interested in. 
    68     enum 
    69     { 
    70         ID_PROPERTY_GRID_MAN=wxID_HIGHEST+1 
    71     }; 
    72  
    73     DECLARE_EVENT_TABLE() 
     59    MapDocumentT*          m_MapDoc; 
     60    wxPropertyGridManager* m_PropMan; 
     61    wxStaticText*          m_SelectionText;   ///< Text that is displayed above the property grid. It shows the number of selected primitives. 
     62    bool                   m_IsRecursiveSelfNotify; 
    7463}; 
    7564 
  • cafu/trunk/CaWE/ToolOptionsBars.cpp

    r285 r442  
    2727#include "ToolClip.hpp" 
    2828#include "ToolMorph.hpp" 
    29 #include "MapCommands/SetBPSubdivs.hpp" 
    3029 
    3130#include "wx/statline.h" 
     
    234233 
    235234BEGIN_EVENT_TABLE(OptionsBar_NewBezierPatchToolT, wxPanel) 
    236     EVT_CHOICE  (OptionsBar_NewBezierPatchToolT::ID_PATCHTYPE,   OptionsBar_NewBezierPatchToolT::OnPatchTypeChoice) 
    237     EVT_SPINCTRL(OptionsBar_NewBezierPatchToolT::ID_SUBDIVSHORZ, OptionsBar_NewBezierPatchToolT::OnSubdivsSpinChangeHorz) 
    238     EVT_SPINCTRL(OptionsBar_NewBezierPatchToolT::ID_SUBDIVSVERT, OptionsBar_NewBezierPatchToolT::OnSubdivsSpinChangeVert) 
    239     EVT_TEXT    (OptionsBar_NewBezierPatchToolT::ID_SUBDIVSHORZ, OptionsBar_NewBezierPatchToolT::OnSubdivsManualChangeHorz) 
    240     EVT_TEXT    (OptionsBar_NewBezierPatchToolT::ID_SUBDIVSVERT, OptionsBar_NewBezierPatchToolT::OnSubdivsManualChangeVert) 
     235    EVT_CHOICE(OptionsBar_NewBezierPatchToolT::ID_PATCHTYPE, OptionsBar_NewBezierPatchToolT::OnPatchTypeChoice) 
    241236END_EVENT_TABLE() 
    242237 
     
    399394 
    400395 
    401 void OptionsBar_NewBezierPatchToolT::OnSubdivsSpinChangeHorz(wxSpinEvent& Event) 
    402 { 
    403     // If more objects or no BP is selected, do nothing. 
    404     if (m_MapDoc.GetSelection().Size()!=1) return; 
    405  
    406     // If one object is selected and this object is a bezier patch, update the BP. 
    407     MapBezierPatchT* selectedBP=dynamic_cast<MapBezierPatchT*>(m_MapDoc.GetSelection()[0]); 
    408  
    409     if (selectedBP!=NULL) 
    410         m_MapDoc.GetHistory().SubmitCommand(new CommandSetBPSubdivsT(&m_MapDoc, selectedBP, m_SpinCtrlSubdivsHorz->GetValue(), HORIZONTAL)); 
    411 } 
    412  
    413  
    414 void OptionsBar_NewBezierPatchToolT::OnSubdivsSpinChangeVert(wxSpinEvent& Event) 
    415 { 
    416     // If more objects or no BP is selected, do nothing. 
    417     if (m_MapDoc.GetSelection().Size()!=1) return; 
    418  
    419     // If one object is selected and this object is a bezier patch, update the BP. 
    420     MapBezierPatchT* selectedBP=dynamic_cast<MapBezierPatchT*>(m_MapDoc.GetSelection()[0]); 
    421  
    422     if (selectedBP!=NULL) 
    423         m_MapDoc.GetHistory().SubmitCommand(new CommandSetBPSubdivsT(&m_MapDoc, selectedBP, m_SpinCtrlSubdivsVert->GetValue(), VERTICAL)); 
    424 } 
    425  
    426  
    427 void OptionsBar_NewBezierPatchToolT::OnSubdivsManualChangeHorz(wxCommandEvent& Event) 
    428 { 
    429     // SpinCtrl handles manual inputs aumatically and maps them to it's own value range, so nothing to do here except 
    430     // call the spinchange method to update the selected BP. 
    431     wxSpinEvent tmpEvent; 
    432     OnSubdivsSpinChangeHorz(tmpEvent); 
    433 } 
    434  
    435  
    436 void OptionsBar_NewBezierPatchToolT::OnSubdivsManualChangeVert(wxCommandEvent& Event) 
    437 { 
    438     // SpinCtrl handles manual inputs aumatically and maps them to it's own value range, so nothing to do here except 
    439     // call the spinchange method to update the selected BP. 
    440     wxSpinEvent tmpEvent; 
    441     OnSubdivsSpinChangeVert(tmpEvent); 
    442 } 
    443  
    444  
    445396BEGIN_EVENT_TABLE(OptionsBar_NewTerrainToolT, wxPanel) 
    446397    EVT_BUTTON(OptionsBar_NewTerrainToolT::ID_BUTTON_BROWSE, OptionsBar_NewTerrainToolT::OnButtonBrowse) 
  • cafu/trunk/CaWE/ToolOptionsBars.hpp

    r285 r442  
    150150    wxCheckBox*   m_CheckConcave; 
    151151 
    152     void OnPatchTypeChoice(wxCommandEvent& Event);         ///< Handles events that occur, when a patch type is choosen from the patch type choice box. 
    153     void OnSubdivsSpinChangeHorz(wxSpinEvent& Event);      ///< Handles events that occur, when the content of the horizontal Subdivs SpinCtrl is changed using the +/- buttons. 
    154     void OnSubdivsSpinChangeVert(wxSpinEvent& Event);      ///< Handles events that occur, when the content of the vertical Subdivs SpinCtrl is changed using the +/- buttons. 
    155     void OnSubdivsManualChangeHorz(wxCommandEvent& Event); ///< Handles events that occur, when the content of the horizontal Subdivs SpinCtrl is changed entering values manually. 
    156     void OnSubdivsManualChangeVert(wxCommandEvent& Event); ///< Handles events that occur, when the content of the vertical Subdivs SpinCtrl is changed entering values manually. 
     152    void OnPatchTypeChoice(wxCommandEvent& Event);      ///< Handles events that occur when a patch type is choosen from the patch type choice box. 
    157153 
    158154    /// IDs for the controls whose events we are interested in.