• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ basicgl::Graphic类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中basicgl::Graphic的典型用法代码示例。如果您正苦于以下问题:C++ Graphic类的具体用法?C++ Graphic怎么用?C++ Graphic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Graphic类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: addSymbol

//------------------------------------------------------------------------------
// addSymbol() - adds a symbol to our array list;
// -- return the symbol's index; range [ 1 .. getMaxSymbols() ]
//    or zero if not added.
//------------------------------------------------------------------------------
int SymbolLoader::addSymbol(const int nType, const char* const id, int specName)
{
    int idx = 0;

    if (templates != 0) {

        // Find the graphic template for this type symbol, and make
        // sure that the template is a BasicGL::Graphic, since it
        // will be use as the symbol's graphical component.
        Basic::Pair* tpair = templates->getPosition(nType);
        if (tpair != 0) {
            BasicGL::Graphic* tg = dynamic_cast<BasicGL::Graphic*>(tpair->object());
            if (tg != 0) {

                // Find an empty symbol slot in our master symbol table
                for (int i = 0; i < MAX_SYMBOLS && idx == 0; i++) {
                    if ( symbols[i] == 0 ) {

                        // Create a new SlSymbol object to manage this symbol.
                        symbols[i] = symbolFactory();

                        // Clone the graphic template and set it as the
                        // symbol's graphical component.
                        Basic::Pair* newPair = tpair->clone();
                        BasicGL::Graphic* newGraph = (BasicGL::Graphic*)(newPair->object());

                        // Set the new graphical component's select name
                        GLuint mySelName = 0;
                        if (specName > 0) mySelName = specName;
                        else mySelName = BasicGL::Graphic::getNewSelectName();
                        newGraph->setSelectName(mySelName);

                        // Add the symbol's graphical component to our component list.
                        {
                            Basic::PairStream* comp = getComponents();
                            Basic::Component::processComponents(comp, typeid(BasicGL::Graphic), newPair);
                            if (comp != 0) comp->unref();
                        }

                        // Set the symbol's graphical component pointer
                        symbols[i]->setSymbolPair( newPair );
                        newPair->unref(); // symbol[i] now owns it.

                        // Set the symbol's type and ID.
                        symbols[i]->setType( nType );
                        symbols[i]->setId( id );

                        // And this is the new symbol's index
                        idx = (i + 1);
                    }
                }
            }
        }
    }

    return idx;
}
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:62,代码来源:SymbolLoader.cpp


示例2: setSymbolType

//------------------------------------------------------------------------------
// setSymbolType() - change an existing symbol type to another type
//------------------------------------------------------------------------------
bool SymbolLoader::setSymbolType(const int idx, const int nType)
{
    bool ok = false;

    // Find the symbol
    if (idx >= 1 && idx <= MAX_SYMBOLS) {
        const int i = (idx - 1);
        if (symbols[i] != 0) {

            // Find the graphic template for this type symbol, and make
            // sure that the template is a BasicGL::Graphic, since it
            // will be use as the symbol's graphical component.
            if (templates != 0) {
                Basic::Pair* tpair = templates->getPosition(nType);
                if (tpair != 0) {
                    BasicGL::Graphic* tg = dynamic_cast<BasicGL::Graphic*>(tpair->object());
                    if (tg != 0) {

                        // Get the symbol's old graphical component
                        Basic::Pair* oldPair = (Basic::Pair*) symbols[i]->getSymbolPair();
                        BasicGL::Graphic* oldG = (BasicGL::Graphic*) (oldPair->object());

                        // Clone the new graphical component from the template
                        Basic::Pair* newPair = tpair->clone();

                        // Set the new graphical component's select name using the old's
                        BasicGL::Graphic* newGraph = (BasicGL::Graphic*) newPair->object();
                        GLuint mySelName = oldG->getSelectName();
                        newGraph->setSelectName(mySelName);

                        // Add the new and remove the old components from our subcomponent list
                        {
                            Basic::PairStream* comp = getComponents();
                            Basic::Component::processComponents(comp, typeid(BasicGL::Graphic), newPair, oldG);
                            if (comp != 0) comp->unref();
                        }

                        // Set the symbol's graphical component pointer
                        symbols[i]->setSymbolPair( newPair );
                        newPair->unref(); // symbol[i] now owns it.

                        // Set new type
                        symbols[i]->setType( nType );

                        ok = true;
                    }

                }
            }
        }

    }
    return ok;
}
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:57,代码来源:SymbolLoader.cpp


示例3: build

//------------------------------------------------------------------------------
// build() -- build the table in our components list
//------------------------------------------------------------------------------
void Table::build()
{
   Basic::PairStream* newList = 0;

   if (rows > 0 && columns != 0) {

      newList = new Basic::PairStream();

      // For each row: create a TableRow containing all the items in 'columns'
      for (unsigned int i = 1; i <= rows; i++) {

         // new row
         TableRow* row = new TableRow(); 
         row->container(this);

         const Basic::List::Item* item = columns->getFirstItem();
         while (item != 0) {
            const Basic::Pair* pair = static_cast<const Basic::Pair*>(item->getValue());
            const Basic::Object* obj = pair->object();
            if (obj->isClassType(typeid(BasicGL::Graphic))) {
               Basic::Pair* pp = pair->clone();
               BasicGL::Graphic* gobj = static_cast<BasicGL::Graphic*>(pp->object());
               gobj->container(row);
               row->put(pp);
               pp->unref();
            }

            item = item->getNext();
         }

         // put the row on our components list with a slotname equal to its row number
         {
            char cbuf[8];
            sprintf(cbuf,"%d",i);
            Basic::Pair* pp = new Basic::Pair(cbuf,row);
            newList->put(pp);
            pp->unref();
         }

         row->unref();
      }

      // Position our subcomponents
      position();
   }

   // These are new our subcomponents ...
   processComponents(newList,typeid(Basic::Component));
   if (newList != 0) newList->unref();
}
开发者ID:dfileccia,项目名称:OpenEaaglesExamples,代码行数:53,代码来源:Table.cpp


示例4: draw

// Rotary - we do this "pre-draw" of all of our possible selections, that will 
// eliminate the "flicker" on the first selection of the item, because we will have
// already drawn the item one time before (here). 
void Rotary::draw()
{
   if (preDrawSelectList) {
      int start = 1;
      Basic::Pair* p = findByIndex(start);
      while (p != 0) {
         BasicGL::Graphic* g = dynamic_cast<BasicGL::Graphic*>(p->object());
         if (g != 0) g->draw();
         p = findByIndex(++start);
      }
      preDrawSelectList = false;
   }

   BaseClass::draw();
}
开发者ID:AFIT-Hodson,项目名称:OpenEaagles,代码行数:18,代码来源:Readouts.cpp


示例5: updateSymbolText

//------------------------------------------------------------------------------
// Updates the value of the named NumericReadout type subcomponent
//------------------------------------------------------------------------------
bool SymbolLoader::updateSymbolText(const int idx, const char* name, const LCreal x)
{
    bool ok = false;

    // Find the symbol
    if (idx >= 1 && idx <= MAX_SYMBOLS) {
        const int i = (idx - 1);
        if(symbols[i] != 0) {

            // Get its graphical component
            Basic::Pair* p = (Basic::Pair*)symbols[i]->getSymbolPair();
            if (p != 0) {
                BasicGL::Graphic* g = dynamic_cast<BasicGL::Graphic*>(p->object());
                if (g != 0) {

                    // If we were passed a name then use it to find the subcomponent
                    // and change 'g' to point to the subcomponent instead.
                    if (name != 0) {
                        Basic::Pair* spair = g->findByName(name);
                        if (spair != 0) {
                            // subcomponent found by name
                            g = (BasicGL::Graphic*)(spair->object());
                        }
                        else {
                            // no subcomponent was found by that name
                            g = 0;
                        }
                    }

                    if (g != 0) {
                        // Have a graphic, but make sure it's a numeric readout
                        BasicGL::NumericReadout* text = dynamic_cast<BasicGL::NumericReadout*>(g);
                        if (text != 0) {
                            // It's a NumericReadout type, so update its value
                            text->setValue(x);
                            ok = true;
                        }
                    }

                }
            }

        }
    }
    return ok;
}
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:49,代码来源:SymbolLoader.cpp


示例6: updateSymbolText

//------------------------------------------------------------------------------
// Updates the text of the named AsciiText type subcomponent
//------------------------------------------------------------------------------
bool SymbolLoader::updateSymbolText(const int idx, const char* name, const char newString[])
{
   bool ok = false;

   // Find the symbol
   if (idx >= 1 && idx <= MAX_SYMBOLS) {
      const int i = (idx - 1);
      if (symbols[i] != nullptr) {

         // Get its graphical component
         Basic::Pair* p = static_cast<Basic::Pair*>(symbols[i]->getSymbolPair());
         if (p != nullptr) {
            BasicGL::Graphic* g = static_cast<BasicGL::Graphic*>(p->object());
            if (g != nullptr) {

               // If we were passed a name then use it to find the subcomponent
               // and change 'g' to point to the subcomponent instead.
               if (name != nullptr) {
                  Basic::Pair* spair = g->findByName(name);
                  if (spair != nullptr) {
                     // subcomponent found by name
                     g = static_cast<BasicGL::Graphic*>(spair->object());
                  }
                  else {
                     // no subcomponent was found by that name
                     g = nullptr;
                  }
               }

               if (g != nullptr) {
                  // Have a graphic, but make sure it's an AsciiText
                  BasicGL::AsciiText* text = dynamic_cast<BasicGL::AsciiText*>(g);
                  if (text != nullptr) {
                     // It's an AsciiText, so change the its text string.
                     text->setText(newString);
                     ok = true;
                  }
               }

            }
         }

      }
   }
   return ok;
}
开发者ID:derekworth,项目名称:afit-swarm-simulation,代码行数:49,代码来源:SymbolLoader.cpp


示例7: updateSymbolSelectName

//------------------------------------------------------------------------------
// Update the symbol's select name
//------------------------------------------------------------------------------
bool SymbolLoader::updateSymbolSelectName(const int idx, const int newSN)
{
    bool ok = false;
    if (idx >= 1 && idx <= MAX_SYMBOLS) {
        const int i = (idx - 1);
        if (symbols[i] != 0) {

            Basic::Pair* pair = (Basic::Pair*)symbols[i]->getSymbolPair();
            if (pair != 0) {
                BasicGL::Graphic* graphic = (BasicGL::Graphic*)(pair->object());
                if (graphic != 0) graphic->setSelectName(newSN);
            }
            ok = true;

        }
    }
    return ok;
}
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:21,代码来源:SymbolLoader.cpp


示例8: setSymbolVisible

//------------------------------------------------------------------------------
// setSymbolVisible() - set symbol visible / invisible
//------------------------------------------------------------------------------
bool SymbolLoader:: setSymbolVisible(const int idx, const char* name, bool visibility)
{
    bool ok = false;

    // Find the symbol
    if (idx >= 1 && idx <= MAX_SYMBOLS) {
        const int i = (idx - 1);
        if (symbols[i] != 0) {
            // if no name is passed, the symbol is invisible, otherwise just
            // parts are
            if (name == 0) symbols[i]->setVisible(visibility);

            // Get its graphical component
            Basic::Pair* p = symbols[i]->getSymbolPair();
            if (p != 0) {
                BasicGL::Graphic* g = (BasicGL::Graphic*)(p->object());
                if (g != 0) {

                    // If we were passed a name then use it to find the subcomponent
                    // and change 'g' to point to the subcomponent instead.
                    if (name != 0) {
                        Basic::Pair* spair = g->findByName(name);
                        if (spair != 0) {
                            // subcomponent found by name
                            g = (BasicGL::Graphic*)(spair->object());
                        }
                        else {
                            // no subcomponent was found by that name
                            g = 0;
                        }
                    }

                    // Set the visibility (if we found one)
                    if (g != 0) ok = g->setVisibility(visibility);

                }

            }
        }
    }
    return ok;
}
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:45,代码来源:SymbolLoader.cpp


示例9: setSymbolColor

//------------------------------------------------------------------------------
// update the symbol's color based on Identifier
//------------------------------------------------------------------------------
bool SymbolLoader::setSymbolColor(const int idx, const char* name, const Basic::Identifier* cname)
{
    bool ok = false;

    // Find the symbol
    if (idx >= 1 && idx <= MAX_SYMBOLS) {
        const int i = (idx - 1);
        if(symbols[i] != 0) {

            // Get its graphical component
            Basic::Pair* p = (Basic::Pair*)symbols[i]->getSymbolPair();
            if (p != 0) {
                BasicGL::Graphic* g = dynamic_cast<BasicGL::Graphic*>(p->object());
                if (g != 0) {

                    // If we were passed a name then use it to find the subcomponent
                    // and change 'g' to point to the subcomponent instead.
                    if (name != 0) {
                        Basic::Pair* spair = g->findByName(name);
                        if (spair != 0) {
                            // subcomponent found by name
                            g = (BasicGL::Graphic*)(spair->object());
                        }
                        else {
                            // no subcomponent was found by that name
                            g = 0;
                        }
                    }

                    // Set the color (if we found one)
                    if (g != 0) ok = g->setColor(cname);
                }
            }
        }
    }

    return ok;
}
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:41,代码来源:SymbolLoader.cpp


示例10: setSymbolFlashRate

//------------------------------------------------------------------------------
// setSymbolFlashRate() - set symbol and child components flashing
//------------------------------------------------------------------------------
bool SymbolLoader::setSymbolFlashRate(const int idx, const char* name, const LCreal flashRate )
{
   bool ok = false;

   // Find the symbol
   if (idx >= 1 && idx <= MAX_SYMBOLS) {
      const int i = (idx - 1);
      if (symbols[i] != nullptr) {

         // Get its graphical component
         Basic::Pair* p = symbols[i]->getSymbolPair();
         if (p != nullptr) {
            BasicGL::Graphic* g = static_cast<BasicGL::Graphic*>(p->object());
            if (g != nullptr) {

               // If we were passed a name then use it to find the subcomponent
               // and change 'g' to point to the subcomponent instead.
               if (name != nullptr) {
                  Basic::Pair* spair = g->findByName(name);
                  if (spair != nullptr) {
                     // subcomponent found by name
                     g = static_cast<BasicGL::Graphic*>(spair->object());
                  }
                  else {
                     // no subcomponent was found by that name
                     g = nullptr;
                  }
               }

               // Set the flash rate (if we found one)
               if (g != nullptr) ok = g->setFlashRate(flashRate);

            }
         }
      }
   }
   return ok;
}
开发者ID:derekworth,项目名称:afit-swarm-simulation,代码行数:41,代码来源:SymbolLoader.cpp


示例11: draw

//------------------------------------------------------------------------------
// draw() - draw the objects in their proper place
//------------------------------------------------------------------------------
void SymbolLoader::draw()
{
    if (isVisible()) {

        // Y Displacement (ie, decentered)
        LCreal displacement = 0;
        if (!getCentered()) displacement = getDisplacement();

        // Radius (ie., range)
        LCreal radius = 0;
        if (!getCentered()) radius = getOuterRadiusDC();
        else radius = getOuterRadius();
        LCreal radius2 = radius * radius;

        // ---
        // Setup the drawing parameters for all of our symbols ...
        // ---
        for (int i = 0; i < MAX_SYMBOLS; i++) {

            if (symbols[i] != 0) {

                // When the symbol visibility flag is true ...
                if (symbols[i]->isVisible()) {

                    // Get the pointer to the symbol's graphical component
                    Basic::Pair* p = symbols[i]->getSymbolPair();
                    BasicGL::Graphic* g = (BasicGL::Graphic*)p->object();

                    // We need the symbol's position in screen coordinates (inches) ...
                    LCreal xScn = (LCreal) symbols[i]->getScreenXPos();
                    LCreal yScn = (LCreal) symbols[i]->getScreenYPos();

                    if ( !(symbols[i]->isPositionScreen()) ) {

                        // But when we were not give screen coordinates,
                        // we'll need to compute them from A/C coordinates
                        LCreal acX = 0.0;
                        LCreal acY = 0.0;

                        // 1) when given A/C coordinates ...
                        if ( symbols[i]->isPositionAC() ) {
                            acX = (LCreal) symbols[i]->getXPosition();
                            acY = (LCreal) symbols[i]->getYPosition();
                        }

                        // 2) when given NED or L/L coordinates ..
                        else {
                            LCreal north = 0;
                            LCreal east  = 0;

                            if (symbols[i]->isPositionLL()) {
                                // 2a) we were give L/L so convert to NED coordinates
                                double lat = symbols[i]->getXPosition();
                                double lon = symbols[i]->getYPosition();
                                latLon2Earth(lat, lon, &north, &east);
                            }
                            else {
                                // 2b) we were give NED coordinates
                                north = (LCreal) symbols[i]->getXPosition();
                                east  = (LCreal) symbols[i]->getYPosition();
                            }

                            // 2c) convert the NED coordinates to aircraft coordinates
                            earth2Aircraft(north, east, &acX, &acY);
                        }

                        // 3) Convert the aircraft coordinates to screen coordinates
                        aircraft2Screen(acX, acY, &xScn, &yScn);

                        // 4) Save the screen coordinates (inches)
                        symbols[i]->setXScreenPos(xScn);
                        symbols[i]->setYScreenPos(yScn);
                    }

                    // In range?  Do we care?
                    bool inRange  = !showInRangeOnly || (((xScn * xScn) + (yScn * yScn)) <= radius2);

                    if (inRange) {

                        // set symbol's visibility
                        g->setVisibility(true);

                        // and set the symbol's position
                        g->lcSaveMatrix();
                        g->lcTranslate(xScn, yScn + displacement);

                        // pass the argument value to the symbol (if needed)
                        if (symbols[i]->getValue() != 0) {
                            g->event(UPDATE_VALUE, symbols[i]->getValue());
                        }

                        // rotate the symbol's heading subcomponent (if needed)
                        // -- sending a 'Z' rotation event to a component named 'hdg'
                        if (symbols[i]->isHeadingValid()) {
                            BasicGL::Graphic* phdg = symbols[i]->getHdgGraphics();
                            if (phdg == 0) {
                                Basic::Pair* hpair = (Basic::Pair*) g->findByName("hdg");
//.........这里部分代码省略.........
开发者ID:azcbuell,项目名称:OpenEaagles,代码行数:101,代码来源:SymbolLoader.cpp



注:本文中的basicgl::Graphic类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ beagle::Context类代码示例发布时间:2022-05-31
下一篇:
C++ basicblock::iterator类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap