Example #1
0
//*****************************************************************************
//
// Function Name:  RColorDialog::ShowPage
//
// Description:    Helper function for creating/displaying the correct
//						 property sheet in the tab control.
//
// Returns:        VOID
//
// Exceptions:	    None
//
//*****************************************************************************
void RColorDialog::ShowPage( int nPage )
{
	CDialog* pPrevPage  = m_pCurrentPage;
	CDialog* pPages[]   = { &m_dlgColorPalette, &m_dlgColorTexture, &m_dlgColorPhoto };
	int		pPageIDs[] = { DIALOG_COLOR_DIALOG_GRADIENTS, m_dlgColorTexture.IDD, m_dlgColorPhoto.IDD };

	TpsAssert( nPage < NumElements( pPages ), "Invalid page number!" );

	if (m_pCurrentPage != pPages[nPage])
	{
		m_pCurrentPage = pPages[nPage] ;

		if (!IsWindow( m_pCurrentPage->m_hWnd ))
		{
			CRect   rectAdjust(0,0,0,0);
			CRect   rectWindow(0,0,0,0);

			m_ctlTabCtrl.AdjustRect( TRUE, &rectAdjust );
			m_ctlTabCtrl.GetWindowRect( &rectWindow );

			rectWindow.left -= rectAdjust.left;
			rectWindow.top  -= rectAdjust.top;
			ScreenToClient( &rectWindow );

			if (!m_pCurrentPage->Create( pPageIDs[nPage], this ))
			{
				if (!pPrevPage) return ;

				// Restore the current page pointer to the previous one.
				m_pCurrentPage = pPrevPage ;
				pPrevPage = NULL;

				// Find the index of the previous page. (For setting the tab)
				for (int i = 0; i < NumElements( pPages ); i++)
				{
					if (m_pCurrentPage == pPages[i])
					{
						m_ctlTabCtrl.SetCurSel( i ) ;
						break ;
					}
				}
			}

			m_pCurrentPage->SetWindowPos( &wndTop, rectWindow.left,
				rectWindow.top, 0, 0, SWP_NOSIZE ) ;

		} // if (IsWindow())
			
	} // if (new page)

	if (pPrevPage && IsWindow( pPrevPage->m_hWnd ))
		pPrevPage->ShowWindow( SW_HIDE ) ;

	m_pCurrentPage->ShowWindow( SW_SHOW ) ;

	GetDlgItem( IDC_COLOR_MORE )->EnableWindow( m_pCurrentPage == &m_dlgColorPalette );
}
//////////////////////////////////////////////////////////////////////////
//																		//
//																		//
//////////////////////////////////////////////////////////////////////////
CChars* CArrayString::Tail(void)
{
	if (NumElements() > 0)
	{
		return Get(NumElements()-1);
	}
	else
	{
		return NULL;
	}
}
//////////////////////////////////////////////////////////////////////////
//																		//
//																		//
//////////////////////////////////////////////////////////////////////////
BOOL CArrayString::RemoveTail(void)
{
	if (NumElements() > 0)
	{
		Remove(NumElements()-1);
		return TRUE;
	}
	else
	{
		return FALSE;
	}
}
Example #4
0
BOOL UnwrapMod::AddDefaultActionToBar(ICustToolbar *toolBar, int id)
{

	int numOps = NumElements(spActions)/3;
	UnwrapAction *wtActions = NULL;
	int ct = 0;
	for (int i =0; i < numOps; i++)
	{
		int testid, ids1, ids2;
		testid = spActions[ct++];
		ids1 = spActions[ct++];
		ids2 = spActions[ct++];
		if (testid == id)
		{
			TSTR name;
			name.printf(_T("%s"),GetString(ids2));
			int l = name.Length();
			toolBar->AddTool(ToolButtonItem(CTB_PUSHBUTTON,0, 0, 0, 0, 16, 15, l*8, 22, id));
			ICustButton *but  = toolBar->GetICustButton(id);
			but->SetHighlightColor(GREEN_WASH);
			but->SetTooltip(TRUE,GetString(ids1));
			but->SetImage(NULL,0,0,0,0,0,0);
			but->SetText(GetString(ids2));

			ReleaseICustButton(but);				
			i = numOps;
			return TRUE;
		}
	}

	return FALSE;
}
Example #5
0
void UnwrapMod::ActivateActionTable()
{
	pCallback = new UnwrapActionCallback();
	pCallback->SetUnwrap(this);

	if  (GetCOREInterface()->GetActionManager()->ActivateActionTable(pCallback, kUnwrapActions) )
	{
		ActionTable *actionTable =  GetCOREInterface()->GetActionManager()->FindTable(kUnwrapActions);
		if (actionTable)
		{
			int actionCount = NumElements(spActions)/3;
			for (int i =0; i < actionCount; i++)
			{
				int id = spActions[i*3];
				UnwrapAction *action =  (UnwrapAction *) actionTable->GetAction(spActions[i*3]);
				if (action)
				{
					action->SetUnwrap(this);
				}

			}

		}
	}

}
Example #6
0
ActionTable* UnwrapClassDesc::GetActions()
{
	TSTR name = GetString(IDS_RB_UNWRAPMOD);
	ActionTable* pTab;
	pTab = new ActionTable(kUnwrapActions, kUnwrapContext, name);        

	int numOps = NumElements(spActions)/3;
	UnwrapAction *wtActions = NULL;
	int ct = 0;
	for (int i =0; i < numOps; i++)
	{
		wtActions = new UnwrapAction();
		int id, ids1, ids2;

		id = spActions[ct++];
		ids1 = spActions[ct++];
		ids2 = spActions[ct++];


		wtActions->Init(id,GetString(ids1),GetString(ids2),
			GetString(IDS_RB_UNWRAPMOD), GetString(IDS_RB_UNWRAPMOD)  );
		pTab->AppendOperation(wtActions);
	}

	GetCOREInterface()->GetActionManager()->RegisterActionContext(kUnwrapContext, name.data());
	return pTab;
}
Example #7
0
//action Table methods
void UnwrapMod::DeActivateActionTable()
{
	ActionTable *actionTable =  GetCOREInterface()->GetActionManager()->FindTable(kUnwrapActions);
	if (actionTable)
	{
		int actionCount = NumElements(spActions)/3;
		for (int i =0; i < actionCount; i++)
		{
			UnwrapAction *action =  (UnwrapAction *) actionTable->GetAction(spActions[i*3]);
			if (action)
			{
				action->SetUnwrap(NULL);
			}
		}
	}

	if (pCallback) {
		GetCOREInterface()->GetActionManager()->DeactivateActionTable(pCallback, kUnwrapActions); 
		delete pCallback;
		pCallback = NULL;
	}
}
//////////////////////////////////////////////////////////////////////////
//																		//
//																		//
//////////////////////////////////////////////////////////////////////////
BOOL CArrayString::Equals(CArrayString* pcOther)
{
	int		i;
	CChars*	pszThis;
	CChars*	pszOther;

	if (mcArray.NumElements() != pcOther->mcArray.NumElements())
	{
		return FALSE;
	}

	for (i = 0; i < NumElements(); i++)
	{
		pszThis = Get(i);
		pszOther = pcOther->Get(i);
		if (!pszThis->Equals(*pszOther))
		{
			return FALSE;
		}
	}
	return TRUE;
}
BOOL CMapCommon::IsNotEmpty(void)
{
	return NumElements() != 0;
}
BOOL CMapCommon::IsEmpty(void)
{
	return NumElements() == 0;
}
Example #11
0
RBitmapImage&	RWinColorPalette::GetPaletteBitmapImage( )
{
	static BOOLEAN			m_fPaletteInitialized = FALSE;
	static RBitmapImage	m_biPalette;

	if ( !m_fPaletteInitialized )
	{
		// find the resource in the resource file
		HRSRC hRsrc = FindResource( AfxGetResourceHandle(), 
			MAKEINTRESOURCE( m_uPaletteBitmapID ), RT_BITMAP );

		if ( hRsrc != NULL )
		{
			// get a handle to the resource data
			HGLOBAL hTemp = LoadResource( AfxGetResourceHandle(), hRsrc );

			if ( hTemp != NULL )
			{
				// Initlize the palette bitmap with the resource data
				m_biPalette.Initialize( LockResource( hTemp ) );

				// unlock and free the resource
				UnlockResource( hTemp );
				FreeResource( hTemp );
			}
			else
				AfxThrowResourceException( );
		}
		else
			AfxThrowResourceException( );

		m_fPaletteInitialized = TRUE;

		COLORMAP crColorMap[] =
		{
			{ RGB( 255, 255, 255 ), GetSysColor( COLOR_BTNHIGHLIGHT ) },
			{ RGB( 192, 192, 192 ), GetSysColor( COLOR_BTNFACE )      },
			{ RGB( 128, 128, 128 ), GetSysColor( COLOR_BTNSHADOW )    }
		};

		RIntPoint ptCells[] = 
		{
			FindColor( crColorMap[0].from ),
			FindColor( crColorMap[1].from ),
			FindColor( crColorMap[2].from )
		};

		void*     pRawData   = m_biPalette.GetRawData();
		RGBQUAD*  pColorData = (RGBQUAD *) RBitmapImage::GetColorData( pRawData );
		LPBYTE    pImageData = (LPBYTE) RBitmapImage::GetImageData( pRawData );

		for (int j = 0; (LPVOID) pColorData < (LPVOID) pImageData; j++, pColorData++)
		{
			for (int i = 0; i < NumElements( crColorMap ); i++)
			{
				if (crColorMap[i].from == RGB( pColorData->rgbRed, pColorData->rgbGreen, pColorData->rgbBlue ))
				{
					pColorData->rgbBlue  = GetBValue( crColorMap[i].to );
					pColorData->rgbRed   = GetRValue( crColorMap[i].to );
					pColorData->rgbGreen = GetGValue( crColorMap[i].to );
					pColorData->rgbReserved = 0;
				}
			}

			if (j == 9)
			{
				// We only need to look at the system colors, so
				// jump to the last 10 entries in the palette.
				pColorData += 235;
			}
		}

		m_biPalette.UpdatePalette();

		//
		// Relace the cells that got remapped
		//
		ROffscreenDrawingSurface dsMem;
		dsMem.SetImage( &m_biPalette );

		RSolidColor rSolid;

		for (int i = 0; i < NumElements( ptCells ); i++)
		{
			if (ptCells[i].m_x >= 0 && ptCells[i].m_y >= 0)
			{
				RIntRect rcCell( RIntSize( kCellSize.m_dx - 2, kCellSize.m_dy - 2 ) );
				rcCell.Offset( RIntSize( ptCells[i].m_x + 1, ptCells[i].m_y + 1 ) );

				rSolid = crColorMap[i].from;

				RColor rColor( rSolid );
				dsMem.SetFillColor( rColor );
				dsMem.FillRectangle( rcCell );
			}
		}

		dsMem.ReleaseImage();
	}

	return m_biPalette;
}
  //
  // extrapolate from integration points and compute output nodal/element
  // values
  //
  void FSDielectricElastomer2DT::ComputeOutput(const iArrayT& n_codes,
      dArray2DT& n_values, const iArrayT& e_codes, dArray2DT& e_values)
  {
    //
    // number of output values
    //
    int n_out = n_codes.Sum();
    int e_out = e_codes.Sum();

    // nothing to output
    if (n_out == 0 && e_out == 0) return;

    // dimensions
    int nsd = NumSD();
    int ndof = NumDOF();
    int nen = NumElementNodes();
    int nnd = ElementSupport().NumNodes();

    // reset averaging work space
    ElementSupport().ResetAverage(n_out);

    // allocate element results space
    e_values.Dimension(NumElements(), e_out);

    // nodal work arrays
    dArray2DT nodal_space(nen, n_out);
    dArray2DT nodal_all(nen, n_out);
    dArray2DT coords, disp;
    dArray2DT nodalstress, princstress, matdat;
    dArray2DT energy, speed;
    dArray2DT ndElectricScalarPotential;
    dArray2DT ndElectricDisplacement;
    dArray2DT ndElectricField;

    // ip values
    dArrayT ipmat(n_codes[iMaterialData]), ipenergy(1);
    dArrayT ipspeed(nsd), ipprincipal(nsd);
    dMatrixT ippvector(nsd);

    // set shallow copies
    double* pall = nodal_space.Pointer();
    coords.Alias(nen, n_codes[iNodalCoord], pall);
    pall += coords.Length();
    disp.Alias(nen, n_codes[iNodalDisp], pall);
    pall += disp.Length();

    nodalstress.Alias(nen, n_codes[iNodalStress], pall);
    pall += nodalstress.Length();
    princstress.Alias(nen, n_codes[iPrincipal], pall);
    pall += princstress.Length();
    energy.Alias(nen, n_codes[iEnergyDensity], pall);
    pall += energy.Length();
    speed.Alias(nen, n_codes[iWaveSpeeds], pall);
    pall += speed.Length();
    matdat.Alias(nen, n_codes[iMaterialData], pall);
    pall += matdat.Length();

    ndElectricDisplacement.Alias(nen, n_codes[ND_ELEC_DISP], pall);
    pall += ndElectricDisplacement.Length();

    ndElectricField.Alias(nen, n_codes[ND_ELEC_FLD], pall);
    pall += ndElectricField.Length();
    
    ndElectricScalarPotential.Alias(nen, n_codes[ND_ELEC_POT_SCALAR], pall);
    pall += ndElectricScalarPotential.Length();

    // element work arrays
    dArrayT element_values(e_values.MinorDim());
    pall = element_values.Pointer();
    dArrayT centroid, ip_centroid, ip_mass;
    dArrayT ip_coords(nsd);
    if (e_codes[iCentroid]) {
      centroid.Alias(nsd, pall);
      pall += nsd;
      ip_centroid.Dimension(nsd);
    }
    if (e_codes[iMass]) {
      ip_mass.Alias(NumIP(), pall);
      pall += NumIP();
    }
    double w_tmp, ke_tmp;
    double mass;
    double& strain_energy = (e_codes[iStrainEnergy])
        ? *pall++
        : w_tmp;
    double& kinetic_energy = (e_codes[iKineticEnergy])
        ? *pall++
        : ke_tmp;
    dArrayT linear_momentum, ip_velocity;

    if (e_codes[iLinearMomentum]) {
      linear_momentum.Alias(ndof, pall);
      pall += ndof;
      ip_velocity.Dimension(ndof);
    } else if (e_codes[iKineticEnergy]) ip_velocity.Dimension(ndof);

    dArray2DT ip_stress;
    if (e_codes[iIPStress]) {
      ip_stress.Alias(NumIP(), e_codes[iIPStress] / NumIP(), pall);
      pall += ip_stress.Length();
    }
    dArray2DT ip_material_data;
    if (e_codes[iIPMaterialData]) {
      ip_material_data.Alias(NumIP(), e_codes[iIPMaterialData] / NumIP(), pall);
      pall += ip_material_data.Length();
      ipmat.Dimension(ip_material_data.MinorDim());
    }

    dArray2DT ipElectricDisplacement;
    if (e_codes[IP_ELEC_DISP]) {
      ipElectricDisplacement.Alias(NumIP(), NumSD(), pall);
      pall += NumIP() * NumSD();
    }

    dArray2DT ipElectricField;
    if (e_codes[IP_ELEC_FLD]) {
      ipElectricField.Alias(NumIP(), NumSD(), pall);
      pall += NumIP() * NumSD();
    }

    // check that degrees are displacements
    int interpolant_DOF = InterpolantDOFs();

    Top();
    while (NextElement()) {

      if (CurrentElement().Flag() == ElementCardT::kOFF) continue;

      // initialize
      nodal_space = 0.0;

      // global shape function values
      SetGlobalShape();

      // collect nodal values
      if (e_codes[iKineticEnergy] || e_codes[iLinearMomentum]) {
        if (fLocVel.IsRegistered())
          SetLocalU(fLocVel);
        else
          fLocVel = 0.0;
      }

      // coordinates and displacements all at once
      if (n_codes[iNodalCoord]) fLocInitCoords.ReturnTranspose(coords);
      if (n_codes[iNodalDisp]) {
        if (interpolant_DOF)
          fLocDisp.ReturnTranspose(disp);
        else
          NodalDOFs(CurrentElement().NodesX(), disp);
      }

      if (n_codes[ND_ELEC_POT_SCALAR]) {
        if (interpolant_DOF) {
          fLocScalarPotential.ReturnTranspose(ndElectricScalarPotential);
        } else {
          NodalDOFs(CurrentElement().NodesX(), ndElectricScalarPotential);
        }
      }

      // initialize element values
      mass = strain_energy = kinetic_energy = 0;
      if (e_codes[iCentroid]) centroid = 0.0;
      if (e_codes[iLinearMomentum]) linear_momentum = 0.0;
      const double* j = fShapes->IPDets();
      const double* w = fShapes->IPWeights();

      // integrate
      dArray2DT Na_X_ip_w;
      fShapes->TopIP();
      while (fShapes->NextIP() != 0) {

        // density may change with integration point
        double density = fCurrMaterial->Density();

        // element integration weight
        double ip_w = (*j++) * (*w++);

        if (qNoExtrap) {
          Na_X_ip_w.Dimension(nen, 1);
          for (int k = 0; k < nen; k++) {
            Na_X_ip_w(k, 0) = 1.;
          }
        }

        // get Cauchy stress
        const dSymMatrixT& stress = fCurrMaterial->s_ij();
        dSymMatrixT strain;

        // stresses
        if (n_codes[iNodalStress]) {
          if (qNoExtrap) {
            for (int k = 0; k < nen; k++) {
              nodalstress.AddToRowScaled(k, Na_X_ip_w(k, 0), stress);
            }
          } else {
            fShapes->Extrapolate(stress, nodalstress);
          }
        }

        if (e_codes[iIPStress]) {
          double* row = ip_stress(fShapes->CurrIP());
          strain.Set(nsd, row);
          strain = stress;
          row += stress.Length();
          strain.Set(nsd, row);
          fCurrMaterial->Strain(strain);
        }

        // wave speeds
        if (n_codes[iWaveSpeeds]) {
          // acoustic wave speeds
          fCurrMaterial->WaveSpeeds(fNormal, ipspeed);
          if (qNoExtrap) {
            for (int k = 0; k < nen; k++) {
              speed.AddToRowScaled(k, Na_X_ip_w(k, 0), ipspeed);
            }
          } else {
            fShapes->Extrapolate(ipspeed, speed);
          }
        }

        // principal values - compute principal before smoothing
        if (n_codes[iPrincipal]) {
          // compute eigenvalues
          stress.PrincipalValues(ipprincipal);

          if (qNoExtrap) {
            for (int k = 0; k < nen; k++) {
              princstress.AddToRowScaled(k, Na_X_ip_w(k, 0), ipprincipal);
            }
          } else {
            fShapes->Extrapolate(ipprincipal, princstress);
          }
        }

        // strain energy density
        if (n_codes[iEnergyDensity] || e_codes[iStrainEnergy]) {
          double ip_strain_energy = fCurrMaterial->StrainEnergyDensity();

          // nodal average
          if (n_codes[iEnergyDensity]) {
            ipenergy[0] = ip_strain_energy;
            if (qNoExtrap) {
              for (int k = 0; k < nen; k++) {
                energy.AddToRowScaled(k, Na_X_ip_w(k, 0), ipenergy);
              }
            } else {
              fShapes->Extrapolate(ipenergy, energy);
            }
          }

          // integrate over element
          if (e_codes[iStrainEnergy]) {
            strain_energy += ip_w * ip_strain_energy;
          }

        }

        // material stuff
        if (n_codes[iMaterialData] || e_codes[iIPMaterialData]) {
          // compute material output
          fCurrMaterial->ComputeOutput(ipmat);

          // store nodal data
          if (n_codes[iMaterialData]) {
            if (qNoExtrap) {
              for (int k = 0; k < nen; k++) {
                matdat.AddToRowScaled(k, Na_X_ip_w(k, 0), ipmat);
              }
            } else {
              fShapes->Extrapolate(ipmat, matdat);
            }
          }

          // store element data
          if (e_codes[iIPMaterialData]) {
            ip_material_data.SetRow(fShapes->CurrIP(), ipmat);
          }
        }

        // mass averaged centroid
        if (e_codes[iCentroid] || e_codes[iMass]) {
          // mass
          mass += ip_w * density;

          // integration point mass
          if (e_codes[iMass]) ip_mass[fShapes->CurrIP()] = ip_w * density;

          // moment
          if (e_codes[iCentroid]) {
            fShapes->IPCoords(ip_centroid);
            centroid.AddScaled(ip_w * density, ip_centroid);
          }
        }

        // kinetic energy/linear momentum
        if (e_codes[iKineticEnergy] || e_codes[iLinearMomentum]) {
          // velocity at integration point
          fShapes->InterpolateU(fLocVel, ip_velocity);
          double ke_density = 0.5 * density * dArrayT::Dot(ip_velocity,
              ip_velocity);

          // kinetic energy
          if (e_codes[iKineticEnergy]) {
            kinetic_energy += ip_w * ke_density;
          }

          // linear momentum
          if (e_codes[iLinearMomentum]) {
            linear_momentum.AddScaled(ip_w * density, ip_velocity);
          }

        }

        // electric displacements
        const dArrayT& D = fCurrMaterial->D_I();
        if (n_codes[ND_ELEC_DISP]) {
          if (qNoExtrap) {
            for (int k = 0; k < nen; k++) {
              ndElectricDisplacement.AddToRowScaled(k, Na_X_ip_w(k, 0), D);
            }
          } else {
            fShapes->Extrapolate(D, ndElectricDisplacement);
          }
        }

        // electric field
        const dArrayT& E = fCurrMaterial->E_I();
        if (n_codes[ND_ELEC_FLD]) {
          if (qNoExtrap) {
            for (int k = 0; k < nen; k++) {
              ndElectricField.AddToRowScaled(k, Na_X_ip_w(k, 0), E);
            }
          } else {
            fShapes->Extrapolate(E, ndElectricField);
          }
        }

      }

      // copy in the cols
      int colcount = 0;
      nodal_all.BlockColumnCopyAt(disp, colcount);
      colcount += disp.MinorDim();

      nodal_all.BlockColumnCopyAt(coords, colcount);
      colcount += coords.MinorDim();

      if (qNoExtrap) {
        double nip(fShapes->NumIP());
        nodalstress /= nip;
        princstress /= nip;
        energy /= nip;
        speed /= nip;
        matdat /= nip;
        ndElectricDisplacement /= nip;
        ndElectricField /= nip;
        ndElectricScalarPotential /= nip;
      }
      nodal_all.BlockColumnCopyAt(nodalstress, colcount);
      colcount += nodalstress.MinorDim();

      nodal_all.BlockColumnCopyAt(princstress, colcount);
      colcount += princstress.MinorDim();

      nodal_all.BlockColumnCopyAt(energy, colcount);
      colcount += energy.MinorDim();

      nodal_all.BlockColumnCopyAt(speed, colcount);
      colcount += speed.MinorDim();

      nodal_all.BlockColumnCopyAt(matdat, colcount);
      colcount += matdat.MinorDim();

      nodal_all.BlockColumnCopyAt(ndElectricDisplacement, colcount);
      colcount += ndElectricDisplacement.MinorDim();

      nodal_all.BlockColumnCopyAt(ndElectricField, colcount);
      colcount += ndElectricField.MinorDim();

      nodal_all.BlockColumnCopyAt(ndElectricScalarPotential, colcount);
      colcount += ndElectricScalarPotential.MinorDim();

      // accumulate - extrapolation done from ip's to corners => X nodes
      ElementSupport().AssembleAverage(CurrentElement().NodesX(), nodal_all);

      // element values
      if (e_codes[iCentroid]) centroid /= mass;

      // store results
      e_values.SetRow(CurrElementNumber(), element_values);

    }

    // get nodally averaged values
    const OutputSetT& output_set = ElementSupport().OutputSet(fOutputID);
    const iArrayT& nodes_used = output_set.NodesUsed();
    dArray2DT extrap_values(nodes_used.Length(), n_out);
    extrap_values.RowCollect(nodes_used, ElementSupport().OutputAverage());

    int tmpDim = extrap_values.MajorDim();
    n_values.Dimension(tmpDim, n_out);
    n_values.BlockColumnCopyAt(extrap_values, 0);
   }