示例#1
0
//------------------------------------------------------------------------------
// static std::string ToRgbString(const UnsignedInt &intColor)
//------------------------------------------------------------------------------
std::string RgbColor::ToRgbString(const UnsignedInt &intColor)
{
   char buffer[20];
   RgbColor color = RgbColor(intColor);
   sprintf(buffer, "[%d %d %d]", color.Red(), color.Green(), color.Blue());
   return std::string(buffer);
}
//------------------------------------------------------------------------------
// void ShowSpacePointColor(const wxString &name, UnsignedInt color = GmatColor::RED)
//------------------------------------------------------------------------------
void GroundTrackPlotPanel::ShowSpacePointColor(const wxString &name, UnsignedInt color)
{
   #ifdef DEBUG_PANEL_COLOR
   MessageInterface::ShowMessage
      ("OrbitViewPanel::ShowSpacePointColor() name='%s'\n", name.c_str());
   #endif
   
   if (!name.IsSameAs(""))
   {
      std::string selObjName = name.c_str();
      
      // if object name not found, insert
      if (mOrbitColorMap.find(selObjName) == mOrbitColorMap.end())
      {
         #ifdef DEBUG_PANEL_COLOR
         MessageInterface::ShowMessage
            ("ShowSpacePointColor() name not found, so adding it to color map\n");
         #endif
         
         mOrbitColorMap[selObjName] = RgbColor(color);
         mTargetColorMap[selObjName] = RgbColor(GmatColor::ORANGE);
      }
      
      RgbColor orbColor = mOrbitColorMap[selObjName];
      RgbColor targColor = mTargetColorMap[selObjName];
      
      #ifdef DEBUG_PANEL_COLOR
      MessageInterface::ShowMessage
         ("OrbitViewPanel::ShowSpacePointColor() orbColor=%u, targColor=%u\n",
          orbColor.GetIntColor(), targColor.GetIntColor());
      #endif
      
      mOrbitColor.Set(orbColor.Red(), orbColor.Green(), orbColor.Blue());      
      mTargetColor.Set(targColor.Red(), targColor.Green(), targColor.Blue());
      
      mOrbitColorCtrl->SetColour(mOrbitColor);
      mTargetColorCtrl->SetColour(mTargetColor);
   }
}
示例#3
0
//--------------------------------------------------------------------
void SurfaceMesh::Render (Structure* structure) const
// Draw the mesh in opengl
   {
   float white[4] = {255.0f, 255.0f, 255.0f, 1.0f};
   RgbColor color = structure->Color;
   ZMaterial* mat = structure->FindMaterial (TheMaterial);
   bool havetexture = false;
   if (mat != 0)
      {
      color = mat->Color;
      if (mat->GlTextureId != -1)
         {
         // As long as have a texture id, we bind it and enable textures
         GLint params = -13;
         glBindTexture(GL_TEXTURE_2D, mat->GlTextureId);
         glGetIntegerv(GL_TEXTURE_BINDING_2D, &params);
         glEnable(GL_TEXTURE_2D);
         glColor4fv(white);  // This is mixed with texture, best if all 255.0F 
         havetexture = true;
         }
      if (mat->Shininess > 0)
         {
         glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, mat->Shininess);
         } 
      }
   if (!havetexture)
      {
      // No texture, set color
      float rgba[4];
      rgba[0] = color.Red()/255.0f;
      rgba[1] = color.Green()/255.0f;
      rgba[2] = color.Blue()/255.0f;
      rgba[3] = 1;
      glDisable(GL_TEXTURE_2D);
      glColor4fv(rgba);
      }

   glBegin(GL_TRIANGLES);
   for (Integer j=0; j<=FacesSize-1; ++j)
      {
      ZFace& face (Faces[j]);
      glEnable(GL_NORMALIZE); // added (LOJ: 2012.07.11)
      for (Integer k=0;  k<=3-1;  ++k)
         {
         glNormal3fv(GetVectorWrt(face.NormalIndex[k],false).V);
         glTexCoord2fv(face.TextureCoord[k].V);
         glVertex3fv(GetVectorWrt(face.VertexIndex[k],false).V);
         }
      }
   glEnd();
   }
示例#4
0
//------------------------------------------------------------------------------
// void OnCheckBoxChange(wxCommandEvent& event)
//------------------------------------------------------------------------------
void GmatColorPanel::OnCheckBoxChange(wxCommandEvent& event)
{
   mHasOverrideColorChanged = true;
   mOverrideOrbitColor = mOverrideOrbitColorCheckBox->GetValue();
   
   if (mOverrideOrbitColor)
   {
      mOrbitColorLabel->Enable(true);
      mOrbitColorCtrl->Enable(true);      
   }
   else
   {
      // Show original orbit color
      RgbColor rgbOrbitColor = RgbColor(mDefaultOrbitColor);
      mOrbitColor.Set(rgbOrbitColor.Red(), rgbOrbitColor.Green(), rgbOrbitColor.Blue());      
      mOrbitColorCtrl->SetColour(mOrbitColor);
      mOrbitIntColor = rgbOrbitColor.GetIntColor();
      mOrbitColorLabel->Enable(false);
      mOrbitColorCtrl->Enable(false);
   }
   
	theParentGmatPanel->EnableUpdate(true);
}
示例#5
0
//------------------------------------------------------------------------------
// void LoadData()
//------------------------------------------------------------------------------
void GmatColorPanel::LoadData()
{
   #ifdef DEBUG_PANEL_LOAD
   MessageInterface::ShowMessage("GmatColorPanel::LoadData() entered.\n");
   #endif

   try
   {
      if (mUseInputObjectColor)
      {
         // Load colors from the input object name
         SpacePoint *sp = (SpacePoint*)
            ((theParentGmatPanel->GetGuiInterpreter())->GetConfiguredObject(mSpacePointName));
         if (sp)
         {
            mOrbitIntColor = sp->GetCurrentOrbitColor();
            mTargetIntColor = sp->GetCurrentTargetColor();
         }
      }
      else
      {
         // Load colors from the spacecraft
         mOrbitIntColor = theClonedSpacePoint->GetCurrentOrbitColor();
         mTargetIntColor = theClonedSpacePoint->GetCurrentTargetColor();
      }
      
      mDefaultOrbitColor = mOrbitIntColor;
      if (mOverrideOrbitColor)
         mOrbitIntColor = mOverrdingColor;
      
      RgbColor rgbOrbitColor = RgbColor(mOrbitIntColor);
      RgbColor rgbTargetColor = RgbColor(mTargetIntColor);
      
      #ifdef DEBUG_PANEL_LOAD
      MessageInterface::ShowMessage("   rgbOrbitColor  = %06X\n", rgbOrbitColor.GetIntColor());
      MessageInterface::ShowMessage("   rgbTargetColor = %06X\n", rgbTargetColor.GetIntColor());
      #endif
      
      mOrbitColor.Set(rgbOrbitColor.Red(), rgbOrbitColor.Green(), rgbOrbitColor.Blue());      
      mOrbitColorCtrl->SetColour(mOrbitColor);
      mTargetColor.Set(rgbTargetColor.Red(), rgbTargetColor.Green(), rgbTargetColor.Blue());
      mTargetColorCtrl->SetColour(mTargetColor);
      
      // If showing only orbit color, hide target color
      if (mShowOrbitColorOnly)
      {
         mTargetColorLabel->Hide();
         mTargetColorCtrl->Hide();
      }
      
      // Set value to overrding color CheckBox
      if (mOverrideOrbitColor)
         mOverrideOrbitColorCheckBox->SetValue(true);
      else
         mOverrideOrbitColorCheckBox->SetValue(false);
      
      // If not showing override color check box, hide it
      if (!mShowOverrideOrbitColorCheckBox)
         mOverrideOrbitColorCheckBox->Hide();
      else
      {
         // If not overriding orbit color, disable it
         if (!mOverrideOrbitColor)
         {
            mOrbitColorLabel->Disable();
            mOrbitColorCtrl->Disable();
         }
      }
      Layout();
   }
   catch (BaseException &e)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, e.GetFullMessage().c_str());
   }
   
   #ifdef DEBUG_PANEL_LOAD
   MessageInterface::ShowMessage("GmatColorPanel::LoadData() leaving\n");
   #endif
}