cursor_ch_control.cpp

Go to the documentation of this file.
00001 
00002 // Name:        cursor_ch_control.cpp
00003 // Purpose:     
00004 // Author:      NDA
00005 // Modified by: 
00006 // Created:     12/10/2006 10:56:03
00007 // RCS-ID:      
00008 // Copyright:   CAEN S.p.A All rights reserved.
00009 // Licence:     
00011 
00012 // Generated by DialogBlocks (unregistered), 12/10/2006 10:56:03
00013 
00014 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
00015 #pragma implementation "cursor_ch_control.h"
00016 #endif
00017 
00018 // For compilers that support precompilation, includes "wx/wx.h".
00019 #include "wx/wxprec.h"
00020 
00021 #ifdef __BORLANDC__
00022 #pragma hdrstop
00023 #endif
00024 
00025 #ifndef WX_PRECOMP
00026 #include "wx/wx.h"
00027 #endif
00028 
00031 
00032 #include "cursor_ch_control.h"
00033 
00036 
00041 IMPLEMENT_DYNAMIC_CLASS( CursorChControl, wxPanel )
00042 
00043 
00047 BEGIN_EVENT_TABLE( CursorChControl, wxPanel )
00048 
00050     EVT_TOGGLEBUTTON( ID_CURSOR_TOGGLEBUTTON, CursorChControl::OnCursorTogglebuttonClick )
00051 
00052     EVT_BUTTON( ID_CURSOR_RESET_BUTTON, CursorChControl::OnCursorResetButtonClick )
00053 
00054     EVT_SPIN( ID_CURSOR_POSITION_SPINBUTTON, CursorChControl::OnCursorPositionSpinbuttonUpdated )
00055 
00056     EVT_CHOICE( ID_CURSOR_POS_MULTIPLIER_CHOICE, CursorChControl::OnCursorPosMultiplierChoiceSelected )
00057 
00059 
00060 END_EVENT_TABLE()
00061 
00066  CursorChControl::CursorChControl( ): m_last_cursor_pos( 0)
00067 {
00068 }
00069 
00070 CursorChControl::CursorChControl( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
00071                                                                 : m_last_cursor_pos( 0)
00072 {
00073     Create(parent, id, pos, size, style);
00074 }
00075 
00080 bool CursorChControl::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
00081 {
00083     m_main_sizer_text = NULL;
00084     m_ch_enable_control = NULL;
00085     m_ch_cursor_reset_control = NULL;
00086     m_set_cursor_position_control = NULL;
00087     m_cursor_pos_multiplier_control = NULL;
00088     m_cursor_position_control = NULL;
00089     m_cursor_value_control = NULL;
00090     m_mV_label = NULL;
00092 
00094     wxPanel::Create( parent, id, pos, size, style );
00095 
00096     CreateControls();
00097     if (GetSizer())
00098     {
00099         GetSizer()->SetSizeHints(this);
00100     }
00101     Centre();
00103     return true;
00104 }
00105 
00110 void CursorChControl::CreateControls()
00111 {    
00113     // Generated by DialogBlocks, 17/01/2007 09:57:38 (unregistered)
00114 
00115     CursorChControl* itemPanel1 = this;
00116 
00117     m_main_sizer_text = new wxStaticBox(itemPanel1, wxID_ANY, _("???"));
00118     wxStaticBoxSizer* itemStaticBoxSizer2 = new wxStaticBoxSizer(m_main_sizer_text, wxHORIZONTAL);
00119     itemPanel1->SetSizer(itemStaticBoxSizer2);
00120 
00121     wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
00122     itemStaticBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_VERTICAL, 2);
00123 
00124     m_ch_enable_control = new wxToggleButton( itemPanel1, ID_CURSOR_TOGGLEBUTTON, _("???"), wxDefaultPosition, wxSize(60, -1), 0 );
00125     m_ch_enable_control->SetValue(true);
00126     m_ch_enable_control->SetHelpText(_("Enable/Disable channel cursor"));
00127     if (ShowToolTips())
00128         m_ch_enable_control->SetToolTip(_("Enable/Disable channel cursor"));
00129     m_ch_enable_control->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, _T("Verdana")));
00130     itemBoxSizer3->Add(m_ch_enable_control, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
00131 
00132     wxStaticBox* itemStaticBoxSizer5Static = new wxStaticBox(itemPanel1, wxID_ANY, _T(""));
00133     wxStaticBoxSizer* itemStaticBoxSizer5 = new wxStaticBoxSizer(itemStaticBoxSizer5Static, wxVERTICAL);
00134     itemStaticBoxSizer2->Add(itemStaticBoxSizer5, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 3);
00135 
00136     wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
00137     itemStaticBoxSizer5->Add(itemBoxSizer6, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxBOTTOM, 5);
00138 
00139     m_ch_cursor_reset_control = new wxButton( itemPanel1, ID_CURSOR_RESET_BUTTON, _("0"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
00140     m_ch_cursor_reset_control->SetHelpText(_("Reset cursor position"));
00141     if (ShowToolTips())
00142         m_ch_cursor_reset_control->SetToolTip(_("Reset cursor position"));
00143     m_ch_cursor_reset_control->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, _T("Tahoma")));
00144     itemBoxSizer6->Add(m_ch_cursor_reset_control, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 2);
00145 
00146     m_set_cursor_position_control = new wxSpinButton( itemPanel1, ID_CURSOR_POSITION_SPINBUTTON, wxDefaultPosition, wxDefaultSize, wxSP_HORIZONTAL );
00147     m_set_cursor_position_control->SetHelpText(_("Set cursor position"));
00148     if (ShowToolTips())
00149         m_set_cursor_position_control->SetToolTip(_("Set cursor position"));
00150     itemBoxSizer6->Add(m_set_cursor_position_control, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxTOP|wxBOTTOM, 2);
00151 
00152     wxString* m_cursor_pos_multiplier_controlStrings = NULL;
00153     m_cursor_pos_multiplier_control = new wxChoice( itemPanel1, ID_CURSOR_POS_MULTIPLIER_CHOICE, wxDefaultPosition, wxSize(70, -1), 0, m_cursor_pos_multiplier_controlStrings, 0 );
00154     m_cursor_pos_multiplier_control->SetHelpText(_("Set cursor position multiplier factor"));
00155     if (ShowToolTips())
00156         m_cursor_pos_multiplier_control->SetToolTip(_("Set cursor position multiplier factor"));
00157     itemStaticBoxSizer5->Add(m_cursor_pos_multiplier_control, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
00158 
00159     wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL);
00160     itemStaticBoxSizer2->Add(itemBoxSizer10, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
00161 
00162     wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxHORIZONTAL);
00163     itemBoxSizer10->Add(itemBoxSizer11, 0, wxALIGN_RIGHT|wxALL, 0);
00164 
00165     m_cursor_position_control = new wxStaticText( itemPanel1, wxID_STATIC, _("0"), wxDefaultPosition, wxSize(70, -1), 0 );
00166     m_cursor_position_control->SetHelpText(_("Cursor position (uSec)"));
00167     if (ShowToolTips())
00168         m_cursor_position_control->SetToolTip(_("Cursor position (uSec)"));
00169     m_cursor_position_control->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, _T("Tahoma")));
00170     itemBoxSizer11->Add(m_cursor_position_control, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 2);
00171 
00172     wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL);
00173     itemBoxSizer10->Add(itemBoxSizer13, 0, wxALIGN_RIGHT|wxALL, 0);
00174 
00175     m_cursor_value_control = new wxStaticText( itemPanel1, wxID_STATIC, _("0"), wxDefaultPosition, wxSize(70, -1), 0 );
00176     m_cursor_value_control->SetHelpText(_("Signal value at cursor position (mV)"));
00177     if (ShowToolTips())
00178         m_cursor_value_control->SetToolTip(_("Signal value at cursor position (mV)"));
00179     m_cursor_value_control->SetFont(wxFont(8, wxSWISS, wxNORMAL, wxBOLD, false, _T("Tahoma")));
00180     itemBoxSizer13->Add(m_cursor_value_control, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 2);
00181 
00182     wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxVERTICAL);
00183     itemStaticBoxSizer2->Add(itemBoxSizer15, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
00184 
00185     wxBoxSizer* itemBoxSizer16 = new wxBoxSizer(wxHORIZONTAL);
00186     itemBoxSizer15->Add(itemBoxSizer16, 0, wxALIGN_RIGHT|wxALL, 0);
00187 
00188     wxStaticText* itemStaticText17 = new wxStaticText( itemPanel1, wxID_STATIC, _("uS"), wxDefaultPosition, wxSize(20, -1), 0 );
00189     itemBoxSizer16->Add(itemStaticText17, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 2);
00190 
00191     wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxHORIZONTAL);
00192     itemBoxSizer15->Add(itemBoxSizer18, 0, wxALIGN_RIGHT|wxALL, 0);
00193 
00194     m_mV_label = new wxStaticText( itemPanel1, wxID_STATIC, _("mV"), wxDefaultPosition, wxSize(20, -1), 0 );
00195     itemBoxSizer18->Add(m_mV_label, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 2);
00196 
00198         this->m_set_cursor_position_control->SetRange( -9999999, 9999999);
00199 
00200         this->m_cursor_pos_multiplier_control->Append( _("x   1"));
00201         this->m_cursor_pos_multiplier_control->Append( _("x  10"));
00202         this->m_cursor_pos_multiplier_control->Append( _("x 100"));
00203         this->m_cursor_pos_multiplier_control->Append( _("x1000"));
00204 
00205         this->m_cursor_pos_multiplier_control->SetSelection( 0);
00206 }
00207 
00212 bool CursorChControl::ShowToolTips()
00213 {
00214     return true;
00215 }
00216 
00221 wxBitmap CursorChControl::GetBitmapResource( const wxString& name )
00222 {
00223     // Bitmap retrieval
00225     wxUnusedVar(name);
00226     return wxNullBitmap;
00228 }
00229 
00234 wxIcon CursorChControl::GetIconResource( const wxString& name )
00235 {
00236     // Icon retrieval
00238     wxUnusedVar(name);
00239     return wxNullIcon;
00241 }
00246 void CursorChControl::OnCursorTogglebuttonClick( wxCommandEvent& /* event*/ )
00247 {
00248         this->m_p_board_channel->m_cursor_enabled[ this->m_scope_index]= this->m_ch_enable_control->GetValue( )!= 0;
00249         this->m_ch_enable_control->SetLabel( this->m_ch_enable_control->GetValue( )? _("Disable"): _("Enable"));
00250         (this->m_p_board_channel->ScopeRefresh)( this->m_scope_index, true);
00251 }
00252 
00257 void CursorChControl::OnCursorResetButtonClick( wxCommandEvent& /*event*/ )
00258 {
00259         this->m_last_cursor_pos= 0;
00260         this->m_set_cursor_position_control->SetValue( this->m_last_cursor_pos);
00261         this->UpdateCursorPosition( 0);
00262 }
00263 
00268 void CursorChControl::OnCursorPositionSpinbuttonUpdated( wxSpinEvent& /*event*/ )
00269 {
00270         int new_pos= this->m_set_cursor_position_control->GetValue( );
00271         this->m_last_cursor_pos+= ( new_pos- this->m_last_cursor_pos)* this->GetCursorMultipler();
00272         this->m_set_cursor_position_control->SetValue( this->m_last_cursor_pos);
00273 
00274         this->UpdateCursorPosition( this->m_set_cursor_position_control->GetValue( ));
00275 }
00276 
00277 bool CursorChControl::SetupBoard( GenericBoard* p_board, int ch_index, int ch_count, int scope_index, bool is_virtual)
00278 {
00279         this->m_is_virtual= is_virtual;
00280         this->m_p_board= p_board;
00281         this->m_ch_index= ch_index;
00282         this->m_ch_count= ch_count;
00283         this->m_scope_index= scope_index;
00284         if( this->m_is_virtual)
00285         {
00286                 this->m_mV_label->SetLabel( _("  "));
00287                 if( ( size_t)this->m_ch_index>= this->m_p_board->m_virtual_channel_array.GetCount())
00288                         return false;
00289                 this->m_p_board_channel= (GenericBoardChannel*)this->m_p_board->m_virtual_channel_array[ this->m_ch_index];
00290         }
00291         else
00292         {
00293                 if( ( size_t)this->m_ch_index>= this->m_p_board->m_channel_array.GetCount())
00294                         return false;
00295                 this->m_p_board_channel= (GenericBoardChannel*)this->m_p_board->m_channel_array[ this->m_ch_index];
00296         }
00297 
00298         this->m_p_board_channel->m_p_cursor_ch_control[ scope_index]= this;
00299         
00300         if( !this->UpdateControls())
00301                 return false;
00302         return true;
00303 }
00304 bool CursorChControl::UpdateControls( )
00305 {
00306         if( this->m_is_virtual)
00307         {
00308                 this->m_main_sizer_text->SetLabel( wxString::Format( "VIRT %d", this->m_ch_count));
00309         }
00310         else
00311         {
00312                 this->m_main_sizer_text->SetLabel( wxString::Format( "%d", this->m_ch_count));
00313         }
00314         this->m_ch_enable_control->SetValue( this->m_p_board_channel->m_cursor_enabled[ this->m_scope_index]);
00315         this->m_ch_enable_control->SetLabel( this->m_ch_enable_control->GetValue( )? _("Disable"): _("Enable"));
00316 
00317         return true;
00318 }
00319 int CursorChControl::GetCursorMultipler( void)
00320 {
00321         const int MULTIPLIER_TABLE[]=
00322         {
00323                 1,
00324                 10,
00325                 100,
00326                 1000
00327         };
00328         int multiplier= 100;
00329         if( this->m_cursor_pos_multiplier_control->GetSelection()< ( sizeof( MULTIPLIER_TABLE)/ sizeof( MULTIPLIER_TABLE[0])))
00330         {
00331                 multiplier= MULTIPLIER_TABLE[ this->m_cursor_pos_multiplier_control->GetSelection()];
00332         }
00333         return multiplier;
00334 }
00335 bool CursorChControl::UpdateCursorPosition( int cursor_position)
00336 {
00337         this->m_p_board_channel->m_cursor_position[ this->m_scope_index]= cursor_position;
00338         (this->m_p_board_channel->ScopeRefresh)( this->m_scope_index, true);
00339 
00340         double position_usec= this->m_p_board_channel->Sample2Sec( this->m_p_board_channel->m_cursor_position[ this->m_scope_index])* 1000000.0;
00341         this->m_cursor_position_control->SetLabel( wxString::Format( "%.3f", position_usec));
00342         return true;
00343 }
00344 
00349 void CursorChControl::OnCursorPosMultiplierChoiceSelected( wxCommandEvent& /*event*/ )
00350 {
00351         // this->UpdateCursorPosition( this->m_set_cursor_position_control->GetValue( ));
00352 }
00353 
00354 

Generated on Mon Mar 19 17:14:07 2007 for CAENScope by  doxygen 1.4.6-NO