FIELDS_GRID_TABLE<SCH_FIELD>* m_fields;
WX_GRID* m_fieldsGrid;
simEnableFieldRow = (int) m_fields->size();
m_fields->emplace_back( VECTOR2I( 0, 0 ), simEnableFieldRow, m_symbol, SIM_ENABLE_FIELD );
// notify the grid
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
m_fieldsGrid->ProcessTableMessage( msg );
这段代码定义了两个指针变量 m_fields 和 m_fieldsGrid,分别指向 FIELDS_GRID_TABLE
ProcessTableMessage函数主要作用是什么?
ProcessTableMessage 函数是 wxGrid 类的一个成员函数,用于处理 wxGridTableMessage 类型的消息。它的主要作用是在网格表格中执行与消息相关的操作,例如添加、删除或更新行和列。在上述代码中,ProcessTableMessage 函数用于通知网格表格添加了一行。
FIELDS_GRID_TABLE<SCH_FIELD>* m_fields;
WX_GRID* m_fieldsGrid;
SCHEMATIC_SETTINGS& settings = m_symbol->Schematic()->Settings();
int fieldID = (int) m_fields->size();
SCH_FIELD newField( VECTOR2I( 0, 0 ), fieldID, m_symbol,
TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldID, DO_TRANSLATE ) );
newField.SetTextAngle( m_fields->at( REFERENCE_FIELD ).GetTextAngle() );
newField.SetTextSize( VECTOR2I( settings.m_DefaultTextSize, settings.m_DefaultTextSize ) );
m_fields->push_back( newField );
// notify the grid
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
m_fieldsGrid->ProcessTableMessage( msg );
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, m_fields->size() );这句代码什么意思
这句代码创建了一个 wxGridTableMessage 对象 msg,用于通知网格表格添加行。它包含以下参数:
通过创建并发送这个消息,可以告知网格表格添加一行新数据。
FIELDS_GRID_TABLE<SCH_FIELD>* m_fields;
WX_GRID* m_fieldsGrid;
for( int ii = (int) m_fields->size() - 1; ii >= 0; --ii )
{
SCH_FIELD& existingField = m_fields->at( ii );
bool found = false;
if( editedField.GetName() == existingField.GetName() )
{
found = true;
break;
}
if( !found )
{
m_fields->erase( m_fields->begin() + ii );
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
m_fieldsGrid->ClearSelection();
m_fieldsGrid->ProcessTableMessage( msg );
}
}
其中:
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
这句代码创建了一个 wxGridTableMessage 对象 msg,用于通知网格表格删除行。它包含以下参数:
通过创建并发送这个消息,可以告知网格表格删除指定范围内的行。
for( SCH_FIELD& existingField : *m_fields )
{
if( existingField.GetName() == editedField.GetName() )
{
found = true;
existingField.SetText( editedField.GetText() );
break;
}
}
void DIALOG_SYMBOL_PROPERTIES::UpdateModelVersion()
{
wxString lib=m_symbol->GetLibId().GetLibNickname().wx_str();
wxString item =m_symbol->GetLibId().GetLibItemName().wx_str();
if(lib=="Simulation_SPICE"&&item=="NMOS_Substrate")
{
wxString type = m_symbol->GetFieldText( "Sim.Type" );
wxString version = m_symbol->GetModleVersion( );
if(type=="BSIM_CMG"||type=="BSIMBULK")
{
bool found=false;
for( SCH_FIELD& existingField : *m_fields )
{
std::cout<<"existingField.GetName() "<<existingField.GetName()<<std::endl;
if( existingField.GetName() == "Model.Version" )
{
found = true;
break;
}
}
if(!found)
{
//m_symbol->AddField( _( "Model.Version" ), wxT( "Model.Version" ), true, true );
SCH_FIELD field( VECTOR2I( 0, 0 ), m_fields->size(), m_symbol, "Model.Version" );
field.SetVisible( true );
field.SetText("107.0");
m_symbol->AddField(field);
m_fields->push_back( field );
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_APPENDED, 1 );
m_fieldsGrid->ProcessTableMessage( msg );
}
}else{
bool found=false;
for( int ii = (int) m_fields->size() - 1; ii >= 0; --ii )
{
SCH_FIELD& existingField = m_fields->at( ii );
bool found = false;
if( existingField.GetName() == "Model.Version")
{
found = true;
break;
}
if( found )
{
m_symbol->RemoveField("Model.Version");
m_fields->erase( m_fields->begin() + ii );
wxGridTableMessage msg( m_fields, wxGRIDTABLE_NOTIFY_ROWS_DELETED, ii, 1 );
m_fieldsGrid->ClearSelection();
m_fieldsGrid->ProcessTableMessage( msg );
}
}
}
}
}
这个代码还有一点问题,需要进一步研究。