bool FStructureEditorUtils::ChangeVariableType(UUserDefinedStruct* Struct, FGuid VarGuid, const FEdGraphPinType& NewType) { if (Struct) { FString ErrorMessage; if(!CanHaveAMemberVariableOfType(Struct, NewType, &ErrorMessage)) { UE_LOG(LogBlueprint, Warning, TEXT("%s"), *ErrorMessage); return false; } auto VarDesc = GetVarDescByGuid(Struct, VarGuid); if(VarDesc) { const bool bChangedType = (VarDesc->ToPinType() != NewType); if (bChangedType) { const FScopedTransaction Transaction(LOCTEXT("ChangeVariableType", "Change Variable Type")); ModifyStructData(Struct); VarDesc->VarName = FMemberVariableNameHelper::Generate(Struct, VarDesc->FriendlyName, VarDesc->VarGuid); VarDesc->DefaultValue = FString(); VarDesc->SetPinType(NewType); OnStructureChanged(Struct); return true; } } } return false; }
int SetType(void){ if(rx[0]&0b00000001){ int i=0; int npa=0; for(;i<PINSNUMBER;i++){ if(rx[3+i/8]&(1<<(7-(i%8)))){ uint8_t val1=rx[3+(PINSNUMBER+npa*3)/8]&(0b10000000>>((PINSNUMBER+3*npa)%8)); uint8_t val2=rx[3+(PINSNUMBER+npa*3+1)/8]&(0b10000000>>((PINSNUMBER+3*npa+1)%8)); uint8_t val3=rx[3+(PINSNUMBER+npa*3+2)/8]&(0b10000000>>((PINSNUMBER+3*npa+2)%8)); uint8_t val=(val1<<2)|(val2<<1)|(val3<<0); val=0; if(val1!=0) val=val|1<<2; if(val2!=0) val=val|1<<1; if(val3!=0) val=val|1<<0; if( !SetPinType(i,val)) return 7; ; npa++; } }
void WinEDA_PinPropertiesFrame::PinPropertiesAccept(wxCommandEvent& event) /*************************************************************************/ /* Met a jour les differents parametres pour le composant en cours d'édition */ { wxString msg; LastPinType = m_PinElectricalType->GetSelection(); LastPinShape = CodeShape[m_PinShape->GetSelection()]; LastPinOrient = CodeOrient[m_PinOrient->GetSelection()]; LastPinCommonConvert = m_CommonConvert->GetValue(); LastPinCommonUnit = m_CommonUnit->GetValue(); LastPinNoDraw = m_NoDraw->GetValue(); LastPinSize = m_PinSize->GetValue(); msg = m_PinNameSizeCtrl->GetValue(); LastPinNameSize = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits); msg = m_PinNumSizeCtrl->GetValue(); LastPinNumSize = ReturnValueFromString(g_UnitMetric, msg, m_Parent->m_InternalUnits); if ( CurrentDrawItem ) // Set Pin Name & Num { if ( ! (CurrentDrawItem->m_Flags & IS_NEW) ) // if IS_NEW, copy for undo is done before place m_Parent->SaveCopyInUndoList(); LibDrawPin * CurrentPin = (LibDrawPin *) CurrentDrawItem; wxClientDC dc(m_Parent->DrawPanel); m_Parent->DrawPanel->PrepareGraphicContext(&dc); if ( m_Parent->GetScreen()->ManageCurseur ) // Pin is moving m_Parent->GetScreen()->ManageCurseur(m_Parent->DrawPanel, &dc, FALSE); else DrawLibraryDrawStruct(m_Parent->DrawPanel, &dc, CurrentLibEntry, 0,0, CurrentPin,CurrentUnit, g_XorMode); SetPinName(m_PinNameCtrl->GetValue(), LastPinNameSize); msg = m_PinNumCtrl->GetValue(); if ( msg.IsEmpty() ) msg = wxT("~"); SetPinNum(msg, LastPinNumSize); NewSizePin(LastPinSize); SetPinShape(LastPinShape); SetPinType(LastPinType); SetPinOrient(LastPinOrient); SetAttributsPin(TRUE, TRUE, TRUE); if ( m_Parent->GetScreen()->ManageCurseur ) m_Parent->GetScreen()->ManageCurseur(m_Parent->DrawPanel, &dc, FALSE); else DrawLibraryDrawStruct(m_Parent->DrawPanel, &dc, CurrentLibEntry, 0,0, CurrentPin,CurrentUnit, g_XorMode); } if ( CurrentDrawItem ) CurrentDrawItem->Display_Infos_DrawEntry(m_Parent); Close(); }