KiCad PCB EDA Suite
Loading...
Searching...
No Matches
orcad_converter_sheet.cpp File Reference
#include <sch_io/orcad/orcad_converter.h>
#include <sch_io/ole_image.h>
#include <algorithm>
#include <array>
#include <charconv>
#include <cctype>
#include <chrono>
#include <cmath>
#include <functional>
#include <numeric>
#include <limits>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include <wx/buffer.h>
#include <wx/filename.h>
#include <wx/image.h>
#include <wx/log.h>
#include <wx/tokenzr.h>
#include <wx/translation.h>
#include <base_units.h>
#include <bitmap_base.h>
#include <connection_graph.h>
#include <core/kicad_algo.h>
#include <font/font.h>
#include <ki_exception.h>
#include <kiid.h>
#include <layer_ids.h>
#include <lib_symbol.h>
#include <math/util.h>
#include <page_info.h>
#include <progress_reporter.h>
#include <project.h>
#include <reference_image.h>
#include <reporter.h>
#include <schematic.h>
#include <sch_bitmap.h>
#include <sch_bus_entry.h>
#include <sch_junction.h>
#include <sch_label.h>
#include <sch_line.h>
#include <sch_no_connect.h>
#include <sch_screen.h>
#include <sch_shape.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>
#include <sch_sheet_pin.h>
#include <sch_symbol.h>
#include <sch_pin.h>
#include <import_net_map.h>
#include <sch_text.h>
#include <string_utils.h>
#include <stroke_params.h>
#include <template_fieldnames.h>
#include <title_block.h>
#include <sch_io/orcad/orcad_stream.h>

Go to the source code of this file.

Classes

struct  BUS_RANGE
 A vector bus name "PREFIX[first..last]" (or ':' as separator); last may be below first. More...
 

Functions

void OrcadTransformPrimitivePoints (ORCAD_PRIMITIVE &aPrim, const std::function< ORCAD_POINT(const ORCAD_POINT &)> &aMap)
 Map the point members of a primitive: points, arc start and arc end.
 
void OrcadOffsetPrimitive (ORCAD_PRIMITIVE &aPrim, int aDx, int aDy)
 Translate a primitive, box included.
 
void OrcadForEachLeafPrimitive (const std::vector< ORCAD_PRIMITIVE > &aPrimitives, const std::function< void(const ORCAD_PRIMITIVE &, int, int)> &aVisit)
 Visit every non-group primitive in drawing order with the accumulated offset of its enclosing groups.
 
VECTOR2I OrcadStretchedImageSize (int aWidth, int aHeight, int aBoxWidth, int aBoxHeight)
 
KIGFX::COLOR4D OrcadColor (int aColorIndex)
 
int OrcadPageOrder (wxString &aName)
 Return a numeric page prefix (or -1); strip only the "N - title" convention.
 
static std::string scopedHierBusName (const std::string &aName, uint32_t aOccurrenceId)
 
static std::vector< std::pair< BUS_RANGE, BUS_RANGE > > scopedBusRanges (const std::map< std::string, std::string > &aBusNames)
 Only renames whose source and scoped ranges have the same length map member by member.
 
static std::string scopedHierBusMember (const std::string &aName, const std::map< std::string, std::string > &aBusNames)
 
static std::string scopedHierBusRange (const std::string &aName, const std::map< std::string, std::string > &aBusNames)
 
static bool rawPointOnSegment (int aX, int aY, const ORCAD_WIRE &aWire)
 
static std::optional< VECTOR2I > rawWireIntersection (const ORCAD_WIRE &aFirst, const ORCAD_WIRE &aSecond)
 
static bool rawBusSegmentsTouch (const ORCAD_WIRE &aFirst, const ORCAD_WIRE &aSecond)
 
static std::vector< std::string > busPrefixRuns (const std::string &aPrefix)
 
static std::set< std::string > busPrefixTokens (const std::string &aPrefix)
 
static std::string firstBusPrefixToken (const std::string &aPrefix)
 
static std::set< std::string > pageNetNames (const ORCAD_RAW_PAGE &aPage, uint32_t aNetId)
 
static std::set< uint32_t > pageNetIdsNamed (const ORCAD_RAW_PAGE &aPage, std::string_view aName)
 
static std::string connectedBusName (const ORCAD_RAW_PAGE &aPage, const ORCAD_BLOCK_PIN &aPin, const std::string &aFallback)
 
static LABEL_FLAG_SHAPE hierarchicalPinShape (ORCAD_PORT_TYPE aType)
 
static uint32_t busNetAt (const ORCAD_RAW_PAGE &aPage, const ORCAD_BLOCK_PIN &aPin)
 
static std::string flatNetSuffix (const ORCAD_DRAWN_INSTANCE &aBlock)
 
static std::string appendOccurrenceSuffix (const std::string &aParentSuffix, const ORCAD_DRAWN_INSTANCE &aBlock)
 
static const ORCAD_DRAWN_INSTANCE * findDrawnBlock (const ORCAD_RAW_PAGE &aPage, uint32_t aDbId)
 
static std::pair< const ORCAD_DRAWN_INSTANCE *, const ORCAD_RAW_PAGE * > findDrawnBlock (const std::vector< ORCAD_RAW_PAGE > &aPages, uint32_t aDbId)
 
static std::vector< const ORCAD_OCC_BLOCK * > sortedOccurrences (const ORCAD_OCC_SCOPE &aScope)
 Capture orders child pages by numeric folder prefix, then by folder name without case.
 
static SHEET_SIDE nearestSheetSide (const ORCAD_BLOCK_PIN &aPin, const ORCAD_DRAWN_INSTANCE &aBlock)
 
static std::optional< VECTOR2I > safeConnectivityLabelPosition (SCH_SCREEN *aScreen, const VECTOR2I &aPosition, const std::optional< std::vector< SEG > > &aSourceWires)
 
static std::optional< std::vector< SEG > > eligibleSourceConnectivityWires (const ORCAD_RAW_PAGE &aPage, const VECTOR2I &aPosition, const std::set< std::string > &aNames, bool aBus=false, uint32_t *aNetId=nullptr)
 
static std::optional< std::vector< SEG > > interfaceSourceWires (const ORCAD_RAW_PAGE &aPage, const VECTOR2I &aPosition, const std::set< std::string > &aNames, const std::string &aNet)
 Bus labels fall back to bus wires; a net label with no eligible net wire may still sit on a bus.
 

Function Documentation

◆ appendOccurrenceSuffix()

static std::string appendOccurrenceSuffix ( const std::string & aParentSuffix,
const ORCAD_DRAWN_INSTANCE & aBlock )
static

◆ busNetAt()

◆ busPrefixRuns()

static std::vector< std::string > busPrefixRuns ( const std::string & aPrefix)
static

Definition at line 969 of file orcad_converter_sheet.cpp.

References end.

Referenced by busPrefixTokens(), and firstBusPrefixToken().

◆ busPrefixTokens()

static std::set< std::string > busPrefixTokens ( const std::string & aPrefix)
static

Definition at line 994 of file orcad_converter_sheet.cpp.

References busPrefixRuns(), and result.

Referenced by connectedBusName().

◆ connectedBusName()

◆ eligibleSourceConnectivityWires()

static std::optional< std::vector< SEG > > eligibleSourceConnectivityWires ( const ORCAD_RAW_PAGE & aPage,
const VECTOR2I & aPosition,
const std::set< std::string > & aNames,
bool aBus = false,
uint32_t * aNetId = nullptr )
static

◆ findDrawnBlock() [1/2]

◆ findDrawnBlock() [2/2]

static std::pair< const ORCAD_DRAWN_INSTANCE *, const ORCAD_RAW_PAGE * > findDrawnBlock ( const std::vector< ORCAD_RAW_PAGE > & aPages,
uint32_t aDbId )
static

Definition at line 1326 of file orcad_converter_sheet.cpp.

References findDrawnBlock().

◆ firstBusPrefixToken()

static std::string firstBusPrefixToken ( const std::string & aPrefix)
static

Definition at line 1008 of file orcad_converter_sheet.cpp.

References busPrefixRuns().

Referenced by connectedBusName().

◆ flatNetSuffix()

static std::string flatNetSuffix ( const ORCAD_DRAWN_INSTANCE & aBlock)
static

◆ hierarchicalPinShape()

static LABEL_FLAG_SHAPE hierarchicalPinShape ( ORCAD_PORT_TYPE aType)
static

◆ interfaceSourceWires()

static std::optional< std::vector< SEG > > interfaceSourceWires ( const ORCAD_RAW_PAGE & aPage,
const VECTOR2I & aPosition,
const std::set< std::string > & aNames,
const std::string & aNet )
static

Bus labels fall back to bus wires; a net label with no eligible net wire may still sit on a bus.

Definition at line 7017 of file orcad_converter_sheet.cpp.

References eligibleSourceConnectivityWires(), FromOrcadString(), and SCH_CONNECTION::IsBusLabel().

Referenced by ORCAD_CONVERTER::placeOffpageConnectors(), and ORCAD_CONVERTER::placePorts().

◆ nearestSheetSide()

◆ OrcadColor()

◆ OrcadForEachLeafPrimitive()

void OrcadForEachLeafPrimitive ( const std::vector< ORCAD_PRIMITIVE > & aPrimitives,
const std::function< void(const ORCAD_PRIMITIVE &, int, int)> & aVisit )

Visit every non-group primitive in drawing order with the accumulated offset of its enclosing groups.

Definition at line 357 of file orcad_converter_sheet.cpp.

References GROUP_PRIM.

Referenced by ORCAD_CONVERTER::placeDefinitionImages(), ORCAD_CONVERTER::placeDefinitionVectors(), and ORCAD_CONVERTER::placeGraphics().

◆ OrcadOffsetPrimitive()

void OrcadOffsetPrimitive ( ORCAD_PRIMITIVE & aPrim,
int aDx,
int aDy )

Translate a primitive, box included.

Group children are relative to the group and need no shift.

Definition at line 343 of file orcad_converter_sheet.cpp.

References OrcadTransformPrimitivePoints(), ORCAD_POINT::x, ORCAD_PRIMITIVE::x1, ORCAD_PRIMITIVE::x2, ORCAD_POINT::y, ORCAD_PRIMITIVE::y1, and ORCAD_PRIMITIVE::y2.

Referenced by ORCAD_CONVERTER::offsetPage(), and ORCAD_CONVERTER::placeGraphics().

◆ OrcadPageOrder()

int OrcadPageOrder ( wxString & aName)

Return a numeric page prefix (or -1); strip only the "N - title" convention.

Definition at line 717 of file orcad_converter_sheet.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ OrcadStretchedImageSize()

VECTOR2I OrcadStretchedImageSize ( int aWidth,
int aHeight,
int aBoxWidth,
int aBoxHeight )

◆ OrcadTransformPrimitivePoints()

void OrcadTransformPrimitivePoints ( ORCAD_PRIMITIVE & aPrim,
const std::function< ORCAD_POINT(const ORCAD_POINT &)> & aMap )

Map the point members of a primitive: points, arc start and arc end.

The box corners are left alone.

Definition at line 329 of file orcad_converter_sheet.cpp.

References ORCAD_PRIMITIVE::end, ORCAD_PRIMITIVE::points, and ORCAD_PRIMITIVE::start.

Referenced by OrcadOffsetPrimitive(), and ORCAD_CONVERTER::placeDefinitionVectors().

◆ pageNetIdsNamed()

static std::set< uint32_t > pageNetIdsNamed ( const ORCAD_RAW_PAGE & aPage,
std::string_view aName )
static

◆ pageNetNames()

◆ rawBusSegmentsTouch()

static bool rawBusSegmentsTouch ( const ORCAD_WIRE & aFirst,
const ORCAD_WIRE & aSecond )
static

◆ rawPointOnSegment()

◆ rawWireIntersection()

static std::optional< VECTOR2I > rawWireIntersection ( const ORCAD_WIRE & aFirst,
const ORCAD_WIRE & aSecond )
static

◆ safeConnectivityLabelPosition()

◆ scopedBusRanges()

static std::vector< std::pair< BUS_RANGE, BUS_RANGE > > scopedBusRanges ( const std::map< std::string, std::string > & aBusNames)
static

Only renames whose source and scoped ranges have the same length map member by member.

Definition at line 848 of file orcad_converter_sheet.cpp.

References BUS_RANGE::Parse(), and source.

Referenced by scopedHierBusMember(), and scopedHierBusRange().

◆ scopedHierBusMember()

static std::string scopedHierBusMember ( const std::string & aName,
const std::map< std::string, std::string > & aBusNames )
static

Definition at line 865 of file orcad_converter_sheet.cpp.

References next(), scopedBusRanges(), and source.

Referenced by ORCAD_CONVERTER::recordNetNameMap().

◆ scopedHierBusName()

static std::string scopedHierBusName ( const std::string & aName,
uint32_t aOccurrenceId )
static

Definition at line 773 of file orcad_converter_sheet.cpp.

Referenced by ORCAD_CONVERTER::createBlockSheet().

◆ scopedHierBusRange()

static std::string scopedHierBusRange ( const std::string & aName,
const std::map< std::string, std::string > & aBusNames )
static

◆ sortedOccurrences()

static std::vector< const ORCAD_OCC_BLOCK * > sortedOccurrences ( const ORCAD_OCC_SCOPE & aScope)
static

Capture orders child pages by numeric folder prefix, then by folder name without case.

Definition at line 1339 of file orcad_converter_sheet.cpp.

References ORCAD_OCC_SCOPE::blocks.

Referenced by ORCAD_CONVERTER::placeFolder().